Commit c36bbaaf authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Liftoff] Support calls to native code

Liftoff could only call to code object on the gc heap so far. This CL
extends this to support calls to the native wasm heap. This became
urgent since --jit-to-native is enabled by default now.

R=titzer@chromium.org

Bug: v8:6600
Change-Id: Ie07416a4041d4e6ea26a8c315008a41d81f52aab
Reviewed-on: https://chromium-review.googlesource.com/863667
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50537}
parent 86ab878b
......@@ -2392,7 +2392,7 @@ Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args, Node*** rets,
DCHECK_NULL(args[0]);
wasm::FunctionSig* sig = env_->module->functions[index].sig;
if (FLAG_wasm_jit_to_native) {
// Simply encode the index of the target.
// Just encode the function index. This will be patched at instantiation.
Address code = reinterpret_cast<Address>(index);
args[0] = jsgraph()->RelocatableIntPtrConstant(
reinterpret_cast<intptr_t>(code), RelocInfo::WASM_CALL);
......
......@@ -159,6 +159,8 @@ void LiftoffAssembler::EmitCCall(ExternalReference ext_ref,
UNIMPLEMENTED();
}
void LiftoffAssembler::CallNativeWasmCode(Address addr) { UNIMPLEMENTED(); }
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -159,6 +159,8 @@ void LiftoffAssembler::EmitCCall(ExternalReference ext_ref,
UNIMPLEMENTED();
}
void LiftoffAssembler::CallNativeWasmCode(Address addr) { UNIMPLEMENTED(); }
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -562,6 +562,10 @@ void LiftoffAssembler::EmitCCall(ExternalReference ext_ref,
CallCFunction(ext_ref, static_cast<int>(num_params));
}
void LiftoffAssembler::CallNativeWasmCode(Address addr) {
wasm_call(addr, RelocInfo::WASM_CALL);
}
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -351,6 +351,8 @@ class LiftoffAssembler : public TurboAssembler {
uint32_t param_idx, uint32_t num_params);
inline void EmitCCall(ExternalReference ext_ref, uint32_t num_params);
inline void CallNativeWasmCode(Address addr);
////////////////////////////////////
// End of platform-specific part. //
////////////////////////////////////
......
......@@ -864,7 +864,9 @@ class LiftoffCompiler {
__ pc_offset(), SourcePosition(decoder->position()), false);
if (FLAG_wasm_jit_to_native) {
return unsupported(decoder, "call with jit-to-native");
// Just encode the function index. This will be patched at instantiation.
Address addr = reinterpret_cast<Address>(operand.index);
__ CallNativeWasmCode(addr);
} else {
Handle<Code> target = operand.index < env_->function_code.size()
? env_->function_code[operand.index]
......
......@@ -159,6 +159,8 @@ void LiftoffAssembler::EmitCCall(ExternalReference ext_ref,
UNIMPLEMENTED();
}
void LiftoffAssembler::CallNativeWasmCode(Address addr) { UNIMPLEMENTED(); }
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -159,6 +159,8 @@ void LiftoffAssembler::EmitCCall(ExternalReference ext_ref,
UNIMPLEMENTED();
}
void LiftoffAssembler::CallNativeWasmCode(Address addr) { UNIMPLEMENTED(); }
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -159,6 +159,8 @@ void LiftoffAssembler::EmitCCall(ExternalReference ext_ref,
UNIMPLEMENTED();
}
void LiftoffAssembler::CallNativeWasmCode(Address addr) { UNIMPLEMENTED(); }
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -159,6 +159,8 @@ void LiftoffAssembler::EmitCCall(ExternalReference ext_ref,
UNIMPLEMENTED();
}
void LiftoffAssembler::CallNativeWasmCode(Address addr) { UNIMPLEMENTED(); }
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -533,6 +533,10 @@ void LiftoffAssembler::EmitCCall(ExternalReference ext_ref,
CallCFunction(ext_ref, static_cast<int>(num_params));
}
void LiftoffAssembler::CallNativeWasmCode(Address addr) {
near_call(addr, RelocInfo::WASM_CALL);
}
} // namespace wasm
} // namespace internal
} // namespace v8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment