Skip to content

Commit 754ef09

Browse files
committed
implement more of Alex' suggestions
1 parent 820552a commit 754ef09

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

crates/cranelift/src/func_environ.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ wasmtime_environ::foreach_builtin_function!(declare_function_signatures);
9191
/// The `FuncEnvironment` implementation for use by the `ModuleEnvironment`.
9292
pub struct FuncEnvironment<'module_environment> {
9393
compiler: &'module_environment Compiler,
94-
/// NOTE(frank-emrich) pub for use in crate::wasmfx::* modules
9594
pub(crate) isa: &'module_environment (dyn TargetIsa + 'module_environment),
9695
pub(crate) module: &'module_environment Module,
9796
pub(crate) types: &'module_environment ModuleTypesBuilder,
@@ -138,7 +137,6 @@ pub struct FuncEnvironment<'module_environment> {
138137
/// VMStoreContext` for this function's vmctx argument. This pointer is stored
139138
/// in the vmctx itself, but never changes for the lifetime of the function,
140139
/// so if we load it up front we can continue to use it throughout.
141-
/// NOTE(frank-emrich) pub for use in stack_switching modules
142140
pub(crate) vmstore_context_ptr: ir::Value,
143141

144142
/// A cached epoch deadline value, when performing epoch-based
@@ -1719,7 +1717,8 @@ impl<'module_environment> TargetEnvironment for FuncEnvironment<'module_environm
17191717
let needs_stack_map = match wasm_ty.top() {
17201718
WasmHeapTopType::Extern | WasmHeapTopType::Any => true,
17211719
WasmHeapTopType::Func => false,
1722-
// FIXME(frank-emrich) Don't we actually need to include continuations in stack maps??
1720+
// TODO(#10248) Once continuations can be stored on the GC heap, we
1721+
// will need stack maps for continuation objects.
17231722
WasmHeapTopType::Cont => false,
17241723
};
17251724
(ty, needs_stack_map)
@@ -3279,7 +3278,10 @@ impl FuncEnvironment<'_> {
32793278
_tag_index: u32,
32803279
_cont: ir::Value,
32813280
) -> WasmResult<ir::Value> {
3282-
todo!()
3281+
// TODO(#10248)
3282+
Err(wasmtime_environ::WasmError::Unsupported(
3283+
"resume.throw instruction not implemented, yet".to_string(),
3284+
))
32833285
}
32843286

32853287
pub fn translate_suspend(

crates/cranelift/src/gc/enabled.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,10 @@ pub fn translate_ref_test(
10681068
func_env.is_subtype(builder, actual_shared_ty, expected_shared_ty)
10691069
}
10701070
WasmHeapType::ConcreteCont(_) => {
1071-
unimplemented!("Stack switching feature not compatbile with GC, yet")
1071+
// TODO(#10248)
1072+
return Err(wasmtime_environ::WasmError::Unsupported(
1073+
"Stack switching feature not compatbile with GC, yet".to_string(),
1074+
));
10721075
}
10731076
};
10741077
builder.ins().jump(continue_block, &[result]);

crates/cranelift/src/stack_switching/control_effect.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use wasmtime_environ::stack_switching as stack_switching_environ;
88
/// resume signal, suspension signal, and handler index into a
99
/// u64 value. This instance is used at compile time. There is a runtime
1010
/// counterpart in `continuations/src/lib.rs`.
11-
/// We convert to and from u64 as follows: The 4 LSBs of the u64 are the
12-
/// discriminant, the 4 MSBs are the handler_index (if `Suspend`)
11+
/// We convert to and from u64 as follows: The low 32 bits of the u64 are the
12+
/// discriminant, the high 32 bits are the handler_index (if `Suspend`)
1313
#[derive(Clone, Copy)]
1414
pub struct ControlEffect(ir::Value);
1515

@@ -37,7 +37,7 @@ impl ControlEffect {
3737
) -> Self {
3838
let discriminant = builder.ins().iconst(
3939
I64,
40-
stack_switching_environ::CONTROL_EFFECT_RESUME_DISCRIMINANT as i64,
40+
i64::from(stack_switching_environ::CONTROL_EFFECT_RESUME_DISCRIMINANT),
4141
);
4242
let val = builder.ins().ishl_imm(discriminant, 32);
4343

@@ -50,7 +50,7 @@ impl ControlEffect {
5050
) -> Self {
5151
let discriminant = builder.ins().iconst(
5252
I64,
53-
stack_switching_environ::CONTROL_EFFECT_SWITCH_DISCRIMINANT as i64,
53+
i64::from(stack_switching_environ::CONTROL_EFFECT_SWITCH_DISCRIMINANT),
5454
);
5555
let val = builder.ins().ishl_imm(discriminant, 32);
5656

@@ -64,7 +64,7 @@ impl ControlEffect {
6464
) -> Self {
6565
let discriminant = builder.ins().iconst(
6666
I64,
67-
stack_switching_environ::CONTROL_EFFECT_SUSPEND_DISCRIMINANT as i64,
67+
i64::from(stack_switching_environ::CONTROL_EFFECT_SUSPEND_DISCRIMINANT),
6868
);
6969
let val = builder.ins().ishl_imm(discriminant, 32);
7070
let handler_index = builder.ins().uextend(I64, handler_index);

0 commit comments

Comments
 (0)