Bug 1562393: Cranelift: Don't panic when seeing unexpected number of memories/tables; r=lth

Differential Revision: https://phabricator.services.mozilla.com/D36465

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Benjamin Bouvier 2019-07-01 12:18:40 +00:00
Родитель 43069b8e39
Коммит 79e55332e8
1 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -29,7 +29,7 @@ use cranelift_codegen::isa::{CallConv, TargetFrontendConfig, TargetIsa};
use cranelift_codegen::packed_option::PackedOption;
use cranelift_wasm::{
FuncEnvironment, FuncIndex, GlobalIndex, GlobalVariable, MemoryIndex, ReturnMode,
SignatureIndex, TableIndex, WasmResult,
SignatureIndex, TableIndex, WasmError, WasmResult,
};
use std::collections::HashMap;
@ -434,7 +434,11 @@ impl<'a, 'b, 'c> FuncEnvironment for TransEnv<'a, 'b, 'c> {
}
fn make_heap(&mut self, func: &mut ir::Function, index: MemoryIndex) -> WasmResult<ir::Heap> {
assert_eq!(index.index(), 0, "Only one WebAssembly memory supported");
// Currently, Baldrdash doesn't support multiple memories.
if index.index() != 0 {
return Err(WasmError::Unsupported("only one wasm memory supported"));
}
// Get the address of the `TlsData::memoryBase` field.
let base_addr = self.get_vmctx_gv(func);
// Get the `TlsData::memoryBase` field. We assume this is never modified during execution
@ -550,8 +554,10 @@ impl<'a, 'b, 'c> FuncEnvironment for TransEnv<'a, 'b, 'c> {
) -> WasmResult<ir::Inst> {
let wsig = self.env.signature(sig_index);
// Currently, WebAssembly doesn't support multiple tables. That may change.
assert_eq!(table_index.index(), 0);
// Currently, Baldrdash doesn't support multiple tables.
if table_index.index() != 0 {
return Err(WasmError::Unsupported("only one wasm table supported"));
}
let wtable = self.get_table(pos.func, table_index);
// Follows `MacroAssembler::wasmCallIndirect`: