Skip to content

Commit

Permalink
Fix(global_allocator): Switch wee_alloc for dlmalloc the standard…
Browse files Browse the repository at this point in the history
… allocator for wasm.
  • Loading branch information
RomanHodulak committed Aug 31, 2022
1 parent 43ca751 commit cbda40e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
11 changes: 10 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn repro_GdASJ3KESs() {
block_timestamp: 1645717564644206730,
input_path: "src/tests/res/input_GdASJ3KESs.hex",
evm_gas_used: 706713,
near_gas_used: 132,
near_gas_used: 133,
});
}

Expand All @@ -52,7 +52,7 @@ fn repro_8ru7VEA() {
block_timestamp: 1648829935343349589,
input_path: "src/tests/res/input_8ru7VEA.hex",
evm_gas_used: 1732181,
near_gas_used: 240,
near_gas_used: 242,
});
}

Expand All @@ -72,7 +72,7 @@ fn repro_FRcorNv() {
block_timestamp: 1650960438774745116,
input_path: "src/tests/res/input_FRcorNv.hex",
evm_gas_used: 1239721,
near_gas_used: 196,
near_gas_used: 197,
});
}

Expand Down Expand Up @@ -107,7 +107,7 @@ fn repro_D98vwmi() {
block_timestamp: 1651753443421003245,
input_path: "src/tests/res/input_D98vwmi.hex",
evm_gas_used: 1_035_348,
near_gas_used: 198,
near_gas_used: 199,
});
}

Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/uniswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn test_uniswap_input_multihop() {

let (_amount_out, _evm_gas, profile) = context.exact_input(&tokens, INPUT_AMOUNT.into());

assert_eq!(122, profile.all_gas() / 1_000_000_000_000);
assert_eq!(123, profile.all_gas() / 1_000_000_000_000);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rlp = { version = "0.5.0", default-features = false }
serde = { version = "1", features = ["derive"], optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wee_alloc = { version = "0.4.5", default-features = false }
dlmalloc = { version = "0.2.4", default-features = false, features = ["global"] }

[dev-dependencies]
serde_json = "1"
Expand Down
4 changes: 3 additions & 1 deletion engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use aurora_engine_types::parameters::PromiseCreateArgs;
extern crate alloc;
#[cfg(not(feature = "std"))]
extern crate core;
#[cfg(not(feature = "std"))]
extern crate dlmalloc;

mod map;
pub mod parameters;
Expand All @@ -32,7 +34,7 @@ pub mod xcc;

#[cfg(target_arch = "wasm32")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;

#[cfg(target_arch = "wasm32")]
#[panic_handler]
Expand Down
2 changes: 1 addition & 1 deletion etc/tests/benchmark-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]

[dependencies]
wee_alloc = { version = "0.4.5", default-features = false }
dlmalloc = { version = "0.2.4", default-features = false, features = ["global"] }
2 changes: 1 addition & 1 deletion etc/tests/benchmark-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern crate alloc;
use alloc::format;

#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;

#[panic_handler]
#[no_mangle]
Expand Down

0 comments on commit cbda40e

Please sign in to comment.