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/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 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 // Process the result from the native regexp code. | 1618 // Process the result from the native regexp code. |
1619 __ bind(&success); | 1619 __ bind(&success); |
1620 __ lw(a1, | 1620 __ lw(a1, |
1621 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); | 1621 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); |
1622 // Calculate number of capture registers (number_of_captures + 1) * 2. | 1622 // Calculate number of capture registers (number_of_captures + 1) * 2. |
1623 // Multiplying by 2 comes for free since r1 is smi-tagged. | 1623 // Multiplying by 2 comes for free since r1 is smi-tagged. |
1624 STATIC_ASSERT(kSmiTag == 0); | 1624 STATIC_ASSERT(kSmiTag == 0); |
1625 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 1625 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); |
1626 __ Addu(a1, a1, Operand(2)); // a1 was a smi. | 1626 __ Addu(a1, a1, Operand(2)); // a1 was a smi. |
1627 | 1627 |
1628 __ lw(a0, MemOperand(sp, kLastMatchInfoOffset)); | 1628 // Check that the last match info is a FixedArray. |
1629 __ JumpIfSmi(a0, &runtime); | 1629 __ lw(last_match_info_elements, MemOperand(sp, kLastMatchInfoOffset)); |
1630 __ GetObjectType(a0, a2, a2); | 1630 __ JumpIfSmi(last_match_info_elements, &runtime); |
1631 __ Branch(&runtime, ne, a2, Operand(JS_OBJECT_TYPE)); | 1631 __ GetObjectType(last_match_info_elements, a2, a2); |
| 1632 __ Branch(&runtime, ne, a2, Operand(FIXED_ARRAY_TYPE)); |
1632 // Check that the object has fast elements. | 1633 // Check that the object has fast elements. |
1633 __ lw(last_match_info_elements, | |
1634 FieldMemOperand(a0, JSArray::kElementsOffset)); | |
1635 __ lw(a0, FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset)); | 1634 __ lw(a0, FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset)); |
1636 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex); | 1635 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex); |
1637 __ Branch(&runtime, ne, a0, Operand(at)); | 1636 __ Branch(&runtime, ne, a0, Operand(at)); |
1638 // Check that the last match info has space for the capture registers and the | 1637 // Check that the last match info has space for the capture registers and the |
1639 // additional information. | 1638 // additional information. |
1640 __ lw(a0, | 1639 __ lw(a0, |
1641 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); | 1640 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); |
1642 __ Addu(a2, a1, Operand(RegExpImpl::kLastMatchOverhead)); | 1641 __ Addu(a2, a1, Operand(RegExpMatchInfo::kLastMatchOverhead)); |
1643 __ sra(at, a0, kSmiTagSize); | 1642 __ sra(at, a0, kSmiTagSize); |
1644 __ Branch(&runtime, gt, a2, Operand(at)); | 1643 __ Branch(&runtime, gt, a2, Operand(at)); |
1645 | 1644 |
1646 // a1: number of capture registers | 1645 // a1: number of capture registers |
1647 // subject: subject string | 1646 // subject: subject string |
1648 // Store the capture count. | 1647 // Store the capture count. |
1649 __ sll(a2, a1, kSmiTagSize + kSmiShiftSize); // To smi. | 1648 __ sll(a2, a1, kSmiTagSize + kSmiShiftSize); // To smi. |
1650 __ sw(a2, FieldMemOperand(last_match_info_elements, | 1649 __ sw(a2, FieldMemOperand(last_match_info_elements, |
1651 RegExpImpl::kLastCaptureCountOffset)); | 1650 RegExpMatchInfo::kNumberOfCapturesOffset)); |
1652 // Store last subject and last input. | 1651 // Store last subject and last input. |
1653 __ sw(subject, | 1652 __ sw(subject, FieldMemOperand(last_match_info_elements, |
1654 FieldMemOperand(last_match_info_elements, | 1653 RegExpMatchInfo::kLastSubjectOffset)); |
1655 RegExpImpl::kLastSubjectOffset)); | |
1656 __ mov(a2, subject); | 1654 __ mov(a2, subject); |
1657 __ RecordWriteField(last_match_info_elements, | 1655 __ RecordWriteField(last_match_info_elements, |
1658 RegExpImpl::kLastSubjectOffset, | 1656 RegExpMatchInfo::kLastSubjectOffset, subject, t3, |
1659 subject, | 1657 kRAHasNotBeenSaved, kDontSaveFPRegs); |
1660 t3, | |
1661 kRAHasNotBeenSaved, | |
1662 kDontSaveFPRegs); | |
1663 __ mov(subject, a2); | 1658 __ mov(subject, a2); |
1664 __ sw(subject, | 1659 __ sw(subject, FieldMemOperand(last_match_info_elements, |
1665 FieldMemOperand(last_match_info_elements, | 1660 RegExpMatchInfo::kLastInputOffset)); |
1666 RegExpImpl::kLastInputOffset)); | |
1667 __ RecordWriteField(last_match_info_elements, | 1661 __ RecordWriteField(last_match_info_elements, |
1668 RegExpImpl::kLastInputOffset, | 1662 RegExpMatchInfo::kLastInputOffset, subject, t3, |
1669 subject, | 1663 kRAHasNotBeenSaved, kDontSaveFPRegs); |
1670 t3, | |
1671 kRAHasNotBeenSaved, | |
1672 kDontSaveFPRegs); | |
1673 | 1664 |
1674 // Get the static offsets vector filled by the native regexp code. | 1665 // Get the static offsets vector filled by the native regexp code. |
1675 ExternalReference address_of_static_offsets_vector = | 1666 ExternalReference address_of_static_offsets_vector = |
1676 ExternalReference::address_of_static_offsets_vector(isolate()); | 1667 ExternalReference::address_of_static_offsets_vector(isolate()); |
1677 __ li(a2, Operand(address_of_static_offsets_vector)); | 1668 __ li(a2, Operand(address_of_static_offsets_vector)); |
1678 | 1669 |
1679 // a1: number of capture registers | 1670 // a1: number of capture registers |
1680 // a2: offsets vector | 1671 // a2: offsets vector |
1681 Label next_capture, done; | 1672 Label next_capture, done; |
1682 // Capture register counter starts from number of capture registers and | 1673 // Capture register counter starts from number of capture registers and |
1683 // counts down until wrapping after zero. | 1674 // counts down until wrapping after zero. |
1684 __ Addu(a0, | 1675 __ Addu(a0, last_match_info_elements, |
1685 last_match_info_elements, | 1676 Operand(RegExpMatchInfo::kFirstCaptureOffset - kHeapObjectTag)); |
1686 Operand(RegExpImpl::kFirstCaptureOffset - kHeapObjectTag)); | |
1687 __ bind(&next_capture); | 1677 __ bind(&next_capture); |
1688 __ Subu(a1, a1, Operand(1)); | 1678 __ Subu(a1, a1, Operand(1)); |
1689 __ Branch(&done, lt, a1, Operand(zero_reg)); | 1679 __ Branch(&done, lt, a1, Operand(zero_reg)); |
1690 // Read the value from the static offsets vector buffer. | 1680 // Read the value from the static offsets vector buffer. |
1691 __ lw(a3, MemOperand(a2, 0)); | 1681 __ lw(a3, MemOperand(a2, 0)); |
1692 __ addiu(a2, a2, kPointerSize); | 1682 __ addiu(a2, a2, kPointerSize); |
1693 // Store the smi value in the last match info. | 1683 // Store the smi value in the last match info. |
1694 __ sll(a3, a3, kSmiTagSize); // Convert to Smi. | 1684 __ sll(a3, a3, kSmiTagSize); // Convert to Smi. |
1695 __ sw(a3, MemOperand(a0, 0)); | 1685 __ sw(a3, MemOperand(a0, 0)); |
1696 __ Branch(&next_capture, USE_DELAY_SLOT); | 1686 __ Branch(&next_capture, USE_DELAY_SLOT); |
1697 __ addiu(a0, a0, kPointerSize); // In branch delay slot. | 1687 __ addiu(a0, a0, kPointerSize); // In branch delay slot. |
1698 | 1688 |
1699 __ bind(&done); | 1689 __ bind(&done); |
1700 | 1690 |
1701 // Return last match info. | 1691 // Return last match info. |
1702 __ lw(v0, MemOperand(sp, kLastMatchInfoOffset)); | 1692 __ lw(v0, last_match_info_elements); |
1703 __ DropAndRet(4); | 1693 __ DropAndRet(4); |
1704 | 1694 |
1705 // Do the runtime call to execute the regexp. | 1695 // Do the runtime call to execute the regexp. |
1706 __ bind(&runtime); | 1696 __ bind(&runtime); |
1707 __ TailCallRuntime(Runtime::kRegExpExec); | 1697 __ TailCallRuntime(Runtime::kRegExpExec); |
1708 | 1698 |
1709 // Deferred code for string handling. | 1699 // Deferred code for string handling. |
1710 // (5) Long external string? If not, go to (7). | 1700 // (5) Long external string? If not, go to (7). |
1711 __ bind(¬_seq_nor_cons); | 1701 __ bind(¬_seq_nor_cons); |
1712 // Go to (7). | 1702 // Go to (7). |
(...skipping 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4855 kStackUnwindSpace, kInvalidStackOffset, | 4845 kStackUnwindSpace, kInvalidStackOffset, |
4856 return_value_operand, NULL); | 4846 return_value_operand, NULL); |
4857 } | 4847 } |
4858 | 4848 |
4859 #undef __ | 4849 #undef __ |
4860 | 4850 |
4861 } // namespace internal | 4851 } // namespace internal |
4862 } // namespace v8 | 4852 } // namespace v8 |
4863 | 4853 |
4864 #endif // V8_TARGET_ARCH_MIPS | 4854 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |