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 3947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3958 } | 3958 } |
3959 | 3959 |
3960 | 3960 |
3961 void CEntryStub::GenerateAheadOfTime() { | 3961 void CEntryStub::GenerateAheadOfTime() { |
3962 CEntryStub stub(1, kDontSaveFPRegs); | 3962 CEntryStub stub(1, kDontSaveFPRegs); |
3963 Handle<Code> code = stub.GetCode(); | 3963 Handle<Code> code = stub.GetCode(); |
3964 code->set_is_pregenerated(true); | 3964 code->set_is_pregenerated(true); |
3965 } | 3965 } |
3966 | 3966 |
3967 | 3967 |
| 3968 static void JumpIfOOM(MacroAssembler* masm, |
| 3969 Register value, |
| 3970 Register scratch, |
| 3971 Label* oom_label) { |
| 3972 STATIC_ASSERT(Failure::OUT_OF_MEMORY_EXCEPTION == 3); |
| 3973 STATIC_ASSERT(kFailureTag == 3); |
| 3974 __ andi(scratch, value, 0xf); |
| 3975 __ Branch(oom_label, eq, scratch, Operand(0xf)); |
| 3976 } |
| 3977 |
| 3978 |
3968 void CEntryStub::GenerateCore(MacroAssembler* masm, | 3979 void CEntryStub::GenerateCore(MacroAssembler* masm, |
3969 Label* throw_normal_exception, | 3980 Label* throw_normal_exception, |
3970 Label* throw_termination_exception, | 3981 Label* throw_termination_exception, |
3971 Label* throw_out_of_memory_exception, | 3982 Label* throw_out_of_memory_exception, |
3972 bool do_gc, | 3983 bool do_gc, |
3973 bool always_allocate) { | 3984 bool always_allocate) { |
3974 // v0: result parameter for PerformGC, if any | 3985 // v0: result parameter for PerformGC, if any |
3975 // s0: number of arguments including receiver (C callee-saved) | 3986 // s0: number of arguments including receiver (C callee-saved) |
3976 // s1: pointer to the first argument (C callee-saved) | 3987 // s1: pointer to the first argument (C callee-saved) |
3977 // s2: pointer to builtin function (C callee-saved) | 3988 // s2: pointer to builtin function (C callee-saved) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4064 __ LeaveExitFrame(save_doubles_, s0, true); | 4075 __ LeaveExitFrame(save_doubles_, s0, true); |
4065 | 4076 |
4066 // Check if we should retry or throw exception. | 4077 // Check if we should retry or throw exception. |
4067 Label retry; | 4078 Label retry; |
4068 __ bind(&failure_returned); | 4079 __ bind(&failure_returned); |
4069 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); | 4080 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); |
4070 __ andi(t0, v0, ((1 << kFailureTypeTagSize) - 1) << kFailureTagSize); | 4081 __ andi(t0, v0, ((1 << kFailureTypeTagSize) - 1) << kFailureTagSize); |
4071 __ Branch(&retry, eq, t0, Operand(zero_reg)); | 4082 __ Branch(&retry, eq, t0, Operand(zero_reg)); |
4072 | 4083 |
4073 // Special handling of out of memory exceptions. | 4084 // Special handling of out of memory exceptions. |
4074 Failure* out_of_memory = Failure::OutOfMemoryException(); | 4085 JumpIfOOM(masm, v0, t0, throw_out_of_memory_exception); |
4075 __ Branch(USE_DELAY_SLOT, | |
4076 throw_out_of_memory_exception, | |
4077 eq, | |
4078 v0, | |
4079 Operand(reinterpret_cast<int32_t>(out_of_memory))); | |
4080 // If we throw the OOM exception, the value of a3 doesn't matter. | |
4081 // Any instruction can be in the delay slot that's not a jump. | |
4082 | 4086 |
4083 // Retrieve the pending exception and clear the variable. | 4087 // Retrieve the pending exception and clear the variable. |
4084 __ LoadRoot(a3, Heap::kTheHoleValueRootIndex); | 4088 __ LoadRoot(a3, Heap::kTheHoleValueRootIndex); |
4085 __ li(t0, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 4089 __ li(t0, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
4086 isolate))); | 4090 isolate))); |
4087 __ lw(v0, MemOperand(t0)); | 4091 __ lw(v0, MemOperand(t0)); |
4088 __ sw(a3, MemOperand(t0)); | 4092 __ sw(a3, MemOperand(t0)); |
4089 | 4093 |
4090 // Special handling of termination exceptions which are uncatchable | 4094 // Special handling of termination exceptions which are uncatchable |
4091 // by javascript code. | 4095 // by javascript code. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4163 __ bind(&throw_out_of_memory_exception); | 4167 __ bind(&throw_out_of_memory_exception); |
4164 // Set external caught exception to false. | 4168 // Set external caught exception to false. |
4165 Isolate* isolate = masm->isolate(); | 4169 Isolate* isolate = masm->isolate(); |
4166 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, | 4170 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, |
4167 isolate); | 4171 isolate); |
4168 __ li(a0, Operand(false, RelocInfo::NONE32)); | 4172 __ li(a0, Operand(false, RelocInfo::NONE32)); |
4169 __ li(a2, Operand(external_caught)); | 4173 __ li(a2, Operand(external_caught)); |
4170 __ sw(a0, MemOperand(a2)); | 4174 __ sw(a0, MemOperand(a2)); |
4171 | 4175 |
4172 // Set pending exception and v0 to out of memory exception. | 4176 // Set pending exception and v0 to out of memory exception. |
4173 Failure* out_of_memory = Failure::OutOfMemoryException(); | 4177 Label already_have_failure; |
| 4178 JumpIfOOM(masm, v0, t0, &already_have_failure); |
| 4179 Failure* out_of_memory = Failure::OutOfMemoryException(0x1); |
4174 __ li(v0, Operand(reinterpret_cast<int32_t>(out_of_memory))); | 4180 __ li(v0, Operand(reinterpret_cast<int32_t>(out_of_memory))); |
| 4181 __ bind(&already_have_failure); |
4175 __ li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 4182 __ li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
4176 isolate))); | 4183 isolate))); |
4177 __ sw(v0, MemOperand(a2)); | 4184 __ sw(v0, MemOperand(a2)); |
4178 // Fall through to the next label. | 4185 // Fall through to the next label. |
4179 | 4186 |
4180 __ bind(&throw_termination_exception); | 4187 __ bind(&throw_termination_exception); |
4181 __ ThrowUncatchable(v0); | 4188 __ ThrowUncatchable(v0); |
4182 | 4189 |
4183 __ bind(&throw_normal_exception); | 4190 __ bind(&throw_normal_exception); |
4184 __ Throw(v0); | 4191 __ Throw(v0); |
(...skipping 3684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7869 __ Pop(ra, t1, a1); | 7876 __ Pop(ra, t1, a1); |
7870 __ Ret(); | 7877 __ Ret(); |
7871 } | 7878 } |
7872 | 7879 |
7873 | 7880 |
7874 #undef __ | 7881 #undef __ |
7875 | 7882 |
7876 } } // namespace v8::internal | 7883 } } // namespace v8::internal |
7877 | 7884 |
7878 #endif // V8_TARGET_ARCH_MIPS | 7885 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |