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 4111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4122 // rbx: pointer to C function (C callee-saved) | 4122 // rbx: pointer to C function (C callee-saved) |
4123 // rbp: frame pointer of calling JS frame (restored after C call) | 4123 // rbp: frame pointer of calling JS frame (restored after C call) |
4124 // rsp: stack pointer (restored after C call) | 4124 // rsp: stack pointer (restored after C call) |
4125 // rsi: current context (restored) | 4125 // rsi: current context (restored) |
4126 | 4126 |
4127 // NOTE: Invocations of builtins may return failure objects | 4127 // NOTE: Invocations of builtins may return failure objects |
4128 // instead of a proper result. The builtin entry handles | 4128 // instead of a proper result. The builtin entry handles |
4129 // this by performing a garbage collection and retrying the | 4129 // this by performing a garbage collection and retrying the |
4130 // builtin once. | 4130 // builtin once. |
4131 | 4131 |
4132 ProfileEntryHookStub::MaybeCallEntryHook(masm); | |
4133 | |
4134 // Enter the exit frame that transitions from JavaScript to C++. | 4132 // Enter the exit frame that transitions from JavaScript to C++. |
4135 #ifdef _WIN64 | 4133 #ifdef _WIN64 |
4136 int arg_stack_space = (result_size_ < 2 ? 2 : 4); | 4134 int arg_stack_space = (result_size_ < 2 ? 2 : 4); |
4137 #else | 4135 #else |
4138 int arg_stack_space = 0; | 4136 int arg_stack_space = 0; |
4139 #endif | 4137 #endif |
4140 __ EnterExitFrame(arg_stack_space, save_doubles_); | 4138 __ EnterExitFrame(arg_stack_space, save_doubles_); |
4141 | 4139 |
4142 // rax: Holds the context at this point, but should not be used. | 4140 // rax: Holds the context at this point, but should not be used. |
4143 // On entry to code generated by GenerateCore, it must hold | 4141 // On entry to code generated by GenerateCore, it must hold |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4204 | 4202 |
4205 __ bind(&throw_normal_exception); | 4203 __ bind(&throw_normal_exception); |
4206 __ Throw(rax); | 4204 __ Throw(rax); |
4207 } | 4205 } |
4208 | 4206 |
4209 | 4207 |
4210 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 4208 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
4211 Label invoke, handler_entry, exit; | 4209 Label invoke, handler_entry, exit; |
4212 Label not_outermost_js, not_outermost_js_2; | 4210 Label not_outermost_js, not_outermost_js_2; |
4213 | 4211 |
4214 ProfileEntryHookStub::MaybeCallEntryHook(masm); | |
4215 | |
4216 { // NOLINT. Scope block confuses linter. | 4212 { // NOLINT. Scope block confuses linter. |
4217 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); | 4213 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); |
4218 // Set up frame. | 4214 // Set up frame. |
4219 __ push(rbp); | 4215 __ push(rbp); |
4220 __ movq(rbp, rsp); | 4216 __ movq(rbp, rsp); |
4221 | 4217 |
4222 // Push the stack frame type marker twice. | 4218 // Push the stack frame type marker twice. |
4223 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; | 4219 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
4224 // Scratch register is neither callee-save, nor an argument register on any | 4220 // Scratch register is neither callee-save, nor an argument register on any |
4225 // platform. It's free to use at this point. | 4221 // platform. It's free to use at this point. |
(...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6660 __ pop(rcx); | 6656 __ pop(rcx); |
6661 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE | 6657 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE |
6662 ? kPointerSize | 6658 ? kPointerSize |
6663 : 0; | 6659 : 0; |
6664 __ lea(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); | 6660 __ lea(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); |
6665 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. | 6661 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. |
6666 } | 6662 } |
6667 | 6663 |
6668 | 6664 |
6669 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 6665 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
6670 if (masm->isolate()->function_entry_hook() != NULL) { | 6666 if (entry_hook_ != NULL) { |
6671 // It's always safe to call the entry hook stub, as the hook itself | |
6672 // is not allowed to call back to V8. | |
6673 AllowStubCallsScope allow_stub_calls(masm, true); | |
6674 | |
6675 ProfileEntryHookStub stub; | 6667 ProfileEntryHookStub stub; |
6676 masm->CallStub(&stub); | 6668 masm->CallStub(&stub); |
6677 } | 6669 } |
6678 } | 6670 } |
6679 | 6671 |
6680 | 6672 |
6681 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { | 6673 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { |
6682 // This stub can be called from essentially anywhere, so it needs to save | 6674 // Save volatile registers. |
6683 // all volatile and callee-save registers. | 6675 // Live registers at this point are the same as at the start of any |
6684 const size_t kNumSavedRegisters = 2; | 6676 // JS function: |
6685 __ push(arg_reg_1); | 6677 // o rdi: the JS function object being called (i.e. ourselves) |
6686 __ push(arg_reg_2); | 6678 // o rsi: our context |
| 6679 // o rbp: our caller's frame pointer |
| 6680 // o rsp: stack pointer (pointing to return address) |
| 6681 // o rcx: rcx is zero for method calls and non-zero for function calls. |
| 6682 #ifdef _WIN64 |
| 6683 const int kNumSavedRegisters = 1; |
| 6684 |
| 6685 __ push(rcx); |
| 6686 #else |
| 6687 const int kNumSavedRegisters = 3; |
| 6688 |
| 6689 __ push(rcx); |
| 6690 __ push(rdi); |
| 6691 __ push(rsi); |
| 6692 #endif |
6687 | 6693 |
6688 // Calculate the original stack pointer and store it in the second arg. | 6694 // Calculate the original stack pointer and store it in the second arg. |
6689 __ lea(arg_reg_2, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize)); | 6695 #ifdef _WIN64 |
| 6696 __ lea(rdx, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize)); |
| 6697 #else |
| 6698 __ lea(rsi, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize)); |
| 6699 #endif |
6690 | 6700 |
6691 // Calculate the function address to the first arg. | 6701 // Calculate the function address to the first arg. |
6692 __ movq(arg_reg_1, Operand(rsp, kNumSavedRegisters * kPointerSize)); | 6702 #ifdef _WIN64 |
6693 __ subq(arg_reg_1, Immediate(Assembler::kShortCallInstructionLength)); | 6703 __ movq(rcx, Operand(rsp, kNumSavedRegisters * kPointerSize)); |
6694 | 6704 __ subq(rcx, Immediate(Assembler::kShortCallInstructionLength)); |
6695 // Save the remainder of the volatile registers. | 6705 #else |
6696 masm->PushCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); | 6706 __ movq(rdi, Operand(rsp, kNumSavedRegisters * kPointerSize)); |
| 6707 __ subq(rdi, Immediate(Assembler::kShortCallInstructionLength)); |
| 6708 #endif |
6697 | 6709 |
6698 // Call the entry hook function. | 6710 // Call the entry hook function. |
6699 __ movq(rax, FUNCTION_ADDR(masm->isolate()->function_entry_hook()), | 6711 __ movq(rax, &entry_hook_, RelocInfo::NONE64); |
6700 RelocInfo::NONE64); | 6712 __ movq(rax, Operand(rax, 0)); |
6701 | 6713 |
6702 AllowExternalCallThatCantCauseGC scope(masm); | 6714 AllowExternalCallThatCantCauseGC scope(masm); |
6703 | 6715 |
6704 const int kArgumentCount = 2; | 6716 const int kArgumentCount = 2; |
6705 __ PrepareCallCFunction(kArgumentCount); | 6717 __ PrepareCallCFunction(kArgumentCount); |
6706 __ CallCFunction(rax, kArgumentCount); | 6718 __ CallCFunction(rax, kArgumentCount); |
6707 | 6719 |
6708 // Restore volatile regs. | 6720 // Restore volatile regs. |
6709 masm->PopCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); | 6721 #ifdef _WIN64 |
6710 __ pop(arg_reg_2); | 6722 __ pop(rcx); |
6711 __ pop(arg_reg_1); | 6723 #else |
| 6724 __ pop(rsi); |
| 6725 __ pop(rdi); |
| 6726 __ pop(rcx); |
| 6727 #endif |
6712 | 6728 |
6713 __ Ret(); | 6729 __ Ret(); |
6714 } | 6730 } |
6715 | 6731 |
6716 | 6732 |
6717 template<class T> | 6733 template<class T> |
6718 static void CreateArrayDispatch(MacroAssembler* masm) { | 6734 static void CreateArrayDispatch(MacroAssembler* masm) { |
6719 int last_index = GetSequenceIndexFromFastElementsKind( | 6735 int last_index = GetSequenceIndexFromFastElementsKind( |
6720 TERMINAL_FAST_ELEMENTS_KIND); | 6736 TERMINAL_FAST_ELEMENTS_KIND); |
6721 for (int i = 0; i <= last_index; ++i) { | 6737 for (int i = 0; i <= last_index; ++i) { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6990 __ bind(&fast_elements_case); | 7006 __ bind(&fast_elements_case); |
6991 GenerateCase(masm, FAST_ELEMENTS); | 7007 GenerateCase(masm, FAST_ELEMENTS); |
6992 } | 7008 } |
6993 | 7009 |
6994 | 7010 |
6995 #undef __ | 7011 #undef __ |
6996 | 7012 |
6997 } } // namespace v8::internal | 7013 } } // namespace v8::internal |
6998 | 7014 |
6999 #endif // V8_TARGET_ARCH_X64 | 7015 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |