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

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 1899813003: [crankshaft] Fragmentation-free allocation folding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/macro-assembler.h » ('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 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_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 1520
1521 1521
1522 void MacroAssembler::Allocate(int object_size, 1522 void MacroAssembler::Allocate(int object_size,
1523 Register result, 1523 Register result,
1524 Register result_end, 1524 Register result_end,
1525 Register scratch, 1525 Register scratch,
1526 Label* gc_required, 1526 Label* gc_required,
1527 AllocationFlags flags) { 1527 AllocationFlags flags) {
1528 DCHECK((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0); 1528 DCHECK((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0);
1529 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); 1529 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize);
1530 DCHECK((flags & ALLOCATION_FOLDED) == 0);
1530 if (!FLAG_inline_new) { 1531 if (!FLAG_inline_new) {
1531 if (emit_debug_code()) { 1532 if (emit_debug_code()) {
1532 // Trash the registers to simulate an allocation failure. 1533 // Trash the registers to simulate an allocation failure.
1533 mov(result, Immediate(0x7091)); 1534 mov(result, Immediate(0x7091));
1534 if (result_end.is_valid()) { 1535 if (result_end.is_valid()) {
1535 mov(result_end, Immediate(0x7191)); 1536 mov(result_end, Immediate(0x7191));
1536 } 1537 }
1537 if (scratch.is_valid()) { 1538 if (scratch.is_valid()) {
1538 mov(scratch, Immediate(0x7291)); 1539 mov(scratch, Immediate(0x7291));
1539 } 1540 }
(...skipping 21 matching lines...) Expand all
1561 j(above_equal, gc_required); 1562 j(above_equal, gc_required);
1562 } 1563 }
1563 mov(Operand(result, 0), 1564 mov(Operand(result, 0),
1564 Immediate(isolate()->factory()->one_pointer_filler_map())); 1565 Immediate(isolate()->factory()->one_pointer_filler_map()));
1565 add(result, Immediate(kDoubleSize / 2)); 1566 add(result, Immediate(kDoubleSize / 2));
1566 bind(&aligned); 1567 bind(&aligned);
1567 } 1568 }
1568 1569
1569 // Calculate new top and bail out if space is exhausted. 1570 // Calculate new top and bail out if space is exhausted.
1570 Register top_reg = result_end.is_valid() ? result_end : result; 1571 Register top_reg = result_end.is_valid() ? result_end : result;
1572
1571 if (!top_reg.is(result)) { 1573 if (!top_reg.is(result)) {
1572 mov(top_reg, result); 1574 mov(top_reg, result);
1573 } 1575 }
1574 add(top_reg, Immediate(object_size)); 1576 add(top_reg, Immediate(object_size));
1575 cmp(top_reg, Operand::StaticVariable(allocation_limit)); 1577 cmp(top_reg, Operand::StaticVariable(allocation_limit));
1576 j(above, gc_required); 1578 j(above, gc_required);
1577 1579
1578 // Update allocation top. 1580 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) {
1579 UpdateAllocationTopHelper(top_reg, scratch, flags); 1581 // The top pointer is not updated for allocation folding dominators.
1582 UpdateAllocationTopHelper(top_reg, scratch, flags);
1583 }
1580 1584
1581 if (top_reg.is(result)) { 1585 if (top_reg.is(result)) {
1582 sub(result, Immediate(object_size - kHeapObjectTag)); 1586 sub(result, Immediate(object_size - kHeapObjectTag));
1583 } else { 1587 } else {
1584 // Tag the result. 1588 // Tag the result.
1585 DCHECK(kHeapObjectTag == 1); 1589 DCHECK(kHeapObjectTag == 1);
1586 inc(result); 1590 inc(result);
1587 } 1591 }
1588 } 1592 }
1589 1593
1590 1594
1591 void MacroAssembler::Allocate(int header_size, 1595 void MacroAssembler::Allocate(int header_size,
1592 ScaleFactor element_size, 1596 ScaleFactor element_size,
1593 Register element_count, 1597 Register element_count,
1594 RegisterValueType element_count_type, 1598 RegisterValueType element_count_type,
1595 Register result, 1599 Register result,
1596 Register result_end, 1600 Register result_end,
1597 Register scratch, 1601 Register scratch,
1598 Label* gc_required, 1602 Label* gc_required,
1599 AllocationFlags flags) { 1603 AllocationFlags flags) {
1600 DCHECK((flags & SIZE_IN_WORDS) == 0); 1604 DCHECK((flags & SIZE_IN_WORDS) == 0);
1605 DCHECK((flags & ALLOCATION_FOLDING_DOMINATOR) == 0);
1606 DCHECK((flags & ALLOCATION_FOLDED) == 0);
1601 if (!FLAG_inline_new) { 1607 if (!FLAG_inline_new) {
1602 if (emit_debug_code()) { 1608 if (emit_debug_code()) {
1603 // Trash the registers to simulate an allocation failure. 1609 // Trash the registers to simulate an allocation failure.
1604 mov(result, Immediate(0x7091)); 1610 mov(result, Immediate(0x7091));
1605 mov(result_end, Immediate(0x7191)); 1611 mov(result_end, Immediate(0x7191));
1606 if (scratch.is_valid()) { 1612 if (scratch.is_valid()) {
1607 mov(scratch, Immediate(0x7291)); 1613 mov(scratch, Immediate(0x7291));
1608 } 1614 }
1609 // Register element_count is not modified by the function. 1615 // Register element_count is not modified by the function.
1610 } 1616 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 if (element_count_type == REGISTER_VALUE_IS_SMI) { 1648 if (element_count_type == REGISTER_VALUE_IS_SMI) {
1643 STATIC_ASSERT(static_cast<ScaleFactor>(times_2 - 1) == times_1); 1649 STATIC_ASSERT(static_cast<ScaleFactor>(times_2 - 1) == times_1);
1644 STATIC_ASSERT(static_cast<ScaleFactor>(times_4 - 1) == times_2); 1650 STATIC_ASSERT(static_cast<ScaleFactor>(times_4 - 1) == times_2);
1645 STATIC_ASSERT(static_cast<ScaleFactor>(times_8 - 1) == times_4); 1651 STATIC_ASSERT(static_cast<ScaleFactor>(times_8 - 1) == times_4);
1646 DCHECK(element_size >= times_2); 1652 DCHECK(element_size >= times_2);
1647 DCHECK(kSmiTagSize == 1); 1653 DCHECK(kSmiTagSize == 1);
1648 element_size = static_cast<ScaleFactor>(element_size - 1); 1654 element_size = static_cast<ScaleFactor>(element_size - 1);
1649 } else { 1655 } else {
1650 DCHECK(element_count_type == REGISTER_VALUE_IS_INT32); 1656 DCHECK(element_count_type == REGISTER_VALUE_IS_INT32);
1651 } 1657 }
1658
1652 lea(result_end, Operand(element_count, element_size, header_size)); 1659 lea(result_end, Operand(element_count, element_size, header_size));
1653 add(result_end, result); 1660 add(result_end, result);
1654 j(carry, gc_required);
1655 cmp(result_end, Operand::StaticVariable(allocation_limit)); 1661 cmp(result_end, Operand::StaticVariable(allocation_limit));
1656 j(above, gc_required); 1662 j(above, gc_required);
1657 1663
1658 // Tag result. 1664 // Tag result.
1659 DCHECK(kHeapObjectTag == 1); 1665 DCHECK(kHeapObjectTag == 1);
1660 inc(result); 1666 inc(result);
1661 1667
1662 // Update allocation top.
1663 UpdateAllocationTopHelper(result_end, scratch, flags); 1668 UpdateAllocationTopHelper(result_end, scratch, flags);
1664 } 1669 }
1665 1670
1666 1671
1667 void MacroAssembler::Allocate(Register object_size, 1672 void MacroAssembler::Allocate(Register object_size,
1668 Register result, 1673 Register result,
1669 Register result_end, 1674 Register result_end,
1670 Register scratch, 1675 Register scratch,
1671 Label* gc_required, 1676 Label* gc_required,
1672 AllocationFlags flags) { 1677 AllocationFlags flags) {
1673 DCHECK((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0); 1678 DCHECK((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0);
1679 DCHECK((flags & ALLOCATION_FOLDED) == 0);
1674 if (!FLAG_inline_new) { 1680 if (!FLAG_inline_new) {
1675 if (emit_debug_code()) { 1681 if (emit_debug_code()) {
1676 // Trash the registers to simulate an allocation failure. 1682 // Trash the registers to simulate an allocation failure.
1677 mov(result, Immediate(0x7091)); 1683 mov(result, Immediate(0x7091));
1678 mov(result_end, Immediate(0x7191)); 1684 mov(result_end, Immediate(0x7191));
1679 if (scratch.is_valid()) { 1685 if (scratch.is_valid()) {
1680 mov(scratch, Immediate(0x7291)); 1686 mov(scratch, Immediate(0x7291));
1681 } 1687 }
1682 // object_size is left unchanged by this function. 1688 // object_size is left unchanged by this function.
1683 } 1689 }
(...skipping 23 matching lines...) Expand all
1707 Immediate(isolate()->factory()->one_pointer_filler_map())); 1713 Immediate(isolate()->factory()->one_pointer_filler_map()));
1708 add(result, Immediate(kDoubleSize / 2)); 1714 add(result, Immediate(kDoubleSize / 2));
1709 bind(&aligned); 1715 bind(&aligned);
1710 } 1716 }
1711 1717
1712 // Calculate new top and bail out if space is exhausted. 1718 // Calculate new top and bail out if space is exhausted.
1713 if (!object_size.is(result_end)) { 1719 if (!object_size.is(result_end)) {
1714 mov(result_end, object_size); 1720 mov(result_end, object_size);
1715 } 1721 }
1716 add(result_end, result); 1722 add(result_end, result);
1717 j(carry, gc_required);
1718 cmp(result_end, Operand::StaticVariable(allocation_limit)); 1723 cmp(result_end, Operand::StaticVariable(allocation_limit));
1719 j(above, gc_required); 1724 j(above, gc_required);
1720 1725
1721 // Tag result. 1726 // Tag result.
1722 DCHECK(kHeapObjectTag == 1); 1727 DCHECK(kHeapObjectTag == 1);
1723 inc(result); 1728 inc(result);
1724 1729
1725 // Update allocation top. 1730 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) {
1726 UpdateAllocationTopHelper(result_end, scratch, flags); 1731 // The top pointer is not updated for allocation folding dominators.
1732 UpdateAllocationTopHelper(result_end, scratch, flags);
1733 }
1734 }
1735
1736 void MacroAssembler::FastAllocate(int object_size, Register result,
1737 Register result_end, AllocationFlags flags) {
1738 DCHECK(!result.is(result_end));
1739 // Load address of new object into result.
1740 LoadAllocationTopHelper(result, no_reg, flags);
1741
1742 if ((flags & DOUBLE_ALIGNMENT) != 0) {
1743 DCHECK(kPointerAlignment * 2 == kDoubleAlignment);
1744 Label aligned;
1745 test(result, Immediate(kDoubleAlignmentMask));
1746 j(zero, &aligned, Label::kNear);
1747 mov(Operand(result, 0),
1748 Immediate(isolate()->factory()->one_pointer_filler_map()));
1749 add(result, Immediate(kDoubleSize / 2));
1750 bind(&aligned);
1751 }
1752
1753 lea(result_end, Operand(result, object_size));
1754 UpdateAllocationTopHelper(result_end, no_reg, flags);
1755
1756 DCHECK(kHeapObjectTag == 1);
1757 inc(result);
1758 }
1759
1760 void MacroAssembler::FastAllocate(Register object_size, Register result,
1761 Register result_end, AllocationFlags flags) {
1762 DCHECK(!result.is(result_end));
1763 // Load address of new object into result.
1764 LoadAllocationTopHelper(result, no_reg, flags);
1765
1766 if ((flags & DOUBLE_ALIGNMENT) != 0) {
1767 DCHECK(kPointerAlignment * 2 == kDoubleAlignment);
1768 Label aligned;
1769 test(result, Immediate(kDoubleAlignmentMask));
1770 j(zero, &aligned, Label::kNear);
1771 mov(Operand(result, 0),
1772 Immediate(isolate()->factory()->one_pointer_filler_map()));
1773 add(result, Immediate(kDoubleSize / 2));
1774 bind(&aligned);
1775 }
1776
1777 lea(result_end, Operand(result, object_size, times_1, 0));
1778 UpdateAllocationTopHelper(result_end, no_reg, flags);
1779
1780 DCHECK(kHeapObjectTag == 1);
1781 inc(result);
1727 } 1782 }
1728 1783
1729 1784
1730 void MacroAssembler::AllocateHeapNumber(Register result, 1785 void MacroAssembler::AllocateHeapNumber(Register result,
1731 Register scratch1, 1786 Register scratch1,
1732 Register scratch2, 1787 Register scratch2,
1733 Label* gc_required, 1788 Label* gc_required,
1734 MutableMode mode) { 1789 MutableMode mode) {
1735 // Allocate heap number in new space. 1790 // Allocate heap number in new space.
1736 Allocate(HeapNumber::kSize, result, scratch1, scratch2, gc_required, 1791 Allocate(HeapNumber::kSize, result, scratch1, scratch2, gc_required,
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
3400 mov(eax, dividend); 3455 mov(eax, dividend);
3401 shr(eax, 31); 3456 shr(eax, 31);
3402 add(edx, eax); 3457 add(edx, eax);
3403 } 3458 }
3404 3459
3405 3460
3406 } // namespace internal 3461 } // namespace internal
3407 } // namespace v8 3462 } // namespace v8
3408 3463
3409 #endif // V8_TARGET_ARCH_IA32 3464 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/macro-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698