mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Moving the rest word-size data from Ext to Runtime [#81470252]
This commit is contained in:
parent
bfe1216d91
commit
088a4efa16
5 changed files with 41 additions and 59 deletions
|
|
@ -722,14 +722,14 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
|
||||
case Instruction::CALLDATASIZE:
|
||||
{
|
||||
auto value = ext.calldatasize();
|
||||
auto value = _runtimeManager.get(RuntimeData::CallDataSize);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::CODESIZE:
|
||||
{
|
||||
auto value = ext.codesize();
|
||||
auto value = _runtimeManager.get(RuntimeData::CodeSize);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
|
@ -749,7 +749,7 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
auto reqBytes = stack.pop();
|
||||
|
||||
auto srcPtr = ext.calldata();
|
||||
auto srcSize = ext.calldatasize();
|
||||
auto srcSize = _runtimeManager.get(RuntimeData::CallDataSize);
|
||||
|
||||
memory.copyBytes(srcPtr, srcSize, srcIdx, destMemIdx, reqBytes);
|
||||
break;
|
||||
|
|
@ -762,7 +762,7 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
auto reqBytes = stack.pop();
|
||||
|
||||
auto srcPtr = ext.code(); // TODO: Code & its size are constants, feature #80814234
|
||||
auto srcSize = ext.codesize();
|
||||
auto srcSize = _runtimeManager.get(RuntimeData::CodeSize);
|
||||
|
||||
memory.copyBytes(srcPtr, srcSize, srcIdx, destMemIdx, reqBytes);
|
||||
break;
|
||||
|
|
@ -792,49 +792,49 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
|
||||
case Instruction::GASPRICE:
|
||||
{
|
||||
auto value = ext.gasprice();
|
||||
auto value = _runtimeManager.get(RuntimeData::GasPrice);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::PREVHASH:
|
||||
{
|
||||
auto value = ext.prevhash();
|
||||
auto value = _runtimeManager.get(RuntimeData::PrevHash);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::COINBASE:
|
||||
{
|
||||
auto value = ext.coinbase();
|
||||
auto value = _runtimeManager.get(RuntimeData::CoinBase);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::TIMESTAMP:
|
||||
{
|
||||
auto value = ext.timestamp();
|
||||
auto value = _runtimeManager.get(RuntimeData::TimeStamp);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::NUMBER:
|
||||
{
|
||||
auto value = ext.number();
|
||||
auto value = _runtimeManager.get(RuntimeData::Number);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::DIFFICULTY:
|
||||
{
|
||||
auto value = ext.difficulty();
|
||||
auto value = _runtimeManager.get(RuntimeData::Difficulty);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
||||
case Instruction::GASLIMIT:
|
||||
{
|
||||
auto value = ext.gaslimit();
|
||||
auto value = _runtimeManager.get(RuntimeData::GasLimit);
|
||||
stack.push(value);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,15 +27,6 @@ inline u256 fromAddress(Address _a)
|
|||
|
||||
struct ExtData
|
||||
{
|
||||
i256 calldatasize;
|
||||
i256 gasprice;
|
||||
i256 prevhash;
|
||||
i256 coinbase;
|
||||
i256 timestamp;
|
||||
i256 number;
|
||||
i256 difficulty;
|
||||
i256 gaslimit;
|
||||
i256 codesize;
|
||||
const byte* calldata;
|
||||
const byte* code;
|
||||
};
|
||||
|
|
@ -61,15 +52,6 @@ Ext::Ext(RuntimeManager& _runtimeManager):
|
|||
m_arg8 = m_builder.CreateAlloca(i256Ty, nullptr, "ext.arg8");
|
||||
|
||||
Type* elements[] = {
|
||||
i256Ty, // i256 calldatasize;
|
||||
i256Ty, // i256 gasprice;
|
||||
i256Ty, // i256 prevhash;
|
||||
i256Ty, // i256 coinbase;
|
||||
i256Ty, // i256 timestamp;
|
||||
i256Ty, // i256 number;
|
||||
i256Ty, // i256 difficulty;
|
||||
i256Ty, // i256 gaslimit;
|
||||
i256Ty, // i256 codesize
|
||||
i8PtrTy, // byte* calldata
|
||||
i8PtrTy, // byte* code
|
||||
|
||||
|
|
@ -118,17 +100,8 @@ Value* Ext::getDataElem(unsigned _index, const Twine& _name)
|
|||
return m_builder.CreateLoad(valuePtr);
|
||||
}
|
||||
|
||||
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::calldata() { return getDataElem(0, "calldata"); }
|
||||
Value* Ext::code() { return getDataElem(1, "code"); }
|
||||
|
||||
Value* Ext::calldataload(Value* _index)
|
||||
{
|
||||
|
|
@ -231,15 +204,6 @@ using namespace dev::eth::jit;
|
|||
EXPORT void ext_init(ExtData* _extData)
|
||||
{
|
||||
auto&& ext = Runtime::getExt();
|
||||
_extData->gasprice = eth2llvm(ext.gasPrice);
|
||||
_extData->calldatasize = eth2llvm(ext.data.size());
|
||||
_extData->prevhash = eth2llvm(ext.previousBlock.hash);
|
||||
_extData->coinbase = eth2llvm(fromAddress(ext.currentBlock.coinbaseAddress));
|
||||
_extData->timestamp = eth2llvm(ext.currentBlock.timestamp);
|
||||
_extData->number = eth2llvm(ext.currentBlock.number);
|
||||
_extData->difficulty = eth2llvm(ext.currentBlock.difficulty);
|
||||
_extData->gaslimit = eth2llvm(ext.currentBlock.gasLimit);
|
||||
_extData->codesize = eth2llvm(ext.code.size());
|
||||
_extData->calldata = ext.data.data();
|
||||
_extData->code = ext.code.data();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,15 +20,6 @@ public:
|
|||
llvm::Value* store(llvm::Value* _index);
|
||||
void setStore(llvm::Value* _index, llvm::Value* _value);
|
||||
|
||||
llvm::Value* calldatasize();
|
||||
llvm::Value* gasprice();
|
||||
llvm::Value* prevhash();
|
||||
llvm::Value* coinbase();
|
||||
llvm::Value* timestamp();
|
||||
llvm::Value* number();
|
||||
llvm::Value* difficulty();
|
||||
llvm::Value* gaslimit();
|
||||
llvm::Value* codesize();
|
||||
llvm::Value* calldata();
|
||||
llvm::Value* code();
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,15 @@ llvm::Twine getName(RuntimeData::Index _index)
|
|||
case RuntimeData::Caller: return "caller";
|
||||
case RuntimeData::Origin: return "origin";
|
||||
case RuntimeData::CallValue: return "callvalue";
|
||||
case RuntimeData::CallDataSize: return "calldatasize";
|
||||
case RuntimeData::GasPrice: return "gasprice";
|
||||
case RuntimeData::PrevHash: return "prevhash";
|
||||
case RuntimeData::CoinBase: return "coinbase";
|
||||
case RuntimeData::TimeStamp: return "timestamp";
|
||||
case RuntimeData::Number: return "number";
|
||||
case RuntimeData::Difficulty: return "difficulty";
|
||||
case RuntimeData::GasLimit: return "gaslimit";
|
||||
case RuntimeData::CodeSize: return "codesize";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -57,6 +66,15 @@ Runtime::Runtime(u256 _gas, ExtVMFace& _ext):
|
|||
set(RuntimeData::Caller, fromAddress(_ext.caller));
|
||||
set(RuntimeData::Origin, fromAddress(_ext.origin));
|
||||
set(RuntimeData::CallValue, _ext.value);
|
||||
set(RuntimeData::CallDataSize, _ext.data.size());
|
||||
set(RuntimeData::GasPrice, _ext.gasPrice);
|
||||
set(RuntimeData::PrevHash, _ext.previousBlock.hash);
|
||||
set(RuntimeData::CoinBase, fromAddress(_ext.currentBlock.coinbaseAddress));
|
||||
set(RuntimeData::TimeStamp, _ext.currentBlock.timestamp);
|
||||
set(RuntimeData::Number, _ext.currentBlock.number);
|
||||
set(RuntimeData::Difficulty, _ext.currentBlock.difficulty);
|
||||
set(RuntimeData::GasLimit, _ext.currentBlock.gasLimit);
|
||||
set(RuntimeData::CodeSize, _ext.code.size()); // TODO: Use constant
|
||||
}
|
||||
|
||||
Runtime::~Runtime()
|
||||
|
|
|
|||
|
|
@ -31,6 +31,15 @@ struct RuntimeData
|
|||
Caller,
|
||||
Origin,
|
||||
CallValue,
|
||||
CallDataSize,
|
||||
GasPrice,
|
||||
PrevHash,
|
||||
CoinBase,
|
||||
TimeStamp,
|
||||
Number,
|
||||
Difficulty,
|
||||
GasLimit,
|
||||
CodeSize,
|
||||
|
||||
_size
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue