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 5059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5070 | 5070 |
5071 | 5071 |
5072 void CEntryStub::Generate(MacroAssembler* masm) { | 5072 void CEntryStub::Generate(MacroAssembler* masm) { |
5073 // eax: number of arguments including receiver | 5073 // eax: number of arguments including receiver |
5074 // ebx: pointer to C function (C callee-saved) | 5074 // ebx: pointer to C function (C callee-saved) |
5075 // ebp: frame pointer (restored after C call) | 5075 // ebp: frame pointer (restored after C call) |
5076 // esp: stack pointer (restored after C call) | 5076 // esp: stack pointer (restored after C call) |
5077 // esi: current context (C callee-saved) | 5077 // esi: current context (C callee-saved) |
5078 // edi: JS function of the caller (C callee-saved) | 5078 // edi: JS function of the caller (C callee-saved) |
5079 | 5079 |
| 5080 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 5081 |
5080 // NOTE: Invocations of builtins may return failure objects instead | 5082 // NOTE: Invocations of builtins may return failure objects instead |
5081 // of a proper result. The builtin entry handles this by performing | 5083 // of a proper result. The builtin entry handles this by performing |
5082 // a garbage collection and retrying the builtin (twice). | 5084 // a garbage collection and retrying the builtin (twice). |
5083 | 5085 |
5084 // Enter the exit frame that transitions from JavaScript to C++. | 5086 // Enter the exit frame that transitions from JavaScript to C++. |
5085 __ EnterExitFrame(save_doubles_ == kSaveFPRegs); | 5087 __ EnterExitFrame(save_doubles_ == kSaveFPRegs); |
5086 | 5088 |
5087 // eax: result parameter for PerformGC, if any (setup below) | 5089 // eax: result parameter for PerformGC, if any (setup below) |
5088 // ebx: pointer to builtin function (C callee-saved) | 5090 // ebx: pointer to builtin function (C callee-saved) |
5089 // ebp: frame pointer (restored after C call) | 5091 // ebp: frame pointer (restored after C call) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5143 | 5145 |
5144 __ bind(&throw_normal_exception); | 5146 __ bind(&throw_normal_exception); |
5145 __ Throw(eax); | 5147 __ Throw(eax); |
5146 } | 5148 } |
5147 | 5149 |
5148 | 5150 |
5149 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 5151 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
5150 Label invoke, handler_entry, exit; | 5152 Label invoke, handler_entry, exit; |
5151 Label not_outermost_js, not_outermost_js_2; | 5153 Label not_outermost_js, not_outermost_js_2; |
5152 | 5154 |
| 5155 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 5156 |
5153 // Set up frame. | 5157 // Set up frame. |
5154 __ push(ebp); | 5158 __ push(ebp); |
5155 __ mov(ebp, esp); | 5159 __ mov(ebp, esp); |
5156 | 5160 |
5157 // Push marker in two places. | 5161 // Push marker in two places. |
5158 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; | 5162 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
5159 __ push(Immediate(Smi::FromInt(marker))); // context slot | 5163 __ push(Immediate(Smi::FromInt(marker))); // context slot |
5160 __ push(Immediate(Smi::FromInt(marker))); // function slot | 5164 __ push(Immediate(Smi::FromInt(marker))); // function slot |
5161 // Save callee-saved registers (C calling conventions). | 5165 // Save callee-saved registers (C calling conventions). |
5162 __ push(edi); | 5166 __ push(edi); |
(...skipping 2521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7684 __ pop(ecx); | 7688 __ pop(ecx); |
7685 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE | 7689 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE |
7686 ? kPointerSize | 7690 ? kPointerSize |
7687 : 0; | 7691 : 0; |
7688 __ lea(esp, MemOperand(esp, ebx, times_pointer_size, additional_offset)); | 7692 __ lea(esp, MemOperand(esp, ebx, times_pointer_size, additional_offset)); |
7689 __ jmp(ecx); // Return to IC Miss stub, continuation still on stack. | 7693 __ jmp(ecx); // Return to IC Miss stub, continuation still on stack. |
7690 } | 7694 } |
7691 | 7695 |
7692 | 7696 |
7693 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 7697 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
7694 if (entry_hook_ != NULL) { | 7698 if (masm->isolate()->function_entry_hook() != NULL) { |
| 7699 // It's always safe to call the entry hook stub, as the hook itself |
| 7700 // is not allowed to call back to V8. |
| 7701 AllowStubCallsScope allow_stub_calls(masm, true); |
| 7702 |
7695 ProfileEntryHookStub stub; | 7703 ProfileEntryHookStub stub; |
7696 masm->CallStub(&stub); | 7704 masm->CallStub(&stub); |
7697 } | 7705 } |
7698 } | 7706 } |
7699 | 7707 |
7700 | 7708 |
7701 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { | 7709 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { |
7702 // Ecx is the only volatile register we must save. | 7710 // Save volatile registers. |
7703 const int kNumSavedRegisters = 1; | 7711 const int kNumSavedRegisters = 3; |
| 7712 __ push(eax); |
7704 __ push(ecx); | 7713 __ push(ecx); |
| 7714 __ push(edx); |
7705 | 7715 |
7706 // Calculate and push the original stack pointer. | 7716 // Calculate and push the original stack pointer. |
7707 __ lea(eax, Operand(esp, (kNumSavedRegisters + 1) * kPointerSize)); | 7717 __ lea(eax, Operand(esp, (kNumSavedRegisters + 1) * kPointerSize)); |
7708 __ push(eax); | 7718 __ push(eax); |
7709 | 7719 |
7710 // Retrieve our return address and use it to calculate the calling | 7720 // Retrieve our return address and use it to calculate the calling |
7711 // function's address. | 7721 // function's address. |
7712 __ mov(eax, Operand(esp, (kNumSavedRegisters + 1) * kPointerSize)); | 7722 __ mov(eax, Operand(esp, (kNumSavedRegisters + 1) * kPointerSize)); |
7713 __ sub(eax, Immediate(Assembler::kCallInstructionLength)); | 7723 __ sub(eax, Immediate(Assembler::kCallInstructionLength)); |
7714 __ push(eax); | 7724 __ push(eax); |
7715 | 7725 |
7716 // Call the entry hook. | 7726 // Call the entry hook. |
7717 int32_t hook_location = reinterpret_cast<int32_t>(&entry_hook_); | 7727 ASSERT(masm->isolate()->function_entry_hook() != NULL); |
7718 __ call(Operand(hook_location, RelocInfo::NONE32)); | 7728 __ call(FUNCTION_ADDR(masm->isolate()->function_entry_hook()), |
| 7729 RelocInfo::RUNTIME_ENTRY); |
7719 __ add(esp, Immediate(2 * kPointerSize)); | 7730 __ add(esp, Immediate(2 * kPointerSize)); |
7720 | 7731 |
7721 // Restore ecx. | 7732 // Restore ecx. |
| 7733 __ pop(edx); |
7722 __ pop(ecx); | 7734 __ pop(ecx); |
| 7735 __ pop(eax); |
| 7736 |
7723 __ ret(0); | 7737 __ ret(0); |
7724 } | 7738 } |
7725 | 7739 |
7726 | 7740 |
7727 template<class T> | 7741 template<class T> |
7728 static void CreateArrayDispatch(MacroAssembler* masm) { | 7742 static void CreateArrayDispatch(MacroAssembler* masm) { |
7729 int last_index = GetSequenceIndexFromFastElementsKind( | 7743 int last_index = GetSequenceIndexFromFastElementsKind( |
7730 TERMINAL_FAST_ELEMENTS_KIND); | 7744 TERMINAL_FAST_ELEMENTS_KIND); |
7731 for (int i = 0; i <= last_index; ++i) { | 7745 for (int i = 0; i <= last_index; ++i) { |
7732 Label next; | 7746 Label next; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7998 __ bind(&fast_elements_case); | 8012 __ bind(&fast_elements_case); |
7999 GenerateCase(masm, FAST_ELEMENTS); | 8013 GenerateCase(masm, FAST_ELEMENTS); |
8000 } | 8014 } |
8001 | 8015 |
8002 | 8016 |
8003 #undef __ | 8017 #undef __ |
8004 | 8018 |
8005 } } // namespace v8::internal | 8019 } } // namespace v8::internal |
8006 | 8020 |
8007 #endif // V8_TARGET_ARCH_IA32 | 8021 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |