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 #include <assert.h> // For assert | 5 #include <assert.h> // For assert |
6 #include <limits.h> // For LONG_MIN, LONG_MAX. | 6 #include <limits.h> // For LONG_MIN, LONG_MAX. |
7 | 7 |
8 #if V8_TARGET_ARCH_PPC | 8 #if V8_TARGET_ARCH_PPC |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1783 const int kValueOffset = | 1783 const int kValueOffset = |
1784 SeededNumberDictionary::kElementsStartOffset + kPointerSize; | 1784 SeededNumberDictionary::kElementsStartOffset + kPointerSize; |
1785 LoadP(result, FieldMemOperand(t2, kValueOffset)); | 1785 LoadP(result, FieldMemOperand(t2, kValueOffset)); |
1786 } | 1786 } |
1787 | 1787 |
1788 | 1788 |
1789 void MacroAssembler::Allocate(int object_size, Register result, | 1789 void MacroAssembler::Allocate(int object_size, Register result, |
1790 Register scratch1, Register scratch2, | 1790 Register scratch1, Register scratch2, |
1791 Label* gc_required, AllocationFlags flags) { | 1791 Label* gc_required, AllocationFlags flags) { |
1792 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); | 1792 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); |
1793 DCHECK((flags & ALLOCATION_FOLDED) == 0); | |
1793 if (!FLAG_inline_new) { | 1794 if (!FLAG_inline_new) { |
1794 if (emit_debug_code()) { | 1795 if (emit_debug_code()) { |
1795 // Trash the registers to simulate an allocation failure. | 1796 // Trash the registers to simulate an allocation failure. |
1796 li(result, Operand(0x7091)); | 1797 li(result, Operand(0x7091)); |
1797 li(scratch1, Operand(0x7191)); | 1798 li(scratch1, Operand(0x7191)); |
1798 li(scratch2, Operand(0x7291)); | 1799 li(scratch2, Operand(0x7291)); |
1799 } | 1800 } |
1800 b(gc_required); | 1801 b(gc_required); |
1801 return; | 1802 return; |
1802 } | 1803 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1868 sub(r0, alloc_limit, result); | 1869 sub(r0, alloc_limit, result); |
1869 if (is_int16(object_size)) { | 1870 if (is_int16(object_size)) { |
1870 cmpi(r0, Operand(object_size)); | 1871 cmpi(r0, Operand(object_size)); |
1871 blt(gc_required); | 1872 blt(gc_required); |
1872 addi(result_end, result, Operand(object_size)); | 1873 addi(result_end, result, Operand(object_size)); |
1873 } else { | 1874 } else { |
1874 Cmpi(r0, Operand(object_size), result_end); | 1875 Cmpi(r0, Operand(object_size), result_end); |
1875 blt(gc_required); | 1876 blt(gc_required); |
1876 add(result_end, result, result_end); | 1877 add(result_end, result, result_end); |
1877 } | 1878 } |
1878 StoreP(result_end, MemOperand(top_address)); | 1879 |
1880 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { | |
1881 // The top pointer is not updated for allocation folding dominators. | |
1882 StoreP(result_end, MemOperand(top_address)); | |
1883 } | |
1879 | 1884 |
1880 // Tag object. | 1885 // Tag object. |
1881 addi(result, result, Operand(kHeapObjectTag)); | 1886 addi(result, result, Operand(kHeapObjectTag)); |
1882 } | 1887 } |
1883 | 1888 |
1884 | 1889 |
1885 void MacroAssembler::Allocate(Register object_size, Register result, | 1890 void MacroAssembler::Allocate(Register object_size, Register result, |
1886 Register result_end, Register scratch, | 1891 Register result_end, Register scratch, |
1887 Label* gc_required, AllocationFlags flags) { | 1892 Label* gc_required, AllocationFlags flags) { |
1893 DCHECK((flags & ALLOCATION_FOLDED) == 0); | |
1888 if (!FLAG_inline_new) { | 1894 if (!FLAG_inline_new) { |
1889 if (emit_debug_code()) { | 1895 if (emit_debug_code()) { |
1890 // Trash the registers to simulate an allocation failure. | 1896 // Trash the registers to simulate an allocation failure. |
1891 li(result, Operand(0x7091)); | 1897 li(result, Operand(0x7091)); |
1892 li(scratch, Operand(0x7191)); | 1898 li(scratch, Operand(0x7191)); |
1893 li(result_end, Operand(0x7291)); | 1899 li(result_end, Operand(0x7291)); |
1894 } | 1900 } |
1895 b(gc_required); | 1901 b(gc_required); |
1896 return; | 1902 return; |
1897 } | 1903 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1967 cmp(r0, object_size); | 1973 cmp(r0, object_size); |
1968 blt(gc_required); | 1974 blt(gc_required); |
1969 add(result_end, result, object_size); | 1975 add(result_end, result, object_size); |
1970 } | 1976 } |
1971 | 1977 |
1972 // Update allocation top. result temporarily holds the new top. | 1978 // Update allocation top. result temporarily holds the new top. |
1973 if (emit_debug_code()) { | 1979 if (emit_debug_code()) { |
1974 andi(r0, result_end, Operand(kObjectAlignmentMask)); | 1980 andi(r0, result_end, Operand(kObjectAlignmentMask)); |
1975 Check(eq, kUnalignedAllocationInNewSpace, cr0); | 1981 Check(eq, kUnalignedAllocationInNewSpace, cr0); |
1976 } | 1982 } |
1983 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { | |
1984 // The top pointer is not updated for allocation folding dominators. | |
1985 StoreP(result_end, MemOperand(top_address)); | |
1986 } | |
1987 | |
1988 // Tag object. | |
1989 addi(result, result, Operand(kHeapObjectTag)); | |
1990 } | |
1991 | |
1992 void MacroAssembler::FastAllocate(Register object_size, Register result, | |
1993 Register result_end, Register scratch, | |
1994 AllocationFlags flags) { | |
1995 // |object_size| and |result_end| may overlap if the DOUBLE_ALIGNMENT flag | |
1996 // is not specified. Other registers must not overlap. | |
1997 DCHECK(!AreAliased(object_size, result, scratch, ip)); | |
1998 DCHECK(!AreAliased(result_end, result, scratch, ip)); | |
1999 DCHECK((flags & DOUBLE_ALIGNMENT) == 0 || !object_size.is(result_end)); | |
2000 | |
2001 ExternalReference allocation_top = | |
2002 AllocationUtils::GetAllocationTopReference(isolate(), flags); | |
2003 | |
2004 Register top_address = scratch; | |
2005 mov(top_address, Operand(allocation_top)); | |
2006 LoadP(result, MemOperand(top_address)); | |
2007 | |
2008 if ((flags & DOUBLE_ALIGNMENT) != 0) { | |
2009 // Align the next allocation. Storing the filler map without checking top is | |
2010 // safe in new-space because the limit of the heap is aligned there. | |
2011 #if V8_TARGET_ARCH_PPC64 | |
2012 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); | |
2013 #else | |
2014 DCHECK(kPointerAlignment * 2 == kDoubleAlignment); | |
2015 andi(result_end, result, Operand(kDoubleAlignmentMask)); | |
2016 Label aligned; | |
2017 beq(&aligned); | |
2018 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); | |
2019 stw(result_end, MemOperand(result)); | |
2020 addi(result, result, Operand(kDoubleSize / 2)); | |
2021 bind(&aligned); | |
2022 #endif | |
2023 } | |
2024 | |
2025 // Calculate new top using result. Object size may be in words so a shift is | |
2026 // required to get the number of bytes. | |
2027 if ((flags & SIZE_IN_WORDS) != 0) { | |
2028 ShiftLeftImm(result_end, object_size, Operand(kPointerSizeLog2)); | |
2029 add(result_end, result, result_end); | |
2030 } else { | |
2031 add(result_end, result, object_size); | |
2032 } | |
2033 | |
2034 // Update allocation top. result temporarily holds the new top. | |
2035 if (emit_debug_code()) { | |
2036 andi(r0, result_end, Operand(kObjectAlignmentMask)); | |
2037 Check(eq, kUnalignedAllocationInNewSpace, cr0); | |
2038 } | |
1977 StoreP(result_end, MemOperand(top_address)); | 2039 StoreP(result_end, MemOperand(top_address)); |
1978 | 2040 |
1979 // Tag object. | 2041 // Tag object. |
2042 addi(result, result, Operand(kHeapObjectTag)); | |
2043 } | |
2044 | |
2045 void MacroAssembler::FastAllocate(int object_size, Register result, | |
2046 Register scratch1, Register scratch2, | |
2047 AllocationFlags flags) { | |
2048 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); | |
2049 DCHECK(!AreAliased(result, scratch1, scratch2, ip)); | |
2050 | |
2051 // Make object size into bytes. | |
2052 if ((flags & SIZE_IN_WORDS) != 0) { | |
2053 object_size *= kPointerSize; | |
2054 } | |
2055 DCHECK_EQ(0, object_size & kObjectAlignmentMask); | |
2056 | |
2057 ExternalReference allocation_top = | |
2058 AllocationUtils::GetAllocationTopReference(isolate(), flags); | |
2059 | |
2060 // Set up allocation top address register. | |
2061 Register top_address = scratch1; | |
2062 Register result_end = scratch2; | |
2063 mov(top_address, Operand(allocation_top)); | |
2064 LoadP(result, MemOperand(top_address)); | |
2065 | |
2066 if ((flags & DOUBLE_ALIGNMENT) != 0) { | |
2067 // Align the next allocation. Storing the filler map without checking top is | |
2068 // safe in new-space because the limit of the heap is aligned there. | |
2069 #if V8_TARGET_ARCH_PPC64 | |
2070 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); | |
2071 #else | |
2072 DCHECK(kPointerAlignment * 2 == kDoubleAlignment); | |
2073 andi(result_end, result, Operand(kDoubleAlignmentMask)); | |
2074 Label aligned; | |
2075 beq(&aligned); | |
2076 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); | |
2077 stw(result_end, MemOperand(result)); | |
2078 addi(result, result, Operand(kDoubleSize / 2)); | |
2079 bind(&aligned); | |
2080 #endif | |
2081 } | |
2082 | |
2083 // Calculate new top using result. | |
2084 if (is_int16(object_size)) { | |
MTBrandyberry
2016/05/11 15:18:22
I think you just want Add here.
| |
2085 addi(result_end, result, Operand(object_size)); | |
2086 } else { | |
2087 add(result_end, result, result_end); | |
2088 } | |
2089 // The top pointer is not updated for allocation folding dominators. | |
2090 StoreP(result_end, MemOperand(top_address)); | |
2091 | |
2092 // Tag object. | |
1980 addi(result, result, Operand(kHeapObjectTag)); | 2093 addi(result, result, Operand(kHeapObjectTag)); |
1981 } | 2094 } |
1982 | 2095 |
1983 | 2096 |
1984 void MacroAssembler::AllocateTwoByteString(Register result, Register length, | 2097 void MacroAssembler::AllocateTwoByteString(Register result, Register length, |
1985 Register scratch1, Register scratch2, | 2098 Register scratch1, Register scratch2, |
1986 Register scratch3, | 2099 Register scratch3, |
1987 Label* gc_required) { | 2100 Label* gc_required) { |
1988 // Calculate the number of bytes needed for the characters in the string while | 2101 // Calculate the number of bytes needed for the characters in the string while |
1989 // observing object alignment. | 2102 // observing object alignment. |
(...skipping 2787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4777 } | 4890 } |
4778 if (mag.shift > 0) srawi(result, result, mag.shift); | 4891 if (mag.shift > 0) srawi(result, result, mag.shift); |
4779 ExtractBit(r0, dividend, 31); | 4892 ExtractBit(r0, dividend, 31); |
4780 add(result, result, r0); | 4893 add(result, result, r0); |
4781 } | 4894 } |
4782 | 4895 |
4783 } // namespace internal | 4896 } // namespace internal |
4784 } // namespace v8 | 4897 } // namespace v8 |
4785 | 4898 |
4786 #endif // V8_TARGET_ARCH_PPC | 4899 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |