| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
| 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 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2240 DCHECK(rmode != RelocInfo::NONE32); | 2240 DCHECK(rmode != RelocInfo::NONE32); |
| 2241 | 2241 |
| 2242 if (rmode == RelocInfo::NONE64) { | 2242 if (rmode == RelocInfo::NONE64) { |
| 2243 return kCallSizeWithoutRelocation; | 2243 return kCallSizeWithoutRelocation; |
| 2244 } else { | 2244 } else { |
| 2245 return kCallSizeWithRelocation; | 2245 return kCallSizeWithRelocation; |
| 2246 } | 2246 } |
| 2247 } | 2247 } |
| 2248 | 2248 |
| 2249 | 2249 |
| 2250 void MacroAssembler::JumpIfHeapNumber(Register object, Label* on_heap_number, |
| 2251 SmiCheckType smi_check_type) { |
| 2252 Label on_not_heap_number; |
| 2250 | 2253 |
| 2254 if (smi_check_type == DO_SMI_CHECK) { |
| 2255 JumpIfSmi(object, &on_not_heap_number); |
| 2256 } |
| 2251 | 2257 |
| 2252 | |
| 2253 void MacroAssembler::JumpForHeapNumber(Register object, | |
| 2254 Register heap_number_map, | |
| 2255 Label* on_heap_number, | |
| 2256 Label* on_not_heap_number) { | |
| 2257 DCHECK(on_heap_number || on_not_heap_number); | |
| 2258 AssertNotSmi(object); | 2258 AssertNotSmi(object); |
| 2259 | 2259 |
| 2260 UseScratchRegisterScope temps(this); | 2260 UseScratchRegisterScope temps(this); |
| 2261 Register temp = temps.AcquireX(); | 2261 Register temp = temps.AcquireX(); |
| 2262 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset)); |
| 2263 JumpIfRoot(temp, Heap::kHeapNumberMapRootIndex, on_heap_number); |
| 2262 | 2264 |
| 2263 // Load the HeapNumber map if it is not passed. | 2265 Bind(&on_not_heap_number); |
| 2264 if (heap_number_map.Is(NoReg)) { | |
| 2265 heap_number_map = temps.AcquireX(); | |
| 2266 LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); | |
| 2267 } else { | |
| 2268 AssertRegisterIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); | |
| 2269 } | |
| 2270 | |
| 2271 DCHECK(!AreAliased(temp, heap_number_map)); | |
| 2272 | |
| 2273 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset)); | |
| 2274 Cmp(temp, heap_number_map); | |
| 2275 | |
| 2276 if (on_heap_number) { | |
| 2277 B(eq, on_heap_number); | |
| 2278 } | |
| 2279 if (on_not_heap_number) { | |
| 2280 B(ne, on_not_heap_number); | |
| 2281 } | |
| 2282 } | |
| 2283 | |
| 2284 | |
| 2285 void MacroAssembler::JumpIfHeapNumber(Register object, | |
| 2286 Label* on_heap_number, | |
| 2287 Register heap_number_map) { | |
| 2288 JumpForHeapNumber(object, | |
| 2289 heap_number_map, | |
| 2290 on_heap_number, | |
| 2291 NULL); | |
| 2292 } | 2266 } |
| 2293 | 2267 |
| 2294 | 2268 |
| 2295 void MacroAssembler::JumpIfNotHeapNumber(Register object, | 2269 void MacroAssembler::JumpIfNotHeapNumber(Register object, |
| 2296 Label* on_not_heap_number, | 2270 Label* on_not_heap_number, |
| 2297 Register heap_number_map) { | 2271 SmiCheckType smi_check_type) { |
| 2298 JumpForHeapNumber(object, | 2272 if (smi_check_type == DO_SMI_CHECK) { |
| 2299 heap_number_map, | 2273 JumpIfSmi(object, on_not_heap_number); |
| 2300 NULL, | 2274 } |
| 2301 on_not_heap_number); | 2275 |
| 2276 AssertNotSmi(object); |
| 2277 |
| 2278 UseScratchRegisterScope temps(this); |
| 2279 Register temp = temps.AcquireX(); |
| 2280 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset)); |
| 2281 JumpIfNotRoot(temp, Heap::kHeapNumberMapRootIndex, on_not_heap_number); |
| 2302 } | 2282 } |
| 2303 | 2283 |
| 2304 | 2284 |
| 2305 void MacroAssembler::LookupNumberStringCache(Register object, | 2285 void MacroAssembler::LookupNumberStringCache(Register object, |
| 2306 Register result, | 2286 Register result, |
| 2307 Register scratch1, | 2287 Register scratch1, |
| 2308 Register scratch2, | 2288 Register scratch2, |
| 2309 Register scratch3, | 2289 Register scratch3, |
| 2310 Label* not_found) { | 2290 Label* not_found) { |
| 2311 DCHECK(!AreAliased(object, result, scratch1, scratch2, scratch3)); | 2291 DCHECK(!AreAliased(object, result, scratch1, scratch2, scratch3)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2325 Sub(mask, mask, 1); // Make mask. | 2305 Sub(mask, mask, 1); // Make mask. |
| 2326 | 2306 |
| 2327 // Calculate the entry in the number string cache. The hash value in the | 2307 // Calculate the entry in the number string cache. The hash value in the |
| 2328 // number string cache for smis is just the smi value, and the hash for | 2308 // number string cache for smis is just the smi value, and the hash for |
| 2329 // doubles is the xor of the upper and lower words. See | 2309 // doubles is the xor of the upper and lower words. See |
| 2330 // Heap::GetNumberStringCache. | 2310 // Heap::GetNumberStringCache. |
| 2331 Label is_smi; | 2311 Label is_smi; |
| 2332 Label load_result_from_cache; | 2312 Label load_result_from_cache; |
| 2333 | 2313 |
| 2334 JumpIfSmi(object, &is_smi); | 2314 JumpIfSmi(object, &is_smi); |
| 2335 CheckMap(object, scratch1, Heap::kHeapNumberMapRootIndex, not_found, | 2315 JumpIfNotHeapNumber(object, not_found); |
| 2336 DONT_DO_SMI_CHECK); | |
| 2337 | 2316 |
| 2338 STATIC_ASSERT(kDoubleSize == (kWRegSize * 2)); | 2317 STATIC_ASSERT(kDoubleSize == (kWRegSize * 2)); |
| 2339 Add(scratch1, object, HeapNumber::kValueOffset - kHeapObjectTag); | 2318 Add(scratch1, object, HeapNumber::kValueOffset - kHeapObjectTag); |
| 2340 Ldp(scratch1.W(), scratch2.W(), MemOperand(scratch1)); | 2319 Ldp(scratch1.W(), scratch2.W(), MemOperand(scratch1)); |
| 2341 Eor(scratch1, scratch1, scratch2); | 2320 Eor(scratch1, scratch1, scratch2); |
| 2342 And(scratch1, scratch1, mask); | 2321 And(scratch1, scratch1, mask); |
| 2343 | 2322 |
| 2344 // Calculate address of entry in string cache: each entry consists of two | 2323 // Calculate address of entry in string cache: each entry consists of two |
| 2345 // pointer sized fields. | 2324 // pointer sized fields. |
| 2346 Add(scratch1, number_string_cache, | 2325 Add(scratch1, number_string_cache, |
| (...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3734 | 3713 |
| 3735 // Sets condition flags based on comparison, and returns type in type_reg. | 3714 // Sets condition flags based on comparison, and returns type in type_reg. |
| 3736 void MacroAssembler::CompareInstanceType(Register map, | 3715 void MacroAssembler::CompareInstanceType(Register map, |
| 3737 Register type_reg, | 3716 Register type_reg, |
| 3738 InstanceType type) { | 3717 InstanceType type) { |
| 3739 Ldrb(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 3718 Ldrb(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
| 3740 Cmp(type_reg, type); | 3719 Cmp(type_reg, type); |
| 3741 } | 3720 } |
| 3742 | 3721 |
| 3743 | 3722 |
| 3744 void MacroAssembler::CompareMap(Register obj, | 3723 void MacroAssembler::CompareObjectMap(Register obj, Heap::RootListIndex index) { |
| 3745 Register scratch, | 3724 UseScratchRegisterScope temps(this); |
| 3746 Handle<Map> map) { | 3725 Register obj_map = temps.AcquireX(); |
| 3726 Ldr(obj_map, FieldMemOperand(obj, HeapObject::kMapOffset)); |
| 3727 CompareRoot(obj_map, index); |
| 3728 } |
| 3729 |
| 3730 |
| 3731 void MacroAssembler::CompareObjectMap(Register obj, Register scratch, |
| 3732 Handle<Map> map) { |
| 3747 Ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); | 3733 Ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); |
| 3748 CompareMap(scratch, map); | 3734 CompareMap(scratch, map); |
| 3749 } | 3735 } |
| 3750 | 3736 |
| 3751 | 3737 |
| 3752 void MacroAssembler::CompareMap(Register obj_map, | 3738 void MacroAssembler::CompareMap(Register obj_map, |
| 3753 Handle<Map> map) { | 3739 Handle<Map> map) { |
| 3754 Cmp(obj_map, Operand(map)); | 3740 Cmp(obj_map, Operand(map)); |
| 3755 } | 3741 } |
| 3756 | 3742 |
| 3757 | 3743 |
| 3758 void MacroAssembler::CheckMap(Register obj, | 3744 void MacroAssembler::CheckMap(Register obj, |
| 3759 Register scratch, | 3745 Register scratch, |
| 3760 Handle<Map> map, | 3746 Handle<Map> map, |
| 3761 Label* fail, | 3747 Label* fail, |
| 3762 SmiCheckType smi_check_type) { | 3748 SmiCheckType smi_check_type) { |
| 3763 if (smi_check_type == DO_SMI_CHECK) { | 3749 if (smi_check_type == DO_SMI_CHECK) { |
| 3764 JumpIfSmi(obj, fail); | 3750 JumpIfSmi(obj, fail); |
| 3765 } | 3751 } |
| 3766 | 3752 |
| 3767 CompareMap(obj, scratch, map); | 3753 CompareObjectMap(obj, scratch, map); |
| 3768 B(ne, fail); | 3754 B(ne, fail); |
| 3769 } | 3755 } |
| 3770 | 3756 |
| 3771 | 3757 |
| 3772 void MacroAssembler::CheckMap(Register obj, | 3758 void MacroAssembler::CheckMap(Register obj, |
| 3773 Register scratch, | 3759 Register scratch, |
| 3774 Heap::RootListIndex index, | 3760 Heap::RootListIndex index, |
| 3775 Label* fail, | 3761 Label* fail, |
| 3776 SmiCheckType smi_check_type) { | 3762 SmiCheckType smi_check_type) { |
| 3777 if (smi_check_type == DO_SMI_CHECK) { | 3763 if (smi_check_type == DO_SMI_CHECK) { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3997 Label store_num; | 3983 Label store_num; |
| 3998 | 3984 |
| 3999 // Speculatively convert the smi to a double - all smis can be exactly | 3985 // Speculatively convert the smi to a double - all smis can be exactly |
| 4000 // represented as a double. | 3986 // represented as a double. |
| 4001 SmiUntagToDouble(fpscratch1, value_reg, kSpeculativeUntag); | 3987 SmiUntagToDouble(fpscratch1, value_reg, kSpeculativeUntag); |
| 4002 | 3988 |
| 4003 // If value_reg is a smi, we're done. | 3989 // If value_reg is a smi, we're done. |
| 4004 JumpIfSmi(value_reg, &store_num); | 3990 JumpIfSmi(value_reg, &store_num); |
| 4005 | 3991 |
| 4006 // Ensure that the object is a heap number. | 3992 // Ensure that the object is a heap number. |
| 4007 CheckMap(value_reg, scratch1, isolate()->factory()->heap_number_map(), | 3993 JumpIfNotHeapNumber(value_reg, fail); |
| 4008 fail, DONT_DO_SMI_CHECK); | |
| 4009 | 3994 |
| 4010 Ldr(fpscratch1, FieldMemOperand(value_reg, HeapNumber::kValueOffset)); | 3995 Ldr(fpscratch1, FieldMemOperand(value_reg, HeapNumber::kValueOffset)); |
| 4011 | 3996 |
| 4012 // Canonicalize NaNs. | 3997 // Canonicalize NaNs. |
| 4013 CanonicalizeNaN(fpscratch1); | 3998 CanonicalizeNaN(fpscratch1); |
| 4014 | 3999 |
| 4015 // Store the result. | 4000 // Store the result. |
| 4016 Bind(&store_num); | 4001 Bind(&store_num); |
| 4017 Add(scratch1, elements_reg, | 4002 Add(scratch1, elements_reg, |
| 4018 Operand::UntagSmiAndScale(key_reg, kDoubleSizeLog2)); | 4003 Operand::UntagSmiAndScale(key_reg, kDoubleSizeLog2)); |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4423 Register dst, | 4408 Register dst, |
| 4424 LinkRegisterStatus lr_status, | 4409 LinkRegisterStatus lr_status, |
| 4425 SaveFPRegsMode fp_mode) { | 4410 SaveFPRegsMode fp_mode) { |
| 4426 ASM_LOCATION("MacroAssembler::RecordWrite"); | 4411 ASM_LOCATION("MacroAssembler::RecordWrite"); |
| 4427 DCHECK(!AreAliased(object, map)); | 4412 DCHECK(!AreAliased(object, map)); |
| 4428 | 4413 |
| 4429 if (emit_debug_code()) { | 4414 if (emit_debug_code()) { |
| 4430 UseScratchRegisterScope temps(this); | 4415 UseScratchRegisterScope temps(this); |
| 4431 Register temp = temps.AcquireX(); | 4416 Register temp = temps.AcquireX(); |
| 4432 | 4417 |
| 4433 CompareMap(map, temp, isolate()->factory()->meta_map()); | 4418 CompareObjectMap(map, temp, isolate()->factory()->meta_map()); |
| 4434 Check(eq, kWrongAddressOrValuePassedToRecordWrite); | 4419 Check(eq, kWrongAddressOrValuePassedToRecordWrite); |
| 4435 } | 4420 } |
| 4436 | 4421 |
| 4437 if (!FLAG_incremental_marking) { | 4422 if (!FLAG_incremental_marking) { |
| 4438 return; | 4423 return; |
| 4439 } | 4424 } |
| 4440 | 4425 |
| 4441 if (emit_debug_code()) { | 4426 if (emit_debug_code()) { |
| 4442 UseScratchRegisterScope temps(this); | 4427 UseScratchRegisterScope temps(this); |
| 4443 Register temp = temps.AcquireX(); | 4428 Register temp = temps.AcquireX(); |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5396 } | 5381 } |
| 5397 } | 5382 } |
| 5398 | 5383 |
| 5399 | 5384 |
| 5400 #undef __ | 5385 #undef __ |
| 5401 | 5386 |
| 5402 | 5387 |
| 5403 } } // namespace v8::internal | 5388 } } // namespace v8::internal |
| 5404 | 5389 |
| 5405 #endif // V8_TARGET_ARCH_ARM64 | 5390 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |