| OLD | NEW |
| 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 4161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4172 // rbx: pointer to C function (C callee-saved) | 4172 // rbx: pointer to C function (C callee-saved) |
| 4173 // rbp: frame pointer of calling JS frame (restored after C call) | 4173 // rbp: frame pointer of calling JS frame (restored after C call) |
| 4174 // rsp: stack pointer (restored after C call) | 4174 // rsp: stack pointer (restored after C call) |
| 4175 // rsi: current context (restored) | 4175 // rsi: current context (restored) |
| 4176 | 4176 |
| 4177 // NOTE: Invocations of builtins may return failure objects | 4177 // NOTE: Invocations of builtins may return failure objects |
| 4178 // instead of a proper result. The builtin entry handles | 4178 // instead of a proper result. The builtin entry handles |
| 4179 // this by performing a garbage collection and retrying the | 4179 // this by performing a garbage collection and retrying the |
| 4180 // builtin once. | 4180 // builtin once. |
| 4181 | 4181 |
| 4182 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 4183 |
| 4182 // Enter the exit frame that transitions from JavaScript to C++. | 4184 // Enter the exit frame that transitions from JavaScript to C++. |
| 4183 #ifdef _WIN64 | 4185 #ifdef _WIN64 |
| 4184 int arg_stack_space = (result_size_ < 2 ? 2 : 4); | 4186 int arg_stack_space = (result_size_ < 2 ? 2 : 4); |
| 4185 #else | 4187 #else |
| 4186 int arg_stack_space = 0; | 4188 int arg_stack_space = 0; |
| 4187 #endif | 4189 #endif |
| 4188 __ EnterExitFrame(arg_stack_space, save_doubles_); | 4190 __ EnterExitFrame(arg_stack_space, save_doubles_); |
| 4189 | 4191 |
| 4190 // rax: Holds the context at this point, but should not be used. | 4192 // rax: Holds the context at this point, but should not be used. |
| 4191 // On entry to code generated by GenerateCore, it must hold | 4193 // On entry to code generated by GenerateCore, it must hold |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4252 | 4254 |
| 4253 __ bind(&throw_normal_exception); | 4255 __ bind(&throw_normal_exception); |
| 4254 __ Throw(rax); | 4256 __ Throw(rax); |
| 4255 } | 4257 } |
| 4256 | 4258 |
| 4257 | 4259 |
| 4258 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 4260 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
| 4259 Label invoke, handler_entry, exit; | 4261 Label invoke, handler_entry, exit; |
| 4260 Label not_outermost_js, not_outermost_js_2; | 4262 Label not_outermost_js, not_outermost_js_2; |
| 4261 | 4263 |
| 4264 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 4265 |
| 4262 { // NOLINT. Scope block confuses linter. | 4266 { // NOLINT. Scope block confuses linter. |
| 4263 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); | 4267 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); |
| 4264 // Set up frame. | 4268 // Set up frame. |
| 4265 __ push(rbp); | 4269 __ push(rbp); |
| 4266 __ movq(rbp, rsp); | 4270 __ movq(rbp, rsp); |
| 4267 | 4271 |
| 4268 // Push the stack frame type marker twice. | 4272 // Push the stack frame type marker twice. |
| 4269 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; | 4273 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
| 4270 // Scratch register is neither callee-save, nor an argument register on any | 4274 // Scratch register is neither callee-save, nor an argument register on any |
| 4271 // platform. It's free to use at this point. | 4275 // platform. It's free to use at this point. |
| (...skipping 2446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6718 __ pop(rcx); | 6722 __ pop(rcx); |
| 6719 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE | 6723 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE |
| 6720 ? kPointerSize | 6724 ? kPointerSize |
| 6721 : 0; | 6725 : 0; |
| 6722 __ lea(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); | 6726 __ lea(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); |
| 6723 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. | 6727 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. |
| 6724 } | 6728 } |
| 6725 | 6729 |
| 6726 | 6730 |
| 6727 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 6731 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
| 6728 if (entry_hook_ != NULL) { | 6732 if (masm->isolate()->HasFunctionEntryHook()) { |
| 6733 // It's always safe to call the entry hook stub, as the hook itself |
| 6734 // is not allowed to call back to V8. |
| 6735 AllowStubCallsScope allow_stub_calls(masm, true); |
| 6736 |
| 6729 ProfileEntryHookStub stub; | 6737 ProfileEntryHookStub stub; |
| 6730 masm->CallStub(&stub); | 6738 masm->CallStub(&stub); |
| 6731 } | 6739 } |
| 6732 } | 6740 } |
| 6733 | 6741 |
| 6734 | 6742 |
| 6735 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { | 6743 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { |
| 6736 // Save volatile registers. | 6744 // This stub can be called from essentially anywhere, so it needs to save |
| 6737 // Live registers at this point are the same as at the start of any | 6745 // all volatile and callee-save registers. |
| 6738 // JS function: | 6746 const size_t kNumSavedRegisters = 2; |
| 6739 // o rdi: the JS function object being called (i.e. ourselves) | 6747 __ push(arg_reg_1); |
| 6740 // o rsi: our context | 6748 __ push(arg_reg_2); |
| 6741 // o rbp: our caller's frame pointer | |
| 6742 // o rsp: stack pointer (pointing to return address) | |
| 6743 // o rcx: rcx is zero for method calls and non-zero for function calls. | |
| 6744 #ifdef _WIN64 | |
| 6745 const int kNumSavedRegisters = 1; | |
| 6746 | |
| 6747 __ push(rcx); | |
| 6748 #else | |
| 6749 const int kNumSavedRegisters = 3; | |
| 6750 | |
| 6751 __ push(rcx); | |
| 6752 __ push(rdi); | |
| 6753 __ push(rsi); | |
| 6754 #endif | |
| 6755 | 6749 |
| 6756 // Calculate the original stack pointer and store it in the second arg. | 6750 // Calculate the original stack pointer and store it in the second arg. |
| 6757 #ifdef _WIN64 | 6751 __ lea(arg_reg_2, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize)); |
| 6758 __ lea(rdx, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize)); | |
| 6759 #else | |
| 6760 __ lea(rsi, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize)); | |
| 6761 #endif | |
| 6762 | 6752 |
| 6763 // Calculate the function address to the first arg. | 6753 // Calculate the function address to the first arg. |
| 6764 #ifdef _WIN64 | 6754 __ movq(arg_reg_1, Operand(rsp, kNumSavedRegisters * kPointerSize)); |
| 6765 __ movq(rcx, Operand(rsp, kNumSavedRegisters * kPointerSize)); | 6755 __ subq(arg_reg_1, Immediate(Assembler::kShortCallInstructionLength)); |
| 6766 __ subq(rcx, Immediate(Assembler::kShortCallInstructionLength)); | 6756 |
| 6767 #else | 6757 // Save the remainder of the volatile registers. |
| 6768 __ movq(rdi, Operand(rsp, kNumSavedRegisters * kPointerSize)); | 6758 masm->PushCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); |
| 6769 __ subq(rdi, Immediate(Assembler::kShortCallInstructionLength)); | |
| 6770 #endif | |
| 6771 | 6759 |
| 6772 // Call the entry hook function. | 6760 // Call the entry hook function. |
| 6773 __ movq(rax, &entry_hook_, RelocInfo::NONE64); | 6761 void* entry_hook_loc = masm->isolate()->function_entry_hook_location(); |
| 6762 __ movq(rax, entry_hook_loc, RelocInfo::NONE64); |
| 6774 __ movq(rax, Operand(rax, 0)); | 6763 __ movq(rax, Operand(rax, 0)); |
| 6775 | 6764 |
| 6776 AllowExternalCallThatCantCauseGC scope(masm); | 6765 AllowExternalCallThatCantCauseGC scope(masm); |
| 6777 | 6766 |
| 6778 const int kArgumentCount = 2; | 6767 const int kArgumentCount = 2; |
| 6779 __ PrepareCallCFunction(kArgumentCount); | 6768 __ PrepareCallCFunction(kArgumentCount); |
| 6780 __ CallCFunction(rax, kArgumentCount); | 6769 __ CallCFunction(rax, kArgumentCount); |
| 6781 | 6770 |
| 6782 // Restore volatile regs. | 6771 // Restore volatile regs. |
| 6783 #ifdef _WIN64 | 6772 masm->PopCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); |
| 6784 __ pop(rcx); | 6773 __ pop(arg_reg_2); |
| 6785 #else | 6774 __ pop(arg_reg_1); |
| 6786 __ pop(rsi); | |
| 6787 __ pop(rdi); | |
| 6788 __ pop(rcx); | |
| 6789 #endif | |
| 6790 | 6775 |
| 6791 __ Ret(); | 6776 __ Ret(); |
| 6792 } | 6777 } |
| 6793 | 6778 |
| 6794 | 6779 |
| 6795 template<class T> | 6780 template<class T> |
| 6796 static void CreateArrayDispatch(MacroAssembler* masm) { | 6781 static void CreateArrayDispatch(MacroAssembler* masm) { |
| 6797 int last_index = GetSequenceIndexFromFastElementsKind( | 6782 int last_index = GetSequenceIndexFromFastElementsKind( |
| 6798 TERMINAL_FAST_ELEMENTS_KIND); | 6783 TERMINAL_FAST_ELEMENTS_KIND); |
| 6799 for (int i = 0; i <= last_index; ++i) { | 6784 for (int i = 0; i <= last_index; ++i) { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7095 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 7080 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 7096 } | 7081 } |
| 7097 } | 7082 } |
| 7098 | 7083 |
| 7099 | 7084 |
| 7100 #undef __ | 7085 #undef __ |
| 7101 | 7086 |
| 7102 } } // namespace v8::internal | 7087 } } // namespace v8::internal |
| 7103 | 7088 |
| 7104 #endif // V8_TARGET_ARCH_X64 | 7089 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |