mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 12:16:44 +00:00
Group instructions that access runtime data [#81470252]
This commit is contained in:
parent
088a4efa16
commit
916f5abaae
3 changed files with 37 additions and 91 deletions
|
|
@ -679,15 +679,22 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
}
|
||||
|
||||
case Instruction::GAS:
|
||||
{
|
||||
stack.push(_runtimeManager.getGas());
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::ADDRESS:
|
||||
case Instruction::CALLER:
|
||||
case Instruction::ORIGIN:
|
||||
case Instruction::CALLVALUE:
|
||||
case Instruction::CALLDATASIZE:
|
||||
case Instruction::CODESIZE:
|
||||
case Instruction::GASPRICE:
|
||||
case Instruction::PREVHASH:
|
||||
case Instruction::COINBASE:
|
||||
case Instruction::TIMESTAMP:
|
||||
case Instruction::NUMBER:
|
||||
case Instruction::DIFFICULTY:
|
||||
case Instruction::GASLIMIT:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::Address);
|
||||
stack.push(value);
|
||||
// Pushes an element of runtime data on stack
|
||||
stack.push(_runtimeManager.get(inst));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -699,41 +706,6 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
break;
|
||||
}
|
||||
|
||||
case Instruction::CALLER:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::Caller);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::ORIGIN:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::Origin);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::CALLVALUE:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::CallValue);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::CALLDATASIZE:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::CallDataSize);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::CODESIZE:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::CodeSize);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::EXTCODESIZE:
|
||||
{
|
||||
auto addr = stack.pop();
|
||||
|
|
@ -790,55 +762,6 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
break;
|
||||
}
|
||||
|
||||
case Instruction::GASPRICE:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::GasPrice);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::PREVHASH:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::PrevHash);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::COINBASE:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::CoinBase);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::TIMESTAMP:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::TimeStamp);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::NUMBER:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::Number);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::DIFFICULTY:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::Difficulty);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::GASLIMIT:
|
||||
{
|
||||
auto value = _runtimeManager.get(RuntimeData::GasLimit);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::CREATE:
|
||||
{
|
||||
auto endowment = stack.pop();
|
||||
|
|
|
|||
|
|
@ -135,6 +135,28 @@ llvm::Value* RuntimeManager::get(RuntimeData::Index _index)
|
|||
return m_builder.CreateLoad(ptr, getName(_index));
|
||||
}
|
||||
|
||||
llvm::Value* RuntimeManager::get(Instruction _inst)
|
||||
{
|
||||
switch (_inst)
|
||||
{
|
||||
default: assert(false); return nullptr;
|
||||
case Instruction::GAS: return get(RuntimeData::Gas);
|
||||
case Instruction::ADDRESS: return get(RuntimeData::Address);
|
||||
case Instruction::CALLER: return get(RuntimeData::Caller);
|
||||
case Instruction::ORIGIN: return get(RuntimeData::Origin);
|
||||
case Instruction::CALLVALUE: return get(RuntimeData::CallValue);
|
||||
case Instruction::CALLDATASIZE: return get(RuntimeData::CallDataSize);
|
||||
case Instruction::GASPRICE: return get(RuntimeData::GasPrice);
|
||||
case Instruction::PREVHASH: return get(RuntimeData::PrevHash);
|
||||
case Instruction::COINBASE: return get(RuntimeData::CoinBase);
|
||||
case Instruction::TIMESTAMP: return get(RuntimeData::TimeStamp);
|
||||
case Instruction::NUMBER: return get(RuntimeData::Number);
|
||||
case Instruction::DIFFICULTY: return get(RuntimeData::Difficulty);
|
||||
case Instruction::GASLIMIT: return get(RuntimeData::GasLimit);
|
||||
case Instruction::CODESIZE: return get(RuntimeData::CodeSize);
|
||||
}
|
||||
}
|
||||
|
||||
llvm::Value* RuntimeManager::getGas()
|
||||
{
|
||||
return get(RuntimeData::Gas);
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ public:
|
|||
llvm::Value* getRuntimePtr();
|
||||
|
||||
llvm::Value* get(RuntimeData::Index _index);
|
||||
llvm::Value* get(Instruction _inst);
|
||||
llvm::Value* getGas();
|
||||
void setGas(llvm::Value* _gas);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue