OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 if (FLAG_trace) { | 194 if (FLAG_trace) { |
195 UNIMPLEMENTED_MIPS(); | 195 UNIMPLEMENTED_MIPS(); |
196 } | 196 } |
197 | 197 |
198 // Compile the body of the function in a vanilla state. Don't | 198 // Compile the body of the function in a vanilla state. Don't |
199 // bother compiling all the code if the scope has an illegal | 199 // bother compiling all the code if the scope has an illegal |
200 // redeclaration. | 200 // redeclaration. |
201 if (!scope()->HasIllegalRedeclaration()) { | 201 if (!scope()->HasIllegalRedeclaration()) { |
202 Comment cmnt(masm_, "[ function body"); | 202 Comment cmnt(masm_, "[ function body"); |
203 #ifdef DEBUG | 203 #ifdef DEBUG |
204 bool is_builtin = Bootstrapper::IsActive(); | 204 bool is_builtin = Isolate::Current()->bootstrapper()->IsActive(); |
205 bool should_trace = | 205 bool should_trace = |
206 is_builtin ? FLAG_trace_builtin_calls : FLAG_trace_calls; | 206 is_builtin ? FLAG_trace_builtin_calls : FLAG_trace_calls; |
207 if (should_trace) { | 207 if (should_trace) { |
208 UNIMPLEMENTED_MIPS(); | 208 UNIMPLEMENTED_MIPS(); |
209 } | 209 } |
210 #endif | 210 #endif |
211 VisitStatementsAndSpill(info->function()->body()); | 211 VisitStatementsAndSpill(info->function()->body()); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 | 1171 |
1172 // Special handling of out of memory exceptions. | 1172 // Special handling of out of memory exceptions. |
1173 Failure* out_of_memory = Failure::OutOfMemoryException(); | 1173 Failure* out_of_memory = Failure::OutOfMemoryException(); |
1174 __ Branch(eq, throw_out_of_memory_exception, | 1174 __ Branch(eq, throw_out_of_memory_exception, |
1175 v0, Operand(reinterpret_cast<int32_t>(out_of_memory))); | 1175 v0, Operand(reinterpret_cast<int32_t>(out_of_memory))); |
1176 | 1176 |
1177 // Retrieve the pending exception and clear the variable. | 1177 // Retrieve the pending exception and clear the variable. |
1178 __ LoadExternalReference(t0, ExternalReference::the_hole_value_location()); | 1178 __ LoadExternalReference(t0, ExternalReference::the_hole_value_location()); |
1179 __ lw(a3, MemOperand(t0)); | 1179 __ lw(a3, MemOperand(t0)); |
1180 __ LoadExternalReference(t0, | 1180 __ LoadExternalReference(t0, |
1181 ExternalReference(Top::k_pending_exception_address)); | 1181 ExternalReference(Isolate::k_pending_exception_address)); |
1182 __ lw(v0, MemOperand(t0)); | 1182 __ lw(v0, MemOperand(t0)); |
1183 __ sw(a3, MemOperand(t0)); | 1183 __ sw(a3, MemOperand(t0)); |
1184 | 1184 |
1185 // Special handling of termination exceptions which are uncatchable | 1185 // Special handling of termination exceptions which are uncatchable |
1186 // by javascript code. | 1186 // by javascript code. |
1187 __ Branch(eq, throw_termination_exception, | 1187 __ Branch(eq, throw_termination_exception, |
1188 v0, Operand(Factory::termination_exception())); | 1188 v0, Operand(FACTORY->termination_exception())); |
1189 | 1189 |
1190 // Handle normal exception. | 1190 // Handle normal exception. |
1191 __ b(throw_normal_exception); | 1191 __ b(throw_normal_exception); |
1192 __ nop(); // Branch delay slot nop. | 1192 __ nop(); // Branch delay slot nop. |
1193 | 1193 |
1194 __ bind(&retry); // pass last failure (r0) as parameter (r0) when retrying | 1194 __ bind(&retry); // pass last failure (r0) as parameter (r0) when retrying |
1195 } | 1195 } |
1196 | 1196 |
1197 void CEntryStub::Generate(MacroAssembler* masm) { | 1197 void CEntryStub::Generate(MacroAssembler* masm) { |
1198 // Called from JavaScript; parameters are on stack as if calling JS function | 1198 // Called from JavaScript; parameters are on stack as if calling JS function |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 // args | 1268 // args |
1269 | 1269 |
1270 // Save callee saved registers on the stack. | 1270 // Save callee saved registers on the stack. |
1271 __ MultiPush((kCalleeSaved | ra.bit()) & ~sp.bit()); | 1271 __ MultiPush((kCalleeSaved | ra.bit()) & ~sp.bit()); |
1272 | 1272 |
1273 // We build an EntryFrame. | 1273 // We build an EntryFrame. |
1274 __ li(t3, Operand(-1)); // Push a bad frame pointer to fail if it is used. | 1274 __ li(t3, Operand(-1)); // Push a bad frame pointer to fail if it is used. |
1275 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; | 1275 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
1276 __ li(t2, Operand(Smi::FromInt(marker))); | 1276 __ li(t2, Operand(Smi::FromInt(marker))); |
1277 __ li(t1, Operand(Smi::FromInt(marker))); | 1277 __ li(t1, Operand(Smi::FromInt(marker))); |
1278 __ LoadExternalReference(t0, ExternalReference(Top::k_c_entry_fp_address)); | 1278 __ LoadExternalReference(t0, |
| 1279 ExternalReference(Isolate::k_c_entry_fp_address)); |
1279 __ lw(t0, MemOperand(t0)); | 1280 __ lw(t0, MemOperand(t0)); |
1280 __ MultiPush(t0.bit() | t1.bit() | t2.bit() | t3.bit()); | 1281 __ MultiPush(t0.bit() | t1.bit() | t2.bit() | t3.bit()); |
1281 | 1282 |
1282 // Setup frame pointer for the frame to be pushed. | 1283 // Setup frame pointer for the frame to be pushed. |
1283 __ addiu(fp, sp, -EntryFrameConstants::kCallerFPOffset); | 1284 __ addiu(fp, sp, -EntryFrameConstants::kCallerFPOffset); |
1284 | 1285 |
1285 // Load argv in s0 register. | 1286 // Load argv in s0 register. |
1286 __ lw(s0, MemOperand(sp, (kNumCalleeSaved + 1) * kPointerSize + | 1287 __ lw(s0, MemOperand(sp, (kNumCalleeSaved + 1) * kPointerSize + |
1287 StandardFrameConstants::kCArgsSlotsSize)); | 1288 StandardFrameConstants::kCArgsSlotsSize)); |
1288 | 1289 |
(...skipping 15 matching lines...) Expand all Loading... |
1304 | 1305 |
1305 // Call a faked try-block that does the invoke. | 1306 // Call a faked try-block that does the invoke. |
1306 __ bal(&invoke); | 1307 __ bal(&invoke); |
1307 __ nop(); // Branch delay slot nop. | 1308 __ nop(); // Branch delay slot nop. |
1308 | 1309 |
1309 // Caught exception: Store result (exception) in the pending | 1310 // Caught exception: Store result (exception) in the pending |
1310 // exception field in the JSEnv and return a failure sentinel. | 1311 // exception field in the JSEnv and return a failure sentinel. |
1311 // Coming in here the fp will be invalid because the PushTryHandler below | 1312 // Coming in here the fp will be invalid because the PushTryHandler below |
1312 // sets it to 0 to signal the existence of the JSEntry frame. | 1313 // sets it to 0 to signal the existence of the JSEntry frame. |
1313 __ LoadExternalReference(t0, | 1314 __ LoadExternalReference(t0, |
1314 ExternalReference(Top::k_pending_exception_address)); | 1315 ExternalReference(Isolate::k_pending_exception_address)); |
1315 __ sw(v0, MemOperand(t0)); // We come back from 'invoke'. result is in v0. | 1316 __ sw(v0, MemOperand(t0)); // We come back from 'invoke'. result is in v0. |
1316 __ li(v0, Operand(reinterpret_cast<int32_t>(Failure::Exception()))); | 1317 __ li(v0, Operand(reinterpret_cast<int32_t>(Failure::Exception()))); |
1317 __ b(&exit); | 1318 __ b(&exit); |
1318 __ nop(); // Branch delay slot nop. | 1319 __ nop(); // Branch delay slot nop. |
1319 | 1320 |
1320 // Invoke: Link this frame into the handler chain. | 1321 // Invoke: Link this frame into the handler chain. |
1321 __ bind(&invoke); | 1322 __ bind(&invoke); |
1322 __ PushTryHandler(IN_JS_ENTRY, JS_ENTRY_HANDLER); | 1323 __ PushTryHandler(IN_JS_ENTRY, JS_ENTRY_HANDLER); |
1323 // If an exception not caught by another handler occurs, this handler | 1324 // If an exception not caught by another handler occurs, this handler |
1324 // returns control to the code after the bal(&invoke) above, which | 1325 // returns control to the code after the bal(&invoke) above, which |
1325 // restores all kCalleeSaved registers (including cp and fp) to their | 1326 // restores all kCalleeSaved registers (including cp and fp) to their |
1326 // saved values before returning a failure to C. | 1327 // saved values before returning a failure to C. |
1327 | 1328 |
1328 // Clear any pending exceptions. | 1329 // Clear any pending exceptions. |
1329 __ LoadExternalReference(t0, ExternalReference::the_hole_value_location()); | 1330 __ LoadExternalReference(t0, ExternalReference::the_hole_value_location()); |
1330 __ lw(t1, MemOperand(t0)); | 1331 __ lw(t1, MemOperand(t0)); |
1331 __ LoadExternalReference(t0, | 1332 __ LoadExternalReference(t0, |
1332 ExternalReference(Top::k_pending_exception_address)); | 1333 ExternalReference(Isolate::k_pending_exception_address)); |
1333 __ sw(t1, MemOperand(t0)); | 1334 __ sw(t1, MemOperand(t0)); |
1334 | 1335 |
1335 // Invoke the function by calling through JS entry trampoline builtin. | 1336 // Invoke the function by calling through JS entry trampoline builtin. |
1336 // Notice that we cannot store a reference to the trampoline code directly in | 1337 // Notice that we cannot store a reference to the trampoline code directly in |
1337 // this stub, because runtime stubs are not traversed when doing GC. | 1338 // this stub, because runtime stubs are not traversed when doing GC. |
1338 | 1339 |
1339 // Registers: | 1340 // Registers: |
1340 // a0: entry_address | 1341 // a0: entry_address |
1341 // a1: function | 1342 // a1: function |
1342 // a2: reveiver_pointer | 1343 // a2: reveiver_pointer |
(...skipping 18 matching lines...) Expand all Loading... |
1361 | 1362 |
1362 // Call JSEntryTrampoline. | 1363 // Call JSEntryTrampoline. |
1363 __ addiu(t9, t9, Code::kHeaderSize - kHeapObjectTag); | 1364 __ addiu(t9, t9, Code::kHeaderSize - kHeapObjectTag); |
1364 __ CallBuiltin(t9); | 1365 __ CallBuiltin(t9); |
1365 | 1366 |
1366 // Unlink this frame from the handler chain. When reading the | 1367 // Unlink this frame from the handler chain. When reading the |
1367 // address of the next handler, there is no need to use the address | 1368 // address of the next handler, there is no need to use the address |
1368 // displacement since the current stack pointer (sp) points directly | 1369 // displacement since the current stack pointer (sp) points directly |
1369 // to the stack handler. | 1370 // to the stack handler. |
1370 __ lw(t1, MemOperand(sp, StackHandlerConstants::kNextOffset)); | 1371 __ lw(t1, MemOperand(sp, StackHandlerConstants::kNextOffset)); |
1371 __ LoadExternalReference(t0, ExternalReference(Top::k_handler_address)); | 1372 __ LoadExternalReference(t0, ExternalReference(Isolate::k_handler_address)); |
1372 __ sw(t1, MemOperand(t0)); | 1373 __ sw(t1, MemOperand(t0)); |
1373 | 1374 |
1374 // This restores sp to its position before PushTryHandler. | 1375 // This restores sp to its position before PushTryHandler. |
1375 __ addiu(sp, sp, StackHandlerConstants::kSize); | 1376 __ addiu(sp, sp, StackHandlerConstants::kSize); |
1376 | 1377 |
1377 __ bind(&exit); // v0 holds result | 1378 __ bind(&exit); // v0 holds result |
1378 // Restore the top frame descriptors from the stack. | 1379 // Restore the top frame descriptors from the stack. |
1379 __ Pop(t1); | 1380 __ Pop(t1); |
1380 __ LoadExternalReference(t0, ExternalReference(Top::k_c_entry_fp_address)); | 1381 __ LoadExternalReference(t0, |
| 1382 ExternalReference(Isolate::k_c_entry_fp_address)); |
1381 __ sw(t1, MemOperand(t0)); | 1383 __ sw(t1, MemOperand(t0)); |
1382 | 1384 |
1383 // Reset the stack to the callee saved registers. | 1385 // Reset the stack to the callee saved registers. |
1384 __ addiu(sp, sp, -EntryFrameConstants::kCallerFPOffset); | 1386 __ addiu(sp, sp, -EntryFrameConstants::kCallerFPOffset); |
1385 | 1387 |
1386 // Restore callee saved registers from the stack. | 1388 // Restore callee saved registers from the stack. |
1387 __ MultiPop((kCalleeSaved | ra.bit()) & ~sp.bit()); | 1389 __ MultiPop((kCalleeSaved | ra.bit()) & ~sp.bit()); |
1388 // Return. | 1390 // Return. |
1389 __ Jump(ra); | 1391 __ Jump(ra); |
1390 } | 1392 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); | 1430 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); |
1429 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); | 1431 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); |
1430 } | 1432 } |
1431 | 1433 |
1432 | 1434 |
1433 #undef __ | 1435 #undef __ |
1434 | 1436 |
1435 } } // namespace v8::internal | 1437 } } // namespace v8::internal |
1436 | 1438 |
1437 #endif // V8_TARGET_ARCH_MIPS | 1439 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |