OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3639 } | 3639 } |
3640 return false; | 3640 return false; |
3641 } | 3641 } |
3642 | 3642 |
3643 | 3643 |
3644 static void GenerateSmiKeyCheck(MacroAssembler* masm, | 3644 static void GenerateSmiKeyCheck(MacroAssembler* masm, |
3645 Register key, | 3645 Register key, |
3646 Register scratch0, | 3646 Register scratch0, |
3647 Register scratch1, | 3647 Register scratch1, |
3648 DwVfpRegister double_scratch0, | 3648 DwVfpRegister double_scratch0, |
| 3649 DwVfpRegister double_scratch1, |
3649 Label* fail) { | 3650 Label* fail) { |
3650 if (CpuFeatures::IsSupported(VFP2)) { | 3651 if (CpuFeatures::IsSupported(VFP2)) { |
3651 CpuFeatures::Scope scope(VFP2); | 3652 CpuFeatures::Scope scope(VFP2); |
3652 Label key_ok; | 3653 Label key_ok; |
3653 // Check for smi or a smi inside a heap number. We convert the heap | 3654 // Check for smi or a smi inside a heap number. We convert the heap |
3654 // number and check if the conversion is exact and fits into the smi | 3655 // number and check if the conversion is exact and fits into the smi |
3655 // range. | 3656 // range. |
3656 __ JumpIfSmi(key, &key_ok); | 3657 __ JumpIfSmi(key, &key_ok); |
3657 __ CheckMap(key, | 3658 __ CheckMap(key, |
3658 scratch0, | 3659 scratch0, |
3659 Heap::kHeapNumberMapRootIndex, | 3660 Heap::kHeapNumberMapRootIndex, |
3660 fail, | 3661 fail, |
3661 DONT_DO_SMI_CHECK); | 3662 DONT_DO_SMI_CHECK); |
3662 __ sub(ip, key, Operand(kHeapObjectTag)); | 3663 __ sub(ip, key, Operand(kHeapObjectTag)); |
3663 __ vldr(double_scratch0, ip, HeapNumber::kValueOffset); | 3664 __ vldr(double_scratch0, ip, HeapNumber::kValueOffset); |
3664 __ EmitVFPTruncate(kRoundToZero, | 3665 __ EmitVFPTruncate(kRoundToZero, |
3665 double_scratch0.low(), | 3666 scratch0, |
3666 double_scratch0, | 3667 double_scratch0, |
3667 scratch0, | |
3668 scratch1, | 3668 scratch1, |
| 3669 double_scratch1, |
3669 kCheckForInexactConversion); | 3670 kCheckForInexactConversion); |
3670 __ b(ne, fail); | 3671 __ b(ne, fail); |
3671 __ vmov(scratch0, double_scratch0.low()); | |
3672 __ TrySmiTag(scratch0, fail, scratch1); | 3672 __ TrySmiTag(scratch0, fail, scratch1); |
3673 __ mov(key, scratch0); | 3673 __ mov(key, scratch0); |
3674 __ bind(&key_ok); | 3674 __ bind(&key_ok); |
3675 } else { | 3675 } else { |
3676 // Check that the key is a smi. | 3676 // Check that the key is a smi. |
3677 __ JumpIfNotSmi(key, fail); | 3677 __ JumpIfNotSmi(key, fail); |
3678 } | 3678 } |
3679 } | 3679 } |
3680 | 3680 |
3681 | 3681 |
3682 void KeyedLoadStubCompiler::GenerateLoadExternalArray( | 3682 void KeyedLoadStubCompiler::GenerateLoadExternalArray( |
3683 MacroAssembler* masm, | 3683 MacroAssembler* masm, |
3684 ElementsKind elements_kind) { | 3684 ElementsKind elements_kind) { |
3685 // ---------- S t a t e -------------- | 3685 // ---------- S t a t e -------------- |
3686 // -- lr : return address | 3686 // -- lr : return address |
3687 // -- r0 : key | 3687 // -- r0 : key |
3688 // -- r1 : receiver | 3688 // -- r1 : receiver |
3689 // ----------------------------------- | 3689 // ----------------------------------- |
3690 Label miss_force_generic, slow, failed_allocation; | 3690 Label miss_force_generic, slow, failed_allocation; |
3691 | 3691 |
3692 Register key = r0; | 3692 Register key = r0; |
3693 Register receiver = r1; | 3693 Register receiver = r1; |
3694 | 3694 |
3695 // This stub is meant to be tail-jumped to, the receiver must already | 3695 // This stub is meant to be tail-jumped to, the receiver must already |
3696 // have been verified by the caller to not be a smi. | 3696 // have been verified by the caller to not be a smi. |
3697 | 3697 |
3698 // Check that the key is a smi or a heap number convertible to a smi. | 3698 // Check that the key is a smi or a heap number convertible to a smi. |
3699 GenerateSmiKeyCheck(masm, key, r4, r5, d1, &miss_force_generic); | 3699 GenerateSmiKeyCheck(masm, key, r4, r5, d1, d2, &miss_force_generic); |
3700 | 3700 |
3701 __ ldr(r3, FieldMemOperand(receiver, JSObject::kElementsOffset)); | 3701 __ ldr(r3, FieldMemOperand(receiver, JSObject::kElementsOffset)); |
3702 // r3: elements array | 3702 // r3: elements array |
3703 | 3703 |
3704 // Check that the index is in range. | 3704 // Check that the index is in range. |
3705 __ ldr(ip, FieldMemOperand(r3, ExternalArray::kLengthOffset)); | 3705 __ ldr(ip, FieldMemOperand(r3, ExternalArray::kLengthOffset)); |
3706 __ cmp(key, ip); | 3706 __ cmp(key, ip); |
3707 // Unsigned comparison catches both negative and too-large values. | 3707 // Unsigned comparison catches both negative and too-large values. |
3708 __ b(hs, &miss_force_generic); | 3708 __ b(hs, &miss_force_generic); |
3709 | 3709 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4023 // Register usage. | 4023 // Register usage. |
4024 Register value = r0; | 4024 Register value = r0; |
4025 Register key = r1; | 4025 Register key = r1; |
4026 Register receiver = r2; | 4026 Register receiver = r2; |
4027 // r3 mostly holds the elements array or the destination external array. | 4027 // r3 mostly holds the elements array or the destination external array. |
4028 | 4028 |
4029 // This stub is meant to be tail-jumped to, the receiver must already | 4029 // This stub is meant to be tail-jumped to, the receiver must already |
4030 // have been verified by the caller to not be a smi. | 4030 // have been verified by the caller to not be a smi. |
4031 | 4031 |
4032 // Check that the key is a smi or a heap number convertible to a smi. | 4032 // Check that the key is a smi or a heap number convertible to a smi. |
4033 GenerateSmiKeyCheck(masm, key, r4, r5, d1, &miss_force_generic); | 4033 GenerateSmiKeyCheck(masm, key, r4, r5, d1, d2, &miss_force_generic); |
4034 | 4034 |
4035 __ ldr(r3, FieldMemOperand(receiver, JSObject::kElementsOffset)); | 4035 __ ldr(r3, FieldMemOperand(receiver, JSObject::kElementsOffset)); |
4036 | 4036 |
4037 // Check that the index is in range | 4037 // Check that the index is in range |
4038 __ ldr(ip, FieldMemOperand(r3, ExternalArray::kLengthOffset)); | 4038 __ ldr(ip, FieldMemOperand(r3, ExternalArray::kLengthOffset)); |
4039 __ cmp(key, ip); | 4039 __ cmp(key, ip); |
4040 // Unsigned comparison catches both negative and too-large values. | 4040 // Unsigned comparison catches both negative and too-large values. |
4041 __ b(hs, &miss_force_generic); | 4041 __ b(hs, &miss_force_generic); |
4042 | 4042 |
4043 // Handle both smis and HeapNumbers in the fast path. Go to the | 4043 // Handle both smis and HeapNumbers in the fast path. Go to the |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4358 // -- lr : return address | 4358 // -- lr : return address |
4359 // -- r0 : key | 4359 // -- r0 : key |
4360 // -- r1 : receiver | 4360 // -- r1 : receiver |
4361 // ----------------------------------- | 4361 // ----------------------------------- |
4362 Label miss_force_generic; | 4362 Label miss_force_generic; |
4363 | 4363 |
4364 // This stub is meant to be tail-jumped to, the receiver must already | 4364 // This stub is meant to be tail-jumped to, the receiver must already |
4365 // have been verified by the caller to not be a smi. | 4365 // have been verified by the caller to not be a smi. |
4366 | 4366 |
4367 // Check that the key is a smi or a heap number convertible to a smi. | 4367 // Check that the key is a smi or a heap number convertible to a smi. |
4368 GenerateSmiKeyCheck(masm, r0, r4, r5, d1, &miss_force_generic); | 4368 GenerateSmiKeyCheck(masm, r0, r4, r5, d1, d2, &miss_force_generic); |
4369 | 4369 |
4370 // Get the elements array. | 4370 // Get the elements array. |
4371 __ ldr(r2, FieldMemOperand(r1, JSObject::kElementsOffset)); | 4371 __ ldr(r2, FieldMemOperand(r1, JSObject::kElementsOffset)); |
4372 __ AssertFastElements(r2); | 4372 __ AssertFastElements(r2); |
4373 | 4373 |
4374 // Check that the key is within bounds. | 4374 // Check that the key is within bounds. |
4375 __ ldr(r3, FieldMemOperand(r2, FixedArray::kLengthOffset)); | 4375 __ ldr(r3, FieldMemOperand(r2, FixedArray::kLengthOffset)); |
4376 __ cmp(r0, Operand(r3)); | 4376 __ cmp(r0, Operand(r3)); |
4377 __ b(hs, &miss_force_generic); | 4377 __ b(hs, &miss_force_generic); |
4378 | 4378 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4410 Register indexed_double_offset = r3; | 4410 Register indexed_double_offset = r3; |
4411 Register scratch = r4; | 4411 Register scratch = r4; |
4412 Register scratch2 = r5; | 4412 Register scratch2 = r5; |
4413 Register scratch3 = r6; | 4413 Register scratch3 = r6; |
4414 Register heap_number_map = r7; | 4414 Register heap_number_map = r7; |
4415 | 4415 |
4416 // This stub is meant to be tail-jumped to, the receiver must already | 4416 // This stub is meant to be tail-jumped to, the receiver must already |
4417 // have been verified by the caller to not be a smi. | 4417 // have been verified by the caller to not be a smi. |
4418 | 4418 |
4419 // Check that the key is a smi or a heap number convertible to a smi. | 4419 // Check that the key is a smi or a heap number convertible to a smi. |
4420 GenerateSmiKeyCheck(masm, key_reg, r4, r5, d1, &miss_force_generic); | 4420 GenerateSmiKeyCheck(masm, key_reg, r4, r5, d1, d2, &miss_force_generic); |
4421 | 4421 |
4422 // Get the elements array. | 4422 // Get the elements array. |
4423 __ ldr(elements_reg, | 4423 __ ldr(elements_reg, |
4424 FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); | 4424 FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); |
4425 | 4425 |
4426 // Check that the key is within bounds. | 4426 // Check that the key is within bounds. |
4427 __ ldr(scratch, FieldMemOperand(elements_reg, FixedArray::kLengthOffset)); | 4427 __ ldr(scratch, FieldMemOperand(elements_reg, FixedArray::kLengthOffset)); |
4428 __ cmp(key_reg, Operand(scratch)); | 4428 __ cmp(key_reg, Operand(scratch)); |
4429 __ b(hs, &miss_force_generic); | 4429 __ b(hs, &miss_force_generic); |
4430 | 4430 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4486 Register receiver_reg = r2; | 4486 Register receiver_reg = r2; |
4487 Register scratch = r4; | 4487 Register scratch = r4; |
4488 Register elements_reg = r3; | 4488 Register elements_reg = r3; |
4489 Register length_reg = r5; | 4489 Register length_reg = r5; |
4490 Register scratch2 = r6; | 4490 Register scratch2 = r6; |
4491 | 4491 |
4492 // This stub is meant to be tail-jumped to, the receiver must already | 4492 // This stub is meant to be tail-jumped to, the receiver must already |
4493 // have been verified by the caller to not be a smi. | 4493 // have been verified by the caller to not be a smi. |
4494 | 4494 |
4495 // Check that the key is a smi or a heap number convertible to a smi. | 4495 // Check that the key is a smi or a heap number convertible to a smi. |
4496 GenerateSmiKeyCheck(masm, key_reg, r4, r5, d1, &miss_force_generic); | 4496 GenerateSmiKeyCheck(masm, key_reg, r4, r5, d1, d2, &miss_force_generic); |
4497 | 4497 |
4498 if (IsFastSmiElementsKind(elements_kind)) { | 4498 if (IsFastSmiElementsKind(elements_kind)) { |
4499 __ JumpIfNotSmi(value_reg, &transition_elements_kind); | 4499 __ JumpIfNotSmi(value_reg, &transition_elements_kind); |
4500 } | 4500 } |
4501 | 4501 |
4502 // Check that the key is within bounds. | 4502 // Check that the key is within bounds. |
4503 __ ldr(elements_reg, | 4503 __ ldr(elements_reg, |
4504 FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); | 4504 FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); |
4505 if (is_js_array) { | 4505 if (is_js_array) { |
4506 __ ldr(scratch, FieldMemOperand(receiver_reg, JSArray::kLengthOffset)); | 4506 __ ldr(scratch, FieldMemOperand(receiver_reg, JSArray::kLengthOffset)); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4654 Register scratch1 = r4; | 4654 Register scratch1 = r4; |
4655 Register scratch2 = r5; | 4655 Register scratch2 = r5; |
4656 Register scratch3 = r6; | 4656 Register scratch3 = r6; |
4657 Register scratch4 = r7; | 4657 Register scratch4 = r7; |
4658 Register length_reg = r7; | 4658 Register length_reg = r7; |
4659 | 4659 |
4660 // This stub is meant to be tail-jumped to, the receiver must already | 4660 // This stub is meant to be tail-jumped to, the receiver must already |
4661 // have been verified by the caller to not be a smi. | 4661 // have been verified by the caller to not be a smi. |
4662 | 4662 |
4663 // Check that the key is a smi or a heap number convertible to a smi. | 4663 // Check that the key is a smi or a heap number convertible to a smi. |
4664 GenerateSmiKeyCheck(masm, key_reg, r4, r5, d1, &miss_force_generic); | 4664 GenerateSmiKeyCheck(masm, key_reg, r4, r5, d1, d2, &miss_force_generic); |
4665 | 4665 |
4666 __ ldr(elements_reg, | 4666 __ ldr(elements_reg, |
4667 FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); | 4667 FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); |
4668 | 4668 |
4669 // Check that the key is within bounds. | 4669 // Check that the key is within bounds. |
4670 if (is_js_array) { | 4670 if (is_js_array) { |
4671 __ ldr(scratch1, FieldMemOperand(receiver_reg, JSArray::kLengthOffset)); | 4671 __ ldr(scratch1, FieldMemOperand(receiver_reg, JSArray::kLengthOffset)); |
4672 } else { | 4672 } else { |
4673 __ ldr(scratch1, | 4673 __ ldr(scratch1, |
4674 FieldMemOperand(elements_reg, FixedArray::kLengthOffset)); | 4674 FieldMemOperand(elements_reg, FixedArray::kLengthOffset)); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4774 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4774 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
4775 } | 4775 } |
4776 } | 4776 } |
4777 | 4777 |
4778 | 4778 |
4779 #undef __ | 4779 #undef __ |
4780 | 4780 |
4781 } } // namespace v8::internal | 4781 } } // namespace v8::internal |
4782 | 4782 |
4783 #endif // V8_TARGET_ARCH_ARM | 4783 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |