return call ref
This commit is contained in:
parent
b29a983ab9
commit
36e3059be7
|
@ -214,6 +214,12 @@ impl<'a> WasmFuncBackend<'a> {
|
|||
table: table.index() as u32,
|
||||
});
|
||||
}
|
||||
WasmBlock::ReturnCallRef { sig, values } => {
|
||||
for &value in &values[..] {
|
||||
self.lower_value(value, func);
|
||||
}
|
||||
func.instruction(&wasm_encoder::Instruction::ReturnCallRef(sig.index() as u32));
|
||||
}
|
||||
WasmBlock::Unreachable => {
|
||||
func.instruction(&wasm_encoder::Instruction::Unreachable);
|
||||
}
|
||||
|
|
|
@ -61,6 +61,12 @@ pub enum WasmBlock<'a> {
|
|||
table: Table,
|
||||
values: &'a [Value],
|
||||
},
|
||||
/// A function refernce tail call instruction
|
||||
ReturnCallRef {
|
||||
sig: Signature,
|
||||
// table: Table,
|
||||
values: &'a [Value],
|
||||
},
|
||||
/// An unreachable instruction.
|
||||
Unreachable,
|
||||
}
|
||||
|
@ -465,6 +471,15 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
table,
|
||||
values: args,
|
||||
}),
|
||||
&Terminator::ReturnCallRef {
|
||||
sig,
|
||||
// table,
|
||||
ref args,
|
||||
} => into.push(WasmBlock::ReturnCallRef {
|
||||
sig,
|
||||
// table,
|
||||
values: args,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1531,7 +1531,22 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> {
|
|||
});
|
||||
self.reachable = false;
|
||||
}
|
||||
|
||||
wasmparser::Operator::ReturnCallRef {
|
||||
type_index,
|
||||
// table_index,
|
||||
} => {
|
||||
let retvals = self.pop_n(
|
||||
self.module.signatures[Signature::new(*type_index as usize)]
|
||||
.params
|
||||
.len(),
|
||||
);
|
||||
self.emit_term(Terminator::ReturnCallRef {
|
||||
sig: Signature::new(*type_index as usize),
|
||||
// table: Table::new(*table_index as usize),
|
||||
args: retvals,
|
||||
});
|
||||
self.reachable = false;
|
||||
}
|
||||
_ => bail!(FrontendError::UnsupportedFeature(format!(
|
||||
"Unsupported operator: {:?}",
|
||||
op
|
||||
|
|
|
@ -325,6 +325,7 @@ impl InterpContext {
|
|||
log::trace!("returning from {}: {:?}", func, values);
|
||||
return InterpResult::Ok(values);
|
||||
}
|
||||
Terminator::ReturnCallRef { sig, args } => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -545,6 +545,10 @@ pub enum Terminator {
|
|||
table: Table,
|
||||
args: Vec<Value>,
|
||||
},
|
||||
ReturnCallRef {
|
||||
sig: Signature,
|
||||
args: Vec<Value>,
|
||||
},
|
||||
Unreachable,
|
||||
None,
|
||||
}
|
||||
|
@ -609,6 +613,16 @@ impl std::fmt::Display for Terminator {
|
|||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
)?,
|
||||
Terminator::ReturnCallRef { sig, args } =>write!(
|
||||
f,
|
||||
"return_call_ref ({})({})",
|
||||
sig,
|
||||
// table,
|
||||
args.iter()
|
||||
.map(|val| format!("{}", val))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -641,6 +655,7 @@ impl Terminator {
|
|||
Terminator::Unreachable => {}
|
||||
Terminator::ReturnCall { func, args } => {}
|
||||
Terminator::ReturnCallIndirect { sig, table, args } => {}
|
||||
Terminator::ReturnCallRef { sig, args } => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -670,6 +685,9 @@ impl Terminator {
|
|||
Terminator::Unreachable => {}
|
||||
Terminator::ReturnCall { func, args } => {}
|
||||
Terminator::ReturnCallIndirect { sig, table, args } => {}
|
||||
Terminator::ReturnCallRef { sig, args } => {
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -787,6 +805,14 @@ impl Terminator {
|
|||
f(value);
|
||||
}
|
||||
}
|
||||
&mut Terminator::ReturnCallRef {
|
||||
sig,
|
||||
ref mut args,
|
||||
} => {
|
||||
for value in args {
|
||||
f(value);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue