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 "src/x87/codegen-x87.h" | 5 #include "src/x87/codegen-x87.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/heap/heap.h" | 10 #include "src/heap/heap.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // Code generators | 211 // Code generators |
212 | 212 |
213 #define __ ACCESS_MASM(masm) | 213 #define __ ACCESS_MASM(masm) |
214 | 214 |
215 void StringCharLoadGenerator::Generate(MacroAssembler* masm, | 215 void StringCharLoadGenerator::Generate(MacroAssembler* masm, |
216 Factory* factory, | 216 Factory* factory, |
217 Register string, | 217 Register string, |
218 Register index, | 218 Register index, |
219 Register result, | 219 Register result, |
220 Label* call_runtime) { | 220 Label* call_runtime) { |
221 Label indirect_string_loaded; | |
222 __ bind(&indirect_string_loaded); | |
223 | |
224 // Fetch the instance type of the receiver into result register. | 221 // Fetch the instance type of the receiver into result register. |
225 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); | 222 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); |
226 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); | 223 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); |
227 | 224 |
228 // We need special handling for indirect strings. | 225 // We need special handling for indirect strings. |
229 Label check_sequential; | 226 Label check_sequential; |
230 __ test(result, Immediate(kIsIndirectStringMask)); | 227 __ test(result, Immediate(kIsIndirectStringMask)); |
231 __ j(zero, &check_sequential, Label::kNear); | 228 __ j(zero, &check_sequential, Label::kNear); |
232 | 229 |
233 // Dispatch on the indirect string shape: slice or cons. | 230 // Dispatch on the indirect string shape: slice or cons. |
234 Label cons_string, thin_string; | 231 Label cons_string; |
235 __ and_(result, Immediate(kStringRepresentationMask)); | 232 __ test(result, Immediate(kSlicedNotConsMask)); |
236 __ cmp(result, Immediate(kConsStringTag)); | 233 __ j(zero, &cons_string, Label::kNear); |
237 __ j(equal, &cons_string, Label::kNear); | |
238 __ cmp(result, Immediate(kThinStringTag)); | |
239 __ j(equal, &thin_string, Label::kNear); | |
240 | 234 |
241 // Handle slices. | 235 // Handle slices. |
| 236 Label indirect_string_loaded; |
242 __ mov(result, FieldOperand(string, SlicedString::kOffsetOffset)); | 237 __ mov(result, FieldOperand(string, SlicedString::kOffsetOffset)); |
243 __ SmiUntag(result); | 238 __ SmiUntag(result); |
244 __ add(index, result); | 239 __ add(index, result); |
245 __ mov(string, FieldOperand(string, SlicedString::kParentOffset)); | 240 __ mov(string, FieldOperand(string, SlicedString::kParentOffset)); |
246 __ jmp(&indirect_string_loaded); | 241 __ jmp(&indirect_string_loaded, Label::kNear); |
247 | |
248 // Handle thin strings. | |
249 __ bind(&thin_string); | |
250 __ mov(string, FieldOperand(string, ThinString::kActualOffset)); | |
251 __ jmp(&indirect_string_loaded); | |
252 | 242 |
253 // Handle cons strings. | 243 // Handle cons strings. |
254 // Check whether the right hand side is the empty string (i.e. if | 244 // Check whether the right hand side is the empty string (i.e. if |
255 // this is really a flat string in a cons string). If that is not | 245 // this is really a flat string in a cons string). If that is not |
256 // the case we would rather go to the runtime system now to flatten | 246 // the case we would rather go to the runtime system now to flatten |
257 // the string. | 247 // the string. |
258 __ bind(&cons_string); | 248 __ bind(&cons_string); |
259 __ cmp(FieldOperand(string, ConsString::kSecondOffset), | 249 __ cmp(FieldOperand(string, ConsString::kSecondOffset), |
260 Immediate(factory->empty_string())); | 250 Immediate(factory->empty_string())); |
261 __ j(not_equal, call_runtime); | 251 __ j(not_equal, call_runtime); |
262 __ mov(string, FieldOperand(string, ConsString::kFirstOffset)); | 252 __ mov(string, FieldOperand(string, ConsString::kFirstOffset)); |
263 __ jmp(&indirect_string_loaded); | 253 |
| 254 __ bind(&indirect_string_loaded); |
| 255 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); |
| 256 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); |
264 | 257 |
265 // Distinguish sequential and external strings. Only these two string | 258 // Distinguish sequential and external strings. Only these two string |
266 // representations can reach here (slices and flat cons strings have been | 259 // representations can reach here (slices and flat cons strings have been |
267 // reduced to the underlying sequential or external string). | 260 // reduced to the underlying sequential or external string). |
268 Label seq_string; | 261 Label seq_string; |
269 __ bind(&check_sequential); | 262 __ bind(&check_sequential); |
270 STATIC_ASSERT(kSeqStringTag == 0); | 263 STATIC_ASSERT(kSeqStringTag == 0); |
271 __ test(result, Immediate(kStringRepresentationMask)); | 264 __ test(result, Immediate(kStringRepresentationMask)); |
272 __ j(zero, &seq_string, Label::kNear); | 265 __ j(zero, &seq_string, Label::kNear); |
273 | 266 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 CodePatcher patcher(isolate, sequence, young_length); | 365 CodePatcher patcher(isolate, sequence, young_length); |
373 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); | 366 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); |
374 } | 367 } |
375 } | 368 } |
376 | 369 |
377 | 370 |
378 } // namespace internal | 371 } // namespace internal |
379 } // namespace v8 | 372 } // namespace v8 |
380 | 373 |
381 #endif // V8_TARGET_ARCH_X87 | 374 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |