Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: src/compiler/arm/code-generator-arm.cc

Issue 2763593002: [wasm][arm] Add an additional stack check for functions with big frames. (Closed)
Patch Set: Load the actual stack limit. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/arm/code-generator-arm.cc
diff --git a/src/compiler/arm/code-generator-arm.cc b/src/compiler/arm/code-generator-arm.cc
index f08a89e4dac7f5bc4362049f2f786751ac2a1651..88ad20142ce12f65062c13b45861f7a63532ec38 100644
--- a/src/compiler/arm/code-generator-arm.cc
+++ b/src/compiler/arm/code-generator-arm.cc
@@ -2399,6 +2399,47 @@ void CodeGenerator::AssembleConstructFrame() {
const RegList saves_fp = descriptor->CalleeSavedFPRegisters();
if (shrink_slots > 0) {
+ if (info()->IsWasm()) {
+ if (shrink_slots > 128) {
+ // For WebAssembly functions with big frames we have to do the stack
+ // overflow check before we construct the frame. Otherwise we may not
+ // have enough space on the stack to call the runtime for the stack
+ // overflow.
+ Label done;
+
+ // If the frame is bigger than the stack, we throw the stack overflow
+ // exception unconditionally. Thereby we can avoid the integer overflow
+ // check in the condition code.
+ if (shrink_slots * kPointerSize < FLAG_stack_size * 1024) {
+ __ Move(kScratchReg,
+ Operand(ExternalReference::address_of_real_stack_limit(
+ isolate())));
+ __ ldr(kScratchReg, MemOperand(kScratchReg));
+ __ add(kScratchReg, kScratchReg,
+ Operand(shrink_slots * kPointerSize));
+ __ cmp(sp, kScratchReg);
+ __ b(cs, &done);
+ }
+
+ if (!frame_access_state()->has_frame()) {
+ __ set_has_frame(true);
+ // There is no need to leave the frame, we will not return from the
+ // runtime call.
+ __ EnterFrame(StackFrame::WASM_COMPILED);
+ }
+ __ Move(cp, Smi::kZero);
+ __ CallRuntime(Runtime::kThrowWasmStackOverflow);
+ // We come from WebAssembly, there are no references for the GC.
+ ReferenceMap* reference_map = new (zone()) ReferenceMap(zone());
+ RecordSafepoint(reference_map, Safepoint::kSimple, 0,
+ Safepoint::kNoLazyDeopt);
+ if (FLAG_debug_code) {
+ __ stop(GetBailoutReason(kUnexpectedReturnFromThrow));
+ }
+
+ __ bind(&done);
+ }
+ }
__ sub(sp, sp, Operand(shrink_slots * kPointerSize));
}
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698