Browse Source

Using gas provided by test engine and fix for creating fake ExtVMFace.

cl-refactor
Paweł Bylica 10 years ago
parent
commit
f31f3bcfc5
  1. 3
      evmcc/evmcc.cpp
  2. 9
      libevmjit/ExecutionEngine.cpp
  3. 2
      libevmjit/ExecutionEngine.h
  4. 2
      libevmjit/VM.cpp

3
evmcc/evmcc.cpp

@ -112,7 +112,8 @@ int main(int argc, char** argv)
auto engine = eth::jit::ExecutionEngine();
auto module = eth::jit::Compiler().compile({bytecode.data(), bytecode.size()});
module->dump();
auto result = engine.run(std::move(module));
u256 gas = 10000;
auto result = engine.run(std::move(module), gas);
return result;
}

9
libevmjit/ExecutionEngine.cpp

@ -36,7 +36,7 @@ ExecutionEngine::ExecutionEngine()
extern "C" { EXPORT std::jmp_buf* rt_jmpBuf; }
int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, ExtVMFace* _ext)
int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtVMFace* _ext)
{
auto module = _module.get(); // Keep ownership of the module in _module
@ -83,7 +83,7 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, ExtVMFace* _ext)
// Create fake ExtVM interface
if (!_ext)
{
auto _ext = new ExtVMFace;
_ext = new ExtVMFace;
_ext->myAddress = Address(1122334455667788);
_ext->caller = Address(0xfacefacefaceface);
_ext->origin = Address(101010101010101010);
@ -102,8 +102,7 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, ExtVMFace* _ext)
}
// Init runtime
uint64_t gas = 100;
Runtime runtime(gas, *_ext);
Runtime runtime(_gas, *_ext);
auto entryFunc = module->getFunction("main");
if (!entryFunc)
@ -124,7 +123,7 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, ExtVMFace* _ext)
else
returnCode = static_cast<ReturnCode>(r);
gas = static_cast<decltype(gas)>(Runtime::getGas());
_gas = Runtime::getGas();
if (returnCode == ReturnCode::Return)
{

2
libevmjit/ExecutionEngine.h

@ -18,7 +18,7 @@ class ExecutionEngine
public:
ExecutionEngine();
int run(std::unique_ptr<llvm::Module> module, ExtVMFace* _ext = nullptr);
int run(std::unique_ptr<llvm::Module> module, u256& _gas, ExtVMFace* _ext = nullptr);
bytes returnData;
};

2
libevmjit/VM.cpp

@ -19,7 +19,7 @@ bytes VM::go(ExtVMFace& _ext)
module->dump();
ExecutionEngine engine;
auto exitCode = engine.run(std::move(module), &_ext);
auto exitCode = engine.run(std::move(module), m_gas, &_ext);
switch (exitCode)
{

Loading…
Cancel
Save