mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 12:16:44 +00:00
Moving ORIGIN, CALLER & CALLVALUE data from Ext to Runtime [#81470252]
This commit is contained in:
parent
5c1e344a3e
commit
bfe1216d91
5 changed files with 26 additions and 34 deletions
|
|
@ -701,21 +701,21 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
|
||||
case Instruction::CALLER:
|
||||
{
|
||||
auto value = ext.caller();
|
||||
auto value = _runtimeManager.get(RuntimeData::Caller);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::ORIGIN:
|
||||
{
|
||||
auto value = ext.origin();
|
||||
auto value = _runtimeManager.get(RuntimeData::Origin);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::CALLVALUE:
|
||||
{
|
||||
auto value = ext.callvalue();
|
||||
auto value = _runtimeManager.get(RuntimeData::CallValue);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@ inline u256 fromAddress(Address _a)
|
|||
|
||||
struct ExtData
|
||||
{
|
||||
i256 address;
|
||||
i256 caller;
|
||||
i256 origin;
|
||||
i256 callvalue;
|
||||
i256 calldatasize;
|
||||
i256 gasprice;
|
||||
i256 prevhash;
|
||||
|
|
@ -65,10 +61,6 @@ Ext::Ext(RuntimeManager& _runtimeManager):
|
|||
m_arg8 = m_builder.CreateAlloca(i256Ty, nullptr, "ext.arg8");
|
||||
|
||||
Type* elements[] = {
|
||||
i256Ty, // i256 address;
|
||||
i256Ty, // i256 caller;
|
||||
i256Ty, // i256 origin;
|
||||
i256Ty, // i256 callvalue;
|
||||
i256Ty, // i256 calldatasize;
|
||||
i256Ty, // i256 gasprice;
|
||||
i256Ty, // i256 prevhash;
|
||||
|
|
@ -126,20 +118,17 @@ Value* Ext::getDataElem(unsigned _index, const Twine& _name)
|
|||
return m_builder.CreateLoad(valuePtr);
|
||||
}
|
||||
|
||||
Value* Ext::caller() { return getDataElem(1, "caller"); }
|
||||
Value* Ext::origin() { return getDataElem(2, "origin"); }
|
||||
Value* Ext::callvalue() { return getDataElem(3, "callvalue"); }
|
||||
Value* Ext::calldatasize() { return getDataElem(4, "calldatasize"); }
|
||||
Value* Ext::gasprice() { return getDataElem(5, "gasprice"); }
|
||||
Value* Ext::prevhash() { return getDataElem(6, "prevhash"); }
|
||||
Value* Ext::coinbase() { return getDataElem(7, "coinbase"); }
|
||||
Value* Ext::timestamp() { return getDataElem(8, "timestamp"); }
|
||||
Value* Ext::number() { return getDataElem(9, "number"); }
|
||||
Value* Ext::difficulty() { return getDataElem(10, "difficulty"); }
|
||||
Value* Ext::gaslimit() { return getDataElem(11, "gaslimit"); }
|
||||
Value* Ext::codesize() { return getDataElem(12, "codesize"); }
|
||||
Value* Ext::calldata() { return getDataElem(13, "calldata"); }
|
||||
Value* Ext::code() { return getDataElem(14, "code"); }
|
||||
Value* Ext::calldatasize() { return getDataElem(0, "calldatasize"); }
|
||||
Value* Ext::gasprice() { return getDataElem(1, "gasprice"); }
|
||||
Value* Ext::prevhash() { return getDataElem(2, "prevhash"); }
|
||||
Value* Ext::coinbase() { return getDataElem(3, "coinbase"); }
|
||||
Value* Ext::timestamp() { return getDataElem(4, "timestamp"); }
|
||||
Value* Ext::number() { return getDataElem(5, "number"); }
|
||||
Value* Ext::difficulty() { return getDataElem(6, "difficulty"); }
|
||||
Value* Ext::gaslimit() { return getDataElem(7, "gaslimit"); }
|
||||
Value* Ext::codesize() { return getDataElem(8, "codesize"); }
|
||||
Value* Ext::calldata() { return getDataElem(9, "calldata"); }
|
||||
Value* Ext::code() { return getDataElem(10, "code"); }
|
||||
|
||||
Value* Ext::calldataload(Value* _index)
|
||||
{
|
||||
|
|
@ -242,9 +231,6 @@ using namespace dev::eth::jit;
|
|||
EXPORT void ext_init(ExtData* _extData)
|
||||
{
|
||||
auto&& ext = Runtime::getExt();
|
||||
_extData->caller = eth2llvm(fromAddress(ext.caller));
|
||||
_extData->origin = eth2llvm(fromAddress(ext.origin));
|
||||
_extData->callvalue = eth2llvm(ext.value);
|
||||
_extData->gasprice = eth2llvm(ext.gasPrice);
|
||||
_extData->calldatasize = eth2llvm(ext.data.size());
|
||||
_extData->prevhash = eth2llvm(ext.previousBlock.hash);
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@ public:
|
|||
llvm::Value* store(llvm::Value* _index);
|
||||
void setStore(llvm::Value* _index, llvm::Value* _value);
|
||||
|
||||
llvm::Value* caller();
|
||||
llvm::Value* origin();
|
||||
llvm::Value* callvalue();
|
||||
llvm::Value* calldatasize();
|
||||
llvm::Value* gasprice();
|
||||
llvm::Value* prevhash();
|
||||
|
|
|
|||
|
|
@ -35,9 +35,12 @@ llvm::Twine getName(RuntimeData::Index _index)
|
|||
{
|
||||
switch (_index)
|
||||
{
|
||||
default: return "data";
|
||||
case RuntimeData::Gas: return "gas";
|
||||
case RuntimeData::Address: return "address";
|
||||
default: return "data";
|
||||
case RuntimeData::Gas: return "gas";
|
||||
case RuntimeData::Address: return "address";
|
||||
case RuntimeData::Caller: return "caller";
|
||||
case RuntimeData::Origin: return "origin";
|
||||
case RuntimeData::CallValue: return "callvalue";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,6 +54,9 @@ Runtime::Runtime(u256 _gas, ExtVMFace& _ext):
|
|||
g_runtime = this;
|
||||
set(RuntimeData::Gas, _gas);
|
||||
set(RuntimeData::Address, fromAddress(_ext.myAddress));
|
||||
set(RuntimeData::Caller, fromAddress(_ext.caller));
|
||||
set(RuntimeData::Origin, fromAddress(_ext.origin));
|
||||
set(RuntimeData::CallValue, _ext.value);
|
||||
}
|
||||
|
||||
Runtime::~Runtime()
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ struct RuntimeData
|
|||
{
|
||||
Gas,
|
||||
Address,
|
||||
Caller,
|
||||
Origin,
|
||||
CallValue,
|
||||
|
||||
_size
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue