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

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

Issue 2415103002: [regexp] Turn last match info into a simple FixedArray (Closed)
Patch Set: Port architectures and move internal match info to context 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 5 #if V8_TARGET_ARCH_ARM64
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 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 Register number_of_capture_registers = x12; 1642 Register number_of_capture_registers = x12;
1643 1643
1644 // Calculate number of capture registers (number_of_captures + 1) * 2 1644 // Calculate number of capture registers (number_of_captures + 1) * 2
1645 // and store it in the last match info. 1645 // and store it in the last match info.
1646 __ Ldrsw(x10, 1646 __ Ldrsw(x10,
1647 UntagSmiFieldMemOperand(regexp_data, 1647 UntagSmiFieldMemOperand(regexp_data,
1648 JSRegExp::kIrregexpCaptureCountOffset)); 1648 JSRegExp::kIrregexpCaptureCountOffset));
1649 __ Add(x10, x10, x10); 1649 __ Add(x10, x10, x10);
1650 __ Add(number_of_capture_registers, x10, 2); 1650 __ Add(number_of_capture_registers, x10, 2);
1651 1651
1652 // Check that the fourth object is a JSObject. 1652 // Check that the last match info is a FixedArray.
1653 DCHECK(jssp.Is(__ StackPointer())); 1653 DCHECK(jssp.Is(__ StackPointer()));
1654 __ Peek(x10, kLastMatchInfoOffset); 1654 __ Peek(last_match_info_elements, kLastMatchInfoOffset);
1655 __ JumpIfSmi(x10, &runtime); 1655 __ JumpIfSmi(last_match_info_elements, &runtime);
1656 __ JumpIfNotObjectType(x10, x11, x11, JS_OBJECT_TYPE, &runtime); 1656 __ JumpIfNotObjectType(last_match_info_elements, x11, x11, FIXED_ARRAY_TYPE,
1657 &runtime);
1657 1658
1658 // Check that the object has fast elements. 1659 // Check that the object has fast elements.
1659 __ Ldr(last_match_info_elements,
1660 FieldMemOperand(x10, JSObject::kElementsOffset));
1661 __ Ldr(x10, 1660 __ Ldr(x10,
1662 FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset)); 1661 FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset));
1663 __ JumpIfNotRoot(x10, Heap::kFixedArrayMapRootIndex, &runtime); 1662 __ JumpIfNotRoot(x10, Heap::kFixedArrayMapRootIndex, &runtime);
1664 1663
1665 // Check that the last match info has space for the capture registers and the 1664 // Check that the last match info has space for the capture registers and the
1666 // additional information (overhead). 1665 // additional information (overhead).
1667 // (number_of_captures + 1) * 2 + overhead <= last match info size 1666 // (number_of_captures + 1) * 2 + overhead <= last match info size
1668 // (number_of_captures * 2) + 2 + overhead <= last match info size 1667 // (number_of_captures * 2) + 2 + overhead <= last match info size
1669 // number_of_capture_registers + overhead <= last match info size 1668 // number_of_capture_registers + overhead <= last match info size
1670 __ Ldrsw(x10, 1669 __ Ldrsw(x10,
1671 UntagSmiFieldMemOperand(last_match_info_elements, 1670 UntagSmiFieldMemOperand(last_match_info_elements,
1672 FixedArray::kLengthOffset)); 1671 FixedArray::kLengthOffset));
1673 __ Add(x11, number_of_capture_registers, RegExpImpl::kLastMatchOverhead); 1672 __ Add(x11, number_of_capture_registers, RegExpMatchInfo::kLastMatchOverhead);
1674 __ Cmp(x11, x10); 1673 __ Cmp(x11, x10);
1675 __ B(gt, &runtime); 1674 __ B(gt, &runtime);
1676 1675
1677 // Store the capture count. 1676 // Store the capture count.
1678 __ SmiTag(x10, number_of_capture_registers); 1677 __ SmiTag(x10, number_of_capture_registers);
1679 __ Str(x10, 1678 __ Str(x10, FieldMemOperand(last_match_info_elements,
1680 FieldMemOperand(last_match_info_elements, 1679 RegExpMatchInfo::kNumberOfCapturesOffset));
1681 RegExpImpl::kLastCaptureCountOffset));
1682 // Store last subject and last input. 1680 // Store last subject and last input.
1683 __ Str(subject, 1681 __ Str(subject, FieldMemOperand(last_match_info_elements,
1684 FieldMemOperand(last_match_info_elements, 1682 RegExpMatchInfo::kLastSubjectOffset));
1685 RegExpImpl::kLastSubjectOffset));
1686 // Use x10 as the subject string in order to only need 1683 // Use x10 as the subject string in order to only need
1687 // one RecordWriteStub. 1684 // one RecordWriteStub.
1688 __ Mov(x10, subject); 1685 __ Mov(x10, subject);
1689 __ RecordWriteField(last_match_info_elements, 1686 __ RecordWriteField(last_match_info_elements,
1690 RegExpImpl::kLastSubjectOffset, 1687 RegExpMatchInfo::kLastSubjectOffset, x10, x11,
1691 x10, 1688 kLRHasNotBeenSaved, kDontSaveFPRegs);
1692 x11, 1689 __ Str(subject, FieldMemOperand(last_match_info_elements,
1693 kLRHasNotBeenSaved, 1690 RegExpMatchInfo::kLastInputOffset));
1694 kDontSaveFPRegs);
1695 __ Str(subject,
1696 FieldMemOperand(last_match_info_elements,
1697 RegExpImpl::kLastInputOffset));
1698 __ Mov(x10, subject); 1691 __ Mov(x10, subject);
1699 __ RecordWriteField(last_match_info_elements, 1692 __ RecordWriteField(last_match_info_elements,
1700 RegExpImpl::kLastInputOffset, 1693 RegExpMatchInfo::kLastInputOffset, x10, x11,
1701 x10, 1694 kLRHasNotBeenSaved, kDontSaveFPRegs);
1702 x11,
1703 kLRHasNotBeenSaved,
1704 kDontSaveFPRegs);
1705 1695
1706 Register last_match_offsets = x13; 1696 Register last_match_offsets = x13;
1707 Register offsets_vector_index = x14; 1697 Register offsets_vector_index = x14;
1708 Register current_offset = x15; 1698 Register current_offset = x15;
1709 1699
1710 // Get the static offsets vector filled by the native regexp code 1700 // Get the static offsets vector filled by the native regexp code
1711 // and fill the last match info. 1701 // and fill the last match info.
1712 ExternalReference address_of_static_offsets_vector = 1702 ExternalReference address_of_static_offsets_vector =
1713 ExternalReference::address_of_static_offsets_vector(isolate()); 1703 ExternalReference::address_of_static_offsets_vector(isolate());
1714 __ Mov(offsets_vector_index, address_of_static_offsets_vector); 1704 __ Mov(offsets_vector_index, address_of_static_offsets_vector);
1715 1705
1716 Label next_capture, done; 1706 Label next_capture, done;
1717 // Capture register counter starts from number of capture registers and 1707 // Capture register counter starts from number of capture registers and
1718 // iterates down to zero (inclusive). 1708 // iterates down to zero (inclusive).
1719 __ Add(last_match_offsets, 1709 __ Add(last_match_offsets, last_match_info_elements,
1720 last_match_info_elements, 1710 RegExpMatchInfo::kFirstCaptureOffset - kHeapObjectTag);
1721 RegExpImpl::kFirstCaptureOffset - kHeapObjectTag);
1722 __ Bind(&next_capture); 1711 __ Bind(&next_capture);
1723 __ Subs(number_of_capture_registers, number_of_capture_registers, 2); 1712 __ Subs(number_of_capture_registers, number_of_capture_registers, 2);
1724 __ B(mi, &done); 1713 __ B(mi, &done);
1725 // Read two 32 bit values from the static offsets vector buffer into 1714 // Read two 32 bit values from the static offsets vector buffer into
1726 // an X register 1715 // an X register
1727 __ Ldr(current_offset, 1716 __ Ldr(current_offset,
1728 MemOperand(offsets_vector_index, kWRegSize * 2, PostIndex)); 1717 MemOperand(offsets_vector_index, kWRegSize * 2, PostIndex));
1729 // Store the smi values in the last match info. 1718 // Store the smi values in the last match info.
1730 __ SmiTag(x10, current_offset); 1719 __ SmiTag(x10, current_offset);
1731 // Clearing the 32 bottom bits gives us a Smi. 1720 // Clearing the 32 bottom bits gives us a Smi.
1732 STATIC_ASSERT(kSmiTag == 0); 1721 STATIC_ASSERT(kSmiTag == 0);
1733 __ Bic(x11, current_offset, kSmiShiftMask); 1722 __ Bic(x11, current_offset, kSmiShiftMask);
1734 __ Stp(x10, 1723 __ Stp(x10,
1735 x11, 1724 x11,
1736 MemOperand(last_match_offsets, kXRegSize * 2, PostIndex)); 1725 MemOperand(last_match_offsets, kXRegSize * 2, PostIndex));
1737 __ B(&next_capture); 1726 __ B(&next_capture);
1738 __ Bind(&done); 1727 __ Bind(&done);
1739 1728
1740 // Return last match info. 1729 // Return last match info.
1741 __ Peek(x0, kLastMatchInfoOffset); 1730 __ Mov(x0, last_match_info_elements);
1742 // Drop the 4 arguments of the stub from the stack. 1731 // Drop the 4 arguments of the stub from the stack.
1743 __ Drop(4); 1732 __ Drop(4);
1744 __ Ret(); 1733 __ Ret();
1745 1734
1746 __ Bind(&exception); 1735 __ Bind(&exception);
1747 Register exception_value = x0; 1736 Register exception_value = x0;
1748 // A stack overflow (on the backtrack stack) may have occured 1737 // A stack overflow (on the backtrack stack) may have occured
1749 // in the RegExp code but no exception has been created yet. 1738 // in the RegExp code but no exception has been created yet.
1750 // If there is no pending exception, handle that in the runtime system. 1739 // If there is no pending exception, handle that in the runtime system.
1751 __ Mov(x10, Operand(isolate()->factory()->the_hole_value())); 1740 __ Mov(x10, Operand(isolate()->factory()->the_hole_value()));
(...skipping 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after
5001 kStackUnwindSpace, NULL, spill_offset, 4990 kStackUnwindSpace, NULL, spill_offset,
5002 return_value_operand, NULL); 4991 return_value_operand, NULL);
5003 } 4992 }
5004 4993
5005 #undef __ 4994 #undef __
5006 4995
5007 } // namespace internal 4996 } // namespace internal
5008 } // namespace v8 4997 } // namespace v8
5009 4998
5010 #endif // V8_TARGET_ARCH_ARM64 4999 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« src/arm/code-stubs-arm.cc ('K') | « src/arm/code-stubs-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698