OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 __ SmiToShortArrayOffset(r5, r5); | 1634 __ SmiToShortArrayOffset(r5, r5); |
1635 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); | 1635 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); |
1636 __ cmpli(r5, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); | 1636 __ cmpli(r5, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); |
1637 __ bgt(&runtime); | 1637 __ bgt(&runtime); |
1638 | 1638 |
1639 // Reset offset for possibly sliced string. | 1639 // Reset offset for possibly sliced string. |
1640 __ li(r11, Operand::Zero()); | 1640 __ li(r11, Operand::Zero()); |
1641 __ LoadP(subject, MemOperand(sp, kSubjectOffset)); | 1641 __ LoadP(subject, MemOperand(sp, kSubjectOffset)); |
1642 __ JumpIfSmi(subject, &runtime); | 1642 __ JumpIfSmi(subject, &runtime); |
1643 __ mr(r6, subject); // Make a copy of the original subject string. | 1643 __ mr(r6, subject); // Make a copy of the original subject string. |
1644 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); | |
1645 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); | |
1646 // subject: subject string | 1644 // subject: subject string |
1647 // r6: subject string | 1645 // r6: subject string |
1648 // r3: subject string instance type | |
1649 // regexp_data: RegExp data (FixedArray) | 1646 // regexp_data: RegExp data (FixedArray) |
1650 // Handle subject string according to its encoding and representation: | 1647 // Handle subject string according to its encoding and representation: |
1651 // (1) Sequential string? If yes, go to (5). | 1648 // (1) Sequential string? If yes, go to (4). |
1652 // (2) Anything but sequential or cons? If yes, go to (6). | 1649 // (2) Sequential or cons? If not, go to (5). |
1653 // (3) Cons string. If the string is flat, replace subject with first string. | 1650 // (3) Cons string. If the string is flat, replace subject with first string |
1654 // Otherwise bailout. | 1651 // and go to (1). Otherwise bail out to runtime. |
1655 // (4) Is subject external? If yes, go to (7). | 1652 // (4) Sequential string. Load regexp code according to encoding. |
1656 // (5) Sequential string. Load regexp code according to encoding. | |
1657 // (E) Carry on. | 1653 // (E) Carry on. |
1658 /// [...] | 1654 /// [...] |
1659 | 1655 |
1660 // Deferred code at the end of the stub: | 1656 // Deferred code at the end of the stub: |
1661 // (6) Not a long external string? If yes, go to (8). | 1657 // (5) Long external string? If not, go to (7). |
1662 // (7) External string. Make it, offset-wise, look like a sequential string. | 1658 // (6) External string. Make it, offset-wise, look like a sequential string. |
1663 // Go to (5). | 1659 // Go to (4). |
1664 // (8) Short external string or not a string? If yes, bail out to runtime. | 1660 // (7) Short external string or not a string? If yes, bail out to runtime. |
1665 // (9) Sliced string. Replace subject with parent. Go to (4). | 1661 // (8) Sliced string. Replace subject with parent. Go to (1). |
1666 | 1662 |
1667 Label seq_string /* 5 */, external_string /* 7 */, check_underlying /* 4 */, | 1663 Label seq_string /* 4 */, external_string /* 6 */, check_underlying /* 1 */, |
1668 not_seq_nor_cons /* 6 */, not_long_external /* 8 */; | 1664 not_seq_nor_cons /* 5 */, not_long_external /* 7 */; |
1669 | 1665 |
1670 // (1) Sequential string? If yes, go to (5). | 1666 __ bind(&check_underlying); |
| 1667 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); |
| 1668 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); |
| 1669 |
| 1670 // (1) Sequential string? If yes, go to (4). |
| 1671 |
1671 STATIC_ASSERT((kIsNotStringMask | kStringRepresentationMask | | 1672 STATIC_ASSERT((kIsNotStringMask | kStringRepresentationMask | |
1672 kShortExternalStringMask) == 0x93); | 1673 kShortExternalStringMask) == 0x93); |
1673 __ andi(r4, r3, Operand(kIsNotStringMask | kStringRepresentationMask | | 1674 __ andi(r4, r3, Operand(kIsNotStringMask | kStringRepresentationMask | |
1674 kShortExternalStringMask)); | 1675 kShortExternalStringMask)); |
1675 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); | 1676 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); |
1676 __ beq(&seq_string, cr0); // Go to (5). | 1677 __ beq(&seq_string, cr0); // Go to (4). |
1677 | 1678 |
1678 // (2) Anything but sequential or cons? If yes, go to (6). | 1679 // (2) Sequential or cons? If not, go to (5). |
1679 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 1680 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
1680 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 1681 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
1681 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); | 1682 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); |
1682 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); | 1683 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); |
1683 STATIC_ASSERT(kExternalStringTag < 0xffffu); | 1684 STATIC_ASSERT(kExternalStringTag < 0xffffu); |
1684 __ cmpi(r4, Operand(kExternalStringTag)); | 1685 __ cmpi(r4, Operand(kExternalStringTag)); |
1685 __ bge(¬_seq_nor_cons); // Go to (6). | 1686 __ bge(¬_seq_nor_cons); // Go to (5). |
1686 | 1687 |
1687 // (3) Cons string. Check that it's flat. | 1688 // (3) Cons string. Check that it's flat. |
1688 // Replace subject with first string and reload instance type. | 1689 // Replace subject with first string and reload instance type. |
1689 __ LoadP(r3, FieldMemOperand(subject, ConsString::kSecondOffset)); | 1690 __ LoadP(r3, FieldMemOperand(subject, ConsString::kSecondOffset)); |
1690 __ CompareRoot(r3, Heap::kempty_stringRootIndex); | 1691 __ CompareRoot(r3, Heap::kempty_stringRootIndex); |
1691 __ bne(&runtime); | 1692 __ bne(&runtime); |
1692 __ LoadP(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); | 1693 __ LoadP(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); |
| 1694 __ b(&check_underlying); |
1693 | 1695 |
1694 // (4) Is subject external? If yes, go to (7). | 1696 // (4) Sequential string. Load regexp code according to encoding. |
1695 __ bind(&check_underlying); | |
1696 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); | |
1697 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); | |
1698 STATIC_ASSERT(kSeqStringTag == 0); | |
1699 STATIC_ASSERT(kStringRepresentationMask == 3); | |
1700 __ andi(r0, r3, Operand(kStringRepresentationMask)); | |
1701 // The underlying external string is never a short external string. | |
1702 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); | |
1703 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); | |
1704 __ bne(&external_string, cr0); // Go to (7). | |
1705 | |
1706 // (5) Sequential string. Load regexp code according to encoding. | |
1707 __ bind(&seq_string); | 1697 __ bind(&seq_string); |
1708 // subject: sequential subject string (or look-alike, external string) | 1698 // subject: sequential subject string (or look-alike, external string) |
1709 // r6: original subject string | 1699 // r6: original subject string |
1710 // Load previous index and check range before r6 is overwritten. We have to | 1700 // Load previous index and check range before r6 is overwritten. We have to |
1711 // use r6 instead of subject here because subject might have been only made | 1701 // use r6 instead of subject here because subject might have been only made |
1712 // to look like a sequential string when it actually is an external string. | 1702 // to look like a sequential string when it actually is an external string. |
1713 __ LoadP(r4, MemOperand(sp, kPreviousIndexOffset)); | 1703 __ LoadP(r4, MemOperand(sp, kPreviousIndexOffset)); |
1714 __ JumpIfNotSmi(r4, &runtime); | 1704 __ JumpIfNotSmi(r4, &runtime); |
1715 __ LoadP(r6, FieldMemOperand(r6, String::kLengthOffset)); | 1705 __ LoadP(r6, FieldMemOperand(r6, String::kLengthOffset)); |
1716 __ cmpl(r6, r4); | 1706 __ cmpl(r6, r4); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 // Return last match info. | 1919 // Return last match info. |
1930 __ LoadP(r3, MemOperand(sp, kLastMatchInfoOffset)); | 1920 __ LoadP(r3, MemOperand(sp, kLastMatchInfoOffset)); |
1931 __ addi(sp, sp, Operand(4 * kPointerSize)); | 1921 __ addi(sp, sp, Operand(4 * kPointerSize)); |
1932 __ Ret(); | 1922 __ Ret(); |
1933 | 1923 |
1934 // Do the runtime call to execute the regexp. | 1924 // Do the runtime call to execute the regexp. |
1935 __ bind(&runtime); | 1925 __ bind(&runtime); |
1936 __ TailCallRuntime(Runtime::kRegExpExec); | 1926 __ TailCallRuntime(Runtime::kRegExpExec); |
1937 | 1927 |
1938 // Deferred code for string handling. | 1928 // Deferred code for string handling. |
1939 // (6) Not a long external string? If yes, go to (8). | 1929 // (5) Long external string? If not, go to (7). |
1940 __ bind(¬_seq_nor_cons); | 1930 __ bind(¬_seq_nor_cons); |
1941 // Compare flags are still set. | 1931 // Compare flags are still set. |
1942 __ bgt(¬_long_external); // Go to (8). | 1932 __ bgt(¬_long_external); // Go to (7). |
1943 | 1933 |
1944 // (7) External string. Make it, offset-wise, look like a sequential string. | 1934 // (6) External string. Make it, offset-wise, look like a sequential string. |
1945 __ bind(&external_string); | 1935 __ bind(&external_string); |
1946 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); | 1936 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); |
1947 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); | 1937 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); |
1948 if (FLAG_debug_code) { | 1938 if (FLAG_debug_code) { |
1949 // Assert that we do not have a cons or slice (indirect strings) here. | 1939 // Assert that we do not have a cons or slice (indirect strings) here. |
1950 // Sequential strings have already been ruled out. | 1940 // Sequential strings have already been ruled out. |
1951 STATIC_ASSERT(kIsIndirectStringMask == 1); | 1941 STATIC_ASSERT(kIsIndirectStringMask == 1); |
1952 __ andi(r0, r3, Operand(kIsIndirectStringMask)); | 1942 __ andi(r0, r3, Operand(kIsIndirectStringMask)); |
1953 __ Assert(eq, kExternalStringExpectedButNotFound, cr0); | 1943 __ Assert(eq, kExternalStringExpectedButNotFound, cr0); |
1954 } | 1944 } |
1955 __ LoadP(subject, | 1945 __ LoadP(subject, |
1956 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); | 1946 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); |
1957 // Move the pointer so that offset-wise, it looks like a sequential string. | 1947 // Move the pointer so that offset-wise, it looks like a sequential string. |
1958 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 1948 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
1959 __ subi(subject, subject, | 1949 __ subi(subject, subject, |
1960 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 1950 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
1961 __ b(&seq_string); // Go to (5). | 1951 __ b(&seq_string); // Go to (4). |
1962 | 1952 |
1963 // (8) Short external string or not a string? If yes, bail out to runtime. | 1953 // (7) Short external string or not a string? If yes, bail out to runtime. |
1964 __ bind(¬_long_external); | 1954 __ bind(¬_long_external); |
1965 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag != 0); | 1955 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag != 0); |
1966 __ andi(r0, r4, Operand(kIsNotStringMask | kShortExternalStringMask)); | 1956 __ andi(r0, r4, Operand(kIsNotStringMask | kShortExternalStringMask)); |
1967 __ bne(&runtime, cr0); | 1957 __ bne(&runtime, cr0); |
1968 | 1958 |
1969 // (9) Sliced string. Replace subject with parent. Go to (4). | 1959 // (8) Sliced string. Replace subject with parent. Go to (4). |
1970 // Load offset into r11 and replace subject string with parent. | 1960 // Load offset into r11 and replace subject string with parent. |
1971 __ LoadP(r11, FieldMemOperand(subject, SlicedString::kOffsetOffset)); | 1961 __ LoadP(r11, FieldMemOperand(subject, SlicedString::kOffsetOffset)); |
1972 __ SmiUntag(r11); | 1962 __ SmiUntag(r11); |
1973 __ LoadP(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); | 1963 __ LoadP(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); |
1974 __ b(&check_underlying); // Go to (4). | 1964 __ b(&check_underlying); // Go to (4). |
1975 #endif // V8_INTERPRETED_REGEXP | 1965 #endif // V8_INTERPRETED_REGEXP |
1976 } | 1966 } |
1977 | 1967 |
1978 | 1968 |
1979 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { | 1969 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { |
(...skipping 3883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5863 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5853 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5864 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5854 kStackUnwindSpace, NULL, return_value_operand, NULL); |
5865 } | 5855 } |
5866 | 5856 |
5867 | 5857 |
5868 #undef __ | 5858 #undef __ |
5869 } // namespace internal | 5859 } // namespace internal |
5870 } // namespace v8 | 5860 } // namespace v8 |
5871 | 5861 |
5872 #endif // V8_TARGET_ARCH_PPC | 5862 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |