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