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 5113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5124 | 5124 |
5125 | 5125 |
5126 void CEntryStub::Generate(MacroAssembler* masm) { | 5126 void CEntryStub::Generate(MacroAssembler* masm) { |
5127 // eax: number of arguments including receiver | 5127 // eax: number of arguments including receiver |
5128 // ebx: pointer to C function (C callee-saved) | 5128 // ebx: pointer to C function (C callee-saved) |
5129 // ebp: frame pointer (restored after C call) | 5129 // ebp: frame pointer (restored after C call) |
5130 // esp: stack pointer (restored after C call) | 5130 // esp: stack pointer (restored after C call) |
5131 // esi: current context (C callee-saved) | 5131 // esi: current context (C callee-saved) |
5132 // edi: JS function of the caller (C callee-saved) | 5132 // edi: JS function of the caller (C callee-saved) |
5133 | 5133 |
| 5134 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 5135 |
5134 // NOTE: Invocations of builtins may return failure objects instead | 5136 // NOTE: Invocations of builtins may return failure objects instead |
5135 // of a proper result. The builtin entry handles this by performing | 5137 // of a proper result. The builtin entry handles this by performing |
5136 // a garbage collection and retrying the builtin (twice). | 5138 // a garbage collection and retrying the builtin (twice). |
5137 | 5139 |
5138 // Enter the exit frame that transitions from JavaScript to C++. | 5140 // Enter the exit frame that transitions from JavaScript to C++. |
5139 __ EnterExitFrame(save_doubles_ == kSaveFPRegs); | 5141 __ EnterExitFrame(save_doubles_ == kSaveFPRegs); |
5140 | 5142 |
5141 // eax: result parameter for PerformGC, if any (setup below) | 5143 // eax: result parameter for PerformGC, if any (setup below) |
5142 // ebx: pointer to builtin function (C callee-saved) | 5144 // ebx: pointer to builtin function (C callee-saved) |
5143 // ebp: frame pointer (restored after C call) | 5145 // ebp: frame pointer (restored after C call) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5197 | 5199 |
5198 __ bind(&throw_normal_exception); | 5200 __ bind(&throw_normal_exception); |
5199 __ Throw(eax); | 5201 __ Throw(eax); |
5200 } | 5202 } |
5201 | 5203 |
5202 | 5204 |
5203 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 5205 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
5204 Label invoke, handler_entry, exit; | 5206 Label invoke, handler_entry, exit; |
5205 Label not_outermost_js, not_outermost_js_2; | 5207 Label not_outermost_js, not_outermost_js_2; |
5206 | 5208 |
| 5209 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 5210 |
5207 // Set up frame. | 5211 // Set up frame. |
5208 __ push(ebp); | 5212 __ push(ebp); |
5209 __ mov(ebp, esp); | 5213 __ mov(ebp, esp); |
5210 | 5214 |
5211 // Push marker in two places. | 5215 // Push marker in two places. |
5212 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; | 5216 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
5213 __ push(Immediate(Smi::FromInt(marker))); // context slot | 5217 __ push(Immediate(Smi::FromInt(marker))); // context slot |
5214 __ push(Immediate(Smi::FromInt(marker))); // function slot | 5218 __ push(Immediate(Smi::FromInt(marker))); // function slot |
5215 // Save callee-saved registers (C calling conventions). | 5219 // Save callee-saved registers (C calling conventions). |
5216 __ push(edi); | 5220 __ push(edi); |
(...skipping 2532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7749 __ pop(ecx); | 7753 __ pop(ecx); |
7750 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE | 7754 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE |
7751 ? kPointerSize | 7755 ? kPointerSize |
7752 : 0; | 7756 : 0; |
7753 __ lea(esp, MemOperand(esp, ebx, times_pointer_size, additional_offset)); | 7757 __ lea(esp, MemOperand(esp, ebx, times_pointer_size, additional_offset)); |
7754 __ jmp(ecx); // Return to IC Miss stub, continuation still on stack. | 7758 __ jmp(ecx); // Return to IC Miss stub, continuation still on stack. |
7755 } | 7759 } |
7756 | 7760 |
7757 | 7761 |
7758 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 7762 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
7759 if (entry_hook_ != NULL) { | 7763 if (masm->isolate()->function_entry_hook() != NULL) { |
| 7764 // It's always safe to call the entry hook stub, as the hook itself |
| 7765 // is not allowed to call back to V8. |
| 7766 AllowStubCallsScope allow_stub_calls(masm, true); |
| 7767 |
7760 ProfileEntryHookStub stub; | 7768 ProfileEntryHookStub stub; |
7761 masm->CallStub(&stub); | 7769 masm->CallStub(&stub); |
7762 } | 7770 } |
7763 } | 7771 } |
7764 | 7772 |
7765 | 7773 |
7766 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { | 7774 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { |
7767 // Ecx is the only volatile register we must save. | 7775 // Save volatile registers. |
7768 const int kNumSavedRegisters = 1; | 7776 const int kNumSavedRegisters = 3; |
| 7777 __ push(eax); |
7769 __ push(ecx); | 7778 __ push(ecx); |
| 7779 __ push(edx); |
7770 | 7780 |
7771 // Calculate and push the original stack pointer. | 7781 // Calculate and push the original stack pointer. |
7772 __ lea(eax, Operand(esp, (kNumSavedRegisters + 1) * kPointerSize)); | 7782 __ lea(eax, Operand(esp, (kNumSavedRegisters + 1) * kPointerSize)); |
7773 __ push(eax); | 7783 __ push(eax); |
7774 | 7784 |
7775 // Retrieve our return address and use it to calculate the calling | 7785 // Retrieve our return address and use it to calculate the calling |
7776 // function's address. | 7786 // function's address. |
7777 __ mov(eax, Operand(esp, (kNumSavedRegisters + 1) * kPointerSize)); | 7787 __ mov(eax, Operand(esp, (kNumSavedRegisters + 1) * kPointerSize)); |
7778 __ sub(eax, Immediate(Assembler::kCallInstructionLength)); | 7788 __ sub(eax, Immediate(Assembler::kCallInstructionLength)); |
7779 __ push(eax); | 7789 __ push(eax); |
7780 | 7790 |
7781 // Call the entry hook. | 7791 // Call the entry hook. |
7782 int32_t hook_location = reinterpret_cast<int32_t>(&entry_hook_); | 7792 ASSERT(masm->isolate()->function_entry_hook() != NULL); |
7783 __ call(Operand(hook_location, RelocInfo::NONE32)); | 7793 __ call(FUNCTION_ADDR(masm->isolate()->function_entry_hook()), |
| 7794 RelocInfo::RUNTIME_ENTRY); |
7784 __ add(esp, Immediate(2 * kPointerSize)); | 7795 __ add(esp, Immediate(2 * kPointerSize)); |
7785 | 7796 |
7786 // Restore ecx. | 7797 // Restore ecx. |
| 7798 __ pop(edx); |
7787 __ pop(ecx); | 7799 __ pop(ecx); |
| 7800 __ pop(eax); |
| 7801 |
7788 __ ret(0); | 7802 __ ret(0); |
7789 } | 7803 } |
7790 | 7804 |
7791 | 7805 |
7792 template<class T> | 7806 template<class T> |
7793 static void CreateArrayDispatch(MacroAssembler* masm) { | 7807 static void CreateArrayDispatch(MacroAssembler* masm) { |
7794 int last_index = GetSequenceIndexFromFastElementsKind( | 7808 int last_index = GetSequenceIndexFromFastElementsKind( |
7795 TERMINAL_FAST_ELEMENTS_KIND); | 7809 TERMINAL_FAST_ELEMENTS_KIND); |
7796 for (int i = 0; i <= last_index; ++i) { | 7810 for (int i = 0; i <= last_index; ++i) { |
7797 Label next; | 7811 Label next; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8090 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 8104 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
8091 } | 8105 } |
8092 } | 8106 } |
8093 | 8107 |
8094 | 8108 |
8095 #undef __ | 8109 #undef __ |
8096 | 8110 |
8097 } } // namespace v8::internal | 8111 } } // namespace v8::internal |
8098 | 8112 |
8099 #endif // V8_TARGET_ARCH_IA32 | 8113 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |