Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lazy static dependency #448

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ cc = "1.0"
[dev-dependencies]
criterion = "0.5.1"
proptest = "1.5.0"
lazy_static = "1.4.0"

[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
jemallocator = "0.5.0"
Expand Down
20 changes: 8 additions & 12 deletions examples/check_real_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Under linux, we choose to use smem, which can monitor memory changes more accurately

use ckb_vm::{run_with_memory, Bytes, FlatMemory, SparseMemory};
use lazy_static::lazy_static;
use std::process::{id, Command};

#[cfg(has_asm)]
Expand All @@ -17,11 +16,8 @@ use ckb_vm::{
#[cfg(has_asm)]
use std::thread;

lazy_static! {
pub static ref BIN_PATH_BUFFER: Bytes =
Bytes::from(&include_bytes!("../tests/programs/alloc_many")[..]);
pub static ref BIN_NAME: String = format!("alloc_many");
}
static BIN_PATH_BUFFER: &'static [u8] = include_bytes!("../tests/programs/alloc_many");
static BIN_NAME: &str = "alloc_many";

#[cfg(not(target_os = "windows"))]
#[global_allocator]
Expand Down Expand Up @@ -128,8 +124,8 @@ fn check_interpreter(memory_size: usize) -> Result<(), ()> {
println!("Base memory: {}", get_current_memory());
for _ in 0..G_CHECK_LOOP {
let result = run_with_memory::<u64, SparseMemory<u64>>(
&BIN_PATH_BUFFER,
&vec![BIN_NAME.clone().into()],
&Bytes::from(BIN_PATH_BUFFER),
&vec![Bytes::from(BIN_NAME)],
SparseMemory::new_with_memory(memory_size),
);
assert!(result.is_ok());
Expand All @@ -148,8 +144,8 @@ fn check_falt(memory_size: usize) -> Result<(), ()> {
println!("Base memory: {}", get_current_memory());
for _ in 0..G_CHECK_LOOP {
let result = run_with_memory::<u64, FlatMemory<u64>>(
&BIN_PATH_BUFFER,
&vec![BIN_NAME.clone().into()],
&Bytes::from(BIN_PATH_BUFFER),
&vec![Bytes::from(BIN_NAME)],
FlatMemory::new_with_memory(memory_size),
);
assert!(result.is_ok());
Expand All @@ -172,7 +168,7 @@ fn check_asm(memory_size: usize) -> Result<(), ()> {
let core = DefaultMachineBuilder::new(asm_core).build();
let mut machine = AsmMachine::new(core);
machine
.load_program(&BIN_PATH_BUFFER, &vec![BIN_NAME.clone().into()])
.load_program(&Bytes::from(BIN_PATH_BUFFER), &vec![Bytes::from(BIN_NAME)])
.unwrap();
let result = machine.run();
assert!(result.is_ok());
Expand All @@ -196,7 +192,7 @@ fn check_asm_in_thread(memory_size: usize) -> Result<(), ()> {
let core = DefaultMachineBuilder::new(asm_core).build();
let mut machine = AsmMachine::new(core);
machine
.load_program(&BIN_PATH_BUFFER, &vec![BIN_NAME.clone().into()])
.load_program(&Bytes::from(BIN_PATH_BUFFER), &vec![Bytes::from(BIN_NAME)])
.unwrap();
let thread_join_handle = thread::spawn(move || {
let result = machine.run();
Expand Down