Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: src/arm64/code-stubs-arm64.cc

Issue 209903003: Reland "Remove Failure::OutOfMemory propagation and V8::IgnoreOutOfMemoryException." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 } 1398 }
1399 1399
1400 1400
1401 void CodeStub::GenerateFPStubs(Isolate* isolate) { 1401 void CodeStub::GenerateFPStubs(Isolate* isolate) {
1402 // Floating-point code doesn't get special handling in ARM64, so there's 1402 // Floating-point code doesn't get special handling in ARM64, so there's
1403 // nothing to do here. 1403 // nothing to do here.
1404 USE(isolate); 1404 USE(isolate);
1405 } 1405 }
1406 1406
1407 1407
1408 static void JumpIfOOM(MacroAssembler* masm,
1409 Register value,
1410 Register scratch,
1411 Label* oom_label) {
1412 STATIC_ASSERT(Failure::OUT_OF_MEMORY_EXCEPTION == 3);
1413 STATIC_ASSERT(kFailureTag == 3);
1414 __ And(scratch, value, 0xf);
1415 __ Cmp(scratch, 0xf);
1416 __ B(eq, oom_label);
1417 }
1418
1419
1420 bool CEntryStub::NeedsImmovableCode() { 1408 bool CEntryStub::NeedsImmovableCode() {
1421 // CEntryStub stores the return address on the stack before calling into 1409 // CEntryStub stores the return address on the stack before calling into
1422 // C++ code. In some cases, the VM accesses this address, but it is not used 1410 // C++ code. In some cases, the VM accesses this address, but it is not used
1423 // when the C++ code returns to the stub because LR holds the return address 1411 // when the C++ code returns to the stub because LR holds the return address
1424 // in AAPCS64. If the stub is moved (perhaps during a GC), we could end up 1412 // in AAPCS64. If the stub is moved (perhaps during a GC), we could end up
1425 // returning to dead code. 1413 // returning to dead code.
1426 // TODO(jbramley): Whilst this is the only analysis that makes sense, I can't 1414 // TODO(jbramley): Whilst this is the only analysis that makes sense, I can't
1427 // find any comment to confirm this, and I don't hit any crashes whatever 1415 // find any comment to confirm this, and I don't hit any crashes whatever
1428 // this function returns. The anaylsis should be properly confirmed. 1416 // this function returns. The anaylsis should be properly confirmed.
1429 return true; 1417 return true;
1430 } 1418 }
1431 1419
1432 1420
1433 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { 1421 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) {
1434 CEntryStub stub(1, kDontSaveFPRegs); 1422 CEntryStub stub(1, kDontSaveFPRegs);
1435 stub.GetCode(isolate); 1423 stub.GetCode(isolate);
1436 CEntryStub stub_fp(1, kSaveFPRegs); 1424 CEntryStub stub_fp(1, kSaveFPRegs);
1437 stub_fp.GetCode(isolate); 1425 stub_fp.GetCode(isolate);
1438 } 1426 }
1439 1427
1440 1428
1441 void CEntryStub::GenerateCore(MacroAssembler* masm, 1429 void CEntryStub::GenerateCore(MacroAssembler* masm,
1442 Label* throw_normal, 1430 Label* throw_normal,
1443 Label* throw_termination, 1431 Label* throw_termination,
1444 Label* throw_out_of_memory,
1445 bool do_gc, 1432 bool do_gc,
1446 bool always_allocate) { 1433 bool always_allocate) {
1447 // x0 : Result parameter for PerformGC, if do_gc is true. 1434 // x0 : Result parameter for PerformGC, if do_gc is true.
1448 // x21 : argv 1435 // x21 : argv
1449 // x22 : argc 1436 // x22 : argc
1450 // x23 : target 1437 // x23 : target
1451 // 1438 //
1452 // The stack (on entry) holds the arguments and the receiver, with the 1439 // The stack (on entry) holds the arguments and the receiver, with the
1453 // receiver at the highest address: 1440 // receiver at the highest address:
1454 // 1441 //
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 // x0 result The return code from the call, including the failure 1569 // x0 result The return code from the call, including the failure
1583 // code and details. 1570 // code and details.
1584 // x21 argv 1571 // x21 argv
1585 // x22 argc 1572 // x22 argc
1586 // x23 target 1573 // x23 target
1587 // Refer to the Failure class for details of the bit layout. 1574 // Refer to the Failure class for details of the bit layout.
1588 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); 1575 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0);
1589 __ Tst(result, kFailureTypeTagMask << kFailureTagSize); 1576 __ Tst(result, kFailureTypeTagMask << kFailureTagSize);
1590 __ B(eq, &retry); // RETRY_AFTER_GC 1577 __ B(eq, &retry); // RETRY_AFTER_GC
1591 1578
1592 // Special handling of out-of-memory exceptions: Pass the failure result,
1593 // rather than the exception descriptor.
1594 JumpIfOOM(masm, result, x10, throw_out_of_memory);
1595
1596 // Retrieve the pending exception. 1579 // Retrieve the pending exception.
1597 const Register& exception = result; 1580 const Register& exception = result;
1598 const Register& exception_address = x11; 1581 const Register& exception_address = x11;
1599 __ Mov(exception_address, 1582 __ Mov(exception_address,
1600 Operand(ExternalReference(Isolate::kPendingExceptionAddress, 1583 Operand(ExternalReference(Isolate::kPendingExceptionAddress,
1601 isolate))); 1584 isolate)));
1602 __ Ldr(exception, MemOperand(exception_address)); 1585 __ Ldr(exception, MemOperand(exception_address));
1603 1586
1604 // See if we just retrieved an OOM exception.
1605 JumpIfOOM(masm, exception, x10, throw_out_of_memory);
1606
1607 // Clear the pending exception. 1587 // Clear the pending exception.
1608 __ Mov(x10, Operand(isolate->factory()->the_hole_value())); 1588 __ Mov(x10, Operand(isolate->factory()->the_hole_value()));
1609 __ Str(x10, MemOperand(exception_address)); 1589 __ Str(x10, MemOperand(exception_address));
1610 1590
1611 // x0 exception The exception descriptor. 1591 // x0 exception The exception descriptor.
1612 // x21 argv 1592 // x21 argv
1613 // x22 argc 1593 // x22 argc
1614 // x23 target 1594 // x23 target
1615 1595
1616 // Special handling of termination exceptions, which are uncatchable by 1596 // Special handling of termination exceptions, which are uncatchable by
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 // could be pushed onto the stack by called stubs and functions, and on the 1670 // could be pushed onto the stack by called stubs and functions, and on the
1691 // stack they can confuse the GC. However, we're only calling C functions 1671 // stack they can confuse the GC. However, we're only calling C functions
1692 // which can push arbitrary data onto the stack anyway, and so the GC won't 1672 // which can push arbitrary data onto the stack anyway, and so the GC won't
1693 // examine that part of the stack. 1673 // examine that part of the stack.
1694 __ Mov(argc, argc_input); 1674 __ Mov(argc, argc_input);
1695 __ Mov(target, target_input); 1675 __ Mov(target, target_input);
1696 __ Mov(argv, temp_argv); 1676 __ Mov(argv, temp_argv);
1697 1677
1698 Label throw_normal; 1678 Label throw_normal;
1699 Label throw_termination; 1679 Label throw_termination;
1700 Label throw_out_of_memory;
1701 1680
1702 // Call the runtime function. 1681 // Call the runtime function.
1703 GenerateCore(masm, 1682 GenerateCore(masm,
1704 &throw_normal, 1683 &throw_normal,
1705 &throw_termination, 1684 &throw_termination,
1706 &throw_out_of_memory,
1707 false, 1685 false,
1708 false); 1686 false);
1709 1687
1710 // If successful, the previous GenerateCore will have returned to the 1688 // If successful, the previous GenerateCore will have returned to the
1711 // calling code. Otherwise, we fall through into the following. 1689 // calling code. Otherwise, we fall through into the following.
1712 1690
1713 // Do space-specific GC and retry runtime call. 1691 // Do space-specific GC and retry runtime call.
1714 GenerateCore(masm, 1692 GenerateCore(masm,
1715 &throw_normal, 1693 &throw_normal,
1716 &throw_termination, 1694 &throw_termination,
1717 &throw_out_of_memory,
1718 true, 1695 true,
1719 false); 1696 false);
1720 1697
1721 // Do full GC and retry runtime call one final time. 1698 // Do full GC and retry runtime call one final time.
1722 __ Mov(x0, reinterpret_cast<uint64_t>(Failure::InternalError())); 1699 __ Mov(x0, reinterpret_cast<uint64_t>(Failure::InternalError()));
1723 GenerateCore(masm, 1700 GenerateCore(masm,
1724 &throw_normal, 1701 &throw_normal,
1725 &throw_termination, 1702 &throw_termination,
1726 &throw_out_of_memory,
1727 true, 1703 true,
1728 true); 1704 true);
1729 1705
1730 // We didn't execute a return case, so the stack frame hasn't been updated 1706 // We didn't execute a return case, so the stack frame hasn't been updated
1731 // (except for the return address slot). However, we don't need to initialize 1707 // (except for the return address slot). However, we don't need to initialize
1732 // jssp because the throw method will immediately overwrite it when it 1708 // jssp because the throw method will immediately overwrite it when it
1733 // unwinds the stack. 1709 // unwinds the stack.
1734 if (__ emit_debug_code()) { 1710 if (__ emit_debug_code()) {
1735 __ Mov(jssp, kDebugZapValue); 1711 __ Mov(jssp, kDebugZapValue);
1736 } 1712 }
1737 __ SetStackPointer(jssp); 1713 __ SetStackPointer(jssp);
1738 1714
1739 // Throw exceptions. 1715 // Throw exceptions.
1740 // If we throw an exception, we can end up re-entering CEntryStub before we 1716 // If we throw an exception, we can end up re-entering CEntryStub before we
1741 // pop the exit frame, so need to ensure that x21-x23 contain GC-safe values 1717 // pop the exit frame, so need to ensure that x21-x23 contain GC-safe values
1742 // here. 1718 // here.
1743 __ Bind(&throw_out_of_memory);
1744 ASM_LOCATION("Throw out of memory");
1745 __ Mov(argv, 0);
1746 __ Mov(argc, 0);
1747 __ Mov(target, 0);
1748 // Set external caught exception to false.
1749 Isolate* isolate = masm->isolate();
1750 __ Mov(x2, Operand(ExternalReference(Isolate::kExternalCaughtExceptionAddress,
1751 isolate)));
1752 __ Str(xzr, MemOperand(x2));
1753
1754 // Set pending exception and x0 to out of memory exception.
1755 Label already_have_failure;
1756 JumpIfOOM(masm, x0, x10, &already_have_failure);
1757 Failure* out_of_memory = Failure::OutOfMemoryException(0x1);
1758 __ Mov(x0, Operand(reinterpret_cast<uint64_t>(out_of_memory)));
1759 __ Bind(&already_have_failure);
1760 __ Mov(x2, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
1761 isolate)));
1762 __ Str(x0, MemOperand(x2));
1763 // Fall through to the next label.
1764 1719
1765 __ Bind(&throw_termination); 1720 __ Bind(&throw_termination);
1766 ASM_LOCATION("Throw termination"); 1721 ASM_LOCATION("Throw termination");
1767 __ Mov(argv, 0); 1722 __ Mov(argv, 0);
1768 __ Mov(argc, 0); 1723 __ Mov(argc, 0);
1769 __ Mov(target, 0); 1724 __ Mov(target, 0);
1770 __ ThrowUncatchable(x0, x10, x11, x12, x13); 1725 __ ThrowUncatchable(x0, x10, x11, x12, x13);
1771 1726
1772 __ Bind(&throw_normal); 1727 __ Bind(&throw_normal);
1773 ASM_LOCATION("Throw normal"); 1728 ASM_LOCATION("Throw normal");
(...skipping 3946 matching lines...) Expand 10 before | Expand all | Expand 10 after
5720 MemOperand(fp, 6 * kPointerSize), 5675 MemOperand(fp, 6 * kPointerSize),
5721 NULL); 5676 NULL);
5722 } 5677 }
5723 5678
5724 5679
5725 #undef __ 5680 #undef __
5726 5681
5727 } } // namespace v8::internal 5682 } } // namespace v8::internal
5728 5683
5729 #endif // V8_TARGET_ARCH_ARM64 5684 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698