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_ARM | 5 #if V8_TARGET_ARCH_ARM |
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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 | 1442 |
1443 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { | 1443 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
1444 // ----------- S t a t e ------------- | 1444 // ----------- S t a t e ------------- |
1445 // -- r0 : argument count (preserved for callee) | 1445 // -- r0 : argument count (preserved for callee) |
1446 // -- r1 : new target (preserved for callee) | 1446 // -- r1 : new target (preserved for callee) |
1447 // -- r3 : target function (preserved for callee) | 1447 // -- r3 : target function (preserved for callee) |
1448 // ----------------------------------- | 1448 // ----------------------------------- |
1449 Label failed; | 1449 Label failed; |
1450 { | 1450 { |
1451 FrameScope scope(masm, StackFrame::INTERNAL); | 1451 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1452 // Preserve argument count for later compare. |
| 1453 __ Move(r4, r0); |
1452 // Push the number of arguments to the callee. | 1454 // Push the number of arguments to the callee. |
1453 __ SmiTag(r0); | 1455 __ SmiTag(r0); |
1454 __ push(r0); | 1456 __ push(r0); |
1455 // Push a copy of the target function and the new target. | 1457 // Push a copy of the target function and the new target. |
1456 __ push(r1); | 1458 __ push(r1); |
1457 __ push(r3); | 1459 __ push(r3); |
1458 | 1460 |
1459 // The function. | 1461 // The function. |
1460 __ push(r1); | 1462 __ push(r1); |
1461 // Copy arguments from caller (stdlib, foreign, heap). | 1463 // Copy arguments from caller (stdlib, foreign, heap). |
1462 for (int i = 2; i >= 0; --i) { | 1464 Label args_done; |
1463 __ ldr(r4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + | 1465 for (int j = 0; j < 4; ++j) { |
1464 i * kPointerSize)); | 1466 Label over; |
1465 __ push(r4); | 1467 if (j < 3) { |
| 1468 __ cmp(r4, Operand(j)); |
| 1469 __ b(ne, &over); |
| 1470 } |
| 1471 for (int i = j - 1; i >= 0; --i) { |
| 1472 __ ldr(r4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
| 1473 i * kPointerSize)); |
| 1474 __ push(r4); |
| 1475 } |
| 1476 for (int i = 0; i < 3 - j; ++i) { |
| 1477 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 1478 } |
| 1479 if (j < 3) { |
| 1480 __ jmp(&args_done); |
| 1481 __ bind(&over); |
| 1482 } |
1466 } | 1483 } |
| 1484 __ bind(&args_done); |
| 1485 |
1467 // Call runtime, on success unwind frame, and parent frame. | 1486 // Call runtime, on success unwind frame, and parent frame. |
1468 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); | 1487 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); |
1469 // A smi 0 is returned on failure, an object on success. | 1488 // A smi 0 is returned on failure, an object on success. |
1470 __ JumpIfSmi(r0, &failed); | 1489 __ JumpIfSmi(r0, &failed); |
| 1490 |
| 1491 __ Drop(2); |
| 1492 __ pop(r4); |
| 1493 __ SmiUntag(r4); |
1471 scope.GenerateLeaveFrame(); | 1494 scope.GenerateLeaveFrame(); |
1472 __ Drop(4); | 1495 |
| 1496 __ add(r4, r4, Operand(1)); |
| 1497 __ Drop(r4); |
1473 __ Ret(); | 1498 __ Ret(); |
1474 | 1499 |
1475 __ bind(&failed); | 1500 __ bind(&failed); |
1476 // Restore target function and new target. | 1501 // Restore target function and new target. |
1477 __ pop(r3); | 1502 __ pop(r3); |
1478 __ pop(r1); | 1503 __ pop(r1); |
1479 __ pop(r0); | 1504 __ pop(r0); |
1480 __ SmiUntag(r0); | 1505 __ SmiUntag(r0); |
1481 } | 1506 } |
1482 // On failure, tail call back to regular js. | 1507 // On failure, tail call back to regular js. |
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 __ bkpt(0); | 2946 __ bkpt(0); |
2922 } | 2947 } |
2923 } | 2948 } |
2924 | 2949 |
2925 #undef __ | 2950 #undef __ |
2926 | 2951 |
2927 } // namespace internal | 2952 } // namespace internal |
2928 } // namespace v8 | 2953 } // namespace v8 |
2929 | 2954 |
2930 #endif // V8_TARGET_ARCH_ARM | 2955 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |