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 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 cmpi(r0, Operand(object_size)); | 1870 cmpi(r0, Operand(object_size)); |
1871 blt(gc_required); | 1871 blt(gc_required); |
1872 addi(result_end, result, Operand(object_size)); | 1872 addi(result_end, result, Operand(object_size)); |
1873 } else { | 1873 } else { |
1874 Cmpi(r0, Operand(object_size), result_end); | 1874 Cmpi(r0, Operand(object_size), result_end); |
1875 blt(gc_required); | 1875 blt(gc_required); |
1876 add(result_end, result, result_end); | 1876 add(result_end, result, result_end); |
1877 } | 1877 } |
1878 StoreP(result_end, MemOperand(top_address)); | 1878 StoreP(result_end, MemOperand(top_address)); |
1879 | 1879 |
1880 // Tag object if requested. | 1880 // Tag object. |
1881 if ((flags & TAG_OBJECT) != 0) { | 1881 addi(result, result, Operand(kHeapObjectTag)); |
1882 addi(result, result, Operand(kHeapObjectTag)); | |
1883 } | |
1884 } | 1882 } |
1885 | 1883 |
1886 | 1884 |
1887 void MacroAssembler::Allocate(Register object_size, Register result, | 1885 void MacroAssembler::Allocate(Register object_size, Register result, |
1888 Register result_end, Register scratch, | 1886 Register result_end, Register scratch, |
1889 Label* gc_required, AllocationFlags flags) { | 1887 Label* gc_required, AllocationFlags flags) { |
1890 if (!FLAG_inline_new) { | 1888 if (!FLAG_inline_new) { |
1891 if (emit_debug_code()) { | 1889 if (emit_debug_code()) { |
1892 // Trash the registers to simulate an allocation failure. | 1890 // Trash the registers to simulate an allocation failure. |
1893 li(result, Operand(0x7091)); | 1891 li(result, Operand(0x7091)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 add(result_end, result, object_size); | 1969 add(result_end, result, object_size); |
1972 } | 1970 } |
1973 | 1971 |
1974 // Update allocation top. result temporarily holds the new top. | 1972 // Update allocation top. result temporarily holds the new top. |
1975 if (emit_debug_code()) { | 1973 if (emit_debug_code()) { |
1976 andi(r0, result_end, Operand(kObjectAlignmentMask)); | 1974 andi(r0, result_end, Operand(kObjectAlignmentMask)); |
1977 Check(eq, kUnalignedAllocationInNewSpace, cr0); | 1975 Check(eq, kUnalignedAllocationInNewSpace, cr0); |
1978 } | 1976 } |
1979 StoreP(result_end, MemOperand(top_address)); | 1977 StoreP(result_end, MemOperand(top_address)); |
1980 | 1978 |
1981 // Tag object if requested. | 1979 // Tag object. |
1982 if ((flags & TAG_OBJECT) != 0) { | 1980 addi(result, result, Operand(kHeapObjectTag)); |
1983 addi(result, result, Operand(kHeapObjectTag)); | |
1984 } | |
1985 } | 1981 } |
1986 | 1982 |
1987 | 1983 |
1988 void MacroAssembler::AllocateTwoByteString(Register result, Register length, | 1984 void MacroAssembler::AllocateTwoByteString(Register result, Register length, |
1989 Register scratch1, Register scratch2, | 1985 Register scratch1, Register scratch2, |
1990 Register scratch3, | 1986 Register scratch3, |
1991 Label* gc_required) { | 1987 Label* gc_required) { |
1992 // Calculate the number of bytes needed for the characters in the string while | 1988 // Calculate the number of bytes needed for the characters in the string while |
1993 // observing object alignment. | 1989 // observing object alignment. |
1994 DCHECK((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 1990 DCHECK((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
1995 slwi(scratch1, length, Operand(1)); // Length in bytes, not chars. | 1991 slwi(scratch1, length, Operand(1)); // Length in bytes, not chars. |
1996 addi(scratch1, scratch1, | 1992 addi(scratch1, scratch1, |
1997 Operand(kObjectAlignmentMask + SeqTwoByteString::kHeaderSize)); | 1993 Operand(kObjectAlignmentMask + SeqTwoByteString::kHeaderSize)); |
1998 mov(r0, Operand(~kObjectAlignmentMask)); | 1994 mov(r0, Operand(~kObjectAlignmentMask)); |
1999 and_(scratch1, scratch1, r0); | 1995 and_(scratch1, scratch1, r0); |
2000 | 1996 |
2001 // Allocate two-byte string in new space. | 1997 // Allocate two-byte string in new space. |
2002 Allocate(scratch1, result, scratch2, scratch3, gc_required, TAG_OBJECT); | 1998 Allocate(scratch1, result, scratch2, scratch3, gc_required, |
| 1999 NO_ALLOCATION_FLAGS); |
2003 | 2000 |
2004 // Set the map, length and hash field. | 2001 // Set the map, length and hash field. |
2005 InitializeNewString(result, length, Heap::kStringMapRootIndex, scratch1, | 2002 InitializeNewString(result, length, Heap::kStringMapRootIndex, scratch1, |
2006 scratch2); | 2003 scratch2); |
2007 } | 2004 } |
2008 | 2005 |
2009 | 2006 |
2010 void MacroAssembler::AllocateOneByteString(Register result, Register length, | 2007 void MacroAssembler::AllocateOneByteString(Register result, Register length, |
2011 Register scratch1, Register scratch2, | 2008 Register scratch1, Register scratch2, |
2012 Register scratch3, | 2009 Register scratch3, |
2013 Label* gc_required) { | 2010 Label* gc_required) { |
2014 // Calculate the number of bytes needed for the characters in the string while | 2011 // Calculate the number of bytes needed for the characters in the string while |
2015 // observing object alignment. | 2012 // observing object alignment. |
2016 DCHECK((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 2013 DCHECK((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
2017 DCHECK(kCharSize == 1); | 2014 DCHECK(kCharSize == 1); |
2018 addi(scratch1, length, | 2015 addi(scratch1, length, |
2019 Operand(kObjectAlignmentMask + SeqOneByteString::kHeaderSize)); | 2016 Operand(kObjectAlignmentMask + SeqOneByteString::kHeaderSize)); |
2020 li(r0, Operand(~kObjectAlignmentMask)); | 2017 li(r0, Operand(~kObjectAlignmentMask)); |
2021 and_(scratch1, scratch1, r0); | 2018 and_(scratch1, scratch1, r0); |
2022 | 2019 |
2023 // Allocate one-byte string in new space. | 2020 // Allocate one-byte string in new space. |
2024 Allocate(scratch1, result, scratch2, scratch3, gc_required, TAG_OBJECT); | 2021 Allocate(scratch1, result, scratch2, scratch3, gc_required, |
| 2022 NO_ALLOCATION_FLAGS); |
2025 | 2023 |
2026 // Set the map, length and hash field. | 2024 // Set the map, length and hash field. |
2027 InitializeNewString(result, length, Heap::kOneByteStringMapRootIndex, | 2025 InitializeNewString(result, length, Heap::kOneByteStringMapRootIndex, |
2028 scratch1, scratch2); | 2026 scratch1, scratch2); |
2029 } | 2027 } |
2030 | 2028 |
2031 | 2029 |
2032 void MacroAssembler::AllocateTwoByteConsString(Register result, Register length, | 2030 void MacroAssembler::AllocateTwoByteConsString(Register result, Register length, |
2033 Register scratch1, | 2031 Register scratch1, |
2034 Register scratch2, | 2032 Register scratch2, |
2035 Label* gc_required) { | 2033 Label* gc_required) { |
2036 Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, | 2034 Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, |
2037 TAG_OBJECT); | 2035 NO_ALLOCATION_FLAGS); |
2038 | 2036 |
2039 InitializeNewString(result, length, Heap::kConsStringMapRootIndex, scratch1, | 2037 InitializeNewString(result, length, Heap::kConsStringMapRootIndex, scratch1, |
2040 scratch2); | 2038 scratch2); |
2041 } | 2039 } |
2042 | 2040 |
2043 | 2041 |
2044 void MacroAssembler::AllocateOneByteConsString(Register result, Register length, | 2042 void MacroAssembler::AllocateOneByteConsString(Register result, Register length, |
2045 Register scratch1, | 2043 Register scratch1, |
2046 Register scratch2, | 2044 Register scratch2, |
2047 Label* gc_required) { | 2045 Label* gc_required) { |
2048 Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, | 2046 Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, |
2049 TAG_OBJECT); | 2047 NO_ALLOCATION_FLAGS); |
2050 | 2048 |
2051 InitializeNewString(result, length, Heap::kConsOneByteStringMapRootIndex, | 2049 InitializeNewString(result, length, Heap::kConsOneByteStringMapRootIndex, |
2052 scratch1, scratch2); | 2050 scratch1, scratch2); |
2053 } | 2051 } |
2054 | 2052 |
2055 | 2053 |
2056 void MacroAssembler::AllocateTwoByteSlicedString(Register result, | 2054 void MacroAssembler::AllocateTwoByteSlicedString(Register result, |
2057 Register length, | 2055 Register length, |
2058 Register scratch1, | 2056 Register scratch1, |
2059 Register scratch2, | 2057 Register scratch2, |
2060 Label* gc_required) { | 2058 Label* gc_required) { |
2061 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, | 2059 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, |
2062 TAG_OBJECT); | 2060 NO_ALLOCATION_FLAGS); |
2063 | 2061 |
2064 InitializeNewString(result, length, Heap::kSlicedStringMapRootIndex, scratch1, | 2062 InitializeNewString(result, length, Heap::kSlicedStringMapRootIndex, scratch1, |
2065 scratch2); | 2063 scratch2); |
2066 } | 2064 } |
2067 | 2065 |
2068 | 2066 |
2069 void MacroAssembler::AllocateOneByteSlicedString(Register result, | 2067 void MacroAssembler::AllocateOneByteSlicedString(Register result, |
2070 Register length, | 2068 Register length, |
2071 Register scratch1, | 2069 Register scratch1, |
2072 Register scratch2, | 2070 Register scratch2, |
2073 Label* gc_required) { | 2071 Label* gc_required) { |
2074 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, | 2072 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, |
2075 TAG_OBJECT); | 2073 NO_ALLOCATION_FLAGS); |
2076 | 2074 |
2077 InitializeNewString(result, length, Heap::kSlicedOneByteStringMapRootIndex, | 2075 InitializeNewString(result, length, Heap::kSlicedOneByteStringMapRootIndex, |
2078 scratch1, scratch2); | 2076 scratch1, scratch2); |
2079 } | 2077 } |
2080 | 2078 |
2081 | 2079 |
2082 void MacroAssembler::CompareObjectType(Register object, Register map, | 2080 void MacroAssembler::CompareObjectType(Register object, Register map, |
2083 Register type_reg, InstanceType type) { | 2081 Register type_reg, InstanceType type) { |
2084 const Register temp = type_reg.is(no_reg) ? r0 : type_reg; | 2082 const Register temp = type_reg.is(no_reg) ? r0 : type_reg; |
2085 | 2083 |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3092 bind(&succeed); | 3090 bind(&succeed); |
3093 } | 3091 } |
3094 | 3092 |
3095 | 3093 |
3096 // Allocates a heap number or jumps to the need_gc label if the young space | 3094 // Allocates a heap number or jumps to the need_gc label if the young space |
3097 // is full and a scavenge is needed. | 3095 // is full and a scavenge is needed. |
3098 void MacroAssembler::AllocateHeapNumber(Register result, Register scratch1, | 3096 void MacroAssembler::AllocateHeapNumber(Register result, Register scratch1, |
3099 Register scratch2, | 3097 Register scratch2, |
3100 Register heap_number_map, | 3098 Register heap_number_map, |
3101 Label* gc_required, | 3099 Label* gc_required, |
3102 TaggingMode tagging_mode, | |
3103 MutableMode mode) { | 3100 MutableMode mode) { |
3104 // Allocate an object in the heap for the heap number and tag it as a heap | 3101 // Allocate an object in the heap for the heap number and tag it as a heap |
3105 // object. | 3102 // object. |
3106 Allocate(HeapNumber::kSize, result, scratch1, scratch2, gc_required, | 3103 Allocate(HeapNumber::kSize, result, scratch1, scratch2, gc_required, |
3107 tagging_mode == TAG_RESULT ? TAG_OBJECT : NO_ALLOCATION_FLAGS); | 3104 NO_ALLOCATION_FLAGS); |
3108 | 3105 |
3109 Heap::RootListIndex map_index = mode == MUTABLE | 3106 Heap::RootListIndex map_index = mode == MUTABLE |
3110 ? Heap::kMutableHeapNumberMapRootIndex | 3107 ? Heap::kMutableHeapNumberMapRootIndex |
3111 : Heap::kHeapNumberMapRootIndex; | 3108 : Heap::kHeapNumberMapRootIndex; |
3112 AssertIsRoot(heap_number_map, map_index); | 3109 AssertIsRoot(heap_number_map, map_index); |
3113 | 3110 |
3114 // Store heap number map in the allocated object. | 3111 // Store heap number map in the allocated object. |
3115 if (tagging_mode == TAG_RESULT) { | 3112 StoreP(heap_number_map, FieldMemOperand(result, HeapObject::kMapOffset), |
3116 StoreP(heap_number_map, FieldMemOperand(result, HeapObject::kMapOffset), | 3113 r0); |
3117 r0); | |
3118 } else { | |
3119 StoreP(heap_number_map, MemOperand(result, HeapObject::kMapOffset)); | |
3120 } | |
3121 } | 3114 } |
3122 | 3115 |
3123 | 3116 |
3124 void MacroAssembler::AllocateHeapNumberWithValue( | 3117 void MacroAssembler::AllocateHeapNumberWithValue( |
3125 Register result, DoubleRegister value, Register scratch1, Register scratch2, | 3118 Register result, DoubleRegister value, Register scratch1, Register scratch2, |
3126 Register heap_number_map, Label* gc_required) { | 3119 Register heap_number_map, Label* gc_required) { |
3127 AllocateHeapNumber(result, scratch1, scratch2, heap_number_map, gc_required); | 3120 AllocateHeapNumber(result, scratch1, scratch2, heap_number_map, gc_required); |
3128 stfd(value, FieldMemOperand(result, HeapNumber::kValueOffset)); | 3121 stfd(value, FieldMemOperand(result, HeapNumber::kValueOffset)); |
3129 } | 3122 } |
3130 | 3123 |
3131 | 3124 |
3132 void MacroAssembler::AllocateJSValue(Register result, Register constructor, | 3125 void MacroAssembler::AllocateJSValue(Register result, Register constructor, |
3133 Register value, Register scratch1, | 3126 Register value, Register scratch1, |
3134 Register scratch2, Label* gc_required) { | 3127 Register scratch2, Label* gc_required) { |
3135 DCHECK(!result.is(constructor)); | 3128 DCHECK(!result.is(constructor)); |
3136 DCHECK(!result.is(scratch1)); | 3129 DCHECK(!result.is(scratch1)); |
3137 DCHECK(!result.is(scratch2)); | 3130 DCHECK(!result.is(scratch2)); |
3138 DCHECK(!result.is(value)); | 3131 DCHECK(!result.is(value)); |
3139 | 3132 |
3140 // Allocate JSValue in new space. | 3133 // Allocate JSValue in new space. |
3141 Allocate(JSValue::kSize, result, scratch1, scratch2, gc_required, TAG_OBJECT); | 3134 Allocate(JSValue::kSize, result, scratch1, scratch2, gc_required, |
| 3135 NO_ALLOCATION_FLAGS); |
3142 | 3136 |
3143 // Initialize the JSValue. | 3137 // Initialize the JSValue. |
3144 LoadGlobalFunctionInitialMap(constructor, scratch1, scratch2); | 3138 LoadGlobalFunctionInitialMap(constructor, scratch1, scratch2); |
3145 StoreP(scratch1, FieldMemOperand(result, HeapObject::kMapOffset), r0); | 3139 StoreP(scratch1, FieldMemOperand(result, HeapObject::kMapOffset), r0); |
3146 LoadRoot(scratch1, Heap::kEmptyFixedArrayRootIndex); | 3140 LoadRoot(scratch1, Heap::kEmptyFixedArrayRootIndex); |
3147 StoreP(scratch1, FieldMemOperand(result, JSObject::kPropertiesOffset), r0); | 3141 StoreP(scratch1, FieldMemOperand(result, JSObject::kPropertiesOffset), r0); |
3148 StoreP(scratch1, FieldMemOperand(result, JSObject::kElementsOffset), r0); | 3142 StoreP(scratch1, FieldMemOperand(result, JSObject::kElementsOffset), r0); |
3149 StoreP(value, FieldMemOperand(result, JSValue::kValueOffset), r0); | 3143 StoreP(value, FieldMemOperand(result, JSValue::kValueOffset), r0); |
3150 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 3144 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
3151 } | 3145 } |
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4679 } | 4673 } |
4680 if (mag.shift > 0) srawi(result, result, mag.shift); | 4674 if (mag.shift > 0) srawi(result, result, mag.shift); |
4681 ExtractBit(r0, dividend, 31); | 4675 ExtractBit(r0, dividend, 31); |
4682 add(result, result, r0); | 4676 add(result, result, r0); |
4683 } | 4677 } |
4684 | 4678 |
4685 } // namespace internal | 4679 } // namespace internal |
4686 } // namespace v8 | 4680 } // namespace v8 |
4687 | 4681 |
4688 #endif // V8_TARGET_ARCH_PPC | 4682 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |