OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 } | 525 } |
526 | 526 |
527 | 527 |
528 void StringCharLoadGenerator::Generate(MacroAssembler* masm, | 528 void StringCharLoadGenerator::Generate(MacroAssembler* masm, |
529 Factory* factory, | 529 Factory* factory, |
530 Register string, | 530 Register string, |
531 Register index, | 531 Register index, |
532 Register result, | 532 Register result, |
533 Label* call_runtime) { | 533 Label* call_runtime) { |
534 // Fetch the instance type of the receiver into result register. | 534 // Fetch the instance type of the receiver into result register. |
535 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); | 535 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); |
Lasse Reichstein
2011/11/23 08:43:20
We're absolutely sure that only strings reach here
Yang
2011/11/23 09:58:48
Yes.
| |
536 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); | 536 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); |
537 | 537 |
538 // We need special handling for indirect strings. | 538 // We need special handling for indirect strings. |
539 Label check_sequential; | 539 Label check_sequential; |
540 __ test(result, Immediate(kIsIndirectStringMask)); | 540 __ test(result, Immediate(kIsIndirectStringMask)); |
541 __ j(zero, &check_sequential); | 541 __ j(zero, &check_sequential); |
542 | 542 |
543 // Dispatch on the indirect string shape: slice or cons. | 543 // Dispatch on the indirect string shape: slice or cons. |
544 Label cons_string; | 544 Label cons_string; |
545 __ test(result, Immediate(kSlicedNotConsMask)); | 545 __ test(result, Immediate(kSlicedNotConsMask)); |
(...skipping 10 matching lines...) Expand all Loading... | |
556 // Handle external strings. | 556 // Handle external strings. |
557 Label external_string, ascii_external, done; | 557 Label external_string, ascii_external, done; |
558 __ bind(&external_string); | 558 __ bind(&external_string); |
559 if (FLAG_debug_code) { | 559 if (FLAG_debug_code) { |
560 // Assert that we do not have a cons or slice (indirect strings) here. | 560 // Assert that we do not have a cons or slice (indirect strings) here. |
561 // Sequential strings have already been ruled out. | 561 // Sequential strings have already been ruled out. |
562 __ test(result, Immediate(kIsIndirectStringMask)); | 562 __ test(result, Immediate(kIsIndirectStringMask)); |
563 __ Assert(zero, "external string expected, but not found"); | 563 __ Assert(zero, "external string expected, but not found"); |
564 } | 564 } |
565 __ mov(result, FieldOperand(string, ExternalString::kResourceDataOffset)); | 565 __ mov(result, FieldOperand(string, ExternalString::kResourceDataOffset)); |
566 // Assert that the external string has not been finalized yet. | |
567 __ test(result, result); | |
568 __ j(zero, call_runtime); | |
569 Register scratch = string; | 566 Register scratch = string; |
570 __ mov(scratch, FieldOperand(string, HeapObject::kMapOffset)); | 567 __ mov(scratch, FieldOperand(string, HeapObject::kMapOffset)); |
571 __ cmp(scratch, Immediate(factory->external_ascii_string_map())); | 568 __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); |
572 __ j(equal, &ascii_external, Label::kNear); | 569 // Rule out short external strings. |
573 __ cmp(scratch, Immediate(factory->external_ascii_symbol_map())); | 570 STATIC_CHECK(kShortExternalStringTag != 0); |
574 __ j(equal, &ascii_external, Label::kNear); | 571 __ test_b(scratch, kShortExternalStringTag); |
Lasse Reichstein
2011/11/23 08:43:20
Test with kShortExternalStringMask instead of ...T
Yang
2011/11/23 09:58:48
Done.
| |
572 __ j(not_zero, call_runtime); | |
573 // Check encoding. | |
574 STATIC_ASSERT(kTwoByteStringTag == 0); | |
575 __ test_b(scratch, kStringEncodingMask); | |
576 __ j(not_equal, &ascii_external, Label::kNear); | |
575 // Two-byte string. | 577 // Two-byte string. |
576 __ movzx_w(result, Operand(result, index, times_2, 0)); | 578 __ movzx_w(result, Operand(result, index, times_2, 0)); |
577 __ jmp(&done); | 579 __ jmp(&done); |
578 __ bind(&ascii_external); | 580 __ bind(&ascii_external); |
579 // Ascii string. | 581 // Ascii string. |
580 __ movzx_b(result, Operand(result, index, times_1, 0)); | 582 __ movzx_b(result, Operand(result, index, times_1, 0)); |
581 __ jmp(&done); | 583 __ jmp(&done); |
582 | 584 |
583 // Handle conses. | 585 // Handle conses. |
584 // Check whether the right hand side is the empty string (i.e. if | 586 // Check whether the right hand side is the empty string (i.e. if |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 times_1, | 631 times_1, |
630 SeqAsciiString::kHeaderSize)); | 632 SeqAsciiString::kHeaderSize)); |
631 __ bind(&done); | 633 __ bind(&done); |
632 } | 634 } |
633 | 635 |
634 #undef __ | 636 #undef __ |
635 | 637 |
636 } } // namespace v8::internal | 638 } } // namespace v8::internal |
637 | 639 |
638 #endif // V8_TARGET_ARCH_IA32 | 640 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |