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