| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 | 1270 |
| 1271 void MacroAssembler::CallRuntimeSaveDoubles(Runtime::FunctionId id) { | 1271 void MacroAssembler::CallRuntimeSaveDoubles(Runtime::FunctionId id) { |
| 1272 const Runtime::Function* function = Runtime::FunctionForId(id); | 1272 const Runtime::Function* function = Runtime::FunctionForId(id); |
| 1273 | 1273 |
| 1274 // Place the necessary arguments. | 1274 // Place the necessary arguments. |
| 1275 Mov(x0, function->nargs); | 1275 Mov(x0, function->nargs); |
| 1276 Mov(x1, Operand(ExternalReference(function, isolate()))); | 1276 Mov(x1, Operand(ExternalReference(function, isolate()))); |
| 1277 | 1277 |
| 1278 // TODO(all): Here we should ask CEntryStub to save floating point registers | 1278 CEntryStub stub(1, kSaveFPRegs); |
| 1279 // but this is not supported at the moment. | |
| 1280 CEntryStub stub(1); | |
| 1281 CallStub(&stub); | 1279 CallStub(&stub); |
| 1282 } | 1280 } |
| 1283 | 1281 |
| 1284 | 1282 |
| 1285 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 1283 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
| 1286 return ref0.address() - ref1.address(); | 1284 return ref0.address() - ref1.address(); |
| 1287 } | 1285 } |
| 1288 | 1286 |
| 1289 | 1287 |
| 1290 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, | 1288 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, |
| (...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 void MacroAssembler::LeaveFrame(StackFrame::Type type) { | 2620 void MacroAssembler::LeaveFrame(StackFrame::Type type) { |
| 2623 ASSERT(jssp.Is(StackPointer())); | 2621 ASSERT(jssp.Is(StackPointer())); |
| 2624 // Drop the execution stack down to the frame pointer and restore | 2622 // Drop the execution stack down to the frame pointer and restore |
| 2625 // the caller frame pointer and return address. | 2623 // the caller frame pointer and return address. |
| 2626 Mov(jssp, fp); | 2624 Mov(jssp, fp); |
| 2627 AssertStackConsistency(); | 2625 AssertStackConsistency(); |
| 2628 Pop(fp, lr); | 2626 Pop(fp, lr); |
| 2629 } | 2627 } |
| 2630 | 2628 |
| 2631 | 2629 |
| 2630 void MacroAssembler::ExitFramePreserveFPRegs() { |
| 2631 PushCPURegList(kCallerSavedFP); |
| 2632 } |
| 2633 |
| 2634 |
| 2635 void MacroAssembler::ExitFrameRestoreFPRegs() { |
| 2636 // Read the registers from the stack without popping them. The stack pointer |
| 2637 // will be reset as part of the unwinding process. |
| 2638 CPURegList saved_fp_regs = kCallerSavedFP; |
| 2639 ASSERT(saved_fp_regs.Count() % 2 == 0); |
| 2640 |
| 2641 int offset = ExitFrameConstants::kLastExitFrameField; |
| 2642 while (!saved_fp_regs.IsEmpty()) { |
| 2643 const CPURegister& dst0 = saved_fp_regs.PopHighestIndex(); |
| 2644 const CPURegister& dst1 = saved_fp_regs.PopHighestIndex(); |
| 2645 offset -= 2 * kDRegSizeInBytes; |
| 2646 Ldp(dst1, dst0, MemOperand(fp, offset)); |
| 2647 } |
| 2648 } |
| 2649 |
| 2650 |
| 2632 // TODO(jbramley): Check that we're handling FP correctly [GOOGJSE-33]. | 2651 // TODO(jbramley): Check that we're handling FP correctly [GOOGJSE-33]. |
| 2633 void MacroAssembler::EnterExitFrame(bool save_doubles, | 2652 void MacroAssembler::EnterExitFrame(bool save_doubles, |
| 2634 const Register& scratch, | 2653 const Register& scratch, |
| 2635 int extra_space) { | 2654 int extra_space) { |
| 2636 ASSERT(jssp.Is(StackPointer())); | 2655 ASSERT(jssp.Is(StackPointer())); |
| 2637 | 2656 |
| 2638 // Set up the new stack frame. | 2657 // Set up the new stack frame. |
| 2639 Mov(scratch, Operand(CodeObject())); | 2658 Mov(scratch, Operand(CodeObject())); |
| 2640 Push(lr, fp); | 2659 Push(lr, fp); |
| 2641 Mov(fp, StackPointer()); | 2660 Mov(fp, StackPointer()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2652 STATIC_ASSERT((-2 * kPointerSize) == ExitFrameConstants::kCodeOffset); | 2671 STATIC_ASSERT((-2 * kPointerSize) == ExitFrameConstants::kCodeOffset); |
| 2653 | 2672 |
| 2654 // Save the frame pointer and context pointer in the top frame. | 2673 // Save the frame pointer and context pointer in the top frame. |
| 2655 Mov(scratch, Operand(ExternalReference(Isolate::kCEntryFPAddress, | 2674 Mov(scratch, Operand(ExternalReference(Isolate::kCEntryFPAddress, |
| 2656 isolate()))); | 2675 isolate()))); |
| 2657 Str(fp, MemOperand(scratch)); | 2676 Str(fp, MemOperand(scratch)); |
| 2658 Mov(scratch, Operand(ExternalReference(Isolate::kContextAddress, | 2677 Mov(scratch, Operand(ExternalReference(Isolate::kContextAddress, |
| 2659 isolate()))); | 2678 isolate()))); |
| 2660 Str(cp, MemOperand(scratch)); | 2679 Str(cp, MemOperand(scratch)); |
| 2661 | 2680 |
| 2681 STATIC_ASSERT((-2 * kPointerSize) == |
| 2682 ExitFrameConstants::kLastExitFrameField); |
| 2662 if (save_doubles) { | 2683 if (save_doubles) { |
| 2663 // TODO(jbramley): Implement kSaveFPRegs. It is only used by Lithium. | 2684 ExitFramePreserveFPRegs(); |
| 2664 TODO_UNIMPLEMENTED("EnterExitFrame: save_doubles"); | |
| 2665 } | 2685 } |
| 2666 | 2686 |
| 2667 // Reserve space for the return address and for user requested memory. | 2687 // Reserve space for the return address and for user requested memory. |
| 2668 // We do this before aligning to make sure that we end up correctly | 2688 // We do this before aligning to make sure that we end up correctly |
| 2669 // aligned with the minimum of wasted space. | 2689 // aligned with the minimum of wasted space. |
| 2670 Claim(extra_space + 1, kXRegSizeInBytes); | 2690 Claim(extra_space + 1, kXRegSizeInBytes); |
| 2671 // fp[8]: CallerPC (lr) | 2691 // fp[8]: CallerPC (lr) |
| 2672 // fp -> fp[0]: CallerFP (old fp) | 2692 // fp -> fp[0]: CallerFP (old fp) |
| 2673 // fp[-8]: Space reserved for SPOffset. | 2693 // fp[-8]: Space reserved for SPOffset. |
| 2674 // fp[-16]: CodeObject() | 2694 // fp[-16]: CodeObject() |
| 2675 // jssp[8 + extra_space * 8]: Saved doubles (if save_doubles is true). | 2695 // jssp[-16 - fp_size]: Saved doubles (if save_doubles is true). |
| 2676 // jssp[8]: Extra space reserved for caller (if extra_space != 0). | 2696 // jssp[8]: Extra space reserved for caller (if extra_space != 0). |
| 2677 // jssp -> jssp[0]: Space reserved for the return address. | 2697 // jssp -> jssp[0]: Space reserved for the return address. |
| 2678 STATIC_ASSERT((-3 * kPointerSize) == | |
| 2679 ExitFrameConstants::kCallerSavedRegsOffset); | |
| 2680 | 2698 |
| 2681 // Align and synchronize the system stack pointer with jssp. | 2699 // Align and synchronize the system stack pointer with jssp. |
| 2682 AlignAndSetCSPForFrame(); | 2700 AlignAndSetCSPForFrame(); |
| 2683 ASSERT(csp.Is(StackPointer())); | 2701 ASSERT(csp.Is(StackPointer())); |
| 2684 | 2702 |
| 2685 // fp[8]: CallerPC (lr) | 2703 // fp[8]: CallerPC (lr) |
| 2686 // fp -> fp[0]: CallerFP (old fp) | 2704 // fp -> fp[0]: CallerFP (old fp) |
| 2687 // fp[-8]: Space reserved for SPOffset. | 2705 // fp[-8]: Space reserved for SPOffset. |
| 2688 // fp[-16]: CodeObject() | 2706 // fp[-16]: CodeObject() |
| 2689 // csp[...]: Saved doubles, if saved_doubles is true. | 2707 // csp[...]: Saved doubles, if saved_doubles is true. |
| 2690 // csp[8]: Memory reserved for the caller if extra_space != 0. | 2708 // csp[8]: Memory reserved for the caller if extra_space != 0. |
| 2691 // Alignment padding, if necessary. | 2709 // Alignment padding, if necessary. |
| 2692 // csp -> csp[0]: Space reserved for the return address. | 2710 // csp -> csp[0]: Space reserved for the return address. |
| 2693 | 2711 |
| 2694 // ExitFrame::GetStateForFramePointer expects to find the return address at | 2712 // ExitFrame::GetStateForFramePointer expects to find the return address at |
| 2695 // the memory address immediately below the pointer stored in SPOffset. | 2713 // the memory address immediately below the pointer stored in SPOffset. |
| 2696 // It is not safe to derive much else from SPOffset, because the size of the | 2714 // It is not safe to derive much else from SPOffset, because the size of the |
| 2697 // padding can vary. | 2715 // padding can vary. |
| 2698 Add(scratch, csp, kXRegSizeInBytes); | 2716 Add(scratch, csp, kXRegSizeInBytes); |
| 2699 Str(scratch, MemOperand(fp, ExitFrameConstants::kSPOffset)); | 2717 Str(scratch, MemOperand(fp, ExitFrameConstants::kSPOffset)); |
| 2700 } | 2718 } |
| 2701 | 2719 |
| 2702 | 2720 |
| 2703 // Leave the current exit frame. | 2721 // Leave the current exit frame. |
| 2704 void MacroAssembler::LeaveExitFrame(bool restore_doubles, | 2722 void MacroAssembler::LeaveExitFrame(bool restore_doubles, |
| 2705 const Register& scratch) { | 2723 const Register& scratch) { |
| 2706 ASSERT(csp.Is(StackPointer())); | 2724 ASSERT(csp.Is(StackPointer())); |
| 2707 | 2725 |
| 2708 if (restore_doubles) { | 2726 if (restore_doubles) { |
| 2709 // TODO(jbramley): Implement kSaveFPRegs. It is only used by Lithium. | 2727 ExitFrameRestoreFPRegs(); |
| 2710 TODO_UNIMPLEMENTED("LeaveExitFrame: restore_doubles"); | |
| 2711 } | 2728 } |
| 2712 | 2729 |
| 2713 // Restore the context pointer from the top frame. | 2730 // Restore the context pointer from the top frame. |
| 2714 Mov(scratch, Operand(ExternalReference(Isolate::kContextAddress, | 2731 Mov(scratch, Operand(ExternalReference(Isolate::kContextAddress, |
| 2715 isolate()))); | 2732 isolate()))); |
| 2716 Ldr(cp, MemOperand(scratch)); | 2733 Ldr(cp, MemOperand(scratch)); |
| 2717 if (emit_debug_code()) { | 2734 if (emit_debug_code()) { |
| 2718 // Also emit debug code to clear the cp in the top frame. | 2735 // Also emit debug code to clear the cp in the top frame. |
| 2719 Str(xzr, MemOperand(scratch)); | 2736 Str(xzr, MemOperand(scratch)); |
| 2720 } | 2737 } |
| (...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4676 } | 4693 } |
| 4677 } | 4694 } |
| 4678 | 4695 |
| 4679 | 4696 |
| 4680 #undef __ | 4697 #undef __ |
| 4681 | 4698 |
| 4682 | 4699 |
| 4683 } } // namespace v8::internal | 4700 } } // namespace v8::internal |
| 4684 | 4701 |
| 4685 #endif // V8_TARGET_ARCH_A64 | 4702 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |