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/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/arm64/macro-assembler-arm64.h" | 8 #include "src/arm64/macro-assembler-arm64.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/compiler/code-generator-impl.h" | 10 #include "src/compiler/code-generator-impl.h" |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 void CodeGenerator::AssembleDeoptimizerCall( | 1424 void CodeGenerator::AssembleDeoptimizerCall( |
1425 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1425 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
1426 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1426 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
1427 isolate(), deoptimization_id, bailout_type); | 1427 isolate(), deoptimization_id, bailout_type); |
1428 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1428 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
1429 } | 1429 } |
1430 | 1430 |
1431 | 1431 |
1432 void CodeGenerator::AssemblePrologue() { | 1432 void CodeGenerator::AssemblePrologue() { |
1433 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1433 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1434 if (descriptor->IsCFunctionCall()) { | 1434 frame()->AlignFrame(16); |
1435 __ SetStackPointer(csp); | 1435 int stack_shrink_slots = frame()->GetSpillSlotCount(); |
1436 __ Push(lr, fp); | 1436 if (frame()->needs_frame()) { |
1437 __ Mov(fp, csp); | 1437 if (descriptor->IsJSFunctionCall()) { |
1438 } else if (descriptor->IsJSFunctionCall()) { | 1438 DCHECK(!descriptor->UseNativeStack()); |
1439 __ SetStackPointer(jssp); | 1439 __ SetStackPointer(jssp); |
1440 __ Prologue(this->info()->GeneratePreagedPrologue()); | 1440 __ Prologue(this->info()->GeneratePreagedPrologue()); |
1441 } else if (frame()->needs_frame()) { | |
1442 if (descriptor->UseNativeStack()) { | |
1443 __ SetStackPointer(csp); | |
1444 } else { | 1441 } else { |
1445 __ SetStackPointer(jssp); | 1442 if (descriptor->UseNativeStack() || descriptor->IsCFunctionCall()) { |
| 1443 __ SetStackPointer(csp); |
| 1444 } else { |
| 1445 __ SetStackPointer(jssp); |
| 1446 } |
| 1447 if (descriptor->IsCFunctionCall()) { |
| 1448 __ Push(lr, fp); |
| 1449 __ Mov(fp, masm_.StackPointer()); |
| 1450 __ Claim(stack_shrink_slots); |
| 1451 } else { |
| 1452 __ StubPrologue(info()->GetOutputStackFrameType(), |
| 1453 frame()->GetTotalFrameSlotCount()); |
| 1454 } |
1446 } | 1455 } |
1447 __ StubPrologue(); | |
1448 } else { | 1456 } else { |
1449 if (descriptor->UseNativeStack()) { | 1457 if (descriptor->UseNativeStack()) { |
1450 __ SetStackPointer(csp); | 1458 __ SetStackPointer(csp); |
1451 } else { | 1459 } else { |
1452 __ SetStackPointer(jssp); | 1460 __ SetStackPointer(jssp); |
1453 } | 1461 } |
1454 frame()->SetElidedFrameSizeInSlots(0); | 1462 frame()->SetElidedFrameSizeInSlots(0); |
1455 } | 1463 } |
1456 frame_access_state()->SetFrameAccessToDefault(); | 1464 frame_access_state()->SetFrameAccessToDefault(); |
1457 | |
1458 int stack_shrink_slots = frame()->GetSpillSlotCount(); | |
1459 if (info()->is_osr()) { | 1465 if (info()->is_osr()) { |
1460 // TurboFan OSR-compiled functions cannot be entered directly. | 1466 // TurboFan OSR-compiled functions cannot be entered directly. |
1461 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1467 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
1462 | 1468 |
1463 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1469 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
1464 // frame is still on the stack. Optimized code uses OSR values directly from | 1470 // frame is still on the stack. Optimized code uses OSR values directly from |
1465 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1471 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
1466 // remaining stack slots. | 1472 // remaining stack slots. |
1467 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1473 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
1468 osr_pc_offset_ = __ pc_offset(); | 1474 osr_pc_offset_ = __ pc_offset(); |
1469 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); | 1475 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); |
1470 } | 1476 } |
1471 | 1477 |
1472 // If frame()->needs_frame() is false, then | 1478 if (descriptor->IsJSFunctionCall()) { |
1473 // frame()->AlignSavedCalleeRegisterSlots() is guaranteed to return 0. | 1479 __ Claim(stack_shrink_slots); |
1474 if (csp.Is(masm()->StackPointer()) && frame()->needs_frame()) { | |
1475 // The system stack pointer requires 16-byte alignment at function call | |
1476 // boundaries. | |
1477 | |
1478 stack_shrink_slots += frame()->AlignSavedCalleeRegisterSlots(); | |
1479 } | 1480 } |
1480 __ Claim(stack_shrink_slots); | |
1481 | 1481 |
1482 // Save FP registers. | 1482 // Save FP registers. |
1483 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, | 1483 CPURegList saves_fp = CPURegList(CPURegister::kFPRegister, kDRegSizeInBits, |
1484 descriptor->CalleeSavedFPRegisters()); | 1484 descriptor->CalleeSavedFPRegisters()); |
1485 int saved_count = saves_fp.Count(); | 1485 int saved_count = saves_fp.Count(); |
1486 if (saved_count != 0) { | 1486 if (saved_count != 0) { |
1487 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list()); | 1487 DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedFP().list()); |
1488 __ PushCPURegList(saves_fp); | 1488 __ PushCPURegList(saves_fp); |
1489 frame()->AllocateSavedCalleeRegisterSlots(saved_count * | 1489 frame()->AllocateSavedCalleeRegisterSlots(saved_count * |
1490 (kDoubleSize / kPointerSize)); | 1490 (kDoubleSize / kPointerSize)); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 padding_size -= kInstructionSize; | 1729 padding_size -= kInstructionSize; |
1730 } | 1730 } |
1731 } | 1731 } |
1732 } | 1732 } |
1733 | 1733 |
1734 #undef __ | 1734 #undef __ |
1735 | 1735 |
1736 } // namespace compiler | 1736 } // namespace compiler |
1737 } // namespace internal | 1737 } // namespace internal |
1738 } // namespace v8 | 1738 } // namespace v8 |
OLD | NEW |