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 8aa8cff940d050a7aff1ead5d5367569bcae970c..ceb42151ab48fac1995cd0bb70890781e51bb334 100644 |
--- a/test/cctest/wasm/wasm-run-utils.h |
+++ b/test/cctest/wasm/wasm-run-utils.h |
@@ -78,6 +78,7 @@ class TestingModule : public ModuleEnv { |
public: |
explicit TestingModule(WasmExecutionMode mode = kExecuteCompiled) |
: execution_mode_(mode), |
+ linked_(false), |
instance_(&module_), |
isolate_(CcTest::InitIsolateOnce()), |
global_offset(0), |
@@ -91,7 +92,6 @@ class TestingModule : public ModuleEnv { |
module_.globals_size = kMaxGlobalsSize; |
instance->mem_start = nullptr; |
instance->mem_size = 0; |
- linker = nullptr; |
origin = kWasmOrigin; |
memset(global_data, 0, sizeof(global_data)); |
} |
@@ -208,8 +208,10 @@ class TestingModule : public ModuleEnv { |
Handle<JSObject> module_object = Handle<JSObject>(0, isolate_); |
Handle<Code> code = instance->function_code[index]; |
WasmJs::InstallWasmFunctionMap(isolate_, isolate_->native_context()); |
- return compiler::CompileJSToWasmWrapper(isolate_, this, name, code, |
- module_object, index); |
+ Handle<JSFunction> ret = compiler::CompileJSToWasmWrapper( |
+ isolate_, this, name, code, module_object, index); |
+ Link(); |
+ return ret; |
} |
void SetFunctionCode(uint32_t index, Handle<Code> code) { |
@@ -242,9 +244,20 @@ class TestingModule : public ModuleEnv { |
WasmInterpreter* interpreter() { return interpreter_; } |
WasmExecutionMode execution_mode() { return execution_mode_; } |
+ void Link() { |
+ if (linked_) return; |
+ compiler::Link(CcTest::i_isolate(), instance->function_code, |
+ instance->function_code, RelocInfo::kWasmDirectCallMask); |
+ compiler::Link(CcTest::i_isolate(), instance->function_code, |
+ instance->import_code, RelocInfo::kWasmImportCallMask); |
+ |
+ linked_ = true; |
+ } |
+ |
private: |
WasmExecutionMode execution_mode_; |
WasmModule module_; |
+ bool linked_; |
WasmModuleInstance instance_; |
Isolate* isolate_; |
v8::base::AccountingAllocator allocator_; |
@@ -699,6 +712,9 @@ class WasmRunner { |
WasmVal args[] = {WasmVal(p0), WasmVal(p1), WasmVal(p2), WasmVal(p3)}; |
return CallInterpreter(ArrayVector(args)); |
} else { |
+ if (compiler_.testing_module_ != nullptr) { |
+ compiler_.testing_module_->Link(); |
+ } |
CodeRunner<int32_t> runner(CcTest::InitIsolateOnce(), |
wrapper_.GetWrapperCode(), |
wrapper_.signature()); |