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