OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2688 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, | 2688 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, |
2689 Register value) { | 2689 Register value) { |
2690 // Adjust this code if not the case. | 2690 // Adjust this code if not the case. |
2691 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | 2691 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); |
2692 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); | 2692 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); |
2693 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); | 2693 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); |
2694 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); | 2694 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); |
2695 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); | 2695 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); |
2696 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); | 2696 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); |
2697 | 2697 |
2698 // v0 is expected to hold the exception. | 2698 // The exception is expected in v0. |
2699 Move(v0, value); | |
2700 | |
2701 // Drop sp to the top stack handler. | |
2702 li(a3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | |
2703 lw(sp, MemOperand(a3)); | |
2704 | |
2705 // Unwind the handlers until the ENTRY handler is found. | |
2706 Label loop, done; | |
2707 bind(&loop); | |
2708 // Load the type of the current stack handler. | |
2709 const int kStateOffset = StackHandlerConstants::kStateOffset; | |
2710 lw(a2, MemOperand(sp, kStateOffset)); | |
2711 Branch(&done, eq, a2, Operand(StackHandler::ENTRY)); | |
2712 // Fetch the next handler in the list. | |
2713 const int kNextOffset = StackHandlerConstants::kNextOffset; | |
2714 lw(sp, MemOperand(sp, kNextOffset)); | |
2715 jmp(&loop); | |
2716 bind(&done); | |
2717 | |
2718 // Set the top handler address to next handler past the current ENTRY handler. | |
2719 pop(a2); | |
2720 sw(a2, MemOperand(a3)); | |
2721 | |
2722 if (type == OUT_OF_MEMORY) { | 2699 if (type == OUT_OF_MEMORY) { |
2723 // Set external caught exception to false. | 2700 // Set external caught exception to false. |
2724 ExternalReference external_caught( | 2701 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, |
2725 Isolate::kExternalCaughtExceptionAddress, isolate()); | 2702 isolate()); |
2726 li(a0, Operand(false, RelocInfo::NONE)); | 2703 li(a0, Operand(false, RelocInfo::NONE)); |
2727 li(a2, Operand(external_caught)); | 2704 li(a2, Operand(external_caught)); |
2728 sw(a0, MemOperand(a2)); | 2705 sw(a0, MemOperand(a2)); |
2729 | 2706 |
2730 // Set pending exception and v0 to out of memory exception. | 2707 // Set pending exception and v0 to out of memory exception. |
2731 Failure* out_of_memory = Failure::OutOfMemoryException(); | 2708 Failure* out_of_memory = Failure::OutOfMemoryException(); |
2732 li(v0, Operand(reinterpret_cast<int32_t>(out_of_memory))); | 2709 li(v0, Operand(reinterpret_cast<int32_t>(out_of_memory))); |
2733 li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 2710 li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
2734 isolate()))); | 2711 isolate()))); |
Kevin Millikin (Chromium)
2011/11/09 11:03:10
Indentation was off here, I'll fix it.
| |
2735 sw(v0, MemOperand(a2)); | 2712 sw(v0, MemOperand(a2)); |
2713 } else if (!value.is(v0)) { | |
2714 mov(v0, value); | |
2736 } | 2715 } |
2737 | 2716 |
2738 // Stack layout at this point. See also StackHandlerConstants. | 2717 // Drop the stack pointer to the top of the top stack handler. |
2739 // sp -> state (ENTRY) | 2718 li(a3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
2740 // cp | 2719 lw(sp, MemOperand(a3)); |
2741 // fp | |
2742 // ra | |
2743 | 2720 |
2744 // Restore context and frame pointer, discard state (r2). | 2721 // Unwind the handlers until the top ENTRY handler is found. |
2722 Label fetch_next, check_kind; | |
2723 jmp(&check_kind); | |
2724 bind(&fetch_next); | |
2725 lw(sp, MemOperand(sp, StackHandlerConstants::kNextOffset)); | |
2726 | |
2727 bind(&check_kind); | |
2728 lw(a2, MemOperand(sp, StackHandlerConstants::kStateOffset)); | |
2729 Branch(&fetch_next, ne, a2, Operand(StackHandler::ENTRY)); | |
2730 | |
2731 // Set the top handler address to next handler past the top ENTRY handler. | |
2732 pop(a2); | |
2733 sw(a2, MemOperand(a3)); | |
2734 | |
2735 // Clear the context and frame pointer (0 was saved in the handler), and | |
2736 // discard the state (a2). | |
2745 MultiPop(a2.bit() | cp.bit() | fp.bit()); | 2737 MultiPop(a2.bit() | cp.bit() | fp.bit()); |
2746 | 2738 |
2747 #ifdef DEBUG | |
2748 // When emitting debug_code, set ra as return address for the jump. | |
2749 // 5 instructions: add: 1, pop: 2, jump: 2. | |
2750 const int kOffsetRaInstructions = 5; | |
2751 Label find_ra; | |
2752 | |
2753 if (emit_debug_code()) { | |
2754 // Compute ra for the Jump(t9). | |
2755 const int kOffsetRaBytes = kOffsetRaInstructions * Assembler::kInstrSize; | |
2756 | |
2757 // This branch-and-link sequence is needed to get the current PC on mips, | |
2758 // saved to the ra register. Then adjusted for instruction count. | |
2759 bal(&find_ra); // bal exposes branch-delay slot. | |
2760 nop(); // Branch delay slot nop. | |
2761 bind(&find_ra); | |
2762 addiu(ra, ra, kOffsetRaBytes); | |
2763 } | |
2764 #endif | |
2765 pop(t9); // 2 instructions: lw, add sp. | 2739 pop(t9); // 2 instructions: lw, add sp. |
2766 Jump(t9); // 2 instructions: jr, nop (in delay slot). | 2740 Jump(t9); // 2 instructions: jr, nop (in delay slot). |
2767 | |
2768 if (emit_debug_code()) { | |
2769 // Make sure that the expected number of instructions were generated. | |
2770 ASSERT_EQ(kOffsetRaInstructions, | |
2771 InstructionsGeneratedSince(&find_ra)); | |
2772 } | |
2773 } | 2741 } |
2774 | 2742 |
2775 | 2743 |
2776 void MacroAssembler::AllocateInNewSpace(int object_size, | 2744 void MacroAssembler::AllocateInNewSpace(int object_size, |
2777 Register result, | 2745 Register result, |
2778 Register scratch1, | 2746 Register scratch1, |
2779 Register scratch2, | 2747 Register scratch2, |
2780 Label* gc_required, | 2748 Label* gc_required, |
2781 AllocationFlags flags) { | 2749 AllocationFlags flags) { |
2782 if (!FLAG_inline_new) { | 2750 if (!FLAG_inline_new) { |
(...skipping 2293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5076 opcode == BGTZL); | 5044 opcode == BGTZL); |
5077 opcode = (cond == eq) ? BEQ : BNE; | 5045 opcode = (cond == eq) ? BEQ : BNE; |
5078 instr = (instr & ~kOpcodeMask) | opcode; | 5046 instr = (instr & ~kOpcodeMask) | opcode; |
5079 masm_.emit(instr); | 5047 masm_.emit(instr); |
5080 } | 5048 } |
5081 | 5049 |
5082 | 5050 |
5083 } } // namespace v8::internal | 5051 } } // namespace v8::internal |
5084 | 5052 |
5085 #endif // V8_TARGET_ARCH_MIPS | 5053 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |