mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 12:16:44 +00:00
parent
d56f60f768
commit
1c70f3d099
1 changed files with 9 additions and 3 deletions
|
|
@ -745,9 +745,7 @@ std::unique_ptr<llvm::Module> Compiler::compile(const dev::bytes& bytecode)
|
||||||
auto srcDataIdx = stack.pop();
|
auto srcDataIdx = stack.pop();
|
||||||
auto reqBytes = stack.pop();
|
auto reqBytes = stack.pop();
|
||||||
|
|
||||||
// FIXME: ensure memory size reqMemSize.
|
memory.require(destMemIdx, reqBytes);
|
||||||
auto reqMemSize = builder.CreateAdd(destMemIdx, reqBytes, "req_mem_size");
|
|
||||||
memory.require(reqMemSize);
|
|
||||||
|
|
||||||
auto memPtr = memory.getData();
|
auto memPtr = memory.getData();
|
||||||
auto destPtr = builder.CreateGEP(memPtr, destMemIdx, "dest_mem_ptr");
|
auto destPtr = builder.CreateGEP(memPtr, destMemIdx, "dest_mem_ptr");
|
||||||
|
|
@ -856,6 +854,14 @@ std::unique_ptr<llvm::Module> Compiler::compile(const dev::bytes& bytecode)
|
||||||
auto outSize = stack.pop();
|
auto outSize = stack.pop();
|
||||||
|
|
||||||
gasMeter.commitCostBlock(gas);
|
gasMeter.commitCostBlock(gas);
|
||||||
|
|
||||||
|
// Require memory for the max of in and out buffers
|
||||||
|
auto inSizeReq = builder.CreateAdd(inOff, inSize, "inSizeReq");
|
||||||
|
auto outSizeReq = builder.CreateAdd(outOff, outSize, "outSizeReq");
|
||||||
|
auto cmp = builder.CreateICmpUGT(inSizeReq, outSizeReq);
|
||||||
|
auto sizeReq = builder.CreateSelect(cmp, inSizeReq, outSizeReq, "sizeReq");
|
||||||
|
memory.require(sizeReq);
|
||||||
|
|
||||||
auto ret = ext.call(gas, receiveAddress, value, inOff, inSize, outOff, outSize);
|
auto ret = ext.call(gas, receiveAddress, value, inOff, inSize, outOff, outSize);
|
||||||
gasMeter.giveBack(gas);
|
gasMeter.giveBack(gas);
|
||||||
stack.push(ret);
|
stack.push(ret);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue