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/ia32/codegen-ia32.h" | 5 #include "src/ia32/codegen-ia32.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 // Code generators | 484 // Code generators |
485 | 485 |
486 #define __ ACCESS_MASM(masm) | 486 #define __ ACCESS_MASM(masm) |
487 | 487 |
488 void StringCharLoadGenerator::Generate(MacroAssembler* masm, | 488 void StringCharLoadGenerator::Generate(MacroAssembler* masm, |
489 Factory* factory, | 489 Factory* factory, |
490 Register string, | 490 Register string, |
491 Register index, | 491 Register index, |
492 Register result, | 492 Register result, |
493 Label* call_runtime) { | 493 Label* call_runtime) { |
| 494 Label indirect_string_loaded; |
| 495 __ bind(&indirect_string_loaded); |
| 496 |
494 // Fetch the instance type of the receiver into result register. | 497 // Fetch the instance type of the receiver into result register. |
495 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); | 498 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); |
496 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); | 499 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); |
497 | 500 |
498 // We need special handling for indirect strings. | 501 // We need special handling for indirect strings. |
499 Label check_sequential; | 502 Label check_sequential; |
500 __ test(result, Immediate(kIsIndirectStringMask)); | 503 __ test(result, Immediate(kIsIndirectStringMask)); |
501 __ j(zero, &check_sequential, Label::kNear); | 504 __ j(zero, &check_sequential, Label::kNear); |
502 | 505 |
503 // Dispatch on the indirect string shape: slice or cons. | 506 // Dispatch on the indirect string shape: slice or cons. |
504 Label cons_string; | 507 Label cons_string, thin_string; |
505 __ test(result, Immediate(kSlicedNotConsMask)); | 508 __ and_(result, Immediate(kStringRepresentationMask)); |
506 __ j(zero, &cons_string, Label::kNear); | 509 __ cmp(result, Immediate(kConsStringTag)); |
| 510 __ j(equal, &cons_string, Label::kNear); |
| 511 __ cmp(result, Immediate(kThinStringTag)); |
| 512 __ j(equal, &thin_string, Label::kNear); |
507 | 513 |
508 // Handle slices. | 514 // Handle slices. |
509 Label indirect_string_loaded; | |
510 __ mov(result, FieldOperand(string, SlicedString::kOffsetOffset)); | 515 __ mov(result, FieldOperand(string, SlicedString::kOffsetOffset)); |
511 __ SmiUntag(result); | 516 __ SmiUntag(result); |
512 __ add(index, result); | 517 __ add(index, result); |
513 __ mov(string, FieldOperand(string, SlicedString::kParentOffset)); | 518 __ mov(string, FieldOperand(string, SlicedString::kParentOffset)); |
514 __ jmp(&indirect_string_loaded, Label::kNear); | 519 __ jmp(&indirect_string_loaded); |
| 520 |
| 521 // Handle thin strings. |
| 522 __ bind(&thin_string); |
| 523 __ mov(string, FieldOperand(string, ThinString::kActualOffset)); |
| 524 __ jmp(&indirect_string_loaded); |
515 | 525 |
516 // Handle cons strings. | 526 // Handle cons strings. |
517 // Check whether the right hand side is the empty string (i.e. if | 527 // Check whether the right hand side is the empty string (i.e. if |
518 // this is really a flat string in a cons string). If that is not | 528 // this is really a flat string in a cons string). If that is not |
519 // the case we would rather go to the runtime system now to flatten | 529 // the case we would rather go to the runtime system now to flatten |
520 // the string. | 530 // the string. |
521 __ bind(&cons_string); | 531 __ bind(&cons_string); |
522 __ cmp(FieldOperand(string, ConsString::kSecondOffset), | 532 __ cmp(FieldOperand(string, ConsString::kSecondOffset), |
523 Immediate(factory->empty_string())); | 533 Immediate(factory->empty_string())); |
524 __ j(not_equal, call_runtime); | 534 __ j(not_equal, call_runtime); |
525 __ mov(string, FieldOperand(string, ConsString::kFirstOffset)); | 535 __ mov(string, FieldOperand(string, ConsString::kFirstOffset)); |
526 | 536 __ jmp(&indirect_string_loaded); |
527 __ bind(&indirect_string_loaded); | |
528 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); | |
529 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); | |
530 | 537 |
531 // Distinguish sequential and external strings. Only these two string | 538 // Distinguish sequential and external strings. Only these two string |
532 // representations can reach here (slices and flat cons strings have been | 539 // representations can reach here (slices and flat cons strings have been |
533 // reduced to the underlying sequential or external string). | 540 // reduced to the underlying sequential or external string). |
534 Label seq_string; | 541 Label seq_string; |
535 __ bind(&check_sequential); | 542 __ bind(&check_sequential); |
536 STATIC_ASSERT(kSeqStringTag == 0); | 543 STATIC_ASSERT(kSeqStringTag == 0); |
537 __ test(result, Immediate(kStringRepresentationMask)); | 544 __ test(result, Immediate(kStringRepresentationMask)); |
538 __ j(zero, &seq_string, Label::kNear); | 545 __ j(zero, &seq_string, Label::kNear); |
539 | 546 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 CodePatcher patcher(isolate, sequence, young_length); | 644 CodePatcher patcher(isolate, sequence, young_length); |
638 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); | 645 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); |
639 } | 646 } |
640 } | 647 } |
641 | 648 |
642 | 649 |
643 } // namespace internal | 650 } // namespace internal |
644 } // namespace v8 | 651 } // namespace v8 |
645 | 652 |
646 #endif // V8_TARGET_ARCH_IA32 | 653 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |