Always insert the entry EBB before translating any WASM.

The FuncEnvironment callbacks (make_global in particular) may need to
insert code in the entry EBB. We need to make sure the entry EBB has
been inserted in the layout before making those callbacks.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-18 11:53:32 -07:00
parent f5f37ac4a6
commit da4cde8117
2 changed files with 5 additions and 1 deletions

View File

@@ -84,6 +84,10 @@ impl FuncTranslator {
let entry_block = builder.create_ebb();
builder.switch_to_block(entry_block, &[]); // This also creates values for the arguments.
builder.seal_block(entry_block);
// Make sure the entry block is inserted in the layout before we make any callbacks to
// `environ`. The callback functions may need to insert things in the entry block.
builder.ensure_inserted_ebb();
let num_args = declare_wasm_arguments(builder);
// Set up the translation state with a single pushed control block representing the whole