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/arm64/codegen-arm64.h" | 5 #include "src/arm64/codegen-arm64.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
8 | 8 |
9 #include "src/arm64/simulator-arm64.h" | 9 #include "src/arm64/simulator-arm64.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 void StringCharLoadGenerator::Generate(MacroAssembler* masm, | 96 void StringCharLoadGenerator::Generate(MacroAssembler* masm, |
97 Register string, | 97 Register string, |
98 Register index, | 98 Register index, |
99 Register result, | 99 Register result, |
100 Label* call_runtime) { | 100 Label* call_runtime) { |
101 DCHECK(string.Is64Bits() && index.Is32Bits() && result.Is64Bits()); | 101 DCHECK(string.Is64Bits() && index.Is32Bits() && result.Is64Bits()); |
| 102 Label indirect_string_loaded; |
| 103 __ Bind(&indirect_string_loaded); |
| 104 |
102 // Fetch the instance type of the receiver into result register. | 105 // Fetch the instance type of the receiver into result register. |
103 __ Ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); | 106 __ Ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
104 __ Ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); | 107 __ Ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
105 | 108 |
106 // We need special handling for indirect strings. | 109 // We need special handling for indirect strings. |
107 Label check_sequential; | 110 Label check_sequential; |
108 __ TestAndBranchIfAllClear(result, kIsIndirectStringMask, &check_sequential); | 111 __ TestAndBranchIfAllClear(result, kIsIndirectStringMask, &check_sequential); |
109 | 112 |
110 // Dispatch on the indirect string shape: slice or cons. | 113 // Dispatch on the indirect string shape: slice or cons. |
111 Label cons_string; | 114 Label cons_string, thin_string; |
112 __ TestAndBranchIfAllClear(result, kSlicedNotConsMask, &cons_string); | 115 __ And(result, result, kStringRepresentationMask); |
| 116 __ Cmp(result, kConsStringTag); |
| 117 __ B(eq, &cons_string); |
| 118 __ Cmp(result, kThinStringTag); |
| 119 __ B(eq, &thin_string); |
113 | 120 |
114 // Handle slices. | 121 // Handle slices. |
115 Label indirect_string_loaded; | |
116 __ Ldr(result.W(), | 122 __ Ldr(result.W(), |
117 UntagSmiFieldMemOperand(string, SlicedString::kOffsetOffset)); | 123 UntagSmiFieldMemOperand(string, SlicedString::kOffsetOffset)); |
118 __ Ldr(string, FieldMemOperand(string, SlicedString::kParentOffset)); | 124 __ Ldr(string, FieldMemOperand(string, SlicedString::kParentOffset)); |
119 __ Add(index, index, result.W()); | 125 __ Add(index, index, result.W()); |
120 __ B(&indirect_string_loaded); | 126 __ B(&indirect_string_loaded); |
121 | 127 |
| 128 // Handle thin strings. |
| 129 __ Bind(&thin_string); |
| 130 __ Ldr(string, FieldMemOperand(string, ThinString::kActualOffset)); |
| 131 __ B(&indirect_string_loaded); |
| 132 |
122 // Handle cons strings. | 133 // Handle cons strings. |
123 // Check whether the right hand side is the empty string (i.e. if | 134 // Check whether the right hand side is the empty string (i.e. if |
124 // this is really a flat string in a cons string). If that is not | 135 // this is really a flat string in a cons string). If that is not |
125 // the case we would rather go to the runtime system now to flatten | 136 // the case we would rather go to the runtime system now to flatten |
126 // the string. | 137 // the string. |
127 __ Bind(&cons_string); | 138 __ Bind(&cons_string); |
128 __ Ldr(result, FieldMemOperand(string, ConsString::kSecondOffset)); | 139 __ Ldr(result, FieldMemOperand(string, ConsString::kSecondOffset)); |
129 __ JumpIfNotRoot(result, Heap::kempty_stringRootIndex, call_runtime); | 140 __ JumpIfNotRoot(result, Heap::kempty_stringRootIndex, call_runtime); |
130 // Get the first of the two strings and load its instance type. | 141 // Get the first of the two strings and load its instance type. |
131 __ Ldr(string, FieldMemOperand(string, ConsString::kFirstOffset)); | 142 __ Ldr(string, FieldMemOperand(string, ConsString::kFirstOffset)); |
132 | 143 __ B(&indirect_string_loaded); |
133 __ Bind(&indirect_string_loaded); | |
134 __ Ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); | |
135 __ Ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); | |
136 | 144 |
137 // Distinguish sequential and external strings. Only these two string | 145 // Distinguish sequential and external strings. Only these two string |
138 // representations can reach here (slices and flat cons strings have been | 146 // representations can reach here (slices and flat cons strings have been |
139 // reduced to the underlying sequential or external string). | 147 // reduced to the underlying sequential or external string). |
140 Label external_string, check_encoding; | 148 Label external_string, check_encoding; |
141 __ Bind(&check_sequential); | 149 __ Bind(&check_sequential); |
142 STATIC_ASSERT(kSeqStringTag == 0); | 150 STATIC_ASSERT(kSeqStringTag == 0); |
143 __ TestAndBranchIfAnySet(result, kStringRepresentationMask, &external_string); | 151 __ TestAndBranchIfAnySet(result, kStringRepresentationMask, &external_string); |
144 | 152 |
145 // Prepare sequential strings | 153 // Prepare sequential strings |
(...skipping 29 matching lines...) Expand all Loading... |
175 __ Ldrb(result, MemOperand(string, index, SXTW)); | 183 __ Ldrb(result, MemOperand(string, index, SXTW)); |
176 __ Bind(&done); | 184 __ Bind(&done); |
177 } | 185 } |
178 | 186 |
179 #undef __ | 187 #undef __ |
180 | 188 |
181 } // namespace internal | 189 } // namespace internal |
182 } // namespace v8 | 190 } // namespace v8 |
183 | 191 |
184 #endif // V8_TARGET_ARCH_ARM64 | 192 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |