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 3161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3172 | 3172 |
3173 | 3173 |
3174 void CEntryStub::Generate(MacroAssembler* masm) { | 3174 void CEntryStub::Generate(MacroAssembler* masm) { |
3175 // Called from JavaScript; parameters are on stack as if calling JS function | 3175 // Called from JavaScript; parameters are on stack as if calling JS function |
3176 // r0: number of arguments including receiver | 3176 // r0: number of arguments including receiver |
3177 // r1: pointer to builtin function | 3177 // r1: pointer to builtin function |
3178 // fp: frame pointer (restored after C call) | 3178 // fp: frame pointer (restored after C call) |
3179 // sp: stack pointer (restored as callee's sp after C call) | 3179 // sp: stack pointer (restored as callee's sp after C call) |
3180 // cp: current context (C callee-saved) | 3180 // cp: current context (C callee-saved) |
3181 | 3181 |
| 3182 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 3183 |
3182 // Result returned in r0 or r0+r1 by default. | 3184 // Result returned in r0 or r0+r1 by default. |
3183 | 3185 |
3184 // NOTE: Invocations of builtins may return failure objects | 3186 // NOTE: Invocations of builtins may return failure objects |
3185 // instead of a proper result. The builtin entry handles | 3187 // instead of a proper result. The builtin entry handles |
3186 // this by performing a garbage collection and retrying the | 3188 // this by performing a garbage collection and retrying the |
3187 // builtin once. | 3189 // builtin once. |
3188 | 3190 |
3189 // Compute the argv pointer in a callee-saved register. | 3191 // Compute the argv pointer in a callee-saved register. |
3190 __ add(r6, sp, Operand(r0, LSL, kPointerSizeLog2)); | 3192 __ add(r6, sp, Operand(r0, LSL, kPointerSizeLog2)); |
3191 __ sub(r6, r6, Operand(kPointerSize)); | 3193 __ sub(r6, r6, Operand(kPointerSize)); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3262 | 3264 |
3263 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 3265 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
3264 // r0: code entry | 3266 // r0: code entry |
3265 // r1: function | 3267 // r1: function |
3266 // r2: receiver | 3268 // r2: receiver |
3267 // r3: argc | 3269 // r3: argc |
3268 // [sp+0]: argv | 3270 // [sp+0]: argv |
3269 | 3271 |
3270 Label invoke, handler_entry, exit; | 3272 Label invoke, handler_entry, exit; |
3271 | 3273 |
| 3274 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 3275 |
3272 // Called from C, so do not pop argc and args on exit (preserve sp) | 3276 // Called from C, so do not pop argc and args on exit (preserve sp) |
3273 // No need to save register-passed args | 3277 // No need to save register-passed args |
3274 // Save callee-saved registers (incl. cp and fp), sp, and lr | 3278 // Save callee-saved registers (incl. cp and fp), sp, and lr |
3275 __ stm(db_w, sp, kCalleeSaved | lr.bit()); | 3279 __ stm(db_w, sp, kCalleeSaved | lr.bit()); |
3276 | 3280 |
3277 // Save callee-saved vfp registers. | 3281 // Save callee-saved vfp registers. |
3278 __ vstm(db_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg); | 3282 __ vstm(db_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg); |
3279 // Set up the reserved register for 0.0. | 3283 // Set up the reserved register for 0.0. |
3280 __ vmov(kDoubleRegZero, 0.0); | 3284 __ vmov(kDoubleRegZero, 0.0); |
3281 __ VFPEnsureFPSCRState(r4); | 3285 __ VFPEnsureFPSCRState(r4); |
(...skipping 3844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7126 __ add(r1, r1, Operand(1)); | 7130 __ add(r1, r1, Operand(1)); |
7127 } | 7131 } |
7128 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); | 7132 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); |
7129 __ mov(r1, Operand(r1, LSL, kPointerSizeLog2)); | 7133 __ mov(r1, Operand(r1, LSL, kPointerSizeLog2)); |
7130 __ add(sp, sp, r1); | 7134 __ add(sp, sp, r1); |
7131 __ Ret(); | 7135 __ Ret(); |
7132 } | 7136 } |
7133 | 7137 |
7134 | 7138 |
7135 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 7139 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
7136 if (entry_hook_ != NULL) { | 7140 if (masm->isolate()->function_entry_hook() != NULL) { |
7137 PredictableCodeSizeScope predictable(masm, 4 * Assembler::kInstrSize); | 7141 PredictableCodeSizeScope predictable(masm, 4 * Assembler::kInstrSize); |
| 7142 AllowStubCallsScope allow_stub_calls(masm, true); |
7138 ProfileEntryHookStub stub; | 7143 ProfileEntryHookStub stub; |
7139 __ push(lr); | 7144 __ push(lr); |
7140 __ CallStub(&stub); | 7145 __ CallStub(&stub); |
7141 __ pop(lr); | 7146 __ pop(lr); |
7142 } | 7147 } |
7143 } | 7148 } |
7144 | 7149 |
7145 | 7150 |
7146 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { | 7151 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { |
7147 // The entry hook is a "push lr" instruction, followed by a call. | 7152 // The entry hook is a "push lr" instruction, followed by a call. |
7148 const int32_t kReturnAddressDistanceFromFunctionStart = | 7153 const int32_t kReturnAddressDistanceFromFunctionStart = |
7149 3 * Assembler::kInstrSize; | 7154 3 * Assembler::kInstrSize; |
7150 | 7155 |
7151 // Save live volatile registers. | 7156 // This should contain all kCallerSaved registers. |
7152 __ Push(lr, r5, r1); | 7157 const RegList kSavedRegs = |
7153 const int32_t kNumSavedRegs = 3; | 7158 1 << 0 | // r0 |
| 7159 1 << 1 | // r1 |
| 7160 1 << 2 | // r2 |
| 7161 1 << 3 | // r3 |
| 7162 1 << 5 | // r5 |
| 7163 1 << 9; // r9 |
| 7164 // We also save lr, so the count here is one higher than the mask indicates. |
| 7165 const int32_t kNumSavedRegs = 7; |
| 7166 |
| 7167 ASSERT((kCallerSaved & kSavedRegs) == kCallerSaved); |
| 7168 |
| 7169 // Save all caller-save registers as this may be called from anywhere. |
| 7170 __ stm(db_w, sp, kSavedRegs | lr.bit()); |
7154 | 7171 |
7155 // Compute the function's address for the first argument. | 7172 // Compute the function's address for the first argument. |
7156 __ sub(r0, lr, Operand(kReturnAddressDistanceFromFunctionStart)); | 7173 __ sub(r0, lr, Operand(kReturnAddressDistanceFromFunctionStart)); |
7157 | 7174 |
7158 // The caller's return address is above the saved temporaries. | 7175 // The caller's return address is above the saved temporaries. |
7159 // Grab that for the second argument to the hook. | 7176 // Grab that for the second argument to the hook. |
7160 __ add(r1, sp, Operand(kNumSavedRegs * kPointerSize)); | 7177 __ add(r1, sp, Operand(kNumSavedRegs * kPointerSize)); |
7161 | 7178 |
7162 // Align the stack if necessary. | 7179 // Align the stack if necessary. |
7163 int frame_alignment = masm->ActivationFrameAlignment(); | 7180 int frame_alignment = masm->ActivationFrameAlignment(); |
7164 if (frame_alignment > kPointerSize) { | 7181 if (frame_alignment > kPointerSize) { |
7165 __ mov(r5, sp); | 7182 __ mov(r5, sp); |
7166 ASSERT(IsPowerOf2(frame_alignment)); | 7183 ASSERT(IsPowerOf2(frame_alignment)); |
7167 __ and_(sp, sp, Operand(-frame_alignment)); | 7184 __ and_(sp, sp, Operand(-frame_alignment)); |
7168 } | 7185 } |
7169 | 7186 |
7170 #if defined(V8_HOST_ARCH_ARM) | 7187 #if defined(V8_HOST_ARCH_ARM) |
7171 __ mov(ip, Operand(reinterpret_cast<int32_t>(&entry_hook_))); | 7188 __ mov(ip, FUNCTION_ADDR(masm->isolate()->function_entry_hook()), |
7172 __ ldr(ip, MemOperand(ip)); | 7189 RelocInfo::NONE)); |
7173 #else | 7190 #else |
7174 // Under the simulator we need to indirect the entry hook through a | 7191 // Under the simulator we need to indirect the entry hook through a |
7175 // trampoline function at a known address. | 7192 // trampoline function at a known address. |
7176 Address trampoline_address = reinterpret_cast<Address>( | 7193 ApiFunction dispatcher(FUNCTION_ADDR(EntryHookTrampoline)); |
7177 reinterpret_cast<intptr_t>(EntryHookTrampoline)); | |
7178 ApiFunction dispatcher(trampoline_address); | |
7179 __ mov(ip, Operand(ExternalReference(&dispatcher, | 7194 __ mov(ip, Operand(ExternalReference(&dispatcher, |
7180 ExternalReference::BUILTIN_CALL, | 7195 ExternalReference::BUILTIN_CALL, |
7181 masm->isolate()))); | 7196 masm->isolate()))); |
7182 #endif | 7197 #endif |
7183 __ Call(ip); | 7198 __ Call(ip); |
7184 | 7199 |
7185 // Restore the stack pointer if needed. | 7200 // Restore the stack pointer if needed. |
7186 if (frame_alignment > kPointerSize) { | 7201 if (frame_alignment > kPointerSize) { |
7187 __ mov(sp, r5); | 7202 __ mov(sp, r5); |
7188 } | 7203 } |
7189 | 7204 |
7190 __ Pop(lr, r5, r1); | 7205 // Also pop pc to get Ret(0). |
7191 __ Ret(); | 7206 __ ldm(ia_w, sp, kSavedRegs | pc.bit()); |
7192 } | 7207 } |
7193 | 7208 |
7194 | 7209 |
7195 template<class T> | 7210 template<class T> |
7196 static void CreateArrayDispatch(MacroAssembler* masm) { | 7211 static void CreateArrayDispatch(MacroAssembler* masm) { |
7197 int last_index = GetSequenceIndexFromFastElementsKind( | 7212 int last_index = GetSequenceIndexFromFastElementsKind( |
7198 TERMINAL_FAST_ELEMENTS_KIND); | 7213 TERMINAL_FAST_ELEMENTS_KIND); |
7199 for (int i = 0; i <= last_index; ++i) { | 7214 for (int i = 0; i <= last_index; ++i) { |
7200 Label next; | 7215 Label next; |
7201 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 7216 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7491 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 7506 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
7492 } | 7507 } |
7493 } | 7508 } |
7494 | 7509 |
7495 | 7510 |
7496 #undef __ | 7511 #undef __ |
7497 | 7512 |
7498 } } // namespace v8::internal | 7513 } } // namespace v8::internal |
7499 | 7514 |
7500 #endif // V8_TARGET_ARCH_ARM | 7515 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |