| 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 64e801d8e267f375b96e6d3f6d92b89b448466ff..efc7aefbfce8768bee22e246ef105459e1cafcf4 100644
|
| --- a/test/cctest/wasm/wasm-run-utils.h
|
| +++ b/test/cctest/wasm/wasm-run-utils.h
|
| @@ -224,14 +224,26 @@ class TestingModule : public ModuleEnv {
|
|
|
| Handle<JSFunction> WrapCode(uint32_t index) {
|
| // Wrap the code so it can be called as a JS function.
|
| - Handle<WasmInstanceObject> instance_obj(0, isolate_);
|
| Handle<Code> code = instance->function_code[index];
|
| Handle<Code> ret_code =
|
| compiler::CompileJSToWasmWrapper(isolate_, &module_, code, index);
|
| Handle<JSFunction> ret = WasmExportedFunction::New(
|
| - isolate_, instance_obj, MaybeHandle<String>(), static_cast<int>(index),
|
| + isolate_, instance_object(), MaybeHandle<String>(),
|
| + static_cast<int>(index),
|
| static_cast<int>(this->module->functions[index].sig->parameter_count()),
|
| ret_code);
|
| +
|
| + // Add weak reference to exported functions.
|
| + Handle<WasmCompiledModule> compiled_module(
|
| + instance_object()->compiled_module(), isolate_);
|
| + Handle<FixedArray> old_arr = compiled_module->weak_exported_functions();
|
| + Handle<FixedArray> new_arr =
|
| + isolate_->factory()->NewFixedArray(old_arr->length() + 1);
|
| + old_arr->CopyTo(0, *new_arr, 0, old_arr->length());
|
| + Handle<WeakCell> weak_fn = isolate_->factory()->NewWeakCell(ret);
|
| + new_arr->set(old_arr->length(), *weak_fn);
|
| + compiled_module->set_weak_exported_functions(new_arr);
|
| +
|
| return ret;
|
| }
|
|
|
| @@ -334,6 +346,10 @@ class TestingModule : public ModuleEnv {
|
| // If tests need more (correct) information, add it later.
|
| compiled_module->set_min_mem_pages(0);
|
| compiled_module->set_max_mem_pages(Smi::kMaxValue);
|
| + Handle<FixedArray> code_table = isolate_->factory()->NewFixedArray(0);
|
| + compiled_module->set_code_table(code_table);
|
| + Handle<FixedArray> weak_exported = isolate_->factory()->NewFixedArray(0);
|
| + compiled_module->set_weak_exported_functions(weak_exported);
|
| DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module));
|
| return WasmInstanceObject::New(isolate_, compiled_module);
|
| }
|
| @@ -541,6 +557,13 @@ class WasmFunctionCompiler : private GraphAndBuilders {
|
| &source_position_table_, start, end);
|
| Handle<Code> code = Compile();
|
| testing_module_->SetFunctionCode(function_index(), code);
|
| +
|
| + // Add to code table.
|
| + 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);
|
| }
|
|
|
| byte AllocateLocal(ValueType type) {
|
| @@ -659,6 +682,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
|
| return functions_[0]->AllocateLocal(type);
|
| }
|
|
|
| + uint32_t function_index() { return functions_[0]->function_index(); }
|
| WasmFunction* function() { return functions_[0]->function_; }
|
| WasmInterpreter* interpreter() { return functions_[0]->interpreter_; }
|
| bool possible_nondeterminism() { return possible_nondeterminism_; }
|
|
|