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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
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/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 // Multiplying by 2 comes for free since a2 is smi-tagged. | 1676 // Multiplying by 2 comes for free since a2 is smi-tagged. |
1677 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); | 1677 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); |
1678 int temp = Isolate::kJSRegexpStaticOffsetsVectorSize / 2 - 1; | 1678 int temp = Isolate::kJSRegexpStaticOffsetsVectorSize / 2 - 1; |
1679 __ Branch(&runtime, hi, a2, Operand(Smi::FromInt(temp))); | 1679 __ Branch(&runtime, hi, a2, Operand(Smi::FromInt(temp))); |
1680 | 1680 |
1681 // Reset offset for possibly sliced string. | 1681 // Reset offset for possibly sliced string. |
1682 __ mov(t0, zero_reg); | 1682 __ mov(t0, zero_reg); |
1683 __ ld(subject, MemOperand(sp, kSubjectOffset)); | 1683 __ ld(subject, MemOperand(sp, kSubjectOffset)); |
1684 __ JumpIfSmi(subject, &runtime); | 1684 __ JumpIfSmi(subject, &runtime); |
1685 __ mov(a3, subject); // Make a copy of the original subject string. | 1685 __ mov(a3, subject); // Make a copy of the original subject string. |
1686 __ ld(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 1686 |
1687 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); | |
1688 // subject: subject string | 1687 // subject: subject string |
1689 // a3: subject string | 1688 // a3: subject string |
1690 // a0: subject string instance type | |
1691 // regexp_data: RegExp data (FixedArray) | 1689 // regexp_data: RegExp data (FixedArray) |
1692 // Handle subject string according to its encoding and representation: | 1690 // Handle subject string according to its encoding and representation: |
1693 // (1) Sequential string? If yes, go to (5). | 1691 // (1) Sequential string? If yes, go to (4). |
1694 // (2) Anything but sequential or cons? If yes, go to (6). | 1692 // (2) Sequential or cons? If not, go to (5). |
1695 // (3) Cons string. If the string is flat, replace subject with first string. | 1693 // (3) Cons string. If the string is flat, replace subject with first string |
1696 // Otherwise bailout. | 1694 // and go to (1). Otherwise bail out to runtime. |
1697 // (4) Is subject external? If yes, go to (7). | 1695 // (4) Sequential string. Load regexp code according to encoding. |
1698 // (5) Sequential string. Load regexp code according to encoding. | |
1699 // (E) Carry on. | 1696 // (E) Carry on. |
1700 /// [...] | 1697 /// [...] |
1701 | 1698 |
1702 // Deferred code at the end of the stub: | 1699 // Deferred code at the end of the stub: |
1703 // (6) Not a long external string? If yes, go to (8). | 1700 // (5) Long external string? If not, go to (7). |
1704 // (7) External string. Make it, offset-wise, look like a sequential string. | 1701 // (6) External string. Make it, offset-wise, look like a sequential string. |
1705 // Go to (5). | 1702 // Go to (4). |
1706 // (8) Short external string or not a string? If yes, bail out to runtime. | 1703 // (7) Short external string or not a string? If yes, bail out to runtime. |
1707 // (9) Sliced string. Replace subject with parent. Go to (4). | 1704 // (8) Sliced string. Replace subject with parent. Go to (1). |
1708 | 1705 |
1709 Label check_underlying; // (4) | 1706 Label check_underlying; // (1) |
1710 Label seq_string; // (5) | 1707 Label seq_string; // (4) |
1711 Label not_seq_nor_cons; // (6) | 1708 Label not_seq_nor_cons; // (5) |
1712 Label external_string; // (7) | 1709 Label external_string; // (6) |
1713 Label not_long_external; // (8) | 1710 Label not_long_external; // (7) |
1714 | 1711 |
1715 // (1) Sequential string? If yes, go to (5). | 1712 __ bind(&check_underlying); |
| 1713 __ ld(a2, FieldMemOperand(subject, HeapObject::kMapOffset)); |
| 1714 __ lbu(a0, FieldMemOperand(a2, Map::kInstanceTypeOffset)); |
| 1715 |
| 1716 // (1) Sequential string? If yes, go to (4). |
1716 __ And(a1, | 1717 __ And(a1, |
1717 a0, | 1718 a0, |
1718 Operand(kIsNotStringMask | | 1719 Operand(kIsNotStringMask | |
1719 kStringRepresentationMask | | 1720 kStringRepresentationMask | |
1720 kShortExternalStringMask)); | 1721 kShortExternalStringMask)); |
1721 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); | 1722 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); |
1722 __ Branch(&seq_string, eq, a1, Operand(zero_reg)); // Go to (5). | 1723 __ Branch(&seq_string, eq, a1, Operand(zero_reg)); // Go to (4). |
1723 | 1724 |
1724 // (2) Anything but sequential or cons? If yes, go to (6). | 1725 // (2) Sequential or cons? If not, go to (5). |
1725 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 1726 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
1726 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 1727 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
1727 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); | 1728 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); |
1728 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); | 1729 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); |
1729 // Go to (6). | 1730 // Go to (5). |
1730 __ Branch(¬_seq_nor_cons, ge, a1, Operand(kExternalStringTag)); | 1731 __ Branch(¬_seq_nor_cons, ge, a1, Operand(kExternalStringTag)); |
1731 | 1732 |
1732 // (3) Cons string. Check that it's flat. | 1733 // (3) Cons string. Check that it's flat. |
1733 // Replace subject with first string and reload instance type. | 1734 // Replace subject with first string and reload instance type. |
1734 __ ld(a0, FieldMemOperand(subject, ConsString::kSecondOffset)); | 1735 __ ld(a0, FieldMemOperand(subject, ConsString::kSecondOffset)); |
1735 __ LoadRoot(a1, Heap::kempty_stringRootIndex); | 1736 __ LoadRoot(a1, Heap::kempty_stringRootIndex); |
1736 __ Branch(&runtime, ne, a0, Operand(a1)); | 1737 __ Branch(&runtime, ne, a0, Operand(a1)); |
1737 __ ld(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); | 1738 __ ld(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); |
| 1739 __ jmp(&check_underlying); |
1738 | 1740 |
1739 // (4) Is subject external? If yes, go to (7). | 1741 // (4) Sequential string. Load regexp code according to encoding. |
1740 __ bind(&check_underlying); | |
1741 __ ld(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); | |
1742 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); | |
1743 STATIC_ASSERT(kSeqStringTag == 0); | |
1744 __ And(at, a0, Operand(kStringRepresentationMask)); | |
1745 // The underlying external string is never a short external string. | |
1746 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); | |
1747 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); | |
1748 __ Branch(&external_string, ne, at, Operand(zero_reg)); // Go to (7). | |
1749 | |
1750 // (5) Sequential string. Load regexp code according to encoding. | |
1751 __ bind(&seq_string); | 1742 __ bind(&seq_string); |
1752 // subject: sequential subject string (or look-alike, external string) | 1743 // subject: sequential subject string (or look-alike, external string) |
1753 // a3: original subject string | 1744 // a3: original subject string |
1754 // Load previous index and check range before a3 is overwritten. We have to | 1745 // Load previous index and check range before a3 is overwritten. We have to |
1755 // use a3 instead of subject here because subject might have been only made | 1746 // use a3 instead of subject here because subject might have been only made |
1756 // to look like a sequential string when it actually is an external string. | 1747 // to look like a sequential string when it actually is an external string. |
1757 __ ld(a1, MemOperand(sp, kPreviousIndexOffset)); | 1748 __ ld(a1, MemOperand(sp, kPreviousIndexOffset)); |
1758 __ JumpIfNotSmi(a1, &runtime); | 1749 __ JumpIfNotSmi(a1, &runtime); |
1759 __ ld(a3, FieldMemOperand(a3, String::kLengthOffset)); | 1750 __ ld(a3, FieldMemOperand(a3, String::kLengthOffset)); |
1760 __ Branch(&runtime, ls, a3, Operand(a1)); | 1751 __ Branch(&runtime, ls, a3, Operand(a1)); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 | 1974 |
1984 // Return last match info. | 1975 // Return last match info. |
1985 __ ld(v0, MemOperand(sp, kLastMatchInfoOffset)); | 1976 __ ld(v0, MemOperand(sp, kLastMatchInfoOffset)); |
1986 __ DropAndRet(4); | 1977 __ DropAndRet(4); |
1987 | 1978 |
1988 // Do the runtime call to execute the regexp. | 1979 // Do the runtime call to execute the regexp. |
1989 __ bind(&runtime); | 1980 __ bind(&runtime); |
1990 __ TailCallRuntime(Runtime::kRegExpExec); | 1981 __ TailCallRuntime(Runtime::kRegExpExec); |
1991 | 1982 |
1992 // Deferred code for string handling. | 1983 // Deferred code for string handling. |
1993 // (6) Not a long external string? If yes, go to (8). | 1984 // (5) Long external string? If not, go to (7). |
1994 __ bind(¬_seq_nor_cons); | 1985 __ bind(¬_seq_nor_cons); |
1995 // Go to (8). | 1986 // Go to (7). |
1996 __ Branch(¬_long_external, gt, a1, Operand(kExternalStringTag)); | 1987 __ Branch(¬_long_external, gt, a1, Operand(kExternalStringTag)); |
1997 | 1988 |
1998 // (7) External string. Make it, offset-wise, look like a sequential string. | 1989 // (6) External string. Make it, offset-wise, look like a sequential string. |
1999 __ bind(&external_string); | 1990 __ bind(&external_string); |
2000 __ ld(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 1991 __ ld(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); |
2001 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); | 1992 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); |
2002 if (FLAG_debug_code) { | 1993 if (FLAG_debug_code) { |
2003 // Assert that we do not have a cons or slice (indirect strings) here. | 1994 // Assert that we do not have a cons or slice (indirect strings) here. |
2004 // Sequential strings have already been ruled out. | 1995 // Sequential strings have already been ruled out. |
2005 __ And(at, a0, Operand(kIsIndirectStringMask)); | 1996 __ And(at, a0, Operand(kIsIndirectStringMask)); |
2006 __ Assert(eq, | 1997 __ Assert(eq, |
2007 kExternalStringExpectedButNotFound, | 1998 kExternalStringExpectedButNotFound, |
2008 at, | 1999 at, |
2009 Operand(zero_reg)); | 2000 Operand(zero_reg)); |
2010 } | 2001 } |
2011 __ ld(subject, | 2002 __ ld(subject, |
2012 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); | 2003 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); |
2013 // Move the pointer so that offset-wise, it looks like a sequential string. | 2004 // Move the pointer so that offset-wise, it looks like a sequential string. |
2014 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 2005 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
2015 __ Dsubu(subject, | 2006 __ Dsubu(subject, |
2016 subject, | 2007 subject, |
2017 SeqTwoByteString::kHeaderSize - kHeapObjectTag); | 2008 SeqTwoByteString::kHeaderSize - kHeapObjectTag); |
2018 __ jmp(&seq_string); // Go to (5). | 2009 __ jmp(&seq_string); // Go to (4). |
2019 | 2010 |
2020 // (8) Short external string or not a string? If yes, bail out to runtime. | 2011 // (7) Short external string or not a string? If yes, bail out to runtime. |
2021 __ bind(¬_long_external); | 2012 __ bind(¬_long_external); |
2022 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); | 2013 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); |
2023 __ And(at, a1, Operand(kIsNotStringMask | kShortExternalStringMask)); | 2014 __ And(at, a1, Operand(kIsNotStringMask | kShortExternalStringMask)); |
2024 __ Branch(&runtime, ne, at, Operand(zero_reg)); | 2015 __ Branch(&runtime, ne, at, Operand(zero_reg)); |
2025 | 2016 |
2026 // (9) Sliced string. Replace subject with parent. Go to (4). | 2017 // (8) Sliced string. Replace subject with parent. Go to (4). |
2027 // Load offset into t0 and replace subject string with parent. | 2018 // Load offset into t0 and replace subject string with parent. |
2028 __ ld(t0, FieldMemOperand(subject, SlicedString::kOffsetOffset)); | 2019 __ ld(t0, FieldMemOperand(subject, SlicedString::kOffsetOffset)); |
2029 __ SmiUntag(t0); | 2020 __ SmiUntag(t0); |
2030 __ ld(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); | 2021 __ ld(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); |
2031 __ jmp(&check_underlying); // Go to (4). | 2022 __ jmp(&check_underlying); // Go to (1). |
2032 #endif // V8_INTERPRETED_REGEXP | 2023 #endif // V8_INTERPRETED_REGEXP |
2033 } | 2024 } |
2034 | 2025 |
2035 | 2026 |
2036 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { | 2027 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { |
2037 // a0 : number of arguments to the construct function | 2028 // a0 : number of arguments to the construct function |
2038 // a2 : feedback vector | 2029 // a2 : feedback vector |
2039 // a3 : slot in feedback vector (Smi) | 2030 // a3 : slot in feedback vector (Smi) |
2040 // a1 : the function to call | 2031 // a1 : the function to call |
2041 FrameScope scope(masm, StackFrame::INTERNAL); | 2032 FrameScope scope(masm, StackFrame::INTERNAL); |
(...skipping 3713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5755 return_value_operand, NULL); | 5746 return_value_operand, NULL); |
5756 } | 5747 } |
5757 | 5748 |
5758 | 5749 |
5759 #undef __ | 5750 #undef __ |
5760 | 5751 |
5761 } // namespace internal | 5752 } // namespace internal |
5762 } // namespace v8 | 5753 } // namespace v8 |
5763 | 5754 |
5764 #endif // V8_TARGET_ARCH_MIPS64 | 5755 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |