OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_S390 | 5 #if V8_TARGET_ARCH_S390 |
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 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 | 1458 |
1459 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { | 1459 void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { |
1460 // ----------- S t a t e ------------- | 1460 // ----------- S t a t e ------------- |
1461 // -- r2 : argument count (preserved for callee) | 1461 // -- r2 : argument count (preserved for callee) |
1462 // -- r3 : new target (preserved for callee) | 1462 // -- r3 : new target (preserved for callee) |
1463 // -- r5 : target function (preserved for callee) | 1463 // -- r5 : target function (preserved for callee) |
1464 // ----------------------------------- | 1464 // ----------------------------------- |
1465 Label failed; | 1465 Label failed; |
1466 { | 1466 { |
1467 FrameScope scope(masm, StackFrame::INTERNAL); | 1467 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1468 // Preserve argument count for later compare. |
| 1469 __ Move(r4, r2); |
1468 // Push a copy of the target function and the new target. | 1470 // Push a copy of the target function and the new target. |
1469 __ SmiTag(r2); | 1471 __ SmiTag(r2); |
1470 // Push another copy as a parameter to the runtime call. | 1472 // Push another copy as a parameter to the runtime call. |
1471 __ Push(r2, r3, r5, r3); | 1473 __ Push(r2, r3, r5, r3); |
1472 | 1474 |
1473 // Copy arguments from caller (stdlib, foreign, heap). | 1475 // Copy arguments from caller (stdlib, foreign, heap). |
1474 for (int i = 2; i >= 0; --i) { | 1476 Label args_done; |
1475 __ LoadP(r4, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + | 1477 __ CmpP(r4, Operand(0)); |
1476 i * kPointerSize)); | 1478 __ b(eq, &args_done); |
1477 __ push(r4); | 1479 |
1478 } | 1480 Label args2; |
| 1481 __ CmpP(r4, Operand(1)); |
| 1482 __ b(ne, &args2); |
| 1483 __ LoadP(r9, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
| 1484 0 * kPointerSize)); |
| 1485 __ push(r9); |
| 1486 __ jmp(&args_done); |
| 1487 |
| 1488 __ bind(&args2); |
| 1489 Label args3; |
| 1490 __ CmpP(r4, Operand(2)); |
| 1491 __ b(ne, &args3); |
| 1492 __ LoadP(r9, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
| 1493 1 * kPointerSize)); |
| 1494 __ push(r9); |
| 1495 __ LoadP(r9, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
| 1496 0 * kPointerSize)); |
| 1497 __ push(r9); |
| 1498 __ jmp(&args_done); |
| 1499 |
| 1500 __ bind(&args3); |
| 1501 __ LoadP(r9, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
| 1502 2 * kPointerSize)); |
| 1503 __ push(r9); |
| 1504 __ LoadP(r9, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
| 1505 1 * kPointerSize)); |
| 1506 __ push(r9); |
| 1507 __ LoadP(r9, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + |
| 1508 0 * kPointerSize)); |
| 1509 __ push(r9); |
| 1510 __ bind(&args_done); |
| 1511 |
| 1512 // Increment and restore argument count to call runtime method |
| 1513 // with function as extra argument. |
| 1514 __ AddP(r4, r4, Operand(1)); |
| 1515 __ Move(r2, r4); |
1479 // Call runtime, on success unwind frame, and parent frame. | 1516 // Call runtime, on success unwind frame, and parent frame. |
1480 __ CallRuntime(Runtime::kInstantiateAsmJs, 4); | 1517 __ CallRuntime(Runtime::kInstantiateAsmJs, -1); |
1481 // A smi 0 is returned on failure, an object on success. | 1518 // A smi 0 is returned on failure, an object on success. |
1482 __ JumpIfSmi(r2, &failed); | 1519 __ JumpIfSmi(r2, &failed); |
| 1520 |
| 1521 __ pop(r4); |
| 1522 __ pop(r4); |
| 1523 __ pop(r4); |
| 1524 __ SmiUntag(r4); |
1483 scope.GenerateLeaveFrame(); | 1525 scope.GenerateLeaveFrame(); |
1484 __ Drop(4); | 1526 |
| 1527 __ pop(r6); |
| 1528 __ AddP(r4, r4, Operand(1)); |
| 1529 __ ShiftLeftP(r4, r4, Operand(kPointerSizeLog2)); |
| 1530 __ AddP(r7, sp, r4); |
| 1531 __ LoadRR(sp, r7); |
| 1532 __ push(r6); |
1485 __ Ret(); | 1533 __ Ret(); |
1486 | 1534 |
1487 __ bind(&failed); | 1535 __ bind(&failed); |
1488 // Restore target function and new target. | 1536 // Restore target function and new target. |
1489 __ Pop(r2, r3, r5); | 1537 __ Pop(r2, r3, r5); |
1490 __ SmiUntag(r2); | 1538 __ SmiUntag(r2); |
1491 } | 1539 } |
1492 // On failure, tail call back to regular js. | 1540 // On failure, tail call back to regular js. |
1493 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); | 1541 GenerateTailCallToReturnedCode(masm, Runtime::kCompileBaseline); |
1494 } | 1542 } |
1495 | 1543 |
1496 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { | 1544 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |
1497 // For now, we are relying on the fact that make_code_young doesn't do any | 1545 // For now, we are relying on the fact that make_code_young doesn't do any |
1498 // garbage collection which allows us to save/restore the registers without | 1546 // garbage collection which allows us to save/restore the registers without |
1499 // worrying about which of them contain pointers. We also don't build an | 1547 // worrying about which of them contain pointers. We also don't build an |
1500 // internal frame to make the code faster, since we shouldn't have to do stack | 1548 // internal frame to make the code faster, since we shouldn't have to do stack |
1501 // crawls in MakeCodeYoung. This seems a bit fragile. | 1549 // crawls in MakeCodeYoung. This seems a bit fragile. |
1502 | 1550 |
1503 // Point r2 at the start of the PlatformCodeAge sequence. | 1551 // Point r2 at the start of the PlatformCodeAge sequence. |
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 __ bkpt(0); | 3066 __ bkpt(0); |
3019 } | 3067 } |
3020 } | 3068 } |
3021 | 3069 |
3022 #undef __ | 3070 #undef __ |
3023 | 3071 |
3024 } // namespace internal | 3072 } // namespace internal |
3025 } // namespace v8 | 3073 } // namespace v8 |
3026 | 3074 |
3027 #endif // V8_TARGET_ARCH_S390 | 3075 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |