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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 __ Push(receiver, key); // Receiver, key. | 1598 __ Push(receiver, key); // Receiver, key. |
1599 | 1599 |
1600 // Perform tail call to the entry. | 1600 // Perform tail call to the entry. |
1601 __ TailCallRuntime(Runtime::kLoadElementWithInterceptor); | 1601 __ TailCallRuntime(Runtime::kLoadElementWithInterceptor); |
1602 | 1602 |
1603 __ bind(&slow); | 1603 __ bind(&slow); |
1604 PropertyAccessCompiler::TailCallBuiltin( | 1604 PropertyAccessCompiler::TailCallBuiltin( |
1605 masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC)); | 1605 masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC)); |
1606 } | 1606 } |
1607 | 1607 |
1608 | |
1609 void RegExpExecStub::Generate(MacroAssembler* masm) { | 1608 void RegExpExecStub::Generate(MacroAssembler* masm) { |
1610 // Just jump directly to runtime if native RegExp is not selected at compile | 1609 // Just jump directly to runtime if native RegExp is not selected at compile |
1611 // time or if regexp entry in generated code is turned off runtime switch or | 1610 // time or if regexp entry in generated code is turned off runtime switch or |
1612 // at compilation. | 1611 // at compilation. |
1613 #ifdef V8_INTERPRETED_REGEXP | 1612 #ifdef V8_INTERPRETED_REGEXP |
1614 __ TailCallRuntime(Runtime::kRegExpExec); | 1613 __ TailCallRuntime(Runtime::kRegExpExec); |
1615 #else // V8_INTERPRETED_REGEXP | 1614 #else // V8_INTERPRETED_REGEXP |
1616 | 1615 |
1617 // Stack frame on entry. | 1616 // Stack frame on entry. |
1618 // sp[0]: last_match_info (expected JSArray) | 1617 // sp[0]: last_match_info (expected JSArray) |
(...skipping 12 matching lines...) Expand all Loading... |
1631 // this code is called using the normal C calling convention. When calling | 1630 // this code is called using the normal C calling convention. When calling |
1632 // directly from generated code the native RegExp code will not do a GC and | 1631 // directly from generated code the native RegExp code will not do a GC and |
1633 // therefore the content of these registers are safe to use after the call. | 1632 // therefore the content of these registers are safe to use after the call. |
1634 // MIPS - using s0..s2, since we are not using CEntry Stub. | 1633 // MIPS - using s0..s2, since we are not using CEntry Stub. |
1635 Register subject = s0; | 1634 Register subject = s0; |
1636 Register regexp_data = s1; | 1635 Register regexp_data = s1; |
1637 Register last_match_info_elements = s2; | 1636 Register last_match_info_elements = s2; |
1638 | 1637 |
1639 // Ensure that a RegExp stack is allocated. | 1638 // Ensure that a RegExp stack is allocated. |
1640 ExternalReference address_of_regexp_stack_memory_address = | 1639 ExternalReference address_of_regexp_stack_memory_address = |
1641 ExternalReference::address_of_regexp_stack_memory_address( | 1640 ExternalReference::address_of_regexp_stack_memory_address(isolate()); |
1642 isolate()); | |
1643 ExternalReference address_of_regexp_stack_memory_size = | 1641 ExternalReference address_of_regexp_stack_memory_size = |
1644 ExternalReference::address_of_regexp_stack_memory_size(isolate()); | 1642 ExternalReference::address_of_regexp_stack_memory_size(isolate()); |
1645 __ li(a0, Operand(address_of_regexp_stack_memory_size)); | 1643 __ li(a0, Operand(address_of_regexp_stack_memory_size)); |
1646 __ lw(a0, MemOperand(a0, 0)); | 1644 __ lw(a0, MemOperand(a0, 0)); |
1647 __ Branch(&runtime, eq, a0, Operand(zero_reg)); | 1645 __ Branch(&runtime, eq, a0, Operand(zero_reg)); |
1648 | 1646 |
1649 // Check that the first argument is a JSRegExp object. | 1647 // Check that the first argument is a JSRegExp object. |
1650 __ lw(a0, MemOperand(sp, kJSRegExpOffset)); | 1648 __ lw(a0, MemOperand(sp, kJSRegExpOffset)); |
1651 STATIC_ASSERT(kSmiTag == 0); | 1649 STATIC_ASSERT(kSmiTag == 0); |
1652 __ JumpIfSmi(a0, &runtime); | 1650 __ JumpIfSmi(a0, &runtime); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 1682 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); |
1685 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); | 1683 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); |
1686 __ Branch( | 1684 __ Branch( |
1687 &runtime, hi, a2, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); | 1685 &runtime, hi, a2, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); |
1688 | 1686 |
1689 // Reset offset for possibly sliced string. | 1687 // Reset offset for possibly sliced string. |
1690 __ mov(t0, zero_reg); | 1688 __ mov(t0, zero_reg); |
1691 __ lw(subject, MemOperand(sp, kSubjectOffset)); | 1689 __ lw(subject, MemOperand(sp, kSubjectOffset)); |
1692 __ JumpIfSmi(subject, &runtime); | 1690 __ JumpIfSmi(subject, &runtime); |
1693 __ mov(a3, subject); // Make a copy of the original subject string. | 1691 __ mov(a3, subject); // Make a copy of the original subject string. |
1694 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); | |
1695 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); | |
1696 // subject: subject string | 1692 // subject: subject string |
1697 // a3: subject string | 1693 // a3: subject string |
1698 // a0: subject string instance type | |
1699 // regexp_data: RegExp data (FixedArray) | 1694 // regexp_data: RegExp data (FixedArray) |
1700 // Handle subject string according to its encoding and representation: | 1695 // Handle subject string according to its encoding and representation: |
1701 // (1) Sequential string? If yes, go to (5). | 1696 // (1) Sequential string? If yes, go to (4). |
1702 // (2) Anything but sequential or cons? If yes, go to (6). | 1697 // (2) Sequential or cons? If not, go to (5). |
1703 // (3) Cons string. If the string is flat, replace subject with first string. | 1698 // (3) Cons string. If the string is flat, replace subject with first string |
1704 // Otherwise bailout. | 1699 // and go to (1). Otherwise bail out to runtime. |
1705 // (4) Is subject external? If yes, go to (7). | 1700 // (4) Sequential string. Load regexp code according to encoding. |
1706 // (5) Sequential string. Load regexp code according to encoding. | |
1707 // (E) Carry on. | 1701 // (E) Carry on. |
1708 /// [...] | 1702 /// [...] |
1709 | 1703 |
1710 // Deferred code at the end of the stub: | 1704 // Deferred code at the end of the stub: |
1711 // (6) Not a long external string? If yes, go to (8). | 1705 // (5) Long external string? If not, go to (7). |
1712 // (7) External string. Make it, offset-wise, look like a sequential string. | 1706 // (6) External string. Make it, offset-wise, look like a sequential string. |
1713 // Go to (5). | 1707 // Go to (4). |
1714 // (8) Short external string or not a string? If yes, bail out to runtime. | 1708 // (7) Short external string or not a string? If yes, bail out to runtime. |
1715 // (9) Sliced string. Replace subject with parent. Go to (4). | 1709 // (8) Sliced string. Replace subject with parent. Go to (1). |
1716 | 1710 |
1717 Label seq_string /* 5 */, external_string /* 7 */, | 1711 Label seq_string /* 4 */, external_string /* 6 */, check_underlying /* 1 */, |
1718 check_underlying /* 4 */, not_seq_nor_cons /* 6 */, | 1712 not_seq_nor_cons /* 5 */, not_long_external /* 7 */; |
1719 not_long_external /* 8 */; | |
1720 | 1713 |
1721 // (1) Sequential string? If yes, go to (5). | 1714 __ bind(&check_underlying); |
| 1715 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); |
| 1716 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); |
| 1717 |
| 1718 // (1) Sequential string? If yes, go to (4). |
1722 __ And(a1, | 1719 __ And(a1, |
1723 a0, | 1720 a0, |
1724 Operand(kIsNotStringMask | | 1721 Operand(kIsNotStringMask | |
1725 kStringRepresentationMask | | 1722 kStringRepresentationMask | |
1726 kShortExternalStringMask)); | 1723 kShortExternalStringMask)); |
1727 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); | 1724 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); |
1728 __ Branch(&seq_string, eq, a1, Operand(zero_reg)); // Go to (5). | 1725 __ Branch(&seq_string, eq, a1, Operand(zero_reg)); // Go to (5). |
1729 | 1726 |
1730 // (2) Anything but sequential or cons? If yes, go to (6). | 1727 // (2) Sequential or cons? If not, go to (5). |
1731 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 1728 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
1732 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 1729 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
1733 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); | 1730 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); |
1734 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); | 1731 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); |
1735 // Go to (6). | 1732 // Go to (5). |
1736 __ Branch(¬_seq_nor_cons, ge, a1, Operand(kExternalStringTag)); | 1733 __ Branch(¬_seq_nor_cons, ge, a1, Operand(kExternalStringTag)); |
1737 | 1734 |
1738 // (3) Cons string. Check that it's flat. | 1735 // (3) Cons string. Check that it's flat. |
1739 // Replace subject with first string and reload instance type. | 1736 // Replace subject with first string and reload instance type. |
1740 __ lw(a0, FieldMemOperand(subject, ConsString::kSecondOffset)); | 1737 __ lw(a0, FieldMemOperand(subject, ConsString::kSecondOffset)); |
1741 __ LoadRoot(a1, Heap::kempty_stringRootIndex); | 1738 __ LoadRoot(a1, Heap::kempty_stringRootIndex); |
1742 __ Branch(&runtime, ne, a0, Operand(a1)); | 1739 __ Branch(&runtime, ne, a0, Operand(a1)); |
1743 __ lw(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); | 1740 __ lw(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); |
| 1741 __ jmp(&check_underlying); |
1744 | 1742 |
1745 // (4) Is subject external? If yes, go to (7). | 1743 // (4) Sequential string. Load regexp code according to encoding. |
1746 __ bind(&check_underlying); | |
1747 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); | |
1748 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); | |
1749 STATIC_ASSERT(kSeqStringTag == 0); | |
1750 __ And(at, a0, Operand(kStringRepresentationMask)); | |
1751 // The underlying external string is never a short external string. | |
1752 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); | |
1753 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); | |
1754 __ Branch(&external_string, ne, at, Operand(zero_reg)); // Go to (7). | |
1755 | |
1756 // (5) Sequential string. Load regexp code according to encoding. | |
1757 __ bind(&seq_string); | 1744 __ bind(&seq_string); |
1758 // subject: sequential subject string (or look-alike, external string) | 1745 // subject: sequential subject string (or look-alike, external string) |
1759 // a3: original subject string | 1746 // a3: original subject string |
1760 // Load previous index and check range before a3 is overwritten. We have to | 1747 // Load previous index and check range before a3 is overwritten. We have to |
1761 // use a3 instead of subject here because subject might have been only made | 1748 // use a3 instead of subject here because subject might have been only made |
1762 // to look like a sequential string when it actually is an external string. | 1749 // to look like a sequential string when it actually is an external string. |
1763 __ lw(a1, MemOperand(sp, kPreviousIndexOffset)); | 1750 __ lw(a1, MemOperand(sp, kPreviousIndexOffset)); |
1764 __ JumpIfNotSmi(a1, &runtime); | 1751 __ JumpIfNotSmi(a1, &runtime); |
1765 __ lw(a3, FieldMemOperand(a3, String::kLengthOffset)); | 1752 __ lw(a3, FieldMemOperand(a3, String::kLengthOffset)); |
1766 __ Branch(&runtime, ls, a3, Operand(a1)); | 1753 __ Branch(&runtime, ls, a3, Operand(a1)); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 | 1975 |
1989 // Return last match info. | 1976 // Return last match info. |
1990 __ lw(v0, MemOperand(sp, kLastMatchInfoOffset)); | 1977 __ lw(v0, MemOperand(sp, kLastMatchInfoOffset)); |
1991 __ DropAndRet(4); | 1978 __ DropAndRet(4); |
1992 | 1979 |
1993 // Do the runtime call to execute the regexp. | 1980 // Do the runtime call to execute the regexp. |
1994 __ bind(&runtime); | 1981 __ bind(&runtime); |
1995 __ TailCallRuntime(Runtime::kRegExpExec); | 1982 __ TailCallRuntime(Runtime::kRegExpExec); |
1996 | 1983 |
1997 // Deferred code for string handling. | 1984 // Deferred code for string handling. |
1998 // (6) Not a long external string? If yes, go to (8). | 1985 // (5) Long external string? If not, go to (7). |
1999 __ bind(¬_seq_nor_cons); | 1986 __ bind(¬_seq_nor_cons); |
2000 // Go to (8). | 1987 // Go to (7). |
2001 __ Branch(¬_long_external, gt, a1, Operand(kExternalStringTag)); | 1988 __ Branch(¬_long_external, gt, a1, Operand(kExternalStringTag)); |
2002 | 1989 |
2003 // (7) External string. Make it, offset-wise, look like a sequential string. | 1990 // (6) External string. Make it, offset-wise, look like a sequential string. |
2004 __ bind(&external_string); | 1991 __ bind(&external_string); |
2005 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 1992 __ lw(a0, FieldMemOperand(subject, HeapObject::kMapOffset)); |
2006 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); | 1993 __ lbu(a0, FieldMemOperand(a0, Map::kInstanceTypeOffset)); |
2007 if (FLAG_debug_code) { | 1994 if (FLAG_debug_code) { |
2008 // Assert that we do not have a cons or slice (indirect strings) here. | 1995 // Assert that we do not have a cons or slice (indirect strings) here. |
2009 // Sequential strings have already been ruled out. | 1996 // Sequential strings have already been ruled out. |
2010 __ And(at, a0, Operand(kIsIndirectStringMask)); | 1997 __ And(at, a0, Operand(kIsIndirectStringMask)); |
2011 __ Assert(eq, | 1998 __ Assert(eq, |
2012 kExternalStringExpectedButNotFound, | 1999 kExternalStringExpectedButNotFound, |
2013 at, | 2000 at, |
2014 Operand(zero_reg)); | 2001 Operand(zero_reg)); |
2015 } | 2002 } |
2016 __ lw(subject, | 2003 __ lw(subject, |
2017 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); | 2004 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); |
2018 // Move the pointer so that offset-wise, it looks like a sequential string. | 2005 // Move the pointer so that offset-wise, it looks like a sequential string. |
2019 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 2006 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
2020 __ Subu(subject, | 2007 __ Subu(subject, |
2021 subject, | 2008 subject, |
2022 SeqTwoByteString::kHeaderSize - kHeapObjectTag); | 2009 SeqTwoByteString::kHeaderSize - kHeapObjectTag); |
2023 __ jmp(&seq_string); // Go to (5). | 2010 __ jmp(&seq_string); // Go to (5). |
2024 | 2011 |
2025 // (8) Short external string or not a string? If yes, bail out to runtime. | 2012 // (7) Short external string or not a string? If yes, bail out to runtime. |
2026 __ bind(¬_long_external); | 2013 __ bind(¬_long_external); |
2027 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); | 2014 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); |
2028 __ And(at, a1, Operand(kIsNotStringMask | kShortExternalStringMask)); | 2015 __ And(at, a1, Operand(kIsNotStringMask | kShortExternalStringMask)); |
2029 __ Branch(&runtime, ne, at, Operand(zero_reg)); | 2016 __ Branch(&runtime, ne, at, Operand(zero_reg)); |
2030 | 2017 |
2031 // (9) Sliced string. Replace subject with parent. Go to (4). | 2018 // (8) Sliced string. Replace subject with parent. Go to (4). |
2032 // Load offset into t0 and replace subject string with parent. | 2019 // Load offset into t0 and replace subject string with parent. |
2033 __ lw(t0, FieldMemOperand(subject, SlicedString::kOffsetOffset)); | 2020 __ lw(t0, FieldMemOperand(subject, SlicedString::kOffsetOffset)); |
2034 __ sra(t0, t0, kSmiTagSize); | 2021 __ sra(t0, t0, kSmiTagSize); |
2035 __ lw(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); | 2022 __ lw(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); |
2036 __ jmp(&check_underlying); // Go to (4). | 2023 __ jmp(&check_underlying); // Go to (4). |
2037 #endif // V8_INTERPRETED_REGEXP | 2024 #endif // V8_INTERPRETED_REGEXP |
2038 } | 2025 } |
2039 | 2026 |
2040 | 2027 |
2041 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { | 2028 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { |
(...skipping 3753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5795 return_value_operand, NULL); | 5782 return_value_operand, NULL); |
5796 } | 5783 } |
5797 | 5784 |
5798 | 5785 |
5799 #undef __ | 5786 #undef __ |
5800 | 5787 |
5801 } // namespace internal | 5788 } // namespace internal |
5802 } // namespace v8 | 5789 } // namespace v8 |
5803 | 5790 |
5804 #endif // V8_TARGET_ARCH_MIPS | 5791 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |