Browse Source

Restore correct memory access in Ext functions

cl-refactor
Paweł Bylica 10 years ago
parent
commit
0eb8311aa1
  1. 9
      libevmjit/Ext.cpp

9
libevmjit/Ext.cpp

@ -225,8 +225,7 @@ EXPORT void ext_create(Runtime* _rt, i256* _endowment, i256* _initOff, i256* _in
u256 gas; // TODO: Handle gas u256 gas; // TODO: Handle gas
auto initOff = static_cast<size_t>(llvm2eth(*_initOff)); auto initOff = static_cast<size_t>(llvm2eth(*_initOff));
auto initSize = static_cast<size_t>(llvm2eth(*_initSize)); auto initSize = static_cast<size_t>(llvm2eth(*_initSize));
//auto&& initRef = bytesConstRef(Runtime::getMemory().data() + initOff, initSize); auto&& initRef = bytesConstRef(_rt->getMemory().data() + initOff, initSize);
bytesConstRef initRef;
OnOpFunc onOp{}; // TODO: Handle that thing OnOpFunc onOp{}; // TODO: Handle that thing
h256 address = ext.create(endowment, &gas, initRef, onOp); h256 address = ext.create(endowment, &gas, initRef, onOp);
*_address = address; *_address = address;
@ -252,8 +251,8 @@ EXPORT void ext_call(Runtime* _rt, i256* _gas, h256* _receiveAddress, i256* _val
auto inSize = static_cast<size_t>(llvm2eth(*_inSize)); auto inSize = static_cast<size_t>(llvm2eth(*_inSize));
auto outOff = static_cast<size_t>(llvm2eth(*_outOff)); auto outOff = static_cast<size_t>(llvm2eth(*_outOff));
auto outSize = static_cast<size_t>(llvm2eth(*_outSize)); auto outSize = static_cast<size_t>(llvm2eth(*_outSize));
auto&& inRef = bytesConstRef(); //Runtime::getMemory().data() + inOff, inSize); auto&& inRef = bytesConstRef(_rt->getMemory().data() + inOff, inSize);
auto&& outRef = bytesConstRef(); // Runtime::getMemory().data() + outOff, outSize); auto&& outRef = bytesConstRef(_rt->getMemory().data() + outOff, outSize);
OnOpFunc onOp{}; // TODO: Handle that thing OnOpFunc onOp{}; // TODO: Handle that thing
auto codeAddress = right160(*_codeAddress); auto codeAddress = right160(*_codeAddress);
ret = ext.call(receiveAddress, value, inRef, &gas, outRef, onOp, {}, codeAddress); ret = ext.call(receiveAddress, value, inRef, &gas, outRef, onOp, {}, codeAddress);
@ -267,7 +266,7 @@ EXPORT void ext_sha3(Runtime* _rt, i256* _inOff, i256* _inSize, i256* _ret)
{ {
auto inOff = static_cast<size_t>(llvm2eth(*_inOff)); auto inOff = static_cast<size_t>(llvm2eth(*_inOff));
auto inSize = static_cast<size_t>(llvm2eth(*_inSize)); auto inSize = static_cast<size_t>(llvm2eth(*_inSize));
auto dataRef = bytesConstRef(); // Runtime::getMemory().data() + inOff, inSize); auto dataRef = bytesConstRef(_rt->getMemory().data() + inOff, inSize);
auto hash = sha3(dataRef); auto hash = sha3(dataRef);
*_ret = *reinterpret_cast<i256*>(&hash); *_ret = *reinterpret_cast<i256*>(&hash);
} }

Loading…
Cancel
Save