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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ | 328 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ |
329 } \ | 329 } \ |
330 __ bind(&done); \ | 330 __ bind(&done); \ |
331 } while (false) | 331 } while (false) |
332 | 332 |
333 void CodeGenerator::AssembleDeconstructFrame() { | 333 void CodeGenerator::AssembleDeconstructFrame() { |
334 __ mov(esp, ebp); | 334 __ mov(esp, ebp); |
335 __ pop(ebp); | 335 __ pop(ebp); |
336 } | 336 } |
337 | 337 |
338 void CodeGenerator::AssembleSetupStackPointer() {} | |
339 | |
340 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { | 338 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
341 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); | 339 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
342 if (sp_slot_delta > 0) { | 340 if (sp_slot_delta > 0) { |
343 __ add(esp, Immediate(sp_slot_delta * kPointerSize)); | 341 __ add(esp, Immediate(sp_slot_delta * kPointerSize)); |
344 } | 342 } |
345 frame_access_state()->SetFrameAccessToDefault(); | 343 frame_access_state()->SetFrameAccessToDefault(); |
346 } | 344 } |
347 | 345 |
348 | 346 |
349 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { | 347 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 // ^ esp ^ ebp | 1601 // ^ esp ^ ebp |
1604 | 1602 |
1605 // --{ mov esp, ebp }----------------------------------------------------------- | 1603 // --{ mov esp, ebp }----------------------------------------------------------- |
1606 // | FP | RET | args | caller frame | | 1604 // | FP | RET | args | caller frame | |
1607 // ^ esp,ebp | 1605 // ^ esp,ebp |
1608 | 1606 |
1609 // --{ pop ebp }---------------------------------------------------------------- | 1607 // --{ pop ebp }---------------------------------------------------------------- |
1610 // | RET | args | caller frame | | 1608 // | RET | args | caller frame | |
1611 // ^ esp ^ ebp | 1609 // ^ esp ^ ebp |
1612 | 1610 |
| 1611 void CodeGenerator::FinishFrame(Frame* frame) { |
| 1612 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 1613 int stack_shrink_slots = frame->GetSpillSlotCount(); |
| 1614 if (info()->is_osr()) { |
| 1615 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); |
| 1616 } |
| 1617 const RegList saves = descriptor->CalleeSavedRegisters(); |
| 1618 if (saves != 0) { // Save callee-saved registers. |
| 1619 DCHECK(!info()->is_osr()); |
| 1620 int pushed = 0; |
| 1621 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { |
| 1622 if (!((1 << i) & saves)) continue; |
| 1623 ++pushed; |
| 1624 } |
| 1625 frame->AllocateSavedCalleeRegisterSlots(pushed); |
| 1626 } |
| 1627 frame->set_stack_shrink_slots(stack_shrink_slots); |
| 1628 } |
1613 | 1629 |
1614 void CodeGenerator::AssemblePrologue() { | 1630 void CodeGenerator::AssembleConstructFrame() { |
1615 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1631 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1616 if (frame_access_state()->has_frame()) { | 1632 if (frame_access_state()->has_frame()) { |
1617 if (descriptor->IsCFunctionCall()) { | 1633 if (descriptor->IsCFunctionCall()) { |
1618 __ push(ebp); | 1634 __ push(ebp); |
1619 __ mov(ebp, esp); | 1635 __ mov(ebp, esp); |
1620 } else if (descriptor->IsJSFunctionCall()) { | 1636 } else if (descriptor->IsJSFunctionCall()) { |
1621 __ Prologue(this->info()->GeneratePreagedPrologue()); | 1637 __ Prologue(this->info()->GeneratePreagedPrologue()); |
1622 } else { | 1638 } else { |
1623 __ StubPrologue(info()->GetOutputStackFrameType()); | 1639 __ StubPrologue(info()->GetOutputStackFrameType()); |
1624 } | 1640 } |
1625 } | 1641 } |
1626 int stack_shrink_slots = frame()->GetSpillSlotCount(); | 1642 |
1627 if (info()->is_osr()) { | 1643 if (info()->is_osr()) { |
1628 // TurboFan OSR-compiled functions cannot be entered directly. | 1644 // TurboFan OSR-compiled functions cannot be entered directly. |
1629 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1645 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
1630 | 1646 |
1631 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1647 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
1632 // frame is still on the stack. Optimized code uses OSR values directly from | 1648 // frame is still on the stack. Optimized code uses OSR values directly from |
1633 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1649 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
1634 // remaining stack slots. | 1650 // remaining stack slots. |
1635 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1651 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
1636 osr_pc_offset_ = __ pc_offset(); | 1652 osr_pc_offset_ = __ pc_offset(); |
1637 stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); | |
1638 } | 1653 } |
1639 | 1654 |
1640 const RegList saves = descriptor->CalleeSavedRegisters(); | 1655 const RegList saves = descriptor->CalleeSavedRegisters(); |
1641 if (stack_shrink_slots > 0) { | 1656 if (frame()->stack_shrink_slots() > 0) { |
1642 __ sub(esp, Immediate(stack_shrink_slots * kPointerSize)); | 1657 __ sub(esp, Immediate(frame()->stack_shrink_slots() * kPointerSize)); |
1643 } | 1658 } |
1644 | 1659 |
1645 if (saves != 0) { // Save callee-saved registers. | 1660 if (saves != 0) { // Save callee-saved registers. |
1646 DCHECK(!info()->is_osr()); | 1661 DCHECK(!info()->is_osr()); |
1647 int pushed = 0; | 1662 int pushed = 0; |
1648 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 1663 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { |
1649 if (!((1 << i) & saves)) continue; | 1664 if (!((1 << i) & saves)) continue; |
1650 __ push(Register::from_code(i)); | 1665 __ push(Register::from_code(i)); |
1651 ++pushed; | 1666 ++pushed; |
1652 } | 1667 } |
1653 frame()->AllocateSavedCalleeRegisterSlots(pushed); | |
1654 } | 1668 } |
1655 } | 1669 } |
1656 | 1670 |
1657 | 1671 |
1658 void CodeGenerator::AssembleReturn() { | 1672 void CodeGenerator::AssembleReturn() { |
1659 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1673 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1660 | 1674 |
1661 const RegList saves = descriptor->CalleeSavedRegisters(); | 1675 const RegList saves = descriptor->CalleeSavedRegisters(); |
1662 // Restore registers. | 1676 // Restore registers. |
1663 if (saves != 0) { | 1677 if (saves != 0) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1900 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
1887 __ Nop(padding_size); | 1901 __ Nop(padding_size); |
1888 } | 1902 } |
1889 } | 1903 } |
1890 | 1904 |
1891 #undef __ | 1905 #undef __ |
1892 | 1906 |
1893 } // namespace compiler | 1907 } // namespace compiler |
1894 } // namespace internal | 1908 } // namespace internal |
1895 } // namespace v8 | 1909 } // namespace v8 |
OLD | NEW |