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 3512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3523 | 3523 |
3524 void CEntryStub::Generate(MacroAssembler* masm) { | 3524 void CEntryStub::Generate(MacroAssembler* masm) { |
3525 // Called from JavaScript; parameters are on stack as if calling JS function | 3525 // Called from JavaScript; parameters are on stack as if calling JS function |
3526 // s0: number of arguments including receiver | 3526 // s0: number of arguments including receiver |
3527 // s1: size of arguments excluding receiver | 3527 // s1: size of arguments excluding receiver |
3528 // s2: pointer to builtin function | 3528 // s2: pointer to builtin function |
3529 // fp: frame pointer (restored after C call) | 3529 // fp: frame pointer (restored after C call) |
3530 // sp: stack pointer (restored as callee's sp after C call) | 3530 // sp: stack pointer (restored as callee's sp after C call) |
3531 // cp: current context (C callee-saved) | 3531 // cp: current context (C callee-saved) |
3532 | 3532 |
| 3533 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 3534 |
3533 // NOTE: Invocations of builtins may return failure objects | 3535 // NOTE: Invocations of builtins may return failure objects |
3534 // instead of a proper result. The builtin entry handles | 3536 // instead of a proper result. The builtin entry handles |
3535 // this by performing a garbage collection and retrying the | 3537 // this by performing a garbage collection and retrying the |
3536 // builtin once. | 3538 // builtin once. |
3537 | 3539 |
3538 // NOTE: s0-s2 hold the arguments of this function instead of a0-a2. | 3540 // NOTE: s0-s2 hold the arguments of this function instead of a0-a2. |
3539 // The reason for this is that these arguments would need to be saved anyway | 3541 // The reason for this is that these arguments would need to be saved anyway |
3540 // so it's faster to set them up directly. | 3542 // so it's faster to set them up directly. |
3541 // See MacroAssembler::PrepareCEntryArgs and PrepareCEntryFunction. | 3543 // See MacroAssembler::PrepareCEntryArgs and PrepareCEntryFunction. |
3542 | 3544 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3616 // Registers: | 3618 // Registers: |
3617 // a0: entry address | 3619 // a0: entry address |
3618 // a1: function | 3620 // a1: function |
3619 // a2: receiver | 3621 // a2: receiver |
3620 // a3: argc | 3622 // a3: argc |
3621 // | 3623 // |
3622 // Stack: | 3624 // Stack: |
3623 // 4 args slots | 3625 // 4 args slots |
3624 // args | 3626 // args |
3625 | 3627 |
| 3628 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 3629 |
3626 // Save callee saved registers on the stack. | 3630 // Save callee saved registers on the stack. |
3627 __ MultiPush(kCalleeSaved | ra.bit()); | 3631 __ MultiPush(kCalleeSaved | ra.bit()); |
3628 | 3632 |
3629 // Save callee-saved FPU registers. | 3633 // Save callee-saved FPU registers. |
3630 __ MultiPushFPU(kCalleeSavedFPU); | 3634 __ MultiPushFPU(kCalleeSavedFPU); |
3631 // Set up the reserved register for 0.0. | 3635 // Set up the reserved register for 0.0. |
3632 __ Move(kDoubleRegZero, 0.0); | 3636 __ Move(kDoubleRegZero, 0.0); |
3633 | 3637 |
3634 | 3638 |
3635 // Load argv in s0 register. | 3639 // Load argv in s0 register. |
(...skipping 3867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7503 __ Addu(a1, a1, Operand(1)); | 7507 __ Addu(a1, a1, Operand(1)); |
7504 } | 7508 } |
7505 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); | 7509 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); |
7506 __ sll(a1, a1, kPointerSizeLog2); | 7510 __ sll(a1, a1, kPointerSizeLog2); |
7507 __ Ret(USE_DELAY_SLOT); | 7511 __ Ret(USE_DELAY_SLOT); |
7508 __ Addu(sp, sp, a1); | 7512 __ Addu(sp, sp, a1); |
7509 } | 7513 } |
7510 | 7514 |
7511 | 7515 |
7512 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 7516 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
7513 if (entry_hook_ != NULL) { | 7517 if (masm->isolate()->function_entry_hook() != NULL) { |
| 7518 AllowStubCallsScope allow_stub_calls(masm, true); |
7514 ProfileEntryHookStub stub; | 7519 ProfileEntryHookStub stub; |
7515 __ push(ra); | 7520 __ push(ra); |
7516 __ CallStub(&stub); | 7521 __ CallStub(&stub); |
7517 __ pop(ra); | 7522 __ pop(ra); |
7518 } | 7523 } |
7519 } | 7524 } |
7520 | 7525 |
7521 | 7526 |
7522 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { | 7527 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { |
7523 // The entry hook is a "push ra" instruction, followed by a call. | 7528 // The entry hook is a "push ra" instruction, followed by a call. |
7524 // Note: on MIPS "push" is 2 instruction | 7529 // Note: on MIPS "push" is 2 instruction |
7525 const int32_t kReturnAddressDistanceFromFunctionStart = | 7530 const int32_t kReturnAddressDistanceFromFunctionStart = |
7526 Assembler::kCallTargetAddressOffset + (2 * Assembler::kInstrSize); | 7531 Assembler::kCallTargetAddressOffset + (2 * Assembler::kInstrSize); |
7527 | 7532 |
7528 // Save live volatile registers. | 7533 // Save live volatile registers. |
7529 __ Push(ra, t1, a1); | 7534 // We also save ra, so the count here is one higher than the mask indicates. |
7530 const int32_t kNumSavedRegs = 3; | 7535 const int32_t kNumSavedRegs = kNumJSCallerSaved + 1; |
| 7536 |
| 7537 // Save all caller-save registers as this may be called from anywhere. |
| 7538 __ MultiPush(kJSCallerSaved | ra.bit()); |
7531 | 7539 |
7532 // Compute the function's address for the first argument. | 7540 // Compute the function's address for the first argument. |
7533 __ Subu(a0, ra, Operand(kReturnAddressDistanceFromFunctionStart)); | 7541 __ Subu(a0, ra, Operand(kReturnAddressDistanceFromFunctionStart)); |
7534 | 7542 |
7535 // The caller's return address is above the saved temporaries. | 7543 // The caller's return address is above the saved temporaries. |
7536 // Grab that for the second argument to the hook. | 7544 // Grab that for the second argument to the hook. |
7537 __ Addu(a1, sp, Operand(kNumSavedRegs * kPointerSize)); | 7545 __ Addu(a1, sp, Operand(kNumSavedRegs * kPointerSize)); |
7538 | 7546 |
7539 // Align the stack if necessary. | 7547 // Align the stack if necessary. |
7540 int frame_alignment = masm->ActivationFrameAlignment(); | 7548 int frame_alignment = masm->ActivationFrameAlignment(); |
7541 if (frame_alignment > kPointerSize) { | 7549 if (frame_alignment > kPointerSize) { |
7542 __ mov(t1, sp); | 7550 __ mov(t1, sp); |
7543 ASSERT(IsPowerOf2(frame_alignment)); | 7551 ASSERT(IsPowerOf2(frame_alignment)); |
7544 __ And(sp, sp, Operand(-frame_alignment)); | 7552 __ And(sp, sp, Operand(-frame_alignment)); |
7545 } | 7553 } |
7546 | 7554 |
7547 #if V8_HOST_ARCH_MIPS | 7555 #if defined(V8_HOST_ARCH_MIPS) |
7548 __ li(at, Operand(reinterpret_cast<int32_t>(&entry_hook_))); | 7556 int32_t entry_hook = |
7549 __ lw(at, MemOperand(at)); | 7557 reinterpret_cast<int32_t>(masm->isolate()->function_entry_hook()); |
| 7558 __ li(at, Operand(entry_hook)); |
7550 #else | 7559 #else |
7551 // Under the simulator we need to indirect the entry hook through a | 7560 // Under the simulator we need to indirect the entry hook through a |
7552 // trampoline function at a known address. | 7561 // trampoline function at a known address. |
7553 Address trampoline_address = reinterpret_cast<Address>( | 7562 ApiFunction dispatcher(FUNCTION_ADDR(EntryHookTrampoline)); |
7554 reinterpret_cast<intptr_t>(EntryHookTrampoline)); | |
7555 ApiFunction dispatcher(trampoline_address); | |
7556 __ li(at, Operand(ExternalReference(&dispatcher, | 7563 __ li(at, Operand(ExternalReference(&dispatcher, |
7557 ExternalReference::BUILTIN_CALL, | 7564 ExternalReference::BUILTIN_CALL, |
7558 masm->isolate()))); | 7565 masm->isolate()))); |
7559 #endif | 7566 #endif |
7560 __ Call(at); | 7567 __ Call(at); |
7561 | 7568 |
7562 // Restore the stack pointer if needed. | 7569 // Restore the stack pointer if needed. |
7563 if (frame_alignment > kPointerSize) { | 7570 if (frame_alignment > kPointerSize) { |
7564 __ mov(sp, t1); | 7571 __ mov(sp, t1); |
7565 } | 7572 } |
7566 | 7573 |
7567 __ Pop(ra, t1, a1); | 7574 // Also pop ra to get Ret(0). |
| 7575 __ MultiPop(kJSCallerSaved | ra.bit()); |
7568 __ Ret(); | 7576 __ Ret(); |
7569 } | 7577 } |
7570 | 7578 |
7571 | 7579 |
7572 template<class T> | 7580 template<class T> |
7573 static void CreateArrayDispatch(MacroAssembler* masm) { | 7581 static void CreateArrayDispatch(MacroAssembler* masm) { |
7574 int last_index = GetSequenceIndexFromFastElementsKind( | 7582 int last_index = GetSequenceIndexFromFastElementsKind( |
7575 TERMINAL_FAST_ELEMENTS_KIND); | 7583 TERMINAL_FAST_ELEMENTS_KIND); |
7576 for (int i = 0; i <= last_index; ++i) { | 7584 for (int i = 0; i <= last_index; ++i) { |
7577 Label next; | 7585 Label next; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7837 __ bind(&fast_elements_case); | 7845 __ bind(&fast_elements_case); |
7838 GenerateCase(masm, FAST_ELEMENTS); | 7846 GenerateCase(masm, FAST_ELEMENTS); |
7839 } | 7847 } |
7840 | 7848 |
7841 | 7849 |
7842 #undef __ | 7850 #undef __ |
7843 | 7851 |
7844 } } // namespace v8::internal | 7852 } } // namespace v8::internal |
7845 | 7853 |
7846 #endif // V8_TARGET_ARCH_MIPS | 7854 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |