mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Moving CALLDATA data from Ext to Runtime [#81470252]
This commit is contained in:
parent
916f5abaae
commit
83b24b627d
5 changed files with 14 additions and 7 deletions
|
|
@ -720,7 +720,7 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
auto srcIdx = stack.pop();
|
||||
auto reqBytes = stack.pop();
|
||||
|
||||
auto srcPtr = ext.calldata();
|
||||
auto srcPtr = _runtimeManager.getCallData();
|
||||
auto srcSize = _runtimeManager.get(RuntimeData::CallDataSize);
|
||||
|
||||
memory.copyBytes(srcPtr, srcSize, srcIdx, destMemIdx, reqBytes);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ Ext::Ext(RuntimeManager& _runtimeManager):
|
|||
m_arg8 = m_builder.CreateAlloca(i256Ty, nullptr, "ext.arg8");
|
||||
|
||||
Type* elements[] = {
|
||||
i8PtrTy, // byte* calldata
|
||||
i8PtrTy, // byte* code
|
||||
|
||||
};
|
||||
|
|
@ -100,8 +99,7 @@ Value* Ext::getDataElem(unsigned _index, const Twine& _name)
|
|||
return m_builder.CreateLoad(valuePtr);
|
||||
}
|
||||
|
||||
Value* Ext::calldata() { return getDataElem(0, "calldata"); }
|
||||
Value* Ext::code() { return getDataElem(1, "code"); }
|
||||
Value* Ext::code() { return getDataElem(0, "code"); }
|
||||
|
||||
Value* Ext::calldataload(Value* _index)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ public:
|
|||
llvm::Value* store(llvm::Value* _index);
|
||||
void setStore(llvm::Value* _index, llvm::Value* _value);
|
||||
|
||||
llvm::Value* calldata();
|
||||
llvm::Value* code();
|
||||
|
||||
llvm::Value* balance(llvm::Value* _address);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ llvm::StructType* RuntimeData::getType()
|
|||
{
|
||||
llvm::Type* elems[] =
|
||||
{
|
||||
llvm::ArrayType::get(Type::i256, _size)
|
||||
llvm::ArrayType::get(Type::i256, _size),
|
||||
Type::BytePtr
|
||||
};
|
||||
type = llvm::StructType::create(elems, "RuntimeData");
|
||||
}
|
||||
|
|
@ -75,6 +76,7 @@ Runtime::Runtime(u256 _gas, ExtVMFace& _ext):
|
|||
set(RuntimeData::Difficulty, _ext.currentBlock.difficulty);
|
||||
set(RuntimeData::GasLimit, _ext.currentBlock.gasLimit);
|
||||
set(RuntimeData::CodeSize, _ext.code.size()); // TODO: Use constant
|
||||
m_data.callData = _ext.data.data();
|
||||
}
|
||||
|
||||
Runtime::~Runtime()
|
||||
|
|
@ -157,6 +159,12 @@ llvm::Value* RuntimeManager::get(Instruction _inst)
|
|||
}
|
||||
}
|
||||
|
||||
llvm::Value* RuntimeManager::getCallData()
|
||||
{
|
||||
auto ptr = getBuilder().CreateStructGEP(getRuntimePtr(), 1, "calldataPtr");
|
||||
return getBuilder().CreateLoad(ptr, "calldata");
|
||||
}
|
||||
|
||||
llvm::Value* RuntimeManager::getGas()
|
||||
{
|
||||
return get(RuntimeData::Gas);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ struct RuntimeData
|
|||
};
|
||||
|
||||
i256 elems[_size];
|
||||
byte const* callData;
|
||||
|
||||
static llvm::StructType* getType();
|
||||
};
|
||||
|
|
@ -89,7 +90,8 @@ public:
|
|||
|
||||
llvm::Value* get(RuntimeData::Index _index);
|
||||
llvm::Value* get(Instruction _inst);
|
||||
llvm::Value* getGas();
|
||||
llvm::Value* getGas(); // TODO: Remove
|
||||
llvm::Value* getCallData();
|
||||
void setGas(llvm::Value* _gas);
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Reference in a new issue