Skip to content

Commit

Permalink
Merge pull request #1832 from fitzgen/externref-stack-maps
Browse files Browse the repository at this point in the history
externref: implement stack map-based garbage collection
  • Loading branch information
fitzgen authored Jun 16, 2020
2 parents 8d671c2 + 683dc15 commit 647d2b4
Show file tree
Hide file tree
Showing 31 changed files with 1,355 additions and 165 deletions.
118 changes: 72 additions & 46 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pretty_env_logger = "0.4.0"
file-per-thread-logger = "0.1.1"
wat = "1.0.18"
libc = "0.2.60"
log = "0.4.8"
rayon = "1.2.1"
humantime = "1.3.0"

Expand Down Expand Up @@ -86,3 +87,6 @@ maintenance = { status = "actively-developed" }
[[test]]
name = "host_segfault"
harness = false

[profile.dev.package.backtrace]
debug = false # FIXME(#1813)
9 changes: 7 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,14 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
// testsuite repo.
("simd", "simd_const") => return true,

("reference_types", "table_copy_on_imported_tables")
| ("reference_types", "externref_id_function") => {
// Ignore if this isn't x64, because Cranelift only supports
// reference types on x64.
return env::var("CARGO_CFG_TARGET_ARCH").unwrap() != "x86_64";
}

// Still working on implementing these. See #929.
("reference_types", "table_copy_on_imported_tables") => return false,
("reference_types", "externref_id_function") => return false,
("reference_types", _) => return true,

_ => {}
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/binemit/stackmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Stackmap {

// Refer to the doc comment for `Stackmap` above to understand the
// bitmap representation used here.
let map_size = (dbg!(info.frame_size) + dbg!(info.inbound_args_size)) as usize;
let map_size = (info.frame_size + info.inbound_args_size) as usize;
let word_size = isa.pointer_bytes() as usize;
let num_words = map_size / word_size;

Expand Down
6 changes: 5 additions & 1 deletion crates/environ/src/cache.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::address_map::{ModuleAddressMap, ValueLabelsRanges};
use crate::compilation::{Compilation, Relocations, Traps};
use crate::compilation::{Compilation, Relocations, StackMaps, Traps};
use cranelift_codegen::ir;
use cranelift_entity::PrimaryMap;
use cranelift_wasm::DefinedFuncIndex;
Expand Down Expand Up @@ -35,6 +35,7 @@ pub struct ModuleCacheData {
value_ranges: ValueLabelsRanges,
stack_slots: PrimaryMap<DefinedFuncIndex, ir::StackSlots>,
traps: Traps,
stack_maps: StackMaps,
}

/// A type alias over the module cache data as a tuple.
Expand All @@ -45,6 +46,7 @@ pub type ModuleCacheDataTupleType = (
ValueLabelsRanges,
PrimaryMap<DefinedFuncIndex, ir::StackSlots>,
Traps,
StackMaps,
);

struct Sha256Hasher(Sha256);
Expand Down Expand Up @@ -204,6 +206,7 @@ impl ModuleCacheData {
value_ranges: data.3,
stack_slots: data.4,
traps: data.5,
stack_maps: data.6,
}
}

Expand All @@ -215,6 +218,7 @@ impl ModuleCacheData {
self.value_ranges,
self.stack_slots,
self.traps,
self.stack_maps,
)
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/environ/src/cache/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@ fn new_module_cache_data() -> Result<ModuleCacheDataTupleType, ()> {
PrimaryMap::new(),
PrimaryMap::new(),
PrimaryMap::new(),
PrimaryMap::new(),
))
}
Loading

0 comments on commit 647d2b4

Please sign in to comment.