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