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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/arm/macro-assembler-arm.h" 7 #include "src/arm/macro-assembler-arm.h"
8 #include "src/assembler-inl.h" 8 #include "src/assembler-inl.h"
9 #include "src/compilation-info.h" 9 #include "src/compilation-info.h"
10 #include "src/compiler/code-generator-impl.h" 10 #include "src/compiler/code-generator-impl.h"
(...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 // frame is still on the stack. Optimized code uses OSR values directly from 2392 // frame is still on the stack. Optimized code uses OSR values directly from
2393 // the unoptimized frame. Thus, all that needs to be done is to allocate the 2393 // the unoptimized frame. Thus, all that needs to be done is to allocate the
2394 // remaining stack slots. 2394 // remaining stack slots.
2395 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 2395 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
2396 osr_pc_offset_ = __ pc_offset(); 2396 osr_pc_offset_ = __ pc_offset();
2397 shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); 2397 shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
2398 } 2398 }
2399 2399
2400 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); 2400 const RegList saves_fp = descriptor->CalleeSavedFPRegisters();
2401 if (shrink_slots > 0) { 2401 if (shrink_slots > 0) {
2402 if (info()->IsWasm()) {
2403 if (shrink_slots > 128) {
2404 // For WebAssembly functions with big frames we have to do the stack
2405 // overflow check before we construct the frame. Otherwise we may not
2406 // have enough space on the stack to call the runtime for the stack
2407 // overflow.
2408 Label done;
2409
2410 // If the frame is bigger than the stack, we throw the stack overflow
2411 // exception unconditionally. Thereby we can avoid the integer overflow
2412 // check in the condition code.
2413 if (shrink_slots * kPointerSize < FLAG_stack_size * 1024) {
2414 __ Move(kScratchReg,
2415 Operand(ExternalReference::address_of_real_stack_limit(
2416 isolate())));
2417 __ ldr(kScratchReg, MemOperand(kScratchReg));
2418 __ add(kScratchReg, kScratchReg,
2419 Operand(shrink_slots * kPointerSize));
2420 __ cmp(sp, kScratchReg);
2421 __ b(cs, &done);
2422 }
2423
2424 if (!frame_access_state()->has_frame()) {
2425 __ set_has_frame(true);
2426 // There is no need to leave the frame, we will not return from the
2427 // runtime call.
2428 __ EnterFrame(StackFrame::WASM_COMPILED);
2429 }
2430 __ Move(cp, Smi::kZero);
2431 __ CallRuntime(Runtime::kThrowWasmStackOverflow);
2432 // We come from WebAssembly, there are no references for the GC.
2433 ReferenceMap* reference_map = new (zone()) ReferenceMap(zone());
2434 RecordSafepoint(reference_map, Safepoint::kSimple, 0,
2435 Safepoint::kNoLazyDeopt);
2436 if (FLAG_debug_code) {
2437 __ stop(GetBailoutReason(kUnexpectedReturnFromThrow));
2438 }
2439
2440 __ bind(&done);
2441 }
2442 }
2402 __ sub(sp, sp, Operand(shrink_slots * kPointerSize)); 2443 __ sub(sp, sp, Operand(shrink_slots * kPointerSize));
2403 } 2444 }
2404 2445
2405 if (saves_fp != 0) { 2446 if (saves_fp != 0) {
Rodolph Perfetta 2017/03/23 13:02:20 this code will decrement the stack further, so sho
ahaas 2017/03/23 14:14:09 Good observation, but I think it does not matter.
2406 // Save callee-saved FP registers. 2447 // Save callee-saved FP registers.
2407 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); 2448 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32);
2408 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; 2449 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1;
2409 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); 2450 uint32_t first = base::bits::CountTrailingZeros32(saves_fp);
2410 DCHECK_EQ((last - first + 1), base::bits::CountPopulation32(saves_fp)); 2451 DCHECK_EQ((last - first + 1), base::bits::CountPopulation32(saves_fp));
2411 __ vstm(db_w, sp, DwVfpRegister::from_code(first), 2452 __ vstm(db_w, sp, DwVfpRegister::from_code(first),
2412 DwVfpRegister::from_code(last)); 2453 DwVfpRegister::from_code(last));
2413 } 2454 }
2414 const RegList saves = FLAG_enable_embedded_constant_pool 2455 const RegList saves = FLAG_enable_embedded_constant_pool
2415 ? (descriptor->CalleeSavedRegisters() & ~pp.bit()) 2456 ? (descriptor->CalleeSavedRegisters() & ~pp.bit())
2416 : descriptor->CalleeSavedRegisters(); 2457 : descriptor->CalleeSavedRegisters();
2417 if (saves != 0) { 2458 if (saves != 0) {
Rodolph Perfetta 2017/03/23 13:02:20 ditto.
2418 // Save callee-saved registers. 2459 // Save callee-saved registers.
2419 __ stm(db_w, sp, saves); 2460 __ stm(db_w, sp, saves);
2420 } 2461 }
2421 } 2462 }
2422 2463
2423 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { 2464 void CodeGenerator::AssembleReturn(InstructionOperand* pop) {
2424 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 2465 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
2425 int pop_count = static_cast<int>(descriptor->StackParameterCount()); 2466 int pop_count = static_cast<int>(descriptor->StackParameterCount());
2426 2467
2427 // Restore registers. 2468 // Restore registers.
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 padding_size -= v8::internal::Assembler::kInstrSize; 2821 padding_size -= v8::internal::Assembler::kInstrSize;
2781 } 2822 }
2782 } 2823 }
2783 } 2824 }
2784 2825
2785 #undef __ 2826 #undef __
2786 2827
2787 } // namespace compiler 2828 } // namespace compiler
2788 } // namespace internal 2829 } // namespace internal
2789 } // namespace v8 2830 } // namespace v8
OLDNEW
« 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