Chromium Code Reviews

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 22267005: Use StackArgumenstAccessor and kPCOnStackSize/kFPOnStackSize to compute stack address/operand (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased with master and refactored newly-introduced GenerateFastApiCall with StackArgumentsAccessor Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2632 matching lines...)
2643 2643
2644 2644
2645 Operand MacroAssembler::SafepointRegisterSlot(Register reg) { 2645 Operand MacroAssembler::SafepointRegisterSlot(Register reg) {
2646 return Operand(rsp, SafepointRegisterStackIndex(reg.code()) * kPointerSize); 2646 return Operand(rsp, SafepointRegisterStackIndex(reg.code()) * kPointerSize);
2647 } 2647 }
2648 2648
2649 2649
2650 void MacroAssembler::PushTryHandler(StackHandler::Kind kind, 2650 void MacroAssembler::PushTryHandler(StackHandler::Kind kind,
2651 int handler_index) { 2651 int handler_index) {
2652 // Adjust this code if not the case. 2652 // Adjust this code if not the case.
2653 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); 2653 STATIC_ASSERT(StackHandlerConstants::kSize >= 5 * kPointerSize);
danno 2013/09/18 12:08:42 Why not (StackHandlerConstants::kSiz == 4 * kPoint
haitao.feng 2013/09/22 08:16:00 Done.
2654 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 2654 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
2655 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); 2655 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize);
2656 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); 2656 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize);
2657 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); 2657 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize);
2658 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); 2658 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize);
2659 2659
2660 // We will build up the handler from the bottom by pushing on the stack. 2660 // We will build up the handler from the bottom by pushing on the stack.
2661 // First push the frame pointer and context. 2661 // First push the frame pointer and context.
2662 if (kind == StackHandler::JS_ENTRY) { 2662 if (kind == StackHandler::JS_ENTRY) {
2663 // The frame pointer does not point to a JS frame so we save NULL for 2663 // The frame pointer does not point to a JS frame so we save NULL for
(...skipping 38 matching lines...)
2702 movq(rdx, 2702 movq(rdx,
2703 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize)); 2703 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize));
2704 SmiToInteger64(rdx, rdx); 2704 SmiToInteger64(rdx, rdx);
2705 lea(rdi, FieldOperand(rdi, rdx, times_1, Code::kHeaderSize)); 2705 lea(rdi, FieldOperand(rdi, rdx, times_1, Code::kHeaderSize));
2706 jmp(rdi); 2706 jmp(rdi);
2707 } 2707 }
2708 2708
2709 2709
2710 void MacroAssembler::Throw(Register value) { 2710 void MacroAssembler::Throw(Register value) {
2711 // Adjust this code if not the case. 2711 // Adjust this code if not the case.
2712 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); 2712 STATIC_ASSERT(StackHandlerConstants::kSize >= 5 * kPointerSize);
2713 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 2713 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
2714 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); 2714 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize);
2715 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); 2715 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize);
2716 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); 2716 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize);
2717 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); 2717 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize);
2718 2718
2719 // The exception is expected in rax. 2719 // The exception is expected in rax.
2720 if (!value.is(rax)) { 2720 if (!value.is(rax)) {
2721 movq(rax, value); 2721 movq(rax, value);
2722 } 2722 }
(...skipping 19 matching lines...)
2742 j(zero, &skip, Label::kNear); 2742 j(zero, &skip, Label::kNear);
2743 movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); 2743 movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
2744 bind(&skip); 2744 bind(&skip);
2745 2745
2746 JumpToHandlerEntry(); 2746 JumpToHandlerEntry();
2747 } 2747 }
2748 2748
2749 2749
2750 void MacroAssembler::ThrowUncatchable(Register value) { 2750 void MacroAssembler::ThrowUncatchable(Register value) {
2751 // Adjust this code if not the case. 2751 // Adjust this code if not the case.
2752 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); 2752 STATIC_ASSERT(StackHandlerConstants::kSize >= 5 * kPointerSize);
2753 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 2753 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
2754 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); 2754 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize);
2755 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); 2755 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize);
2756 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); 2756 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize);
2757 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); 2757 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize);
2758 2758
2759 // The exception is expected in rax. 2759 // The exception is expected in rax.
2760 if (!value.is(rax)) { 2760 if (!value.is(rax)) {
2761 movq(rax, value); 2761 movq(rax, value);
2762 } 2762 }
(...skipping 708 matching lines...)
3471 Check(equal, kStackFrameTypesMustMatch); 3471 Check(equal, kStackFrameTypesMustMatch);
3472 } 3472 }
3473 movq(rsp, rbp); 3473 movq(rsp, rbp);
3474 pop(rbp); 3474 pop(rbp);
3475 } 3475 }
3476 3476
3477 3477
3478 void MacroAssembler::EnterExitFramePrologue(bool save_rax) { 3478 void MacroAssembler::EnterExitFramePrologue(bool save_rax) {
3479 // Set up the frame structure on the stack. 3479 // Set up the frame structure on the stack.
3480 // All constants are relative to the frame pointer of the exit frame. 3480 // All constants are relative to the frame pointer of the exit frame.
3481 ASSERT(ExitFrameConstants::kCallerSPDisplacement == +2 * kPointerSize); 3481 ASSERT(ExitFrameConstants::kCallerSPDisplacement ==
3482 ASSERT(ExitFrameConstants::kCallerPCOffset == +1 * kPointerSize); 3482 kFPOnStackSize + kPCOnStackSize);
3483 ASSERT(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize); 3483 ASSERT(ExitFrameConstants::kCallerPCOffset == kFPOnStackSize);
3484 ASSERT(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize);
3484 push(rbp); 3485 push(rbp);
3485 movq(rbp, rsp); 3486 movq(rbp, rsp);
3486 3487
3487 // Reserve room for entry stack pointer and push the code object. 3488 // Reserve room for entry stack pointer and push the code object.
3488 ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize); 3489 ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize);
3489 push(Immediate(0)); // Saved entry sp, patched before call. 3490 push(Immediate(0)); // Saved entry sp, patched before call.
3490 movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT); 3491 movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT);
3491 push(kScratchRegister); // Accessed from EditFrame::code_slot. 3492 push(kScratchRegister); // Accessed from EditFrame::code_slot.
3492 3493
3493 // Save the frame pointer and the context in top. 3494 // Save the frame pointer and the context in top.
(...skipping 1201 matching lines...)
4695 j(greater, &no_memento_available); 4696 j(greater, &no_memento_available);
4696 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), 4697 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize),
4697 Heap::kAllocationMementoMapRootIndex); 4698 Heap::kAllocationMementoMapRootIndex);
4698 bind(&no_memento_available); 4699 bind(&no_memento_available);
4699 } 4700 }
4700 4701
4701 4702
4702 } } // namespace v8::internal 4703 } } // namespace v8::internal
4703 4704
4704 #endif // V8_TARGET_ARCH_X64 4705 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine