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

Side by Side Diff: src/arm/code-stubs-arm.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/arm/builtins-arm.cc ('k') | src/bootstrapper.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 3163 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 3174
3175 3175
3176 void CEntryStub::Generate(MacroAssembler* masm) { 3176 void CEntryStub::Generate(MacroAssembler* masm) {
3177 // Called from JavaScript; parameters are on stack as if calling JS function 3177 // Called from JavaScript; parameters are on stack as if calling JS function
3178 // r0: number of arguments including receiver 3178 // r0: number of arguments including receiver
3179 // r1: pointer to builtin function 3179 // r1: pointer to builtin function
3180 // fp: frame pointer (restored after C call) 3180 // fp: frame pointer (restored after C call)
3181 // sp: stack pointer (restored as callee's sp after C call) 3181 // sp: stack pointer (restored as callee's sp after C call)
3182 // cp: current context (C callee-saved) 3182 // cp: current context (C callee-saved)
3183 3183
3184 ProfileEntryHookStub::MaybeCallEntryHook(masm);
3185
3184 // Result returned in r0 or r0+r1 by default. 3186 // Result returned in r0 or r0+r1 by default.
3185 3187
3186 // NOTE: Invocations of builtins may return failure objects 3188 // NOTE: Invocations of builtins may return failure objects
3187 // instead of a proper result. The builtin entry handles 3189 // instead of a proper result. The builtin entry handles
3188 // this by performing a garbage collection and retrying the 3190 // this by performing a garbage collection and retrying the
3189 // builtin once. 3191 // builtin once.
3190 3192
3191 // Compute the argv pointer in a callee-saved register. 3193 // Compute the argv pointer in a callee-saved register.
3192 __ add(r6, sp, Operand(r0, LSL, kPointerSizeLog2)); 3194 __ add(r6, sp, Operand(r0, LSL, kPointerSizeLog2));
3193 __ sub(r6, r6, Operand(kPointerSize)); 3195 __ sub(r6, r6, Operand(kPointerSize));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3264 3266
3265 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { 3267 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
3266 // r0: code entry 3268 // r0: code entry
3267 // r1: function 3269 // r1: function
3268 // r2: receiver 3270 // r2: receiver
3269 // r3: argc 3271 // r3: argc
3270 // [sp+0]: argv 3272 // [sp+0]: argv
3271 3273
3272 Label invoke, handler_entry, exit; 3274 Label invoke, handler_entry, exit;
3273 3275
3276 ProfileEntryHookStub::MaybeCallEntryHook(masm);
3277
3274 // Called from C, so do not pop argc and args on exit (preserve sp) 3278 // Called from C, so do not pop argc and args on exit (preserve sp)
3275 // No need to save register-passed args 3279 // No need to save register-passed args
3276 // Save callee-saved registers (incl. cp and fp), sp, and lr 3280 // Save callee-saved registers (incl. cp and fp), sp, and lr
3277 __ stm(db_w, sp, kCalleeSaved | lr.bit()); 3281 __ stm(db_w, sp, kCalleeSaved | lr.bit());
3278 3282
3279 // Save callee-saved vfp registers. 3283 // Save callee-saved vfp registers.
3280 __ vstm(db_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg); 3284 __ vstm(db_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg);
3281 // Set up the reserved register for 0.0. 3285 // Set up the reserved register for 0.0.
3282 __ vmov(kDoubleRegZero, 0.0); 3286 __ vmov(kDoubleRegZero, 0.0);
3283 __ VFPEnsureFPSCRState(r4); 3287 __ VFPEnsureFPSCRState(r4);
(...skipping 3780 matching lines...) Expand 10 before | Expand all | Expand 10 after
7064 __ add(r1, r1, Operand(1)); 7068 __ add(r1, r1, Operand(1));
7065 } 7069 }
7066 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); 7070 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE);
7067 __ mov(r1, Operand(r1, LSL, kPointerSizeLog2)); 7071 __ mov(r1, Operand(r1, LSL, kPointerSizeLog2));
7068 __ add(sp, sp, r1); 7072 __ add(sp, sp, r1);
7069 __ Ret(); 7073 __ Ret();
7070 } 7074 }
7071 7075
7072 7076
7073 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 7077 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
7074 if (entry_hook_ != NULL) { 7078 if (masm->isolate()->function_entry_hook() != NULL) {
7075 PredictableCodeSizeScope predictable(masm, 4 * Assembler::kInstrSize); 7079 PredictableCodeSizeScope predictable(masm, 4 * Assembler::kInstrSize);
7080 AllowStubCallsScope allow_stub_calls(masm, true);
7076 ProfileEntryHookStub stub; 7081 ProfileEntryHookStub stub;
7077 __ push(lr); 7082 __ push(lr);
7078 __ CallStub(&stub); 7083 __ CallStub(&stub);
7079 __ pop(lr); 7084 __ pop(lr);
7080 } 7085 }
7081 } 7086 }
7082 7087
7083 7088
7084 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { 7089 void ProfileEntryHookStub::Generate(MacroAssembler* masm) {
7085 // The entry hook is a "push lr" instruction, followed by a call. 7090 // The entry hook is a "push lr" instruction, followed by a call.
7086 const int32_t kReturnAddressDistanceFromFunctionStart = 7091 const int32_t kReturnAddressDistanceFromFunctionStart =
7087 3 * Assembler::kInstrSize; 7092 3 * Assembler::kInstrSize;
7088 7093
7089 // Save live volatile registers. 7094 // This should contain all kCallerSaved registers.
7090 __ Push(lr, r5, r1); 7095 const RegList kSavedRegs =
7091 const int32_t kNumSavedRegs = 3; 7096 1 << 0 | // r0
7097 1 << 1 | // r1
7098 1 << 2 | // r2
7099 1 << 3 | // r3
7100 1 << 5 | // r5
7101 1 << 9; // r9
7102 // We also save lr, so the count here is one higher than the mask indicates.
7103 const int32_t kNumSavedRegs = 7;
7104
7105 ASSERT((kCallerSaved & kSavedRegs) == kCallerSaved);
7106
7107 // Save all caller-save registers as this may be called from anywhere.
7108 __ stm(db_w, sp, kSavedRegs | lr.bit());
7092 7109
7093 // Compute the function's address for the first argument. 7110 // Compute the function's address for the first argument.
7094 __ sub(r0, lr, Operand(kReturnAddressDistanceFromFunctionStart)); 7111 __ sub(r0, lr, Operand(kReturnAddressDistanceFromFunctionStart));
7095 7112
7096 // The caller's return address is above the saved temporaries. 7113 // The caller's return address is above the saved temporaries.
7097 // Grab that for the second argument to the hook. 7114 // Grab that for the second argument to the hook.
7098 __ add(r1, sp, Operand(kNumSavedRegs * kPointerSize)); 7115 __ add(r1, sp, Operand(kNumSavedRegs * kPointerSize));
7099 7116
7100 // Align the stack if necessary. 7117 // Align the stack if necessary.
7101 int frame_alignment = masm->ActivationFrameAlignment(); 7118 int frame_alignment = masm->ActivationFrameAlignment();
7102 if (frame_alignment > kPointerSize) { 7119 if (frame_alignment > kPointerSize) {
7103 __ mov(r5, sp); 7120 __ mov(r5, sp);
7104 ASSERT(IsPowerOf2(frame_alignment)); 7121 ASSERT(IsPowerOf2(frame_alignment));
7105 __ and_(sp, sp, Operand(-frame_alignment)); 7122 __ and_(sp, sp, Operand(-frame_alignment));
7106 } 7123 }
7107 7124
7108 #if defined(V8_HOST_ARCH_ARM) 7125 #if defined(V8_HOST_ARCH_ARM)
7109 __ mov(ip, Operand(reinterpret_cast<int32_t>(&entry_hook_))); 7126 int32_t entry_hook =
7110 __ ldr(ip, MemOperand(ip)); 7127 reinterpret_cast<int32_t>(masm->isolate()->function_entry_hook());
7128 __ mov(ip, Operand(entry_hook));
7111 #else 7129 #else
7112 // Under the simulator we need to indirect the entry hook through a 7130 // Under the simulator we need to indirect the entry hook through a
7113 // trampoline function at a known address. 7131 // trampoline function at a known address.
7114 Address trampoline_address = reinterpret_cast<Address>( 7132 ApiFunction dispatcher(FUNCTION_ADDR(EntryHookTrampoline));
7115 reinterpret_cast<intptr_t>(EntryHookTrampoline));
7116 ApiFunction dispatcher(trampoline_address);
7117 __ mov(ip, Operand(ExternalReference(&dispatcher, 7133 __ mov(ip, Operand(ExternalReference(&dispatcher,
7118 ExternalReference::BUILTIN_CALL, 7134 ExternalReference::BUILTIN_CALL,
7119 masm->isolate()))); 7135 masm->isolate())));
7120 #endif 7136 #endif
7121 __ Call(ip); 7137 __ Call(ip);
7122 7138
7123 // Restore the stack pointer if needed. 7139 // Restore the stack pointer if needed.
7124 if (frame_alignment > kPointerSize) { 7140 if (frame_alignment > kPointerSize) {
7125 __ mov(sp, r5); 7141 __ mov(sp, r5);
7126 } 7142 }
7127 7143
7128 __ Pop(lr, r5, r1); 7144 // Also pop pc to get Ret(0).
7129 __ Ret(); 7145 __ ldm(ia_w, sp, kSavedRegs | pc.bit());
7130 } 7146 }
7131 7147
7132 7148
7133 template<class T> 7149 template<class T>
7134 static void CreateArrayDispatch(MacroAssembler* masm) { 7150 static void CreateArrayDispatch(MacroAssembler* masm) {
7135 int last_index = GetSequenceIndexFromFastElementsKind( 7151 int last_index = GetSequenceIndexFromFastElementsKind(
7136 TERMINAL_FAST_ELEMENTS_KIND); 7152 TERMINAL_FAST_ELEMENTS_KIND);
7137 for (int i = 0; i <= last_index; ++i) { 7153 for (int i = 0; i <= last_index; ++i) {
7138 Label next; 7154 Label next;
7139 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); 7155 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
7401 __ bind(&fast_elements_case); 7417 __ bind(&fast_elements_case);
7402 GenerateCase(masm, FAST_ELEMENTS); 7418 GenerateCase(masm, FAST_ELEMENTS);
7403 } 7419 }
7404 7420
7405 7421
7406 #undef __ 7422 #undef __
7407 7423
7408 } } // namespace v8::internal 7424 } } // namespace v8::internal
7409 7425
7410 #endif // V8_TARGET_ARCH_ARM 7426 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698