OLD | NEW |
---|---|
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 Loading... | |
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 __ add(kScratchReg, kScratchReg, | |
Rodolph Perfetta
2017/03/20 22:07:17
kScratchReg holds the address of the stack limit n
Michael Starzinger
2017/03/21 09:13:50
Nice catch!
ahaas
2017/03/21 10:44:40
Fixed. Thanks for catching this one.
| |
2418 Operand(shrink_slots * kPointerSize)); | |
2419 __ cmp(sp, kScratchReg); | |
2420 __ b(cs, &done); | |
2421 } | |
2422 | |
2423 if (!frame_access_state()->has_frame()) { | |
2424 __ set_has_frame(true); | |
2425 // There is no need to leave the frame, we will not return from the | |
2426 // runtime call. | |
2427 __ EnterFrame(StackFrame::WASM_COMPILED); | |
2428 } | |
2429 __ Move(cp, Smi::kZero); | |
2430 __ CallRuntime(Runtime::kThrowWasmStackOverflow); | |
2431 // We come from WebAssembly, there are no references for the GC. | |
2432 ReferenceMap* reference_map = new (zone()) ReferenceMap(zone()); | |
2433 RecordSafepoint(reference_map, Safepoint::kSimple, 0, | |
2434 Safepoint::kNoLazyDeopt); | |
2435 if (FLAG_debug_code) { | |
2436 __ stop(GetBailoutReason(kUnexpectedReturnFromThrow)); | |
2437 } | |
2438 | |
2439 __ bind(&done); | |
2440 } | |
2441 } | |
2402 __ sub(sp, sp, Operand(shrink_slots * kPointerSize)); | 2442 __ sub(sp, sp, Operand(shrink_slots * kPointerSize)); |
2403 } | 2443 } |
2404 | 2444 |
2405 if (saves_fp != 0) { | 2445 if (saves_fp != 0) { |
2406 // Save callee-saved FP registers. | 2446 // Save callee-saved FP registers. |
2407 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); | 2447 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); |
2408 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; | 2448 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; |
2409 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); | 2449 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); |
2410 DCHECK_EQ((last - first + 1), base::bits::CountPopulation32(saves_fp)); | 2450 DCHECK_EQ((last - first + 1), base::bits::CountPopulation32(saves_fp)); |
2411 __ vstm(db_w, sp, DwVfpRegister::from_code(first), | 2451 __ vstm(db_w, sp, DwVfpRegister::from_code(first), |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2780 padding_size -= v8::internal::Assembler::kInstrSize; | 2820 padding_size -= v8::internal::Assembler::kInstrSize; |
2781 } | 2821 } |
2782 } | 2822 } |
2783 } | 2823 } |
2784 | 2824 |
2785 #undef __ | 2825 #undef __ |
2786 | 2826 |
2787 } // namespace compiler | 2827 } // namespace compiler |
2788 } // namespace internal | 2828 } // namespace internal |
2789 } // namespace v8 | 2829 } // namespace v8 |
OLD | NEW |