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