OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 } \ | 360 } \ |
361 } \ | 361 } \ |
362 } \ | 362 } \ |
363 } while (0) | 363 } while (0) |
364 | 364 |
365 void CodeGenerator::AssembleDeconstructFrame() { | 365 void CodeGenerator::AssembleDeconstructFrame() { |
366 __ mov(esp, ebp); | 366 __ mov(esp, ebp); |
367 __ pop(ebp); | 367 __ pop(ebp); |
368 } | 368 } |
369 | 369 |
370 void CodeGenerator::AssembleSetupStackPointer() {} | |
371 | |
372 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { | 370 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
373 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); | 371 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
374 if (sp_slot_delta > 0) { | 372 if (sp_slot_delta > 0) { |
375 __ add(esp, Immediate(sp_slot_delta * kPointerSize)); | 373 __ add(esp, Immediate(sp_slot_delta * kPointerSize)); |
376 } | 374 } |
377 frame_access_state()->SetFrameAccessToDefault(); | 375 frame_access_state()->SetFrameAccessToDefault(); |
378 } | 376 } |
379 | 377 |
380 | 378 |
381 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { | 379 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 // ^ esp ^ ebp | 1626 // ^ esp ^ ebp |
1629 | 1627 |
1630 // --{ mov esp, ebp }----------------------------------------------------------- | 1628 // --{ mov esp, ebp }----------------------------------------------------------- |
1631 // | FP | RET | args | caller frame | | 1629 // | FP | RET | args | caller frame | |
1632 // ^ esp,ebp | 1630 // ^ esp,ebp |
1633 | 1631 |
1634 // --{ pop ebp }---------------------------------------------------------------- | 1632 // --{ pop ebp }---------------------------------------------------------------- |
1635 // | RET | args | caller frame | | 1633 // | RET | args | caller frame | |
1636 // ^ esp ^ ebp | 1634 // ^ esp ^ ebp |
1637 | 1635 |
| 1636 void CodeGenerator::FinishFrame(Frame* frame) { |
| 1637 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 1638 const RegList saves = descriptor->CalleeSavedRegisters(); |
| 1639 if (saves != 0) { // Save callee-saved registers. |
| 1640 DCHECK(!info()->is_osr()); |
| 1641 int pushed = 0; |
| 1642 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { |
| 1643 if (!((1 << i) & saves)) continue; |
| 1644 ++pushed; |
| 1645 } |
| 1646 frame->AllocateSavedCalleeRegisterSlots(pushed); |
| 1647 } |
| 1648 } |
1638 | 1649 |
1639 void CodeGenerator::AssemblePrologue() { | 1650 void CodeGenerator::AssembleConstructFrame() { |
1640 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1651 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1641 if (frame_access_state()->has_frame()) { | 1652 if (frame_access_state()->has_frame()) { |
1642 if (descriptor->IsCFunctionCall()) { | 1653 if (descriptor->IsCFunctionCall()) { |
1643 __ push(ebp); | 1654 __ push(ebp); |
1644 __ mov(ebp, esp); | 1655 __ mov(ebp, esp); |
1645 } else if (descriptor->IsJSFunctionCall()) { | 1656 } else if (descriptor->IsJSFunctionCall()) { |
1646 __ Prologue(this->info()->GeneratePreagedPrologue()); | 1657 __ Prologue(this->info()->GeneratePreagedPrologue()); |
1647 } else { | 1658 } else { |
1648 __ StubPrologue(info()->GetOutputStackFrameType()); | 1659 __ StubPrologue(info()->GetOutputStackFrameType()); |
1649 } | 1660 } |
1650 } | 1661 } |
1651 int stack_shrink_slots = frame()->GetSpillSlotCount(); | 1662 |
| 1663 int shrink_slots = frame()->GetSpillSlotCount(); |
| 1664 |
1652 if (info()->is_osr()) { | 1665 if (info()->is_osr()) { |
1653 // TurboFan OSR-compiled functions cannot be entered directly. | 1666 // TurboFan OSR-compiled functions cannot be entered directly. |
1654 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1667 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
1655 | 1668 |
1656 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1669 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
1657 // frame is still on the stack. Optimized code uses OSR values directly from | 1670 // frame is still on the stack. Optimized code uses OSR values directly from |
1658 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1671 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
1659 // remaining stack slots. | 1672 // remaining stack slots. |
1660 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1673 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
1661 osr_pc_offset_ = __ pc_offset(); | 1674 osr_pc_offset_ = __ pc_offset(); |
1662 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); | 1675 shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); |
1663 } | 1676 } |
1664 | 1677 |
1665 const RegList saves = descriptor->CalleeSavedRegisters(); | 1678 const RegList saves = descriptor->CalleeSavedRegisters(); |
1666 if (stack_shrink_slots > 0) { | 1679 if (shrink_slots > 0) { |
1667 __ sub(esp, Immediate(stack_shrink_slots * kPointerSize)); | 1680 __ sub(esp, Immediate(shrink_slots * kPointerSize)); |
1668 } | 1681 } |
1669 | 1682 |
1670 if (saves != 0) { // Save callee-saved registers. | 1683 if (saves != 0) { // Save callee-saved registers. |
1671 DCHECK(!info()->is_osr()); | 1684 DCHECK(!info()->is_osr()); |
1672 int pushed = 0; | 1685 int pushed = 0; |
1673 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 1686 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { |
1674 if (!((1 << i) & saves)) continue; | 1687 if (!((1 << i) & saves)) continue; |
1675 __ push(Register::from_code(i)); | 1688 __ push(Register::from_code(i)); |
1676 ++pushed; | 1689 ++pushed; |
1677 } | 1690 } |
1678 frame()->AllocateSavedCalleeRegisterSlots(pushed); | |
1679 } | 1691 } |
1680 } | 1692 } |
1681 | 1693 |
1682 | 1694 |
1683 void CodeGenerator::AssembleReturn() { | 1695 void CodeGenerator::AssembleReturn() { |
1684 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1696 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1685 | 1697 |
1686 const RegList saves = descriptor->CalleeSavedRegisters(); | 1698 const RegList saves = descriptor->CalleeSavedRegisters(); |
1687 // Restore registers. | 1699 // Restore registers. |
1688 if (saves != 0) { | 1700 if (saves != 0) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1911 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1923 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
1912 __ Nop(padding_size); | 1924 __ Nop(padding_size); |
1913 } | 1925 } |
1914 } | 1926 } |
1915 | 1927 |
1916 #undef __ | 1928 #undef __ |
1917 | 1929 |
1918 } // namespace compiler | 1930 } // namespace compiler |
1919 } // namespace internal | 1931 } // namespace internal |
1920 } // namespace v8 | 1932 } // namespace v8 |
OLD | NEW |