| 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 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2730 // Do space-specific GC and retry runtime call. | 2730 // Do space-specific GC and retry runtime call. |
| 2731 GenerateCore(masm, | 2731 GenerateCore(masm, |
| 2732 &throw_normal_exception, | 2732 &throw_normal_exception, |
| 2733 &throw_termination_exception, | 2733 &throw_termination_exception, |
| 2734 &throw_out_of_memory_exception, | 2734 &throw_out_of_memory_exception, |
| 2735 true, | 2735 true, |
| 2736 false); | 2736 false); |
| 2737 | 2737 |
| 2738 // Do full GC and retry runtime call one final time. | 2738 // Do full GC and retry runtime call one final time. |
| 2739 Failure* failure = Failure::InternalError(); | 2739 Failure* failure = Failure::InternalError(); |
| 2740 __ Move(rax, failure, RelocInfo::NONE64); | 2740 __ Move(rax, failure, Assembler::RelocInfoNone()); |
| 2741 GenerateCore(masm, | 2741 GenerateCore(masm, |
| 2742 &throw_normal_exception, | 2742 &throw_normal_exception, |
| 2743 &throw_termination_exception, | 2743 &throw_termination_exception, |
| 2744 &throw_out_of_memory_exception, | 2744 &throw_out_of_memory_exception, |
| 2745 true, | 2745 true, |
| 2746 true); | 2746 true); |
| 2747 | 2747 |
| 2748 __ bind(&throw_out_of_memory_exception); | 2748 __ bind(&throw_out_of_memory_exception); |
| 2749 // Set external caught exception to false. | 2749 // Set external caught exception to false. |
| 2750 Isolate* isolate = masm->isolate(); | 2750 Isolate* isolate = masm->isolate(); |
| 2751 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, | 2751 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, |
| 2752 isolate); | 2752 isolate); |
| 2753 __ Set(rax, static_cast<int64_t>(false)); | 2753 __ Set(rax, static_cast<int64_t>(false)); |
| 2754 __ Store(external_caught, rax); | 2754 __ Store(external_caught, rax); |
| 2755 | 2755 |
| 2756 // Set pending exception and rax to out of memory exception. | 2756 // Set pending exception and rax to out of memory exception. |
| 2757 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, | 2757 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, |
| 2758 isolate); | 2758 isolate); |
| 2759 Label already_have_failure; | 2759 Label already_have_failure; |
| 2760 JumpIfOOM(masm, rax, kScratchRegister, &already_have_failure); | 2760 JumpIfOOM(masm, rax, kScratchRegister, &already_have_failure); |
| 2761 __ Move(rax, Failure::OutOfMemoryException(0x1), RelocInfo::NONE64); | 2761 __ Move(rax, Failure::OutOfMemoryException(0x1), Assembler::RelocInfoNone()); |
| 2762 __ bind(&already_have_failure); | 2762 __ bind(&already_have_failure); |
| 2763 __ Store(pending_exception, rax); | 2763 __ Store(pending_exception, rax); |
| 2764 // Fall through to the next label. | 2764 // Fall through to the next label. |
| 2765 | 2765 |
| 2766 __ bind(&throw_termination_exception); | 2766 __ bind(&throw_termination_exception); |
| 2767 __ ThrowUncatchable(rax); | 2767 __ ThrowUncatchable(rax); |
| 2768 | 2768 |
| 2769 __ bind(&throw_normal_exception); | 2769 __ bind(&throw_normal_exception); |
| 2770 __ Throw(rax); | 2770 __ Throw(rax); |
| 2771 } | 2771 } |
| 2772 | 2772 |
| 2773 | 2773 |
| 2774 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 2774 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
| 2775 Label invoke, handler_entry, exit; | 2775 Label invoke, handler_entry, exit; |
| 2776 Label not_outermost_js, not_outermost_js_2; | 2776 Label not_outermost_js, not_outermost_js_2; |
| 2777 | 2777 |
| 2778 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 2778 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 2779 | 2779 |
| 2780 { // NOLINT. Scope block confuses linter. | 2780 { // NOLINT. Scope block confuses linter. |
| 2781 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); | 2781 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); |
| 2782 // Set up frame. | 2782 // Set up frame. |
| 2783 __ push(rbp); | 2783 __ push(rbp); |
| 2784 __ movp(rbp, rsp); | 2784 __ movp(rbp, rsp); |
| 2785 | 2785 |
| 2786 // Push the stack frame type marker twice. | 2786 // Push the stack frame type marker twice. |
| 2787 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; | 2787 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
| 2788 // Scratch register is neither callee-save, nor an argument register on any | 2788 // Scratch register is neither callee-save, nor an argument register on any |
| 2789 // platform. It's free to use at this point. | 2789 // platform. It's free to use at this point. |
| 2790 // Cannot use smi-register for loading yet. | 2790 // Cannot use smi-register for loading yet. |
| 2791 __ Move(kScratchRegister, Smi::FromInt(marker), RelocInfo::NONE64); | 2791 __ Move(kScratchRegister, Smi::FromInt(marker), Assembler::RelocInfoNone()); |
| 2792 __ push(kScratchRegister); // context slot | 2792 __ push(kScratchRegister); // context slot |
| 2793 __ push(kScratchRegister); // function slot | 2793 __ push(kScratchRegister); // function slot |
| 2794 // Save callee-saved registers (X64/Win64 calling conventions). | 2794 // Save callee-saved registers (X64/Win64 calling conventions). |
| 2795 __ push(r12); | 2795 __ push(r12); |
| 2796 __ push(r13); | 2796 __ push(r13); |
| 2797 __ push(r14); | 2797 __ push(r14); |
| 2798 __ push(r15); | 2798 __ push(r15); |
| 2799 #ifdef _WIN64 | 2799 #ifdef _WIN64 |
| 2800 __ push(rdi); // Only callee save in Win64 ABI, argument in AMD64 ABI. | 2800 __ push(rdi); // Only callee save in Win64 ABI, argument in AMD64 ABI. |
| 2801 __ push(rsi); // Only callee save in Win64 ABI, argument in AMD64 ABI. | 2801 __ push(rsi); // Only callee save in Win64 ABI, argument in AMD64 ABI. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2849 // Jump to a faked try block that does the invoke, with a faked catch | 2849 // Jump to a faked try block that does the invoke, with a faked catch |
| 2850 // block that sets the pending exception. | 2850 // block that sets the pending exception. |
| 2851 __ jmp(&invoke); | 2851 __ jmp(&invoke); |
| 2852 __ bind(&handler_entry); | 2852 __ bind(&handler_entry); |
| 2853 handler_offset_ = handler_entry.pos(); | 2853 handler_offset_ = handler_entry.pos(); |
| 2854 // Caught exception: Store result (exception) in the pending exception | 2854 // Caught exception: Store result (exception) in the pending exception |
| 2855 // field in the JSEnv and return a failure sentinel. | 2855 // field in the JSEnv and return a failure sentinel. |
| 2856 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, | 2856 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, |
| 2857 isolate); | 2857 isolate); |
| 2858 __ Store(pending_exception, rax); | 2858 __ Store(pending_exception, rax); |
| 2859 __ Move(rax, Failure::Exception(), RelocInfo::NONE64); | 2859 __ Move(rax, Failure::Exception(), Assembler::RelocInfoNone()); |
| 2860 __ jmp(&exit); | 2860 __ jmp(&exit); |
| 2861 | 2861 |
| 2862 // Invoke: Link this frame into the handler chain. There's only one | 2862 // Invoke: Link this frame into the handler chain. There's only one |
| 2863 // handler block in this code object, so its index is 0. | 2863 // handler block in this code object, so its index is 0. |
| 2864 __ bind(&invoke); | 2864 __ bind(&invoke); |
| 2865 __ PushTryHandler(StackHandler::JS_ENTRY, 0); | 2865 __ PushTryHandler(StackHandler::JS_ENTRY, 0); |
| 2866 | 2866 |
| 2867 // Clear any pending exceptions. | 2867 // Clear any pending exceptions. |
| 2868 __ LoadRoot(rax, Heap::kTheHoleValueRootIndex); | 2868 __ LoadRoot(rax, Heap::kTheHoleValueRootIndex); |
| 2869 __ Store(pending_exception, rax); | 2869 __ Store(pending_exception, rax); |
| (...skipping 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5375 | 5375 |
| 5376 // Calculate the function address to the first arg. | 5376 // Calculate the function address to the first arg. |
| 5377 __ movp(arg_reg_1, Operand(rsp, kNumSavedRegisters * kRegisterSize)); | 5377 __ movp(arg_reg_1, Operand(rsp, kNumSavedRegisters * kRegisterSize)); |
| 5378 __ subq(arg_reg_1, Immediate(Assembler::kShortCallInstructionLength)); | 5378 __ subq(arg_reg_1, Immediate(Assembler::kShortCallInstructionLength)); |
| 5379 | 5379 |
| 5380 // Save the remainder of the volatile registers. | 5380 // Save the remainder of the volatile registers. |
| 5381 masm->PushCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); | 5381 masm->PushCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); |
| 5382 | 5382 |
| 5383 // Call the entry hook function. | 5383 // Call the entry hook function. |
| 5384 __ Move(rax, FUNCTION_ADDR(masm->isolate()->function_entry_hook()), | 5384 __ Move(rax, FUNCTION_ADDR(masm->isolate()->function_entry_hook()), |
| 5385 RelocInfo::NONE64); | 5385 Assembler::RelocInfoNone()); |
| 5386 | 5386 |
| 5387 AllowExternalCallThatCantCauseGC scope(masm); | 5387 AllowExternalCallThatCantCauseGC scope(masm); |
| 5388 | 5388 |
| 5389 const int kArgumentCount = 2; | 5389 const int kArgumentCount = 2; |
| 5390 __ PrepareCallCFunction(kArgumentCount); | 5390 __ PrepareCallCFunction(kArgumentCount); |
| 5391 __ CallCFunction(rax, kArgumentCount); | 5391 __ CallCFunction(rax, kArgumentCount); |
| 5392 | 5392 |
| 5393 // Restore volatile regs. | 5393 // Restore volatile regs. |
| 5394 masm->PopCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); | 5394 masm->PopCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); |
| 5395 __ pop(arg_reg_2); | 5395 __ pop(arg_reg_2); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5724 __ bind(&fast_elements_case); | 5724 __ bind(&fast_elements_case); |
| 5725 GenerateCase(masm, FAST_ELEMENTS); | 5725 GenerateCase(masm, FAST_ELEMENTS); |
| 5726 } | 5726 } |
| 5727 | 5727 |
| 5728 | 5728 |
| 5729 #undef __ | 5729 #undef __ |
| 5730 | 5730 |
| 5731 } } // namespace v8::internal | 5731 } } // namespace v8::internal |
| 5732 | 5732 |
| 5733 #endif // V8_TARGET_ARCH_X64 | 5733 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |