Fixing jit feature compilation (#2376)
* Fixing jit feature compilation * Fixing jit feature compilation (#2310) Conflicts: Cargo.lock * Delegatecall support
This commit is contained in:
parent
3c59475be6
commit
1d69b0e124
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -256,6 +256,7 @@ dependencies = [
|
|||||||
"ethcore-util 1.3.2",
|
"ethcore-util 1.3.2",
|
||||||
"ethjson 0.1.0",
|
"ethjson 0.1.0",
|
||||||
"ethstore 0.1.0",
|
"ethstore 0.1.0",
|
||||||
|
"evmjit 1.3.0",
|
||||||
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hyper 0.9.4 (git+https://github.com/ethcore/hyper)",
|
"hyper 0.9.4 (git+https://github.com/ethcore/hyper)",
|
||||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -538,6 +539,13 @@ dependencies = [
|
|||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "evmjit"
|
||||||
|
version = "1.3.0"
|
||||||
|
dependencies = [
|
||||||
|
"tiny-keccak 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fdlimit"
|
name = "fdlimit"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -59,6 +59,7 @@ ui = ["dapps", "ethcore-signer/ui"]
|
|||||||
use-precompiled-js = ["ethcore-dapps/use-precompiled-js", "ethcore-signer/use-precompiled-js"]
|
use-precompiled-js = ["ethcore-dapps/use-precompiled-js", "ethcore-signer/use-precompiled-js"]
|
||||||
dapps = ["ethcore-dapps"]
|
dapps = ["ethcore-dapps"]
|
||||||
ipc = ["ethcore/ipc"]
|
ipc = ["ethcore/ipc"]
|
||||||
|
jit = ["ethcore/jit"]
|
||||||
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev", "ethcore-dapps/dev", "ethcore-signer/dev"]
|
dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "ethcore-rpc/dev", "ethcore-dapps/dev", "ethcore-signer/dev"]
|
||||||
json-tests = ["ethcore/json-tests"]
|
json-tests = ["ethcore/json-tests"]
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
use common::*;
|
use common::*;
|
||||||
use evmjit;
|
use evmjit;
|
||||||
use evm::{self, GasLeft};
|
use evm::{self, GasLeft};
|
||||||
|
use types::executed::CallType;
|
||||||
|
|
||||||
/// Should be used to convert jit types to ethcore
|
/// Should be used to convert jit types to ethcore
|
||||||
trait FromJit<T>: Sized {
|
trait FromJit<T>: Sized {
|
||||||
@ -77,10 +78,11 @@ impl IntoJit<evmjit::I256> for U256 {
|
|||||||
impl IntoJit<evmjit::I256> for H256 {
|
impl IntoJit<evmjit::I256> for H256 {
|
||||||
fn into_jit(self) -> evmjit::I256 {
|
fn into_jit(self) -> evmjit::I256 {
|
||||||
let mut ret = [0; 4];
|
let mut ret = [0; 4];
|
||||||
for i in 0..self.bytes().len() {
|
let len = self.len();
|
||||||
let rev = self.bytes().len() - 1 - i;
|
for i in 0..len {
|
||||||
|
let rev = len - 1 - i;
|
||||||
let pos = rev / 8;
|
let pos = rev / 8;
|
||||||
ret[pos] += (self.bytes()[i] as u64) << ((rev % 8) * 8);
|
ret[pos] += (self[i] as u64) << ((rev % 8) * 8);
|
||||||
}
|
}
|
||||||
evmjit::I256 { words: ret }
|
evmjit::I256 { words: ret }
|
||||||
}
|
}
|
||||||
@ -194,6 +196,7 @@ impl<'a> evmjit::Ext for ExtAdapter<'a> {
|
|||||||
receive_address: *const evmjit::H256,
|
receive_address: *const evmjit::H256,
|
||||||
code_address: *const evmjit::H256,
|
code_address: *const evmjit::H256,
|
||||||
transfer_value: *const evmjit::I256,
|
transfer_value: *const evmjit::I256,
|
||||||
|
// Ignoring apparent value - it's handled correctly in executive.
|
||||||
_apparent_value: *const evmjit::I256,
|
_apparent_value: *const evmjit::I256,
|
||||||
in_beg: *const u8,
|
in_beg: *const u8,
|
||||||
in_size: u64,
|
in_size: u64,
|
||||||
@ -207,10 +210,12 @@ impl<'a> evmjit::Ext for ExtAdapter<'a> {
|
|||||||
let receive_address = unsafe { Address::from_jit(&*receive_address) };
|
let receive_address = unsafe { Address::from_jit(&*receive_address) };
|
||||||
let code_address = unsafe { Address::from_jit(&*code_address) };
|
let code_address = unsafe { Address::from_jit(&*code_address) };
|
||||||
let transfer_value = unsafe { U256::from_jit(&*transfer_value) };
|
let transfer_value = unsafe { U256::from_jit(&*transfer_value) };
|
||||||
let value = Some(transfer_value);
|
|
||||||
|
|
||||||
// receive address and code address are the same in normal calls
|
// receive address and code address are the same in normal calls
|
||||||
let is_callcode = receive_address != code_address;
|
let is_callcode = receive_address != code_address;
|
||||||
|
let is_delegatecall = is_callcode && sender_address != receive_address;
|
||||||
|
|
||||||
|
let value = if is_delegatecall { None } else { Some(transfer_value) };
|
||||||
|
|
||||||
if !is_callcode && !self.ext.exists(&code_address) {
|
if !is_callcode && !self.ext.exists(&code_address) {
|
||||||
gas_cost = gas_cost + U256::from(self.ext.schedule().call_new_account_gas);
|
gas_cost = gas_cost + U256::from(self.ext.schedule().call_new_account_gas);
|
||||||
@ -239,6 +244,12 @@ impl<'a> evmjit::Ext for ExtAdapter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let call_type = match (is_callcode, is_delegatecall) {
|
||||||
|
(_, true) => CallType::DelegateCall,
|
||||||
|
(true, false) => CallType::CallCode,
|
||||||
|
(false, false) => CallType::Call,
|
||||||
|
};
|
||||||
|
|
||||||
match self.ext.call(
|
match self.ext.call(
|
||||||
&call_gas,
|
&call_gas,
|
||||||
&sender_address,
|
&sender_address,
|
||||||
@ -246,7 +257,9 @@ impl<'a> evmjit::Ext for ExtAdapter<'a> {
|
|||||||
value,
|
value,
|
||||||
unsafe { slice::from_raw_parts(in_beg, in_size as usize) },
|
unsafe { slice::from_raw_parts(in_beg, in_size as usize) },
|
||||||
&code_address,
|
&code_address,
|
||||||
unsafe { slice::from_raw_parts_mut(out_beg, out_size as usize) }) {
|
unsafe { slice::from_raw_parts_mut(out_beg, out_size as usize) },
|
||||||
|
call_type,
|
||||||
|
) {
|
||||||
evm::MessageCallResult::Success(gas_left) => unsafe {
|
evm::MessageCallResult::Success(gas_left) => unsafe {
|
||||||
*io_gas = (gas + gas_left).low_u64();
|
*io_gas = (gas + gas_left).low_u64();
|
||||||
true
|
true
|
||||||
|
@ -102,7 +102,8 @@ extern crate rand;
|
|||||||
extern crate bit_set;
|
extern crate bit_set;
|
||||||
extern crate lru_cache;
|
extern crate lru_cache;
|
||||||
|
|
||||||
#[cfg(feature = "jit" )] extern crate evmjit;
|
#[cfg(feature = "jit" )]
|
||||||
|
extern crate evmjit;
|
||||||
|
|
||||||
pub mod account_provider;
|
pub mod account_provider;
|
||||||
pub mod engines;
|
pub mod engines;
|
||||||
|
Loading…
Reference in New Issue
Block a user