OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
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 2336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 Sub(length, length, 1); | 2347 Sub(length, length, 1); |
2348 Ldrb(tmp1, MemOperand(src, 1, PostIndex)); | 2348 Ldrb(tmp1, MemOperand(src, 1, PostIndex)); |
2349 Strb(tmp1, MemOperand(dst, 1, PostIndex)); | 2349 Strb(tmp1, MemOperand(dst, 1, PostIndex)); |
2350 Cbnz(length, &short_loop); | 2350 Cbnz(length, &short_loop); |
2351 | 2351 |
2352 | 2352 |
2353 Bind(&done); | 2353 Bind(&done); |
2354 } | 2354 } |
2355 | 2355 |
2356 | 2356 |
2357 void MacroAssembler::FillFields(Register dst, | 2357 void MacroAssembler::InitializeFieldsWithFiller(Register current_address, |
2358 Register field_count, | 2358 Register end_address, |
2359 Register filler) { | 2359 Register filler) { |
2360 DCHECK(!dst.Is(csp)); | 2360 DCHECK(!current_address.Is(csp)); |
2361 UseScratchRegisterScope temps(this); | 2361 UseScratchRegisterScope temps(this); |
2362 Register field_ptr = temps.AcquireX(); | 2362 Register distance_in_words = temps.AcquireX(); |
2363 Register counter = temps.AcquireX(); | |
2364 Label done; | 2363 Label done; |
2365 | 2364 |
2366 // Decrement count. If the result < zero, count was zero, and there's nothing | 2365 // Calculate the distance. If it's <= zero then there's nothing to do. |
2367 // to do. If count was one, flags are set to fail the gt condition at the end | 2366 Subs(distance_in_words, end_address, current_address); |
2368 // of the pairs loop. | 2367 B(le, &done); |
2369 Subs(counter, field_count, 1); | |
2370 B(lt, &done); | |
2371 | 2368 |
2372 // There's at least one field to fill, so do this unconditionally. | 2369 // There's at least one field to fill, so do this unconditionally. |
2373 Str(filler, MemOperand(dst, kPointerSize, PostIndex)); | 2370 Str(filler, MemOperand(current_address)); |
2374 | 2371 |
2375 // If the bottom bit of counter is set, there are an even number of fields to | 2372 // If the distance_in_words consists of odd number of words we advance |
2376 // fill, so pull the start pointer back by one field, allowing the pairs loop | 2373 // start_address by one word, otherwise the pairs loop will ovwerite the |
2377 // to overwrite the field that was stored above. | 2374 // field that was stored above. |
2378 And(field_ptr, counter, 1); | 2375 And(distance_in_words, distance_in_words, kPointerSize); |
2379 Sub(field_ptr, dst, Operand(field_ptr, LSL, kPointerSizeLog2)); | 2376 Add(current_address, current_address, distance_in_words); |
2380 | 2377 |
2381 // Store filler to memory in pairs. | 2378 // Store filler to memory in pairs. |
2382 Label entry, loop; | 2379 Label loop, entry; |
2383 B(&entry); | 2380 B(&entry); |
2384 Bind(&loop); | 2381 Bind(&loop); |
2385 Stp(filler, filler, MemOperand(field_ptr, 2 * kPointerSize, PostIndex)); | 2382 Stp(filler, filler, MemOperand(current_address, 2 * kPointerSize, PostIndex)); |
2386 Subs(counter, counter, 2); | |
2387 Bind(&entry); | 2383 Bind(&entry); |
2388 B(gt, &loop); | 2384 Cmp(current_address, end_address); |
| 2385 B(lo, &loop); |
2389 | 2386 |
2390 Bind(&done); | 2387 Bind(&done); |
2391 } | 2388 } |
2392 | 2389 |
2393 | 2390 |
2394 void MacroAssembler::JumpIfEitherIsNotSequentialOneByteStrings( | 2391 void MacroAssembler::JumpIfEitherIsNotSequentialOneByteStrings( |
2395 Register first, Register second, Register scratch1, Register scratch2, | 2392 Register first, Register second, Register scratch1, Register scratch2, |
2396 Label* failure, SmiCheckType smi_check) { | 2393 Label* failure, SmiCheckType smi_check) { |
2397 if (smi_check == DO_SMI_CHECK) { | 2394 if (smi_check == DO_SMI_CHECK) { |
2398 JumpIfEitherSmi(first, second, failure); | 2395 JumpIfEitherSmi(first, second, failure); |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3113 B(hi, gc_required); | 3110 B(hi, gc_required); |
3114 Str(scratch3, MemOperand(top_address)); | 3111 Str(scratch3, MemOperand(top_address)); |
3115 | 3112 |
3116 // Tag the object if requested. | 3113 // Tag the object if requested. |
3117 if ((flags & TAG_OBJECT) != 0) { | 3114 if ((flags & TAG_OBJECT) != 0) { |
3118 ObjectTag(result, result); | 3115 ObjectTag(result, result); |
3119 } | 3116 } |
3120 } | 3117 } |
3121 | 3118 |
3122 | 3119 |
3123 void MacroAssembler::Allocate(Register object_size, | 3120 void MacroAssembler::Allocate(Register object_size, Register result, |
3124 Register result, | 3121 Register result_end, Register scratch, |
3125 Register scratch1, | 3122 Label* gc_required, AllocationFlags flags) { |
3126 Register scratch2, | |
3127 Label* gc_required, | |
3128 AllocationFlags flags) { | |
3129 if (!FLAG_inline_new) { | 3123 if (!FLAG_inline_new) { |
3130 if (emit_debug_code()) { | 3124 if (emit_debug_code()) { |
3131 // Trash the registers to simulate an allocation failure. | 3125 // Trash the registers to simulate an allocation failure. |
3132 // We apply salt to the original zap value to easily spot the values. | 3126 // We apply salt to the original zap value to easily spot the values. |
3133 Mov(result, (kDebugZapValue & ~0xffL) | 0x11L); | 3127 Mov(result, (kDebugZapValue & ~0xffL) | 0x11L); |
3134 Mov(scratch1, (kDebugZapValue & ~0xffL) | 0x21L); | 3128 Mov(scratch, (kDebugZapValue & ~0xffL) | 0x21L); |
3135 Mov(scratch2, (kDebugZapValue & ~0xffL) | 0x21L); | 3129 Mov(result_end, (kDebugZapValue & ~0xffL) | 0x21L); |
3136 } | 3130 } |
3137 B(gc_required); | 3131 B(gc_required); |
3138 return; | 3132 return; |
3139 } | 3133 } |
3140 | 3134 |
3141 UseScratchRegisterScope temps(this); | 3135 UseScratchRegisterScope temps(this); |
3142 Register scratch3 = temps.AcquireX(); | 3136 Register scratch2 = temps.AcquireX(); |
3143 | 3137 |
3144 DCHECK(!AreAliased(object_size, result, scratch1, scratch2, scratch3)); | 3138 DCHECK(!AreAliased(object_size, result, scratch, scratch2, result_end)); |
3145 DCHECK(object_size.Is64Bits() && result.Is64Bits() && | 3139 DCHECK(object_size.Is64Bits() && result.Is64Bits() && scratch.Is64Bits() && |
3146 scratch1.Is64Bits() && scratch2.Is64Bits()); | 3140 result_end.Is64Bits()); |
3147 | 3141 |
3148 // Check relative positions of allocation top and limit addresses. | 3142 // Check relative positions of allocation top and limit addresses. |
3149 // The values must be adjacent in memory to allow the use of LDP. | 3143 // The values must be adjacent in memory to allow the use of LDP. |
3150 ExternalReference heap_allocation_top = | 3144 ExternalReference heap_allocation_top = |
3151 AllocationUtils::GetAllocationTopReference(isolate(), flags); | 3145 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
3152 ExternalReference heap_allocation_limit = | 3146 ExternalReference heap_allocation_limit = |
3153 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | 3147 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
3154 intptr_t top = reinterpret_cast<intptr_t>(heap_allocation_top.address()); | 3148 intptr_t top = reinterpret_cast<intptr_t>(heap_allocation_top.address()); |
3155 intptr_t limit = reinterpret_cast<intptr_t>(heap_allocation_limit.address()); | 3149 intptr_t limit = reinterpret_cast<intptr_t>(heap_allocation_limit.address()); |
3156 DCHECK((limit - top) == kPointerSize); | 3150 DCHECK((limit - top) == kPointerSize); |
3157 | 3151 |
3158 // Set up allocation top address and object size registers. | 3152 // Set up allocation top address and object size registers. |
3159 Register top_address = scratch1; | 3153 Register top_address = scratch; |
3160 Register allocation_limit = scratch2; | 3154 Register allocation_limit = scratch2; |
3161 Mov(top_address, heap_allocation_top); | 3155 Mov(top_address, heap_allocation_top); |
3162 | 3156 |
3163 if ((flags & RESULT_CONTAINS_TOP) == 0) { | 3157 if ((flags & RESULT_CONTAINS_TOP) == 0) { |
3164 // Load allocation top into result and the allocation limit. | 3158 // Load allocation top into result and the allocation limit. |
3165 Ldp(result, allocation_limit, MemOperand(top_address)); | 3159 Ldp(result, allocation_limit, MemOperand(top_address)); |
3166 } else { | 3160 } else { |
3167 if (emit_debug_code()) { | 3161 if (emit_debug_code()) { |
3168 // Assert that result actually contains top on entry. | 3162 // Assert that result actually contains top on entry. |
3169 Ldr(scratch3, MemOperand(top_address)); | 3163 Ldr(result_end, MemOperand(top_address)); |
3170 Cmp(result, scratch3); | 3164 Cmp(result, result_end); |
3171 Check(eq, kUnexpectedAllocationTop); | 3165 Check(eq, kUnexpectedAllocationTop); |
3172 } | 3166 } |
3173 // Load the allocation limit. 'result' already contains the allocation top. | 3167 // Load the allocation limit. 'result' already contains the allocation top. |
3174 Ldr(allocation_limit, MemOperand(top_address, limit - top)); | 3168 Ldr(allocation_limit, MemOperand(top_address, limit - top)); |
3175 } | 3169 } |
3176 | 3170 |
3177 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have | 3171 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have |
3178 // the same alignment on ARM64. | 3172 // the same alignment on ARM64. |
3179 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); | 3173 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); |
3180 | 3174 |
3181 // Calculate new top and bail out if new space is exhausted | 3175 // Calculate new top and bail out if new space is exhausted |
3182 if ((flags & SIZE_IN_WORDS) != 0) { | 3176 if ((flags & SIZE_IN_WORDS) != 0) { |
3183 Adds(scratch3, result, Operand(object_size, LSL, kPointerSizeLog2)); | 3177 Adds(result_end, result, Operand(object_size, LSL, kPointerSizeLog2)); |
3184 } else { | 3178 } else { |
3185 Adds(scratch3, result, object_size); | 3179 Adds(result_end, result, object_size); |
3186 } | 3180 } |
3187 | 3181 |
3188 if (emit_debug_code()) { | 3182 if (emit_debug_code()) { |
3189 Tst(scratch3, kObjectAlignmentMask); | 3183 Tst(result_end, kObjectAlignmentMask); |
3190 Check(eq, kUnalignedAllocationInNewSpace); | 3184 Check(eq, kUnalignedAllocationInNewSpace); |
3191 } | 3185 } |
3192 | 3186 |
3193 Ccmp(scratch3, allocation_limit, CFlag, cc); | 3187 Ccmp(result_end, allocation_limit, CFlag, cc); |
3194 B(hi, gc_required); | 3188 B(hi, gc_required); |
3195 Str(scratch3, MemOperand(top_address)); | 3189 Str(result_end, MemOperand(top_address)); |
3196 | 3190 |
3197 // Tag the object if requested. | 3191 // Tag the object if requested. |
3198 if ((flags & TAG_OBJECT) != 0) { | 3192 if ((flags & TAG_OBJECT) != 0) { |
3199 ObjectTag(result, result); | 3193 ObjectTag(result, result); |
3200 } | 3194 } |
3201 } | 3195 } |
3202 | 3196 |
3203 | 3197 |
3204 void MacroAssembler::AllocateTwoByteString(Register result, | 3198 void MacroAssembler::AllocateTwoByteString(Register result, |
3205 Register length, | 3199 Register length, |
(...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5077 } | 5071 } |
5078 | 5072 |
5079 | 5073 |
5080 #undef __ | 5074 #undef __ |
5081 | 5075 |
5082 | 5076 |
5083 } // namespace internal | 5077 } // namespace internal |
5084 } // namespace v8 | 5078 } // namespace v8 |
5085 | 5079 |
5086 #endif // V8_TARGET_ARCH_ARM64 | 5080 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |