Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 16578008: Improved function entry hook coverage (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@post_fix
Patch Set: Fix Windows X64 compile warnings." Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
4132 // Enter the exit frame that transitions from JavaScript to C++. 4134 // Enter the exit frame that transitions from JavaScript to C++.
4133 #ifdef _WIN64 4135 #ifdef _WIN64
4134 int arg_stack_space = (result_size_ < 2 ? 2 : 4); 4136 int arg_stack_space = (result_size_ < 2 ? 2 : 4);
4135 #else 4137 #else
4136 int arg_stack_space = 0; 4138 int arg_stack_space = 0;
4137 #endif 4139 #endif
4138 __ EnterExitFrame(arg_stack_space, save_doubles_); 4140 __ EnterExitFrame(arg_stack_space, save_doubles_);
4139 4141
4140 // rax: Holds the context at this point, but should not be used. 4142 // rax: Holds the context at this point, but should not be used.
4141 // On entry to code generated by GenerateCore, it must hold 4143 // On entry to code generated by GenerateCore, it must hold
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4202 4204
4203 __ bind(&throw_normal_exception); 4205 __ bind(&throw_normal_exception);
4204 __ Throw(rax); 4206 __ Throw(rax);
4205 } 4207 }
4206 4208
4207 4209
4208 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { 4210 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
4209 Label invoke, handler_entry, exit; 4211 Label invoke, handler_entry, exit;
4210 Label not_outermost_js, not_outermost_js_2; 4212 Label not_outermost_js, not_outermost_js_2;
4211 4213
4214 ProfileEntryHookStub::MaybeCallEntryHook(masm);
4215
4212 { // NOLINT. Scope block confuses linter. 4216 { // NOLINT. Scope block confuses linter.
4213 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); 4217 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm);
4214 // Set up frame. 4218 // Set up frame.
4215 __ push(rbp); 4219 __ push(rbp);
4216 __ movq(rbp, rsp); 4220 __ movq(rbp, rsp);
4217 4221
4218 // Push the stack frame type marker twice. 4222 // Push the stack frame type marker twice.
4219 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; 4223 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY;
4220 // Scratch register is neither callee-save, nor an argument register on any 4224 // Scratch register is neither callee-save, nor an argument register on any
4221 // platform. It's free to use at this point. 4225 // platform. It's free to use at this point.
(...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after
6656 __ pop(rcx); 6660 __ pop(rcx);
6657 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE 6661 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE
6658 ? kPointerSize 6662 ? kPointerSize
6659 : 0; 6663 : 0;
6660 __ lea(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); 6664 __ lea(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset));
6661 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. 6665 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack.
6662 } 6666 }
6663 6667
6664 6668
6665 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 6669 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
6666 if (entry_hook_ != NULL) { 6670 if (masm->isolate()->function_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
6667 ProfileEntryHookStub stub; 6675 ProfileEntryHookStub stub;
6668 masm->CallStub(&stub); 6676 masm->CallStub(&stub);
6669 } 6677 }
6670 } 6678 }
6671 6679
6672 6680
6673 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { 6681 void ProfileEntryHookStub::Generate(MacroAssembler* masm) {
6674 // Save volatile registers. 6682 // This stub can be called from essentially anywhere, so it needs to save
6675 // Live registers at this point are the same as at the start of any 6683 // all volatile and callee-save registers.
6676 // JS function: 6684 const size_t kNumSavedRegisters = 2;
6677 // o rdi: the JS function object being called (i.e. ourselves) 6685 __ push(arg_reg_1);
6678 // o rsi: our context 6686 __ push(arg_reg_2);
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
6693 6687
6694 // Calculate the original stack pointer and store it in the second arg. 6688 // Calculate the original stack pointer and store it in the second arg.
6695 #ifdef _WIN64 6689 __ lea(arg_reg_2, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize));
6696 __ lea(rdx, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize));
6697 #else
6698 __ lea(rsi, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize));
6699 #endif
6700 6690
6701 // Calculate the function address to the first arg. 6691 // Calculate the function address to the first arg.
6702 #ifdef _WIN64 6692 __ movq(arg_reg_1, Operand(rsp, kNumSavedRegisters * kPointerSize));
6703 __ movq(rcx, Operand(rsp, kNumSavedRegisters * kPointerSize)); 6693 __ subq(arg_reg_1, Immediate(Assembler::kShortCallInstructionLength));
6704 __ subq(rcx, Immediate(Assembler::kShortCallInstructionLength)); 6694
6705 #else 6695 // Save the remainder of the volatile registers.
6706 __ movq(rdi, Operand(rsp, kNumSavedRegisters * kPointerSize)); 6696 masm->PushCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2);
6707 __ subq(rdi, Immediate(Assembler::kShortCallInstructionLength));
6708 #endif
6709 6697
6710 // Call the entry hook function. 6698 // Call the entry hook function.
6711 __ movq(rax, &entry_hook_, RelocInfo::NONE64); 6699 __ movq(rax, FUNCTION_ADDR(masm->isolate()->function_entry_hook()),
6712 __ movq(rax, Operand(rax, 0)); 6700 RelocInfo::NONE64);
6713 6701
6714 AllowExternalCallThatCantCauseGC scope(masm); 6702 AllowExternalCallThatCantCauseGC scope(masm);
6715 6703
6716 const int kArgumentCount = 2; 6704 const int kArgumentCount = 2;
6717 __ PrepareCallCFunction(kArgumentCount); 6705 __ PrepareCallCFunction(kArgumentCount);
6718 __ CallCFunction(rax, kArgumentCount); 6706 __ CallCFunction(rax, kArgumentCount);
6719 6707
6720 // Restore volatile regs. 6708 // Restore volatile regs.
6721 #ifdef _WIN64 6709 masm->PopCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2);
6722 __ pop(rcx); 6710 __ pop(arg_reg_2);
6723 #else 6711 __ pop(arg_reg_1);
6724 __ pop(rsi);
6725 __ pop(rdi);
6726 __ pop(rcx);
6727 #endif
6728 6712
6729 __ Ret(); 6713 __ Ret();
6730 } 6714 }
6731 6715
6732 6716
6733 template<class T> 6717 template<class T>
6734 static void CreateArrayDispatch(MacroAssembler* masm) { 6718 static void CreateArrayDispatch(MacroAssembler* masm) {
6735 int last_index = GetSequenceIndexFromFastElementsKind( 6719 int last_index = GetSequenceIndexFromFastElementsKind(
6736 TERMINAL_FAST_ELEMENTS_KIND); 6720 TERMINAL_FAST_ELEMENTS_KIND);
6737 for (int i = 0; i <= last_index; ++i) { 6721 for (int i = 0; i <= last_index; ++i) {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
7006 __ bind(&fast_elements_case); 6990 __ bind(&fast_elements_case);
7007 GenerateCase(masm, FAST_ELEMENTS); 6991 GenerateCase(masm, FAST_ELEMENTS);
7008 } 6992 }
7009 6993
7010 6994
7011 #undef __ 6995 #undef __
7012 6996
7013 } } // namespace v8::internal 6997 } } // namespace v8::internal
7014 6998
7015 #endif // V8_TARGET_ARCH_X64 6999 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698