Index: test/cctest/wasm/wasm-run-utils.h |
diff --git a/test/cctest/wasm/wasm-run-utils.h b/test/cctest/wasm/wasm-run-utils.h |
index 7a893df2fb5cd432914033e8871ec179211838ec..9c883fa5fa005aba8b64ad634b0dbc5ba8e7fb26 100644 |
--- a/test/cctest/wasm/wasm-run-utils.h |
+++ b/test/cctest/wasm/wasm-run-utils.h |
@@ -564,8 +564,16 @@ class WasmFunctionCompiler : private GraphAndBuilders { |
Handle<WasmCompiledModule> compiled_module( |
testing_module_->instance_object()->compiled_module(), isolate()); |
Handle<FixedArray> code_table = compiled_module->code_table(); |
- code_table = FixedArray::SetAndGrow(code_table, function_index(), code); |
- compiled_module->set_code_table(code_table); |
+ if (static_cast<int>(function_index()) >= code_table->length()) { |
+ Handle<FixedArray> new_arr = isolate()->factory()->NewFixedArray( |
+ static_cast<int>(function_index()) + 1); |
+ code_table->CopyTo(0, *new_arr, 0, code_table->length()); |
+ code_table = new_arr; |
+ compiled_module->set_code_table(code_table); |
+ } |
+ DCHECK(code_table->get(static_cast<int>(function_index())) |
+ ->IsUndefined(isolate())); |
+ code_table->set(static_cast<int>(function_index()), *code); |
} |
byte AllocateLocal(ValueType type) { |