mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Changes in EVM JIT C interface
This commit is contained in:
parent
d06988a65a
commit
4aabaa1553
2 changed files with 12 additions and 26 deletions
|
|
@ -5,36 +5,22 @@
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
int evmjit_run()
|
int evmjit_run(void* _data, void* _env)
|
||||||
{
|
{
|
||||||
using namespace dev::eth::jit;
|
using namespace dev::eth::jit;
|
||||||
|
|
||||||
|
auto data = static_cast<RuntimeData*>(_data);
|
||||||
|
|
||||||
|
std::cerr << "GAS: " << data->elems[RuntimeData::Gas].a << "\n";
|
||||||
|
|
||||||
ExecutionEngine engine;
|
ExecutionEngine engine;
|
||||||
u256 gas = 100000;
|
|
||||||
|
|
||||||
bytes bytecode = { 0x60, 0x01 };
|
auto codePtr = data->code;
|
||||||
|
auto codeSize = data->elems[RuntimeData::CodeSize].a;
|
||||||
|
bytes bytecode;
|
||||||
|
bytecode.insert(bytecode.end(), codePtr, codePtr + codeSize);
|
||||||
|
|
||||||
// Create random runtime data
|
auto result = engine.run(bytecode, data, static_cast<Env*>(_env));
|
||||||
RuntimeData data;
|
|
||||||
data.set(RuntimeData::Gas, gas);
|
|
||||||
data.set(RuntimeData::Address, 0);
|
|
||||||
data.set(RuntimeData::Caller, 0);
|
|
||||||
data.set(RuntimeData::Origin, 0);
|
|
||||||
data.set(RuntimeData::CallValue, 0xabcd);
|
|
||||||
data.set(RuntimeData::CallDataSize, 3);
|
|
||||||
data.set(RuntimeData::GasPrice, 1003);
|
|
||||||
data.set(RuntimeData::CoinBase, 0);
|
|
||||||
data.set(RuntimeData::TimeStamp, 1005);
|
|
||||||
data.set(RuntimeData::Number, 1006);
|
|
||||||
data.set(RuntimeData::Difficulty, 16);
|
|
||||||
data.set(RuntimeData::GasLimit, 1008);
|
|
||||||
data.set(RuntimeData::CodeSize, bytecode.size());
|
|
||||||
data.callData = (uint8_t*)"abc";
|
|
||||||
data.code = bytecode.data();
|
|
||||||
|
|
||||||
// BROKEN: env_* functions must be implemented & RuntimeData struct created
|
|
||||||
// TODO: Do not compile module again
|
|
||||||
auto result = engine.run(bytecode, &data, nullptr);
|
|
||||||
return static_cast<int>(result);
|
return static_cast<int>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int evmjit_run();
|
int evmjit_run(void* _data, void* _env);
|
||||||
|
|
||||||
// JIT object opaque type
|
// JIT object opaque type
|
||||||
typedef struct evm_jit evm_jit;
|
typedef struct evm_jit evm_jit;
|
||||||
|
|
@ -15,7 +15,7 @@ typedef int evm_jit_return_code;
|
||||||
// Host-endian 256-bit integer type
|
// Host-endian 256-bit integer type
|
||||||
typedef struct i256 i256;
|
typedef struct i256 i256;
|
||||||
|
|
||||||
struct h256
|
struct i256
|
||||||
{
|
{
|
||||||
char b[33];
|
char b[33];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue