| 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 2837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2848 Register heap_number_map, | 2848 Register heap_number_map, |
| 2849 Register scratch, | 2849 Register scratch, |
| 2850 Label* on_not_heap_number) { | 2850 Label* on_not_heap_number) { |
| 2851 ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | 2851 ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); |
| 2852 AssertIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); | 2852 AssertIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); |
| 2853 cmp(scratch, heap_number_map); | 2853 cmp(scratch, heap_number_map); |
| 2854 b(ne, on_not_heap_number); | 2854 b(ne, on_not_heap_number); |
| 2855 } | 2855 } |
| 2856 | 2856 |
| 2857 | 2857 |
| 2858 void MacroAssembler::LookupNumberStringCache(Register object, | |
| 2859 Register result, | |
| 2860 Register scratch1, | |
| 2861 Register scratch2, | |
| 2862 Register scratch3, | |
| 2863 Label* not_found) { | |
| 2864 // Use of registers. Register result is used as a temporary. | |
| 2865 Register number_string_cache = result; | |
| 2866 Register mask = scratch3; | |
| 2867 | |
| 2868 // Load the number string cache. | |
| 2869 LoadRoot(number_string_cache, Heap::kNumberStringCacheRootIndex); | |
| 2870 | |
| 2871 // Make the hash mask from the length of the number string cache. It | |
| 2872 // contains two elements (number and string) for each cache entry. | |
| 2873 ldr(mask, FieldMemOperand(number_string_cache, FixedArray::kLengthOffset)); | |
| 2874 // Divide length by two (length is a smi). | |
| 2875 mov(mask, Operand(mask, ASR, kSmiTagSize + 1)); | |
| 2876 sub(mask, mask, Operand(1)); // Make mask. | |
| 2877 | |
| 2878 // Calculate the entry in the number string cache. The hash value in the | |
| 2879 // number string cache for smis is just the smi value, and the hash for | |
| 2880 // doubles is the xor of the upper and lower words. See | |
| 2881 // Heap::GetNumberStringCache. | |
| 2882 Label is_smi; | |
| 2883 Label load_result_from_cache; | |
| 2884 JumpIfSmi(object, &is_smi); | |
| 2885 CheckMap(object, | |
| 2886 scratch1, | |
| 2887 Heap::kHeapNumberMapRootIndex, | |
| 2888 not_found, | |
| 2889 DONT_DO_SMI_CHECK); | |
| 2890 | |
| 2891 STATIC_ASSERT(8 == kDoubleSize); | |
| 2892 add(scratch1, | |
| 2893 object, | |
| 2894 Operand(HeapNumber::kValueOffset - kHeapObjectTag)); | |
| 2895 ldm(ia, scratch1, scratch1.bit() | scratch2.bit()); | |
| 2896 eor(scratch1, scratch1, Operand(scratch2)); | |
| 2897 and_(scratch1, scratch1, Operand(mask)); | |
| 2898 | |
| 2899 // Calculate address of entry in string cache: each entry consists | |
| 2900 // of two pointer sized fields. | |
| 2901 add(scratch1, | |
| 2902 number_string_cache, | |
| 2903 Operand(scratch1, LSL, kPointerSizeLog2 + 1)); | |
| 2904 | |
| 2905 Register probe = mask; | |
| 2906 ldr(probe, FieldMemOperand(scratch1, FixedArray::kHeaderSize)); | |
| 2907 JumpIfSmi(probe, not_found); | |
| 2908 sub(scratch2, object, Operand(kHeapObjectTag)); | |
| 2909 vldr(d0, scratch2, HeapNumber::kValueOffset); | |
| 2910 sub(probe, probe, Operand(kHeapObjectTag)); | |
| 2911 vldr(d1, probe, HeapNumber::kValueOffset); | |
| 2912 VFPCompareAndSetFlags(d0, d1); | |
| 2913 b(ne, not_found); // The cache did not contain this value. | |
| 2914 b(&load_result_from_cache); | |
| 2915 | |
| 2916 bind(&is_smi); | |
| 2917 Register scratch = scratch1; | |
| 2918 and_(scratch, mask, Operand(object, ASR, 1)); | |
| 2919 // Calculate address of entry in string cache: each entry consists | |
| 2920 // of two pointer sized fields. | |
| 2921 add(scratch, | |
| 2922 number_string_cache, | |
| 2923 Operand(scratch, LSL, kPointerSizeLog2 + 1)); | |
| 2924 | |
| 2925 // Check if the entry is the smi we are looking for. | |
| 2926 ldr(probe, FieldMemOperand(scratch, FixedArray::kHeaderSize)); | |
| 2927 cmp(object, probe); | |
| 2928 b(ne, not_found); | |
| 2929 | |
| 2930 // Get the result from the cache. | |
| 2931 bind(&load_result_from_cache); | |
| 2932 ldr(result, FieldMemOperand(scratch, FixedArray::kHeaderSize + kPointerSize)); | |
| 2933 IncrementCounter(isolate()->counters()->number_to_string_native(), | |
| 2934 1, | |
| 2935 scratch1, | |
| 2936 scratch2); | |
| 2937 } | |
| 2938 | |
| 2939 | |
| 2940 void MacroAssembler::JumpIfNonSmisNotBothSequentialOneByteStrings( | 2858 void MacroAssembler::JumpIfNonSmisNotBothSequentialOneByteStrings( |
| 2941 Register first, Register second, Register scratch1, Register scratch2, | 2859 Register first, Register second, Register scratch1, Register scratch2, |
| 2942 Label* failure) { | 2860 Label* failure) { |
| 2943 // Test that both first and second are sequential one-byte strings. | 2861 // Test that both first and second are sequential one-byte strings. |
| 2944 // Assume that they are non-smis. | 2862 // Assume that they are non-smis. |
| 2945 ldr(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); | 2863 ldr(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); |
| 2946 ldr(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); | 2864 ldr(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); |
| 2947 ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); | 2865 ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); |
| 2948 ldrb(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset)); | 2866 ldrb(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset)); |
| 2949 | 2867 |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3792 } | 3710 } |
| 3793 } | 3711 } |
| 3794 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); | 3712 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); |
| 3795 add(result, result, Operand(dividend, LSR, 31)); | 3713 add(result, result, Operand(dividend, LSR, 31)); |
| 3796 } | 3714 } |
| 3797 | 3715 |
| 3798 } // namespace internal | 3716 } // namespace internal |
| 3799 } // namespace v8 | 3717 } // namespace v8 |
| 3800 | 3718 |
| 3801 #endif // V8_TARGET_ARCH_ARM | 3719 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |