MCPcopy Create free account
hub / github.com/LUX-Core/lux / query

Method query

src/cpp-ethereum/evmjit/libevmjit/Ext.cpp:313–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313llvm::Value* Ext::query(evm_query_key _key)
314{
315 auto func = getQueryFunc(getModule());
316 auto undef = llvm::UndefValue::get(Type::WordPtr);
317 auto pResult = getArgAlloca();
318 createCABICall(func, {pResult, getRuntimeManager().getEnvPtr(), m_builder.getInt32(_key), undef});
319 llvm::Value* v = m_builder.CreateLoad(pResult);
320
321 switch (_key)
322 {
323 case EVM_GAS_PRICE:
324 case EVM_DIFFICULTY:
325 v = Endianness::toNative(m_builder, v);
326 break;
327 case EVM_ADDRESS:
328 case EVM_CALLER:
329 case EVM_ORIGIN:
330 case EVM_COINBASE:
331 {
332 auto mask160 = llvm::APInt(160, -1, true).zext(256);
333 v = Endianness::toNative(m_builder, v);
334 v = m_builder.CreateAnd(v, mask160);
335 break;
336 }
337 case EVM_GAS_LIMIT:
338 case EVM_NUMBER:
339 case EVM_TIMESTAMP:
340 {
341 // Use only 64-bit -- single word. The rest is uninitialized.
342 // We could have mask 63 bits, but there is very little to gain in cost
343 // of additional and operation.
344 auto mask64 = llvm::APInt(256, std::numeric_limits<uint64_t>::max());
345 v = m_builder.CreateAnd(v, mask64);
346 break;
347 }
348 default:
349 break;
350 }
351
352 return v;
353}
354
355llvm::Value* Ext::balance(llvm::Value* _address)
356{

Callers 2

filterbyasnFunction · 0.80
compileBasicBlockMethod · 0.80

Calls 4

getQueryFuncFunction · 0.85
APIntClass · 0.85
maxFunction · 0.85
getEnvPtrMethod · 0.80

Tested by

no test coverage detected