Commit b0b1ba9a authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Stack checks should not call runtime functions but stubs

This CL changes the secondary stack check for WebAssembly functions
with big stack frames in the code generator from calling a runtime
function to calling a code stub. The runtime function caused problems
with serialization.

R=mstarzinger@chromium.org
CC=bbudge@chromium.org

Bug: v8:8882
Change-Id: Iab4a1a8af233726d322722d87433f0cb33e60ac3
Reviewed-on: https://chromium-review.googlesource.com/c/1480375
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59790}
parent ee3f62fb
......@@ -1216,6 +1216,7 @@ namespace internal {
TFC(WasmMemoryGrow, WasmMemoryGrow, 1) \
TFC(WasmRecordWrite, RecordWrite, 1) \
TFC(WasmStackGuard, NoContext, 1) \
TFC(WasmStackOverflow, NoContext, 1) \
TFC(WasmToNumber, TypeConversion, 1) \
TFC(WasmThrow, WasmThrow, 1) \
TFS(ThrowWasmTrapUnreachable) \
......@@ -1522,6 +1523,7 @@ namespace internal {
V(WasmMemoryGrow) \
V(WasmRecordWrite) \
V(WasmStackGuard) \
V(WasmStackOverflow) \
V(WasmToNumber) \
V(WasmThrow) \
V(DoubleToI) \
......
......@@ -90,6 +90,13 @@ TF_BUILTIN(WasmStackGuard, WasmBuiltinsAssembler) {
TailCallRuntimeWithCEntry(Runtime::kWasmStackGuard, centry, context);
}
TF_BUILTIN(WasmStackOverflow, WasmBuiltinsAssembler) {
TNode<Object> instance = LoadInstanceFromFrame();
TNode<Code> centry = LoadCEntryFromInstance(instance);
TNode<Object> context = LoadContextFromInstance(instance);
TailCallRuntimeWithCEntry(Runtime::kThrowWasmStackOverflow, centry, context);
}
TF_BUILTIN(WasmThrow, WasmBuiltinsAssembler) {
TNode<Object> exception = UncheckedParameter(Descriptor::kException);
TNode<Object> instance = LoadInstanceFromFrame();
......
......@@ -3093,10 +3093,7 @@ void CodeGenerator::AssembleConstructFrame() {
__ b(cs, &done);
}
__ ldr(r2, FieldMemOperand(kWasmInstanceRegister,
WasmInstanceObject::kCEntryStubOffset));
__ Move(cp, Smi::zero());
__ CallRuntimeWithCEntry(Runtime::kThrowWasmStackOverflow, r2);
__ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL);
// We come from WebAssembly, there are no references for the GC.
ReferenceMap* reference_map = new (zone()) ReferenceMap(zone());
RecordSafepoint(reference_map, Safepoint::kSimple,
......
......@@ -2470,11 +2470,8 @@ void CodeGenerator::AssembleConstructFrame() {
__ Str(kWasmInstanceRegister,
MemOperand(fp, WasmCompiledFrameConstants::kWasmInstanceOffset));
}
__ LoadTaggedPointerField(
x2, FieldMemOperand(kWasmInstanceRegister,
WasmInstanceObject::kCEntryStubOffset));
__ Mov(cp, Smi::zero());
__ CallRuntimeWithCEntry(Runtime::kThrowWasmStackOverflow, x2);
__ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL);
// We come from WebAssembly, there are no references for the GC.
ReferenceMap* reference_map = new (zone()) ReferenceMap(zone());
RecordSafepoint(reference_map, Safepoint::kSimple,
......
......@@ -4227,10 +4227,9 @@ void CodeGenerator::AssembleConstructFrame() {
__ pop(scratch);
__ j(above_equal, &done);
}
__ mov(ecx, FieldOperand(kWasmInstanceRegister,
WasmInstanceObject::kCEntryStubOffset));
__ Move(esi, Smi::zero());
__ CallRuntimeWithCEntry(Runtime::kThrowWasmStackOverflow, ecx);
__ wasm_call(wasm::WasmCode::kWasmStackOverflow,
RelocInfo::WASM_STUB_CALL);
ReferenceMap* reference_map = new (zone()) ReferenceMap(zone());
RecordSafepoint(reference_map, Safepoint::kSimple,
Safepoint::kNoLazyDeopt);
......
......@@ -3720,11 +3720,9 @@ void CodeGenerator::AssembleConstructFrame() {
__ cmpq(rsp, kScratchRegister);
__ j(above_equal, &done);
}
__ LoadTaggedPointerField(
rcx, FieldOperand(kWasmInstanceRegister,
WasmInstanceObject::kCEntryStubOffset));
__ Move(rsi, Smi::zero());
__ CallRuntimeWithCEntry(Runtime::kThrowWasmStackOverflow, rcx);
__ near_call(wasm::WasmCode::kWasmStackOverflow,
RelocInfo::WASM_STUB_CALL);
ReferenceMap* reference_map = new (zone()) ReferenceMap(zone());
RecordSafepoint(reference_map, Safepoint::kSimple,
Safepoint::kNoLazyDeopt);
......
......@@ -102,8 +102,6 @@ RUNTIME_FUNCTION(Runtime_ThrowWasmError) {
RUNTIME_FUNCTION(Runtime_ThrowWasmStackOverflow) {
SealHandleScope shs(isolate);
DCHECK_LE(0, args.length());
DCHECK(isolate->context().is_null());
isolate->set_context(GetNativeContextFromWasmInstanceOnStackTop(isolate));
return isolate->StackOverflow();
}
......
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