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