| OLD | NEW |
| 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 #include <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
| (...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 Check(eq, kUnexpectedAllocationTop); | 2030 Check(eq, kUnexpectedAllocationTop); |
| 2031 } | 2031 } |
| 2032 // Load allocation limit. Result already contains allocation top. | 2032 // Load allocation limit. Result already contains allocation top. |
| 2033 ldr(alloc_limit, MemOperand(top_address, limit - top)); | 2033 ldr(alloc_limit, MemOperand(top_address, limit - top)); |
| 2034 } | 2034 } |
| 2035 | 2035 |
| 2036 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 2036 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 2037 // Align the next allocation. Storing the filler map without checking top is | 2037 // Align the next allocation. Storing the filler map without checking top is |
| 2038 // safe in new-space because the limit of the heap is aligned there. | 2038 // safe in new-space because the limit of the heap is aligned there. |
| 2039 STATIC_ASSERT(kPointerAlignment * 2 == kDoubleAlignment); | 2039 STATIC_ASSERT(kPointerAlignment * 2 == kDoubleAlignment); |
| 2040 and_(result_end, result, Operand(kDoubleAlignmentMask), SetCC); | 2040 and_(result_end, result, Operand(kDoubleAlignmentMaskTagged), SetCC); |
| 2041 Label aligned; | 2041 Label aligned; |
| 2042 b(eq, &aligned); | 2042 b(eq, &aligned); |
| 2043 if ((flags & PRETENURE) != 0) { | 2043 if ((flags & PRETENURE) != 0) { |
| 2044 cmp(result, Operand(alloc_limit)); | 2044 cmp(result, Operand(alloc_limit)); |
| 2045 b(hs, gc_required); | 2045 b(hs, gc_required); |
| 2046 } | 2046 } |
| 2047 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); | 2047 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); |
| 2048 str(result_end, MemOperand(result, kDoubleSize / 2, PostIndex)); | 2048 str(result_end, MemOperand(result, -kHeapObjectTag)); |
| 2049 add(result, result, Operand(kDoubleSize / 2)); |
| 2049 bind(&aligned); | 2050 bind(&aligned); |
| 2050 } | 2051 } |
| 2051 | 2052 |
| 2052 // Calculate new top and bail out if new space is exhausted. Use result | 2053 // Calculate new top and bail out if new space is exhausted. Use result |
| 2053 // to calculate the new top. We must preserve the ip register at this | 2054 // to calculate the new top. We must preserve the ip register at this |
| 2054 // point, so we cannot just use add(). | 2055 // point, so we cannot just use add(). |
| 2055 DCHECK(object_size > 0); | 2056 DCHECK(object_size > 0); |
| 2056 Register source = result; | 2057 Register source = result; |
| 2057 Condition cond = al; | 2058 Condition cond = al; |
| 2058 int shift = 0; | 2059 int shift = 0; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2071 } | 2072 } |
| 2072 } | 2073 } |
| 2073 | 2074 |
| 2074 cmp(result_end, Operand(alloc_limit)); | 2075 cmp(result_end, Operand(alloc_limit)); |
| 2075 b(hi, gc_required); | 2076 b(hi, gc_required); |
| 2076 | 2077 |
| 2077 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { | 2078 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { |
| 2078 // The top pointer is not updated for allocation folding dominators. | 2079 // The top pointer is not updated for allocation folding dominators. |
| 2079 str(result_end, MemOperand(top_address)); | 2080 str(result_end, MemOperand(top_address)); |
| 2080 } | 2081 } |
| 2081 | |
| 2082 // Tag object. | |
| 2083 add(result, result, Operand(kHeapObjectTag)); | |
| 2084 } | 2082 } |
| 2085 | 2083 |
| 2086 | 2084 |
| 2087 void MacroAssembler::Allocate(Register object_size, Register result, | 2085 void MacroAssembler::Allocate(Register object_size, Register result, |
| 2088 Register result_end, Register scratch, | 2086 Register result_end, Register scratch, |
| 2089 Label* gc_required, AllocationFlags flags) { | 2087 Label* gc_required, AllocationFlags flags) { |
| 2090 DCHECK((flags & ALLOCATION_FOLDED) == 0); | 2088 DCHECK((flags & ALLOCATION_FOLDED) == 0); |
| 2091 if (!FLAG_inline_new) { | 2089 if (!FLAG_inline_new) { |
| 2092 if (emit_debug_code()) { | 2090 if (emit_debug_code()) { |
| 2093 // Trash the registers to simulate an allocation failure. | 2091 // Trash the registers to simulate an allocation failure. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 Check(eq, kUnexpectedAllocationTop); | 2134 Check(eq, kUnexpectedAllocationTop); |
| 2137 } | 2135 } |
| 2138 // Load allocation limit. Result already contains allocation top. | 2136 // Load allocation limit. Result already contains allocation top. |
| 2139 ldr(alloc_limit, MemOperand(top_address, limit - top)); | 2137 ldr(alloc_limit, MemOperand(top_address, limit - top)); |
| 2140 } | 2138 } |
| 2141 | 2139 |
| 2142 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 2140 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 2143 // Align the next allocation. Storing the filler map without checking top is | 2141 // Align the next allocation. Storing the filler map without checking top is |
| 2144 // safe in new-space because the limit of the heap is aligned there. | 2142 // safe in new-space because the limit of the heap is aligned there. |
| 2145 DCHECK(kPointerAlignment * 2 == kDoubleAlignment); | 2143 DCHECK(kPointerAlignment * 2 == kDoubleAlignment); |
| 2146 and_(result_end, result, Operand(kDoubleAlignmentMask), SetCC); | 2144 and_(result_end, result, Operand(kDoubleAlignmentMaskTagged), SetCC); |
| 2147 Label aligned; | 2145 Label aligned; |
| 2148 b(eq, &aligned); | 2146 b(eq, &aligned); |
| 2149 if ((flags & PRETENURE) != 0) { | 2147 if ((flags & PRETENURE) != 0) { |
| 2150 cmp(result, Operand(alloc_limit)); | 2148 cmp(result, Operand(alloc_limit)); |
| 2151 b(hs, gc_required); | 2149 b(hs, gc_required); |
| 2152 } | 2150 } |
| 2153 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); | 2151 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); |
| 2154 str(result_end, MemOperand(result, kDoubleSize / 2, PostIndex)); | 2152 str(result_end, MemOperand(result, -kHeapObjectTag)); |
| 2153 add(result, result, Operand(kDoubleSize / 2)); |
| 2155 bind(&aligned); | 2154 bind(&aligned); |
| 2156 } | 2155 } |
| 2157 | 2156 |
| 2158 // Calculate new top and bail out if new space is exhausted. Use result | 2157 // Calculate new top and bail out if new space is exhausted. Use result |
| 2159 // to calculate the new top. Object size may be in words so a shift is | 2158 // to calculate the new top. Object size may be in words so a shift is |
| 2160 // required to get the number of bytes. | 2159 // required to get the number of bytes. |
| 2161 if ((flags & SIZE_IN_WORDS) != 0) { | 2160 if ((flags & SIZE_IN_WORDS) != 0) { |
| 2162 add(result_end, result, Operand(object_size, LSL, kPointerSizeLog2), SetCC); | 2161 add(result_end, result, Operand(object_size, LSL, kPointerSizeLog2), SetCC); |
| 2163 } else { | 2162 } else { |
| 2164 add(result_end, result, Operand(object_size), SetCC); | 2163 add(result_end, result, Operand(object_size), SetCC); |
| 2165 } | 2164 } |
| 2166 | 2165 |
| 2167 cmp(result_end, Operand(alloc_limit)); | 2166 cmp(result_end, Operand(alloc_limit)); |
| 2168 b(hi, gc_required); | 2167 b(hi, gc_required); |
| 2169 | 2168 |
| 2170 // Update allocation top. result temporarily holds the new top. | 2169 // Update allocation top. result temporarily holds the new top. |
| 2171 if (emit_debug_code()) { | 2170 if (emit_debug_code()) { |
| 2172 tst(result_end, Operand(kObjectAlignmentMask)); | 2171 tst(result_end, Operand(kObjectAlignmentMask)); |
| 2173 Check(eq, kUnalignedAllocationInNewSpace); | 2172 Check(ne, kUnalignedAllocationInNewSpace); |
| 2174 } | 2173 } |
| 2175 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { | 2174 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { |
| 2176 // The top pointer is not updated for allocation folding dominators. | 2175 // The top pointer is not updated for allocation folding dominators. |
| 2177 str(result_end, MemOperand(top_address)); | 2176 str(result_end, MemOperand(top_address)); |
| 2178 } | 2177 } |
| 2179 | |
| 2180 // Tag object. | |
| 2181 add(result, result, Operand(kHeapObjectTag)); | |
| 2182 } | 2178 } |
| 2183 | 2179 |
| 2184 void MacroAssembler::FastAllocate(Register object_size, Register result, | 2180 void MacroAssembler::FastAllocate(Register object_size, Register result, |
| 2185 Register result_end, Register scratch, | 2181 Register result_end, Register scratch, |
| 2186 AllocationFlags flags) { | 2182 AllocationFlags flags) { |
| 2187 // |object_size| and |result_end| may overlap if the DOUBLE_ALIGNMENT flag | 2183 // |object_size| and |result_end| may overlap if the DOUBLE_ALIGNMENT flag |
| 2188 // is not specified. Other registers must not overlap. | 2184 // is not specified. Other registers must not overlap. |
| 2189 DCHECK(!AreAliased(object_size, result, scratch, ip)); | 2185 DCHECK(!AreAliased(object_size, result, scratch, ip)); |
| 2190 DCHECK(!AreAliased(result_end, result, scratch, ip)); | 2186 DCHECK(!AreAliased(result_end, result, scratch, ip)); |
| 2191 DCHECK((flags & DOUBLE_ALIGNMENT) == 0 || !object_size.is(result_end)); | 2187 DCHECK((flags & DOUBLE_ALIGNMENT) == 0 || !object_size.is(result_end)); |
| 2192 | 2188 |
| 2193 ExternalReference allocation_top = | 2189 ExternalReference allocation_top = |
| 2194 AllocationUtils::GetAllocationTopReference(isolate(), flags); | 2190 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
| 2195 | 2191 |
| 2196 Register top_address = scratch; | 2192 Register top_address = scratch; |
| 2197 mov(top_address, Operand(allocation_top)); | 2193 mov(top_address, Operand(allocation_top)); |
| 2198 ldr(result, MemOperand(top_address)); | 2194 ldr(result, MemOperand(top_address)); |
| 2199 | 2195 |
| 2200 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 2196 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 2201 // Align the next allocation. Storing the filler map without checking top is | 2197 // Align the next allocation. Storing the filler map without checking top is |
| 2202 // safe in new-space because the limit of the heap is aligned there. | 2198 // safe in new-space because the limit of the heap is aligned there. |
| 2203 DCHECK(kPointerAlignment * 2 == kDoubleAlignment); | 2199 DCHECK(kPointerAlignment * 2 == kDoubleAlignment); |
| 2204 and_(result_end, result, Operand(kDoubleAlignmentMask), SetCC); | 2200 and_(result_end, result, Operand(kDoubleAlignmentMaskTagged), SetCC); |
| 2205 Label aligned; | 2201 Label aligned; |
| 2206 b(eq, &aligned); | 2202 b(eq, &aligned); |
| 2207 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); | 2203 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); |
| 2208 str(result_end, MemOperand(result, kDoubleSize / 2, PostIndex)); | 2204 str(result_end, MemOperand(result, -kHeapObjectTag)); |
| 2205 add(result, result, Operand(kDoubleSize / 2)); |
| 2209 bind(&aligned); | 2206 bind(&aligned); |
| 2210 } | 2207 } |
| 2211 | 2208 |
| 2212 // Calculate new top using result. Object size may be in words so a shift is | 2209 // Calculate new top using result. Object size may be in words so a shift is |
| 2213 // required to get the number of bytes. | 2210 // required to get the number of bytes. |
| 2214 if ((flags & SIZE_IN_WORDS) != 0) { | 2211 if ((flags & SIZE_IN_WORDS) != 0) { |
| 2215 add(result_end, result, Operand(object_size, LSL, kPointerSizeLog2), SetCC); | 2212 add(result_end, result, Operand(object_size, LSL, kPointerSizeLog2), SetCC); |
| 2216 } else { | 2213 } else { |
| 2217 add(result_end, result, Operand(object_size), SetCC); | 2214 add(result_end, result, Operand(object_size), SetCC); |
| 2218 } | 2215 } |
| 2219 | 2216 |
| 2220 // Update allocation top. result temporarily holds the new top. | 2217 // Update allocation top. result temporarily holds the new top. |
| 2221 if (emit_debug_code()) { | 2218 if (emit_debug_code()) { |
| 2222 tst(result_end, Operand(kObjectAlignmentMask)); | 2219 tst(result_end, Operand(kObjectAlignmentMask)); |
| 2223 Check(eq, kUnalignedAllocationInNewSpace); | 2220 Check(ne, kUnalignedAllocationInNewSpace); |
| 2224 } | 2221 } |
| 2225 // The top pointer is not updated for allocation folding dominators. | 2222 // The top pointer is not updated for allocation folding dominators. |
| 2226 str(result_end, MemOperand(top_address)); | 2223 str(result_end, MemOperand(top_address)); |
| 2227 | |
| 2228 add(result, result, Operand(kHeapObjectTag)); | |
| 2229 } | 2224 } |
| 2230 | 2225 |
| 2231 void MacroAssembler::FastAllocate(int object_size, Register result, | 2226 void MacroAssembler::FastAllocate(int object_size, Register result, |
| 2232 Register scratch1, Register scratch2, | 2227 Register scratch1, Register scratch2, |
| 2233 AllocationFlags flags) { | 2228 AllocationFlags flags) { |
| 2234 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); | 2229 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); |
| 2235 DCHECK(!AreAliased(result, scratch1, scratch2, ip)); | 2230 DCHECK(!AreAliased(result, scratch1, scratch2, ip)); |
| 2236 | 2231 |
| 2237 // Make object size into bytes. | 2232 // Make object size into bytes. |
| 2238 if ((flags & SIZE_IN_WORDS) != 0) { | 2233 if ((flags & SIZE_IN_WORDS) != 0) { |
| 2239 object_size *= kPointerSize; | 2234 object_size *= kPointerSize; |
| 2240 } | 2235 } |
| 2241 DCHECK_EQ(0, object_size & kObjectAlignmentMask); | 2236 DCHECK_EQ(0, object_size & kObjectAlignmentMask); |
| 2242 | 2237 |
| 2243 ExternalReference allocation_top = | 2238 ExternalReference allocation_top = |
| 2244 AllocationUtils::GetAllocationTopReference(isolate(), flags); | 2239 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
| 2245 | 2240 |
| 2246 // Set up allocation top address register. | 2241 // Set up allocation top address register. |
| 2247 Register top_address = scratch1; | 2242 Register top_address = scratch1; |
| 2248 Register result_end = scratch2; | 2243 Register result_end = scratch2; |
| 2249 mov(top_address, Operand(allocation_top)); | 2244 mov(top_address, Operand(allocation_top)); |
| 2250 ldr(result, MemOperand(top_address)); | 2245 ldr(result, MemOperand(top_address)); |
| 2251 | 2246 |
| 2252 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 2247 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 2253 // Align the next allocation. Storing the filler map without checking top is | 2248 // Align the next allocation. Storing the filler map without checking top is |
| 2254 // safe in new-space because the limit of the heap is aligned there. | 2249 // safe in new-space because the limit of the heap is aligned there. |
| 2255 STATIC_ASSERT(kPointerAlignment * 2 == kDoubleAlignment); | 2250 STATIC_ASSERT(kPointerAlignment * 2 == kDoubleAlignment); |
| 2256 and_(result_end, result, Operand(kDoubleAlignmentMask), SetCC); | 2251 and_(result_end, result, Operand(kDoubleAlignmentMaskTagged), SetCC); |
| 2257 Label aligned; | 2252 Label aligned; |
| 2258 b(eq, &aligned); | 2253 b(eq, &aligned); |
| 2259 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); | 2254 mov(result_end, Operand(isolate()->factory()->one_pointer_filler_map())); |
| 2260 str(result_end, MemOperand(result, kDoubleSize / 2, PostIndex)); | 2255 str(result_end, MemOperand(result, -kHeapObjectTag)); |
| 2256 add(result, result, Operand(kDoubleSize / 2)); |
| 2261 bind(&aligned); | 2257 bind(&aligned); |
| 2262 } | 2258 } |
| 2263 | 2259 |
| 2264 // Calculate new top using result. Object size may be in words so a shift is | 2260 // Calculate new top using result. Object size may be in words so a shift is |
| 2265 // required to get the number of bytes. We must preserve the ip register at | 2261 // required to get the number of bytes. We must preserve the ip register at |
| 2266 // this point, so we cannot just use add(). | 2262 // this point, so we cannot just use add(). |
| 2267 DCHECK(object_size > 0); | 2263 DCHECK(object_size > 0); |
| 2268 Register source = result; | 2264 Register source = result; |
| 2269 Condition cond = al; | 2265 Condition cond = al; |
| 2270 int shift = 0; | 2266 int shift = 0; |
| 2271 while (object_size != 0) { | 2267 while (object_size != 0) { |
| 2272 if (((object_size >> shift) & 0x03) == 0) { | 2268 if (((object_size >> shift) & 0x03) == 0) { |
| 2273 shift += 2; | 2269 shift += 2; |
| 2274 } else { | 2270 } else { |
| 2275 int bits = object_size & (0xff << shift); | 2271 int bits = object_size & (0xff << shift); |
| 2276 object_size -= bits; | 2272 object_size -= bits; |
| 2277 shift += 8; | 2273 shift += 8; |
| 2278 Operand bits_operand(bits); | 2274 Operand bits_operand(bits); |
| 2279 DCHECK(bits_operand.instructions_required(this) == 1); | 2275 DCHECK(bits_operand.instructions_required(this) == 1); |
| 2280 add(result_end, source, bits_operand, LeaveCC, cond); | 2276 add(result_end, source, bits_operand, LeaveCC, cond); |
| 2281 source = result_end; | 2277 source = result_end; |
| 2282 cond = cc; | 2278 cond = cc; |
| 2283 } | 2279 } |
| 2284 } | 2280 } |
| 2285 | 2281 |
| 2286 // The top pointer is not updated for allocation folding dominators. | 2282 // The top pointer is not updated for allocation folding dominators. |
| 2287 str(result_end, MemOperand(top_address)); | 2283 str(result_end, MemOperand(top_address)); |
| 2288 | |
| 2289 add(result, result, Operand(kHeapObjectTag)); | |
| 2290 } | 2284 } |
| 2291 | 2285 |
| 2292 void MacroAssembler::AllocateTwoByteString(Register result, | 2286 void MacroAssembler::AllocateTwoByteString(Register result, |
| 2293 Register length, | 2287 Register length, |
| 2294 Register scratch1, | 2288 Register scratch1, |
| 2295 Register scratch2, | 2289 Register scratch2, |
| 2296 Register scratch3, | 2290 Register scratch3, |
| 2297 Label* gc_required) { | 2291 Label* gc_required) { |
| 2298 // Calculate the number of bytes needed for the characters in the string while | 2292 // Calculate the number of bytes needed for the characters in the string while |
| 2299 // observing object alignment. | 2293 // observing object alignment. |
| (...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4042 } | 4036 } |
| 4043 } | 4037 } |
| 4044 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); | 4038 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); |
| 4045 add(result, result, Operand(dividend, LSR, 31)); | 4039 add(result, result, Operand(dividend, LSR, 31)); |
| 4046 } | 4040 } |
| 4047 | 4041 |
| 4048 } // namespace internal | 4042 } // namespace internal |
| 4049 } // namespace v8 | 4043 } // namespace v8 |
| 4050 | 4044 |
| 4051 #endif // V8_TARGET_ARCH_ARM | 4045 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |