OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 8583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8594 __ j(not_equal, &runtime); | 8594 __ j(not_equal, &runtime); |
8595 // Check that the last match info has space for the capture registers and the | 8595 // Check that the last match info has space for the capture registers and the |
8596 // additional information. Ensure no overflow in add. | 8596 // additional information. Ensure no overflow in add. |
8597 ASSERT(FixedArray::kMaxLength < kMaxInt - FixedArray::kLengthOffset); | 8597 ASSERT(FixedArray::kMaxLength < kMaxInt - FixedArray::kLengthOffset); |
8598 __ movq(rax, FieldOperand(rbx, FixedArray::kLengthOffset)); | 8598 __ movq(rax, FieldOperand(rbx, FixedArray::kLengthOffset)); |
8599 __ SmiToInteger32(rax, rax); | 8599 __ SmiToInteger32(rax, rax); |
8600 __ addl(rdx, Immediate(RegExpImpl::kLastMatchOverhead)); | 8600 __ addl(rdx, Immediate(RegExpImpl::kLastMatchOverhead)); |
8601 __ cmpl(rdx, rax); | 8601 __ cmpl(rdx, rax); |
8602 __ j(greater, &runtime); | 8602 __ j(greater, &runtime); |
8603 | 8603 |
8604 // ecx: RegExp data (FixedArray) | 8604 // rcx: RegExp data (FixedArray) |
8605 // Check the representation and encoding of the subject string. | 8605 // Check the representation and encoding of the subject string. |
8606 Label seq_string, seq_two_byte_string, check_code; | 8606 Label seq_ascii_string, seq_two_byte_string, check_code; |
8607 const int kStringRepresentationEncodingMask = | |
8608 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask; | |
8609 __ movq(rax, Operand(rsp, kSubjectOffset)); | 8607 __ movq(rax, Operand(rsp, kSubjectOffset)); |
8610 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); | 8608 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
8611 __ movzxbl(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset)); | 8609 __ movzxbl(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset)); |
8612 __ andb(rbx, Immediate(kStringRepresentationEncodingMask)); | 8610 // First check for flat two byte string. |
8613 // First check for sequential string. | 8611 __ andb(rbx, Immediate( |
8614 ASSERT_EQ(0, kStringTag); | 8612 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask)); |
8615 ASSERT_EQ(0, kSeqStringTag); | 8613 ASSERT_EQ(0, kStringTag | kSeqStringTag | kTwoByteStringTag); |
| 8614 __ j(zero, &seq_two_byte_string); |
| 8615 // Any other flat string must be a flat ascii string. |
8616 __ testb(rbx, Immediate(kIsNotStringMask | kStringRepresentationMask)); | 8616 __ testb(rbx, Immediate(kIsNotStringMask | kStringRepresentationMask)); |
8617 __ j(zero, &seq_string); | 8617 __ j(zero, &seq_ascii_string); |
8618 | 8618 |
8619 // Check for flat cons string. | 8619 // Check for flat cons string. |
8620 // A flat cons string is a cons string where the second part is the empty | 8620 // A flat cons string is a cons string where the second part is the empty |
8621 // string. In that case the subject string is just the first part of the cons | 8621 // string. In that case the subject string is just the first part of the cons |
8622 // string. Also in this case the first part of the cons string is known to be | 8622 // string. Also in this case the first part of the cons string is known to be |
8623 // a sequential string or an external string. | 8623 // a sequential string or an external string. |
8624 __ andb(rbx, Immediate(kStringRepresentationMask)); | 8624 ASSERT(kExternalStringTag !=0); |
8625 __ cmpb(rbx, Immediate(kConsStringTag)); | 8625 ASSERT_EQ(0, kConsStringTag & kExternalStringTag); |
8626 __ j(not_equal, &runtime); | 8626 __ testb(rbx, Immediate(kIsNotStringMask | kExternalStringTag)); |
| 8627 __ j(not_zero, &runtime); |
| 8628 // String is a cons string. |
8627 __ movq(rdx, FieldOperand(rax, ConsString::kSecondOffset)); | 8629 __ movq(rdx, FieldOperand(rax, ConsString::kSecondOffset)); |
8628 __ Cmp(rdx, Factory::empty_string()); | 8630 __ Cmp(rdx, Factory::empty_string()); |
8629 __ j(not_equal, &runtime); | 8631 __ j(not_equal, &runtime); |
8630 __ movq(rax, FieldOperand(rax, ConsString::kFirstOffset)); | 8632 __ movq(rax, FieldOperand(rax, ConsString::kFirstOffset)); |
8631 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); | 8633 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
8632 __ movzxbl(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset)); | 8634 // String is a cons string with empty second part. |
8633 ASSERT_EQ(0, kSeqStringTag); | 8635 // eax: first part of cons string. |
8634 __ testb(rbx, Immediate(kStringRepresentationMask)); | 8636 // ebx: map of first part of cons string. |
| 8637 // Is first part a flat two byte string? |
| 8638 __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), |
| 8639 Immediate(kStringRepresentationMask | kStringEncodingMask)); |
| 8640 ASSERT_EQ(0, kSeqStringTag | kTwoByteStringTag); |
| 8641 __ j(zero, &seq_two_byte_string); |
| 8642 // Any other flat string must be ascii. |
| 8643 __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), |
| 8644 Immediate(kStringRepresentationMask)); |
8635 __ j(not_zero, &runtime); | 8645 __ j(not_zero, &runtime); |
8636 __ andb(rbx, Immediate(kStringRepresentationEncodingMask)); | |
8637 | 8646 |
8638 __ bind(&seq_string); | 8647 __ bind(&seq_ascii_string); |
8639 // rax: subject string (sequential either ascii to two byte) | 8648 // rax: subject string (sequential ascii) |
8640 // rbx: suject string type & kStringRepresentationEncodingMask | |
8641 // rcx: RegExp data (FixedArray) | 8649 // rcx: RegExp data (FixedArray) |
8642 // Check that the irregexp code has been generated for an ascii string. If | |
8643 // it has, the field contains a code object otherwise it contains the hole. | |
8644 const int kSeqTwoByteString = kStringTag | kSeqStringTag | kTwoByteStringTag; | |
8645 __ cmpb(rbx, Immediate(kSeqTwoByteString)); | |
8646 __ j(equal, &seq_two_byte_string); | |
8647 if (FLAG_debug_code) { | |
8648 __ cmpb(rbx, Immediate(kStringTag | kSeqStringTag | kAsciiStringTag)); | |
8649 __ Check(equal, "Expected sequential ascii string"); | |
8650 } | |
8651 __ movq(r12, FieldOperand(rcx, JSRegExp::kDataAsciiCodeOffset)); | 8650 __ movq(r12, FieldOperand(rcx, JSRegExp::kDataAsciiCodeOffset)); |
8652 __ Set(rdi, 1); // Type is ascii. | 8651 __ Set(rdi, 1); // Type is ascii. |
8653 __ jmp(&check_code); | 8652 __ jmp(&check_code); |
8654 | 8653 |
8655 __ bind(&seq_two_byte_string); | 8654 __ bind(&seq_two_byte_string); |
8656 // rax: subject string | 8655 // rax: subject string (flat two-byte) |
8657 // rcx: RegExp data (FixedArray) | 8656 // rcx: RegExp data (FixedArray) |
8658 __ movq(r12, FieldOperand(rcx, JSRegExp::kDataUC16CodeOffset)); | 8657 __ movq(r12, FieldOperand(rcx, JSRegExp::kDataUC16CodeOffset)); |
8659 __ Set(rdi, 0); // Type is two byte. | 8658 __ Set(rdi, 0); // Type is two byte. |
8660 | 8659 |
8661 __ bind(&check_code); | 8660 __ bind(&check_code); |
8662 // Check that the irregexp code has been generated for the actual string | 8661 // Check that the irregexp code has been generated for the actual string |
8663 // encoding. If it has, the field contains a code object otherwise it contains | 8662 // encoding. If it has, the field contains a code object otherwise it contains |
8664 // the hole. | 8663 // the hole. |
8665 __ CmpObjectType(r12, CODE_TYPE, kScratchRegister); | 8664 __ CmpObjectType(r12, CODE_TYPE, kScratchRegister); |
8666 __ j(not_equal, &runtime); | 8665 __ j(not_equal, &runtime); |
(...skipping 3279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11946 } | 11945 } |
11947 | 11946 |
11948 #endif | 11947 #endif |
11949 | 11948 |
11950 | 11949 |
11951 #undef __ | 11950 #undef __ |
11952 | 11951 |
11953 } } // namespace v8::internal | 11952 } } // namespace v8::internal |
11954 | 11953 |
11955 #endif // V8_TARGET_ARCH_X64 | 11954 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |