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 #if V8_TARGET_ARCH_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 | 1437 |
1438 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { | 1438 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
1439 // ----------- S t a t e ------------- | 1439 // ----------- S t a t e ------------- |
1440 // -- a0 : argument count (preserved for callee) | 1440 // -- a0 : argument count (preserved for callee) |
1441 // -- a1 : new target (preserved for callee) | 1441 // -- a1 : new target (preserved for callee) |
1442 // -- a3 : target function (preserved for callee) | 1442 // -- a3 : target function (preserved for callee) |
1443 // ----------------------------------- | 1443 // ----------------------------------- |
1444 Label failed; | 1444 Label failed; |
1445 { | 1445 { |
1446 FrameScope scope(masm, StackFrame::INTERNAL); | 1446 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1447 // Preserve argument count for later compare. |
| 1448 __ Move(t4, a0); |
1447 // Push a copy of the target function and the new target. | 1449 // Push a copy of the target function and the new target. |
1448 // Push function as parameter to the runtime call. | 1450 // Push function as parameter to the runtime call. |
1449 __ SmiTag(a0); | 1451 __ SmiTag(a0); |
1450 __ Push(a0, a1, a3, a1); | 1452 __ Push(a0, a1, a3, a1); |
1451 | 1453 |
1452 // Copy arguments from caller (stdlib, foreign, heap). | 1454 // Copy arguments from caller (stdlib, foreign, heap). |
1453 for (int i = 2; i >= 0; --i) { | 1455 Label args_done; |
1454 __ lw(a3, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + | 1456 for (int j = 0; j < 4; ++j) { |
1455 i * kPointerSize)); | 1457 Label over; |
1456 __ push(a3); | 1458 if (j < 3) { |
| 1459 __ Branch(&over, ne, t4, Operand(j)); |
| 1460 } |
| 1461 for (int i = j - 1; i >= 0; --i) { |
| 1462 __ lw(t4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
| 1463 i * kPointerSize)); |
| 1464 __ push(t4); |
| 1465 } |
| 1466 for (int i = 0; i < 3 - j; ++i) { |
| 1467 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 1468 } |
| 1469 if (j < 3) { |
| 1470 __ jmp(&args_done); |
| 1471 __ bind(&over); |
| 1472 } |
1457 } | 1473 } |
| 1474 __ bind(&args_done); |
| 1475 |
1458 // Call runtime, on success unwind frame, and parent frame. | 1476 // Call runtime, on success unwind frame, and parent frame. |
1459 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); | 1477 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); |
1460 // A smi 0 is returned on failure, an object on success. | 1478 // A smi 0 is returned on failure, an object on success. |
1461 __ JumpIfSmi(a0, &failed); | 1479 __ JumpIfSmi(v0, &failed); |
| 1480 |
| 1481 __ Drop(2); |
| 1482 __ pop(t4); |
| 1483 __ SmiUntag(t4); |
1462 scope.GenerateLeaveFrame(); | 1484 scope.GenerateLeaveFrame(); |
1463 __ Drop(4); | 1485 |
| 1486 __ Addu(t4, t4, Operand(1)); |
| 1487 __ Lsa(sp, sp, t4, kPointerSizeLog2); |
1464 __ Ret(); | 1488 __ Ret(); |
1465 | 1489 |
1466 __ bind(&failed); | 1490 __ bind(&failed); |
1467 // Restore target function and new target. | 1491 // Restore target function and new target. |
1468 __ Pop(a0, a1, a3); | 1492 __ Pop(a0, a1, a3); |
1469 __ SmiUntag(a0); | 1493 __ SmiUntag(a0); |
1470 } | 1494 } |
1471 // On failure, tail call back to regular js. | 1495 // On failure, tail call back to regular js. |
1472 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); | 1496 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); |
1473 } | 1497 } |
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2978 __ break_(0xCC); | 3002 __ break_(0xCC); |
2979 } | 3003 } |
2980 } | 3004 } |
2981 | 3005 |
2982 #undef __ | 3006 #undef __ |
2983 | 3007 |
2984 } // namespace internal | 3008 } // namespace internal |
2985 } // namespace v8 | 3009 } // namespace v8 |
2986 | 3010 |
2987 #endif // V8_TARGET_ARCH_MIPS | 3011 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |