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

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

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

Powered by Google App Engine
This is Rietveld 408576698