Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 2415103002: [regexp] Turn last match info into a simple FixedArray (Closed)
Patch Set: Don't check instance type before map check Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/js/regexp.js ('k') | src/mips64/code-stubs-mips64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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));
1632 // Check that the object has fast elements. 1631 // 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)); 1632 __ lw(a0, FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset));
1636 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex); 1633 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex);
1637 __ Branch(&runtime, ne, a0, Operand(at)); 1634 __ Branch(&runtime, ne, a0, Operand(at));
1638 // Check that the last match info has space for the capture registers and the 1635 // Check that the last match info has space for the capture registers and the
1639 // additional information. 1636 // additional information.
1640 __ lw(a0, 1637 __ lw(a0,
1641 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); 1638 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset));
1642 __ Addu(a2, a1, Operand(RegExpImpl::kLastMatchOverhead)); 1639 __ Addu(a2, a1, Operand(RegExpMatchInfo::kLastMatchOverhead));
1643 __ sra(at, a0, kSmiTagSize); 1640 __ sra(at, a0, kSmiTagSize);
1644 __ Branch(&runtime, gt, a2, Operand(at)); 1641 __ Branch(&runtime, gt, a2, Operand(at));
1645 1642
1646 // a1: number of capture registers 1643 // a1: number of capture registers
1647 // subject: subject string 1644 // subject: subject string
1648 // Store the capture count. 1645 // Store the capture count.
1649 __ sll(a2, a1, kSmiTagSize + kSmiShiftSize); // To smi. 1646 __ sll(a2, a1, kSmiTagSize + kSmiShiftSize); // To smi.
1650 __ sw(a2, FieldMemOperand(last_match_info_elements, 1647 __ sw(a2, FieldMemOperand(last_match_info_elements,
1651 RegExpImpl::kLastCaptureCountOffset)); 1648 RegExpMatchInfo::kNumberOfCapturesOffset));
1652 // Store last subject and last input. 1649 // Store last subject and last input.
1653 __ sw(subject, 1650 __ sw(subject, FieldMemOperand(last_match_info_elements,
1654 FieldMemOperand(last_match_info_elements, 1651 RegExpMatchInfo::kLastSubjectOffset));
1655 RegExpImpl::kLastSubjectOffset));
1656 __ mov(a2, subject); 1652 __ mov(a2, subject);
1657 __ RecordWriteField(last_match_info_elements, 1653 __ RecordWriteField(last_match_info_elements,
1658 RegExpImpl::kLastSubjectOffset, 1654 RegExpMatchInfo::kLastSubjectOffset, subject, t3,
1659 subject, 1655 kRAHasNotBeenSaved, kDontSaveFPRegs);
1660 t3,
1661 kRAHasNotBeenSaved,
1662 kDontSaveFPRegs);
1663 __ mov(subject, a2); 1656 __ mov(subject, a2);
1664 __ sw(subject, 1657 __ sw(subject, FieldMemOperand(last_match_info_elements,
1665 FieldMemOperand(last_match_info_elements, 1658 RegExpMatchInfo::kLastInputOffset));
1666 RegExpImpl::kLastInputOffset));
1667 __ RecordWriteField(last_match_info_elements, 1659 __ RecordWriteField(last_match_info_elements,
1668 RegExpImpl::kLastInputOffset, 1660 RegExpMatchInfo::kLastInputOffset, subject, t3,
1669 subject, 1661 kRAHasNotBeenSaved, kDontSaveFPRegs);
1670 t3,
1671 kRAHasNotBeenSaved,
1672 kDontSaveFPRegs);
1673 1662
1674 // Get the static offsets vector filled by the native regexp code. 1663 // Get the static offsets vector filled by the native regexp code.
1675 ExternalReference address_of_static_offsets_vector = 1664 ExternalReference address_of_static_offsets_vector =
1676 ExternalReference::address_of_static_offsets_vector(isolate()); 1665 ExternalReference::address_of_static_offsets_vector(isolate());
1677 __ li(a2, Operand(address_of_static_offsets_vector)); 1666 __ li(a2, Operand(address_of_static_offsets_vector));
1678 1667
1679 // a1: number of capture registers 1668 // a1: number of capture registers
1680 // a2: offsets vector 1669 // a2: offsets vector
1681 Label next_capture, done; 1670 Label next_capture, done;
1682 // Capture register counter starts from number of capture registers and 1671 // Capture register counter starts from number of capture registers and
1683 // counts down until wrapping after zero. 1672 // counts down until wrapping after zero.
1684 __ Addu(a0, 1673 __ Addu(a0, last_match_info_elements,
1685 last_match_info_elements, 1674 Operand(RegExpMatchInfo::kFirstCaptureOffset - kHeapObjectTag));
1686 Operand(RegExpImpl::kFirstCaptureOffset - kHeapObjectTag));
1687 __ bind(&next_capture); 1675 __ bind(&next_capture);
1688 __ Subu(a1, a1, Operand(1)); 1676 __ Subu(a1, a1, Operand(1));
1689 __ Branch(&done, lt, a1, Operand(zero_reg)); 1677 __ Branch(&done, lt, a1, Operand(zero_reg));
1690 // Read the value from the static offsets vector buffer. 1678 // Read the value from the static offsets vector buffer.
1691 __ lw(a3, MemOperand(a2, 0)); 1679 __ lw(a3, MemOperand(a2, 0));
1692 __ addiu(a2, a2, kPointerSize); 1680 __ addiu(a2, a2, kPointerSize);
1693 // Store the smi value in the last match info. 1681 // Store the smi value in the last match info.
1694 __ sll(a3, a3, kSmiTagSize); // Convert to Smi. 1682 __ sll(a3, a3, kSmiTagSize); // Convert to Smi.
1695 __ sw(a3, MemOperand(a0, 0)); 1683 __ sw(a3, MemOperand(a0, 0));
1696 __ Branch(&next_capture, USE_DELAY_SLOT); 1684 __ Branch(&next_capture, USE_DELAY_SLOT);
1697 __ addiu(a0, a0, kPointerSize); // In branch delay slot. 1685 __ addiu(a0, a0, kPointerSize); // In branch delay slot.
1698 1686
1699 __ bind(&done); 1687 __ bind(&done);
1700 1688
1701 // Return last match info. 1689 // Return last match info.
1702 __ lw(v0, MemOperand(sp, kLastMatchInfoOffset)); 1690 __ mov(v0, last_match_info_elements);
1703 __ DropAndRet(4); 1691 __ DropAndRet(4);
1704 1692
1705 // Do the runtime call to execute the regexp. 1693 // Do the runtime call to execute the regexp.
1706 __ bind(&runtime); 1694 __ bind(&runtime);
1707 __ TailCallRuntime(Runtime::kRegExpExec); 1695 __ TailCallRuntime(Runtime::kRegExpExec);
1708 1696
1709 // Deferred code for string handling. 1697 // Deferred code for string handling.
1710 // (5) Long external string? If not, go to (7). 1698 // (5) Long external string? If not, go to (7).
1711 __ bind(&not_seq_nor_cons); 1699 __ bind(&not_seq_nor_cons);
1712 // Go to (7). 1700 // Go to (7).
(...skipping 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after
4855 kStackUnwindSpace, kInvalidStackOffset, 4843 kStackUnwindSpace, kInvalidStackOffset,
4856 return_value_operand, NULL); 4844 return_value_operand, NULL);
4857 } 4845 }
4858 4846
4859 #undef __ 4847 #undef __
4860 4848
4861 } // namespace internal 4849 } // namespace internal
4862 } // namespace v8 4850 } // namespace v8
4863 4851
4864 #endif // V8_TARGET_ARCH_MIPS 4852 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/js/regexp.js ('k') | src/mips64/code-stubs-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698