Cranelift: Add heap_load and heap_store instructions (#5300)
* Cranelift: Define `heap_load` and `heap_store` instructions
* Cranelift: Implement interpreter support for `heap_load` and `heap_store`
* Cranelift: Add a suite runtests for `heap_{load,store}`
There are so many knobs we can twist for heaps and I wanted to exhaustively test
all of them, so I wrote a script to generate the tests. I've checked in the
script in case we want to make any changes in the future, but I don't think it
is worth adding this to CI to check that scripts are up to date or anything like
that.
* Review feedback
This commit is contained in:
@@ -394,6 +394,34 @@ impl Heap {
|
||||
}
|
||||
}
|
||||
|
||||
/// An opaque reference to some out-of-line immediates for `heap_{load,store}`
|
||||
/// instructions.
|
||||
///
|
||||
/// These immediates are too large to store in
|
||||
/// [`InstructionData`](super::instructions::InstructionData) and therefore must
|
||||
/// be tracked separately in
|
||||
/// [`DataFlowGraph::heap_imms`](super::dfg::DataFlowGraph). `HeapImm` provides
|
||||
/// a way to reference values stored there.
|
||||
///
|
||||
/// While the order is stable, it is arbitrary.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct HeapImm(u32);
|
||||
entity_impl!(HeapImm, "heap_imm");
|
||||
|
||||
impl HeapImm {
|
||||
/// Create a new `HeapImm` reference from its number.
|
||||
///
|
||||
/// This method is for use by the parser.
|
||||
pub fn with_number(n: u32) -> Option<Self> {
|
||||
if n < u32::MAX {
|
||||
Some(Self(n))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An opaque reference to a [WebAssembly
|
||||
/// table](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format#WebAssembly_tables).
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user