| 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 #if V8_TARGET_ARCH_ARM | 5 #if V8_TARGET_ARCH_ARM |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 1574 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); |
| 1575 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); | 1575 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); |
| 1576 __ cmp(r2, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); | 1576 __ cmp(r2, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); |
| 1577 __ b(hi, &runtime); | 1577 __ b(hi, &runtime); |
| 1578 | 1578 |
| 1579 // Reset offset for possibly sliced string. | 1579 // Reset offset for possibly sliced string. |
| 1580 __ mov(r9, Operand::Zero()); | 1580 __ mov(r9, Operand::Zero()); |
| 1581 __ ldr(subject, MemOperand(sp, kSubjectOffset)); | 1581 __ ldr(subject, MemOperand(sp, kSubjectOffset)); |
| 1582 __ JumpIfSmi(subject, &runtime); | 1582 __ JumpIfSmi(subject, &runtime); |
| 1583 __ mov(r3, subject); // Make a copy of the original subject string. | 1583 __ mov(r3, subject); // Make a copy of the original subject string. |
| 1584 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | |
| 1585 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | |
| 1586 // subject: subject string | 1584 // subject: subject string |
| 1587 // r3: subject string | 1585 // r3: subject string |
| 1588 // r0: subject string instance type | |
| 1589 // regexp_data: RegExp data (FixedArray) | 1586 // regexp_data: RegExp data (FixedArray) |
| 1590 // Handle subject string according to its encoding and representation: | 1587 // Handle subject string according to its encoding and representation: |
| 1591 // (1) Sequential string? If yes, go to (5). | 1588 // (1) Sequential string? If yes, go to (4). |
| 1592 // (2) Anything but sequential or cons? If yes, go to (6). | 1589 // (2) Sequential or cons? If not, go to (5). |
| 1593 // (3) Cons string. If the string is flat, replace subject with first string. | 1590 // (3) Cons string. If the string is flat, replace subject with first string |
| 1594 // Otherwise bailout. | 1591 // and go to (1). Otherwise bail out to runtime. |
| 1595 // (4) Is subject external? If yes, go to (7). | 1592 // (4) Sequential string. Load regexp code according to encoding. |
| 1596 // (5) Sequential string. Load regexp code according to encoding. | |
| 1597 // (E) Carry on. | 1593 // (E) Carry on. |
| 1598 /// [...] | 1594 /// [...] |
| 1599 | 1595 |
| 1600 // Deferred code at the end of the stub: | 1596 // Deferred code at the end of the stub: |
| 1601 // (6) Not a long external string? If yes, go to (8). | 1597 // (5) Long external string? If not, go to (7). |
| 1602 // (7) External string. Make it, offset-wise, look like a sequential string. | 1598 // (6) External string. Make it, offset-wise, look like a sequential string. |
| 1603 // Go to (5). | 1599 // Go to (4). |
| 1604 // (8) Short external string or not a string? If yes, bail out to runtime. | 1600 // (7) Short external string or not a string? If yes, bail out to runtime. |
| 1605 // (9) Sliced string. Replace subject with parent. Go to (4). | 1601 // (8) Sliced string. Replace subject with parent. Go to (1). |
| 1606 | 1602 |
| 1607 Label seq_string /* 5 */, external_string /* 7 */, | 1603 Label seq_string /* 4 */, external_string /* 6 */, check_underlying /* 1 */, |
| 1608 check_underlying /* 4 */, not_seq_nor_cons /* 6 */, | 1604 not_seq_nor_cons /* 5 */, not_long_external /* 7 */; |
| 1609 not_long_external /* 8 */; | |
| 1610 | 1605 |
| 1611 // (1) Sequential string? If yes, go to (5). | 1606 __ bind(&check_underlying); |
| 1607 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); |
| 1608 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); |
| 1609 |
| 1610 // (1) Sequential string? If yes, go to (4). |
| 1612 __ and_(r1, | 1611 __ and_(r1, |
| 1613 r0, | 1612 r0, |
| 1614 Operand(kIsNotStringMask | | 1613 Operand(kIsNotStringMask | |
| 1615 kStringRepresentationMask | | 1614 kStringRepresentationMask | |
| 1616 kShortExternalStringMask), | 1615 kShortExternalStringMask), |
| 1617 SetCC); | 1616 SetCC); |
| 1618 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); | 1617 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); |
| 1619 __ b(eq, &seq_string); // Go to (5). | 1618 __ b(eq, &seq_string); // Go to (4). |
| 1620 | 1619 |
| 1621 // (2) Anything but sequential or cons? If yes, go to (6). | 1620 // (2) Sequential or cons? If not, go to (5). |
| 1622 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 1621 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
| 1623 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 1622 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
| 1624 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); | 1623 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); |
| 1625 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); | 1624 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); |
| 1626 __ cmp(r1, Operand(kExternalStringTag)); | 1625 __ cmp(r1, Operand(kExternalStringTag)); |
| 1627 __ b(ge, ¬_seq_nor_cons); // Go to (6). | 1626 __ b(ge, ¬_seq_nor_cons); // Go to (5). |
| 1628 | 1627 |
| 1629 // (3) Cons string. Check that it's flat. | 1628 // (3) Cons string. Check that it's flat. |
| 1630 // Replace subject with first string and reload instance type. | 1629 // Replace subject with first string and reload instance type. |
| 1631 __ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset)); | 1630 __ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset)); |
| 1632 __ CompareRoot(r0, Heap::kempty_stringRootIndex); | 1631 __ CompareRoot(r0, Heap::kempty_stringRootIndex); |
| 1633 __ b(ne, &runtime); | 1632 __ b(ne, &runtime); |
| 1634 __ ldr(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); | 1633 __ ldr(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); |
| 1634 __ jmp(&check_underlying); |
| 1635 | 1635 |
| 1636 // (4) Is subject external? If yes, go to (7). | 1636 // (4) Sequential string. Load regexp code according to encoding. |
| 1637 __ bind(&check_underlying); | |
| 1638 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | |
| 1639 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | |
| 1640 STATIC_ASSERT(kSeqStringTag == 0); | |
| 1641 __ tst(r0, Operand(kStringRepresentationMask)); | |
| 1642 // The underlying external string is never a short external string. | |
| 1643 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); | |
| 1644 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); | |
| 1645 __ b(ne, &external_string); // Go to (7). | |
| 1646 | |
| 1647 // (5) Sequential string. Load regexp code according to encoding. | |
| 1648 __ bind(&seq_string); | 1637 __ bind(&seq_string); |
| 1649 // subject: sequential subject string (or look-alike, external string) | 1638 // subject: sequential subject string (or look-alike, external string) |
| 1650 // r3: original subject string | 1639 // r3: original subject string |
| 1651 // Load previous index and check range before r3 is overwritten. We have to | 1640 // Load previous index and check range before r3 is overwritten. We have to |
| 1652 // use r3 instead of subject here because subject might have been only made | 1641 // use r3 instead of subject here because subject might have been only made |
| 1653 // to look like a sequential string when it actually is an external string. | 1642 // to look like a sequential string when it actually is an external string. |
| 1654 __ ldr(r1, MemOperand(sp, kPreviousIndexOffset)); | 1643 __ ldr(r1, MemOperand(sp, kPreviousIndexOffset)); |
| 1655 __ JumpIfNotSmi(r1, &runtime); | 1644 __ JumpIfNotSmi(r1, &runtime); |
| 1656 __ ldr(r3, FieldMemOperand(r3, String::kLengthOffset)); | 1645 __ ldr(r3, FieldMemOperand(r3, String::kLengthOffset)); |
| 1657 __ cmp(r3, Operand(r1)); | 1646 __ cmp(r3, Operand(r1)); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 // Return last match info. | 1859 // Return last match info. |
| 1871 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset)); | 1860 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset)); |
| 1872 __ add(sp, sp, Operand(4 * kPointerSize)); | 1861 __ add(sp, sp, Operand(4 * kPointerSize)); |
| 1873 __ Ret(); | 1862 __ Ret(); |
| 1874 | 1863 |
| 1875 // Do the runtime call to execute the regexp. | 1864 // Do the runtime call to execute the regexp. |
| 1876 __ bind(&runtime); | 1865 __ bind(&runtime); |
| 1877 __ TailCallRuntime(Runtime::kRegExpExec); | 1866 __ TailCallRuntime(Runtime::kRegExpExec); |
| 1878 | 1867 |
| 1879 // Deferred code for string handling. | 1868 // Deferred code for string handling. |
| 1880 // (6) Not a long external string? If yes, go to (8). | 1869 // (5) Long external string? If not, go to (7). |
| 1881 __ bind(¬_seq_nor_cons); | 1870 __ bind(¬_seq_nor_cons); |
| 1882 // Compare flags are still set. | 1871 // Compare flags are still set. |
| 1883 __ b(gt, ¬_long_external); // Go to (8). | 1872 __ b(gt, ¬_long_external); // Go to (7). |
| 1884 | 1873 |
| 1885 // (7) External string. Make it, offset-wise, look like a sequential string. | 1874 // (6) External string. Make it, offset-wise, look like a sequential string. |
| 1886 __ bind(&external_string); | 1875 __ bind(&external_string); |
| 1887 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 1876 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); |
| 1888 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 1877 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); |
| 1889 if (FLAG_debug_code) { | 1878 if (FLAG_debug_code) { |
| 1890 // Assert that we do not have a cons or slice (indirect strings) here. | 1879 // Assert that we do not have a cons or slice (indirect strings) here. |
| 1891 // Sequential strings have already been ruled out. | 1880 // Sequential strings have already been ruled out. |
| 1892 __ tst(r0, Operand(kIsIndirectStringMask)); | 1881 __ tst(r0, Operand(kIsIndirectStringMask)); |
| 1893 __ Assert(eq, kExternalStringExpectedButNotFound); | 1882 __ Assert(eq, kExternalStringExpectedButNotFound); |
| 1894 } | 1883 } |
| 1895 __ ldr(subject, | 1884 __ ldr(subject, |
| 1896 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); | 1885 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); |
| 1897 // Move the pointer so that offset-wise, it looks like a sequential string. | 1886 // Move the pointer so that offset-wise, it looks like a sequential string. |
| 1898 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 1887 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
| 1899 __ sub(subject, | 1888 __ sub(subject, |
| 1900 subject, | 1889 subject, |
| 1901 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 1890 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 1902 __ jmp(&seq_string); // Go to (5). | 1891 __ jmp(&seq_string); // Go to (4). |
| 1903 | 1892 |
| 1904 // (8) Short external string or not a string? If yes, bail out to runtime. | 1893 // (7) Short external string or not a string? If yes, bail out to runtime. |
| 1905 __ bind(¬_long_external); | 1894 __ bind(¬_long_external); |
| 1906 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); | 1895 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); |
| 1907 __ tst(r1, Operand(kIsNotStringMask | kShortExternalStringMask)); | 1896 __ tst(r1, Operand(kIsNotStringMask | kShortExternalStringMask)); |
| 1908 __ b(ne, &runtime); | 1897 __ b(ne, &runtime); |
| 1909 | 1898 |
| 1910 // (9) Sliced string. Replace subject with parent. Go to (4). | 1899 // (8) Sliced string. Replace subject with parent. Go to (4). |
| 1911 // Load offset into r9 and replace subject string with parent. | 1900 // Load offset into r9 and replace subject string with parent. |
| 1912 __ ldr(r9, FieldMemOperand(subject, SlicedString::kOffsetOffset)); | 1901 __ ldr(r9, FieldMemOperand(subject, SlicedString::kOffsetOffset)); |
| 1913 __ SmiUntag(r9); | 1902 __ SmiUntag(r9); |
| 1914 __ ldr(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); | 1903 __ ldr(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); |
| 1915 __ jmp(&check_underlying); // Go to (4). | 1904 __ jmp(&check_underlying); // Go to (4). |
| 1916 #endif // V8_INTERPRETED_REGEXP | 1905 #endif // V8_INTERPRETED_REGEXP |
| 1917 } | 1906 } |
| 1918 | 1907 |
| 1919 | 1908 |
| 1920 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { | 1909 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { |
| (...skipping 3699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5620 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5609 kStackUnwindSpace, NULL, return_value_operand, NULL); |
| 5621 } | 5610 } |
| 5622 | 5611 |
| 5623 | 5612 |
| 5624 #undef __ | 5613 #undef __ |
| 5625 | 5614 |
| 5626 } // namespace internal | 5615 } // namespace internal |
| 5627 } // namespace v8 | 5616 } // namespace v8 |
| 5628 | 5617 |
| 5629 #endif // V8_TARGET_ARCH_ARM | 5618 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |