| 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 3595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3606 // Any other flat string must be a flat ascii string. | 3606 // Any other flat string must be a flat ascii string. |
| 3607 __ and_(ebx, Immediate(kIsNotStringMask | kStringRepresentationMask)); | 3607 __ and_(ebx, Immediate(kIsNotStringMask | kStringRepresentationMask)); |
| 3608 __ j(zero, &seq_ascii_string, Label::kNear); | 3608 __ j(zero, &seq_ascii_string, Label::kNear); |
| 3609 | 3609 |
| 3610 // Check for flat cons string or sliced string. | 3610 // Check for flat cons string or sliced string. |
| 3611 // A flat cons string is a cons string where the second part is the empty | 3611 // A flat cons string is a cons string where the second part is the empty |
| 3612 // string. In that case the subject string is just the first part of the cons | 3612 // string. In that case the subject string is just the first part of the cons |
| 3613 // string. Also in this case the first part of the cons string is known to be | 3613 // string. Also in this case the first part of the cons string is known to be |
| 3614 // a sequential string or an external string. | 3614 // a sequential string or an external string. |
| 3615 // In the case of a sliced string its offset has to be taken into account. | 3615 // In the case of a sliced string its offset has to be taken into account. |
| 3616 Label cons_string, check_encoding; | 3616 Label cons_string, external_string, check_encoding; |
| 3617 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 3617 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
| 3618 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 3618 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
| 3619 __ cmp(ebx, Immediate(kExternalStringTag)); | 3619 __ cmp(ebx, Immediate(kExternalStringTag)); |
| 3620 __ j(less, &cons_string); | 3620 __ j(less, &cons_string); |
| 3621 __ j(equal, &runtime); | 3621 __ j(equal, &external_string); |
| 3622 | 3622 |
| 3623 // String is sliced. | 3623 // String is sliced. |
| 3624 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset)); | 3624 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset)); |
| 3625 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset)); | 3625 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset)); |
| 3626 // edi: offset of sliced string, smi-tagged. | 3626 // edi: offset of sliced string, smi-tagged. |
| 3627 // eax: parent string. | 3627 // eax: parent string. |
| 3628 __ jmp(&check_encoding, Label::kNear); | 3628 __ jmp(&check_encoding, Label::kNear); |
| 3629 // String is a cons string, check whether it is flat. | 3629 // String is a cons string, check whether it is flat. |
| 3630 __ bind(&cons_string); | 3630 __ bind(&cons_string); |
| 3631 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), factory->empty_string()); | 3631 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), factory->empty_string()); |
| 3632 __ j(not_equal, &runtime); | 3632 __ j(not_equal, &runtime); |
| 3633 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset)); | 3633 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset)); |
| 3634 __ bind(&check_encoding); | 3634 __ bind(&check_encoding); |
| 3635 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 3635 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 3636 // eax: first part of cons string or parent of sliced string. | 3636 // eax: first part of cons string or parent of sliced string. |
| 3637 // ebx: map of first part of cons string or map of parent of sliced string. | 3637 // ebx: map of first part of cons string or map of parent of sliced string. |
| 3638 // Is first part of cons or parent of slice a flat two byte string? | 3638 // Is first part of cons or parent of slice a flat two byte string? |
| 3639 __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), | 3639 __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), |
| 3640 kStringRepresentationMask | kStringEncodingMask); | 3640 kStringRepresentationMask | kStringEncodingMask); |
| 3641 STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0); | 3641 STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0); |
| 3642 __ j(zero, &seq_two_byte_string, Label::kNear); | 3642 __ j(zero, &seq_two_byte_string, Label::kNear); |
| 3643 // Any other flat string must be ascii. | 3643 // Any other flat string must be sequential ascii or external. |
| 3644 __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), | 3644 __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), |
| 3645 kStringRepresentationMask); | 3645 kStringRepresentationMask); |
| 3646 __ j(not_zero, &runtime); | 3646 __ j(not_zero, &external_string); |
| 3647 | 3647 |
| 3648 __ bind(&seq_ascii_string); | 3648 __ bind(&seq_ascii_string); |
| 3649 // eax: subject string (flat ascii) | 3649 // eax: subject string (flat ascii) |
| 3650 // ecx: RegExp data (FixedArray) | 3650 // ecx: RegExp data (FixedArray) |
| 3651 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataAsciiCodeOffset)); | 3651 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataAsciiCodeOffset)); |
| 3652 __ Set(ecx, Immediate(1)); // Type is ascii. | 3652 __ Set(ecx, Immediate(1)); // Type is ascii. |
| 3653 __ jmp(&check_code, Label::kNear); | 3653 __ jmp(&check_code, Label::kNear); |
| 3654 | 3654 |
| 3655 __ bind(&seq_two_byte_string); | 3655 __ bind(&seq_two_byte_string); |
| 3656 // eax: subject string (flat two byte) | 3656 // eax: subject string (flat two byte) |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3857 times_pointer_size, | 3857 times_pointer_size, |
| 3858 RegExpImpl::kFirstCaptureOffset), | 3858 RegExpImpl::kFirstCaptureOffset), |
| 3859 edi); | 3859 edi); |
| 3860 __ jmp(&next_capture); | 3860 __ jmp(&next_capture); |
| 3861 __ bind(&done); | 3861 __ bind(&done); |
| 3862 | 3862 |
| 3863 // Return last match info. | 3863 // Return last match info. |
| 3864 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); | 3864 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); |
| 3865 __ ret(4 * kPointerSize); | 3865 __ ret(4 * kPointerSize); |
| 3866 | 3866 |
| 3867 // String is external. |
| 3868 // eax: subject string (expected to be external) |
| 3869 // ebx: scratch |
| 3870 __ bind(&external_string); |
| 3871 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 3872 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
| 3873 if (FLAG_debug_code) { |
| 3874 // Assert that we do not have a cons or slice (indirect strings) here. |
| 3875 // Sequential strings have already been ruled out. |
| 3876 __ test_b(ebx, kIsIndirectStringMask); |
| 3877 __ Assert(zero, "external string expected, but not found"); |
| 3878 } |
| 3879 // Rule out short external strings. |
| 3880 STATIC_CHECK(kShortExternalStringTag != 0); |
| 3881 __ test_b(ebx, kShortExternalStringMask); |
| 3882 __ j(not_zero, &runtime); |
| 3883 __ mov(eax, FieldOperand(eax, ExternalString::kResourceDataOffset)); |
| 3884 // Move the pointer so that offset-wise, it looks like a sequential string. |
| 3885 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize); |
| 3886 __ sub(eax, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 3887 STATIC_ASSERT(kTwoByteStringTag == 0); |
| 3888 __ test_b(ebx, kStringEncodingMask); |
| 3889 __ j(not_zero, &seq_ascii_string); |
| 3890 __ jmp(&seq_two_byte_string); |
| 3891 |
| 3867 // Do the runtime call to execute the regexp. | 3892 // Do the runtime call to execute the regexp. |
| 3868 __ bind(&runtime); | 3893 __ bind(&runtime); |
| 3869 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); | 3894 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); |
| 3870 #endif // V8_INTERPRETED_REGEXP | 3895 #endif // V8_INTERPRETED_REGEXP |
| 3871 } | 3896 } |
| 3872 | 3897 |
| 3873 | 3898 |
| 3874 void RegExpConstructResultStub::Generate(MacroAssembler* masm) { | 3899 void RegExpConstructResultStub::Generate(MacroAssembler* masm) { |
| 3875 const int kMaxInlineLength = 100; | 3900 const int kMaxInlineLength = 100; |
| 3876 Label slowcase; | 3901 Label slowcase; |
| (...skipping 3247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7124 false); | 7149 false); |
| 7125 __ pop(edx); | 7150 __ pop(edx); |
| 7126 __ ret(0); | 7151 __ ret(0); |
| 7127 } | 7152 } |
| 7128 | 7153 |
| 7129 #undef __ | 7154 #undef __ |
| 7130 | 7155 |
| 7131 } } // namespace v8::internal | 7156 } } // namespace v8::internal |
| 7132 | 7157 |
| 7133 #endif // V8_TARGET_ARCH_IA32 | 7158 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |