OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 isolate->set_fp_stubs_generated(true); | 1026 isolate->set_fp_stubs_generated(true); |
1027 } | 1027 } |
1028 | 1028 |
1029 | 1029 |
1030 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { | 1030 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { |
1031 CEntryStub stub(isolate, 1, kDontSaveFPRegs); | 1031 CEntryStub stub(isolate, 1, kDontSaveFPRegs); |
1032 stub.GetCode(); | 1032 stub.GetCode(); |
1033 } | 1033 } |
1034 | 1034 |
1035 | 1035 |
1036 static void ThrowPendingException(MacroAssembler* masm) { | |
1037 Isolate* isolate = masm->isolate(); | |
1038 | |
1039 ExternalReference pending_handler_context_address( | |
1040 Isolate::kPendingHandlerContextAddress, isolate); | |
1041 ExternalReference pending_handler_code_address( | |
1042 Isolate::kPendingHandlerCodeAddress, isolate); | |
1043 ExternalReference pending_handler_offset_address( | |
1044 Isolate::kPendingHandlerOffsetAddress, isolate); | |
1045 ExternalReference pending_handler_fp_address( | |
1046 Isolate::kPendingHandlerFPAddress, isolate); | |
1047 ExternalReference pending_handler_sp_address( | |
1048 Isolate::kPendingHandlerSPAddress, isolate); | |
1049 | |
1050 // Ask the runtime for help to determine the handler. This will set v0 to | |
1051 // contain the current pending exception, don't clobber it. | |
1052 ExternalReference find_handler(Runtime::kFindExceptionHandler, isolate); | |
1053 { | |
1054 FrameScope scope(masm, StackFrame::MANUAL); | |
1055 __ PrepareCallCFunction(3, 0, a0); | |
1056 __ mov(a0, zero_reg); | |
1057 __ mov(a1, zero_reg); | |
1058 __ li(a2, Operand(ExternalReference::isolate_address(isolate))); | |
1059 __ CallCFunction(find_handler, 3); | |
1060 } | |
1061 | |
1062 // Retrieve the handler context, SP and FP. | |
1063 __ li(cp, Operand(pending_handler_context_address)); | |
1064 __ ld(cp, MemOperand(cp)); | |
1065 __ li(sp, Operand(pending_handler_sp_address)); | |
1066 __ ld(sp, MemOperand(sp)); | |
1067 __ li(fp, Operand(pending_handler_fp_address)); | |
1068 __ ld(fp, MemOperand(fp)); | |
1069 | |
1070 // If the handler is a JS frame, restore the context to the frame. | |
1071 // (kind == ENTRY) == (fp == 0) == (cp == 0), so we could test either fp | |
1072 // or cp. | |
1073 Label zero; | |
1074 __ Branch(&zero, eq, cp, Operand(zero_reg)); | |
1075 __ sd(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
1076 __ bind(&zero); | |
1077 | |
1078 // Compute the handler entry address and jump to it. | |
1079 __ li(a1, Operand(pending_handler_code_address)); | |
1080 __ ld(a1, MemOperand(a1)); | |
1081 __ li(a2, Operand(pending_handler_offset_address)); | |
1082 __ ld(a2, MemOperand(a2)); | |
1083 __ Daddu(a1, a1, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
1084 __ Daddu(t9, a1, a2); | |
1085 __ Jump(t9); | |
1086 } | |
1087 | |
1088 | |
1089 void CEntryStub::Generate(MacroAssembler* masm) { | 1036 void CEntryStub::Generate(MacroAssembler* masm) { |
1090 // Called from JavaScript; parameters are on stack as if calling JS function | 1037 // Called from JavaScript; parameters are on stack as if calling JS function |
1091 // a0: number of arguments including receiver | 1038 // a0: number of arguments including receiver |
1092 // a1: pointer to builtin function | 1039 // a1: pointer to builtin function |
1093 // fp: frame pointer (restored after C call) | 1040 // fp: frame pointer (restored after C call) |
1094 // sp: stack pointer (restored as callee's sp after C call) | 1041 // sp: stack pointer (restored as callee's sp after C call) |
1095 // cp: current context (C callee-saved) | 1042 // cp: current context (C callee-saved) |
1096 | 1043 |
1097 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 1044 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
1098 | 1045 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 | 1134 |
1188 // Exit C frame and return. | 1135 // Exit C frame and return. |
1189 // v0:v1: result | 1136 // v0:v1: result |
1190 // sp: stack pointer | 1137 // sp: stack pointer |
1191 // fp: frame pointer | 1138 // fp: frame pointer |
1192 // s0: still holds argc (callee-saved). | 1139 // s0: still holds argc (callee-saved). |
1193 __ LeaveExitFrame(save_doubles(), s0, true, EMIT_RETURN); | 1140 __ LeaveExitFrame(save_doubles(), s0, true, EMIT_RETURN); |
1194 | 1141 |
1195 // Handling of exception. | 1142 // Handling of exception. |
1196 __ bind(&exception_returned); | 1143 __ bind(&exception_returned); |
1197 ThrowPendingException(masm); | 1144 |
| 1145 ExternalReference pending_handler_context_address( |
| 1146 Isolate::kPendingHandlerContextAddress, isolate()); |
| 1147 ExternalReference pending_handler_code_address( |
| 1148 Isolate::kPendingHandlerCodeAddress, isolate()); |
| 1149 ExternalReference pending_handler_offset_address( |
| 1150 Isolate::kPendingHandlerOffsetAddress, isolate()); |
| 1151 ExternalReference pending_handler_fp_address( |
| 1152 Isolate::kPendingHandlerFPAddress, isolate()); |
| 1153 ExternalReference pending_handler_sp_address( |
| 1154 Isolate::kPendingHandlerSPAddress, isolate()); |
| 1155 |
| 1156 // Ask the runtime for help to determine the handler. This will set v0 to |
| 1157 // contain the current pending exception, don't clobber it. |
| 1158 ExternalReference find_handler(Runtime::kFindExceptionHandler, isolate()); |
| 1159 { |
| 1160 FrameScope scope(masm, StackFrame::MANUAL); |
| 1161 __ PrepareCallCFunction(3, 0, a0); |
| 1162 __ mov(a0, zero_reg); |
| 1163 __ mov(a1, zero_reg); |
| 1164 __ li(a2, Operand(ExternalReference::isolate_address(isolate()))); |
| 1165 __ CallCFunction(find_handler, 3); |
| 1166 } |
| 1167 |
| 1168 // Retrieve the handler context, SP and FP. |
| 1169 __ li(cp, Operand(pending_handler_context_address)); |
| 1170 __ ld(cp, MemOperand(cp)); |
| 1171 __ li(sp, Operand(pending_handler_sp_address)); |
| 1172 __ ld(sp, MemOperand(sp)); |
| 1173 __ li(fp, Operand(pending_handler_fp_address)); |
| 1174 __ ld(fp, MemOperand(fp)); |
| 1175 |
| 1176 // If the handler is a JS frame, restore the context to the frame. |
| 1177 // (kind == ENTRY) == (fp == 0) == (cp == 0), so we could test either fp |
| 1178 // or cp. |
| 1179 Label zero; |
| 1180 __ Branch(&zero, eq, cp, Operand(zero_reg)); |
| 1181 __ sd(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 1182 __ bind(&zero); |
| 1183 |
| 1184 // Compute the handler entry address and jump to it. |
| 1185 __ li(a1, Operand(pending_handler_code_address)); |
| 1186 __ ld(a1, MemOperand(a1)); |
| 1187 __ li(a2, Operand(pending_handler_offset_address)); |
| 1188 __ ld(a2, MemOperand(a2)); |
| 1189 __ Daddu(a1, a1, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1190 __ Daddu(t9, a1, a2); |
| 1191 __ Jump(t9); |
1198 } | 1192 } |
1199 | 1193 |
1200 | 1194 |
1201 void JSEntryStub::Generate(MacroAssembler* masm) { | 1195 void JSEntryStub::Generate(MacroAssembler* masm) { |
1202 Label invoke, handler_entry, exit; | 1196 Label invoke, handler_entry, exit; |
1203 Isolate* isolate = masm->isolate(); | 1197 Isolate* isolate = masm->isolate(); |
1204 | 1198 |
1205 // TODO(plind): unify the ABI description here. | 1199 // TODO(plind): unify the ABI description here. |
1206 // Registers: | 1200 // Registers: |
1207 // a0: entry address | 1201 // a0: entry address |
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2402 // stack overflow (on the backtrack stack) was detected in RegExp code but | 2396 // stack overflow (on the backtrack stack) was detected in RegExp code but |
2403 // haven't created the exception yet. Handle that in the runtime system. | 2397 // haven't created the exception yet. Handle that in the runtime system. |
2404 // TODO(592): Rerunning the RegExp to get the stack overflow exception. | 2398 // TODO(592): Rerunning the RegExp to get the stack overflow exception. |
2405 __ li(a1, Operand(isolate()->factory()->the_hole_value())); | 2399 __ li(a1, Operand(isolate()->factory()->the_hole_value())); |
2406 __ li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 2400 __ li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
2407 isolate()))); | 2401 isolate()))); |
2408 __ ld(v0, MemOperand(a2, 0)); | 2402 __ ld(v0, MemOperand(a2, 0)); |
2409 __ Branch(&runtime, eq, v0, Operand(a1)); | 2403 __ Branch(&runtime, eq, v0, Operand(a1)); |
2410 | 2404 |
2411 // For exception, throw the exception again. | 2405 // For exception, throw the exception again. |
2412 __ EnterExitFrame(false); | 2406 __ TailCallRuntime(Runtime::kRegExpExecReThrow, 4, 1); |
2413 ThrowPendingException(masm); | |
2414 | 2407 |
2415 __ bind(&failure); | 2408 __ bind(&failure); |
2416 // For failure and exception return null. | 2409 // For failure and exception return null. |
2417 __ li(v0, Operand(isolate()->factory()->null_value())); | 2410 __ li(v0, Operand(isolate()->factory()->null_value())); |
2418 __ DropAndRet(4); | 2411 __ DropAndRet(4); |
2419 | 2412 |
2420 // Process the result from the native regexp code. | 2413 // Process the result from the native regexp code. |
2421 __ bind(&success); | 2414 __ bind(&success); |
2422 | 2415 |
2423 __ lw(a1, UntagSmiFieldMemOperand( | 2416 __ lw(a1, UntagSmiFieldMemOperand( |
(...skipping 3122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5546 kStackUnwindSpace, kInvalidStackOffset, | 5539 kStackUnwindSpace, kInvalidStackOffset, |
5547 MemOperand(fp, 6 * kPointerSize), NULL); | 5540 MemOperand(fp, 6 * kPointerSize), NULL); |
5548 } | 5541 } |
5549 | 5542 |
5550 | 5543 |
5551 #undef __ | 5544 #undef __ |
5552 | 5545 |
5553 } } // namespace v8::internal | 5546 } } // namespace v8::internal |
5554 | 5547 |
5555 #endif // V8_TARGET_ARCH_MIPS64 | 5548 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |