| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 __ Bind(&fail); | 377 __ Bind(&fail); |
| 378 BranchOrBacktrack(al, on_no_match); | 378 BranchOrBacktrack(al, on_no_match); |
| 379 | 379 |
| 380 __ Bind(&success); | 380 __ Bind(&success); |
| 381 // Compute new value of character position after the matched part. | 381 // Compute new value of character position after the matched part. |
| 382 __ Sub(current_input_offset().X(), current_position_address, input_end()); | 382 __ Sub(current_input_offset().X(), current_position_address, input_end()); |
| 383 if (masm_->emit_debug_code()) { | 383 if (masm_->emit_debug_code()) { |
| 384 __ Cmp(current_input_offset().X(), Operand(current_input_offset(), SXTW)); | 384 __ Cmp(current_input_offset().X(), Operand(current_input_offset(), SXTW)); |
| 385 __ Ccmp(current_input_offset(), 0, NoFlag, eq); | 385 __ Ccmp(current_input_offset(), 0, NoFlag, eq); |
| 386 // The current input offset should be <= 0, and fit in a W register. | 386 // The current input offset should be <= 0, and fit in a W register. |
| 387 // TODO(all): Add this error code to objects.h. | 387 __ Check(le, kOffsetOutOfRange); |
| 388 // __ Check(le, kCurrentInputOffsetOutOfRange); | |
| 389 __ Check(le, kUnknown); | |
| 390 } | 388 } |
| 391 } else { | 389 } else { |
| 392 ASSERT(mode_ == UC16); | 390 ASSERT(mode_ == UC16); |
| 393 int argument_count = 4; | 391 int argument_count = 4; |
| 394 | 392 |
| 395 // The cached registers need to be retained. | 393 // The cached registers need to be retained. |
| 396 CPURegList cached_registers(CPURegister::kRegister, kXRegSize, 0, 7); | 394 CPURegList cached_registers(CPURegister::kRegister, kXRegSize, 0, 7); |
| 397 ASSERT((cached_registers.Count() * 2) == kNumCachedRegisters); | 395 ASSERT((cached_registers.Count() * 2) == kNumCachedRegisters); |
| 398 __ PushCPURegList(cached_registers); | 396 __ PushCPURegList(cached_registers); |
| 399 | 397 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 BranchOrBacktrack(ne, on_no_match); | 478 BranchOrBacktrack(ne, on_no_match); |
| 481 __ Cmp(capture_start_address, capture_end_address); | 479 __ Cmp(capture_start_address, capture_end_address); |
| 482 __ B(lt, &loop); | 480 __ B(lt, &loop); |
| 483 | 481 |
| 484 // Move current character position to position after match. | 482 // Move current character position to position after match. |
| 485 __ Sub(current_input_offset().X(), current_position_address, input_end()); | 483 __ Sub(current_input_offset().X(), current_position_address, input_end()); |
| 486 if (masm_->emit_debug_code()) { | 484 if (masm_->emit_debug_code()) { |
| 487 __ Cmp(current_input_offset().X(), Operand(current_input_offset(), SXTW)); | 485 __ Cmp(current_input_offset().X(), Operand(current_input_offset(), SXTW)); |
| 488 __ Ccmp(current_input_offset(), 0, NoFlag, eq); | 486 __ Ccmp(current_input_offset(), 0, NoFlag, eq); |
| 489 // The current input offset should be <= 0, and fit in a W register. | 487 // The current input offset should be <= 0, and fit in a W register. |
| 490 // TODO(all): Add this error code to objects.h. | 488 __ Check(le, kOffsetOutOfRange); |
| 491 // __ Check(le, kCurrentInputOffsetOutOfRange); | |
| 492 __ Check(le, kUnknown); | |
| 493 } | 489 } |
| 494 __ Bind(&fallthrough); | 490 __ Bind(&fallthrough); |
| 495 } | 491 } |
| 496 | 492 |
| 497 | 493 |
| 498 void RegExpMacroAssemblerA64::CheckNotCharacter(unsigned c, | 494 void RegExpMacroAssemblerA64::CheckNotCharacter(unsigned c, |
| 499 Label* on_not_equal) { | 495 Label* on_not_equal) { |
| 500 CompareAndBranchOrBacktrack(current_character(), c, ne, on_not_equal); | 496 CompareAndBranchOrBacktrack(current_character(), c, ne, on_not_equal); |
| 501 } | 497 } |
| 502 | 498 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 766 |
| 771 // Initialize success_counter with 0. | 767 // Initialize success_counter with 0. |
| 772 __ Str(wzr, MemOperand(frame_pointer(), kSuccessCounter)); | 768 __ Str(wzr, MemOperand(frame_pointer(), kSuccessCounter)); |
| 773 | 769 |
| 774 // Find negative length (offset of start relative to end). | 770 // Find negative length (offset of start relative to end). |
| 775 __ Sub(x10, input_start(), input_end()); | 771 __ Sub(x10, input_start(), input_end()); |
| 776 if (masm_->emit_debug_code()) { | 772 if (masm_->emit_debug_code()) { |
| 777 // Check that the input string length is < 2^30. | 773 // Check that the input string length is < 2^30. |
| 778 __ Neg(x11, x10); | 774 __ Neg(x11, x10); |
| 779 __ Cmp(x11, (1<<30) - 1); | 775 __ Cmp(x11, (1<<30) - 1); |
| 780 // TODO(all): Add this error code to objects.h. | 776 __ Check(ls, kInputStringTooLong); |
| 781 // __ Check(ls, kInputStringTooLong); | |
| 782 __ Check(ls, kUnknown); | |
| 783 } | 777 } |
| 784 __ Mov(current_input_offset(), w10); | 778 __ Mov(current_input_offset(), w10); |
| 785 | 779 |
| 786 // The non-position value is used as a clearing value for the | 780 // The non-position value is used as a clearing value for the |
| 787 // capture registers, it corresponds to the position of the first character | 781 // capture registers, it corresponds to the position of the first character |
| 788 // minus one. | 782 // minus one. |
| 789 __ Sub(non_position_value(), current_input_offset(), char_size()); | 783 __ Sub(non_position_value(), current_input_offset(), char_size()); |
| 790 __ Sub(non_position_value(), non_position_value(), | 784 __ Sub(non_position_value(), non_position_value(), |
| 791 Operand(start_offset(), LSL, (mode_ == UC16) ? 1 : 0)); | 785 Operand(start_offset(), LSL, (mode_ == UC16) ? 1 : 0)); |
| 792 // We can store this value twice in an X register for initializing | 786 // We can store this value twice in an X register for initializing |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 Register capture_end = w13; | 831 Register capture_end = w13; |
| 838 Register input_length = w14; | 832 Register input_length = w14; |
| 839 | 833 |
| 840 // Copy captures to output. | 834 // Copy captures to output. |
| 841 | 835 |
| 842 // Get string length. | 836 // Get string length. |
| 843 __ Sub(x10, input_end(), input_start()); | 837 __ Sub(x10, input_end(), input_start()); |
| 844 if (masm_->emit_debug_code()) { | 838 if (masm_->emit_debug_code()) { |
| 845 // Check that the input string length is < 2^30. | 839 // Check that the input string length is < 2^30. |
| 846 __ Cmp(x10, (1<<30) - 1); | 840 __ Cmp(x10, (1<<30) - 1); |
| 847 // TODO(all): Add this error code to objects.h. | 841 __ Check(ls, kInputStringTooLong); |
| 848 // __ Check(ls, kInputStringTooLong); | |
| 849 __ Check(ls, kUnknown); | |
| 850 } | 842 } |
| 851 // input_start has a start_offset offset on entry. We need to include | 843 // input_start has a start_offset offset on entry. We need to include |
| 852 // it when computing the length of the whole string. | 844 // it when computing the length of the whole string. |
| 853 if (mode_ == UC16) { | 845 if (mode_ == UC16) { |
| 854 __ Add(input_length, start_offset(), Operand(w10, LSR, 1)); | 846 __ Add(input_length, start_offset(), Operand(w10, LSR, 1)); |
| 855 } else { | 847 } else { |
| 856 __ Add(input_length, start_offset(), w10); | 848 __ Add(input_length, start_offset(), w10); |
| 857 } | 849 } |
| 858 | 850 |
| 859 // Copy the results to the output array from the cached registers first. | 851 // Copy the results to the output array from the cached registers first. |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 void RegExpMacroAssemblerA64::PushBacktrack(Label* label) { | 1129 void RegExpMacroAssemblerA64::PushBacktrack(Label* label) { |
| 1138 if (label->is_bound()) { | 1130 if (label->is_bound()) { |
| 1139 int target = label->pos(); | 1131 int target = label->pos(); |
| 1140 __ Mov(w10, target + Code::kHeaderSize - kHeapObjectTag); | 1132 __ Mov(w10, target + Code::kHeaderSize - kHeapObjectTag); |
| 1141 } else { | 1133 } else { |
| 1142 __ Adr(x10, label); | 1134 __ Adr(x10, label); |
| 1143 __ Sub(x10, x10, code_pointer()); | 1135 __ Sub(x10, x10, code_pointer()); |
| 1144 if (masm_->emit_debug_code()) { | 1136 if (masm_->emit_debug_code()) { |
| 1145 __ Cmp(x10, kWRegMask); | 1137 __ Cmp(x10, kWRegMask); |
| 1146 // The code offset has to fit in a W register. | 1138 // The code offset has to fit in a W register. |
| 1147 // TODO(all): Add this error code to objects.h. | 1139 __ Check(ls, kOffsetOutOfRange); |
| 1148 // __ Check(ls, kCodeOffsetOutOfRange); | |
| 1149 __ Check(ls, kUnknown); | |
| 1150 } | 1140 } |
| 1151 } | 1141 } |
| 1152 Push(w10); | 1142 Push(w10); |
| 1153 CheckStackLimit(); | 1143 CheckStackLimit(); |
| 1154 } | 1144 } |
| 1155 | 1145 |
| 1156 | 1146 |
| 1157 void RegExpMacroAssemblerA64::PushCurrentPosition() { | 1147 void RegExpMacroAssemblerA64::PushCurrentPosition() { |
| 1158 Push(current_input_offset()); | 1148 Push(current_input_offset()); |
| 1159 } | 1149 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 } | 1287 } |
| 1298 } | 1288 } |
| 1299 | 1289 |
| 1300 | 1290 |
| 1301 void RegExpMacroAssemblerA64::WriteStackPointerToRegister(int reg) { | 1291 void RegExpMacroAssemblerA64::WriteStackPointerToRegister(int reg) { |
| 1302 __ Ldr(x10, MemOperand(frame_pointer(), kStackBase)); | 1292 __ Ldr(x10, MemOperand(frame_pointer(), kStackBase)); |
| 1303 __ Sub(x10, backtrack_stackpointer(), x10); | 1293 __ Sub(x10, backtrack_stackpointer(), x10); |
| 1304 if (masm_->emit_debug_code()) { | 1294 if (masm_->emit_debug_code()) { |
| 1305 __ Cmp(x10, Operand(w10, SXTW)); | 1295 __ Cmp(x10, Operand(w10, SXTW)); |
| 1306 // The stack offset needs to fit in a W register. | 1296 // The stack offset needs to fit in a W register. |
| 1307 // TODO(all): Add this error code to objects.h. | 1297 __ Check(eq, kOffsetOutOfRange); |
| 1308 // __ Check(eq, kStackOffsetIsTooLarge); | |
| 1309 __ Check(eq, kUnknown); | |
| 1310 } | 1298 } |
| 1311 StoreRegister(reg, w10); | 1299 StoreRegister(reg, w10); |
| 1312 } | 1300 } |
| 1313 | 1301 |
| 1314 | 1302 |
| 1315 // Helper function for reading a value out of a stack frame. | 1303 // Helper function for reading a value out of a stack frame. |
| 1316 template <typename T> | 1304 template <typename T> |
| 1317 static T& frame_entry(Address re_frame, int frame_offset) { | 1305 static T& frame_entry(Address re_frame, int frame_offset) { |
| 1318 return *reinterpret_cast<T*>(re_frame + frame_offset); | 1306 return *reinterpret_cast<T*>(re_frame + frame_offset); |
| 1319 } | 1307 } |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 if (!CanReadUnaligned()) { | 1690 if (!CanReadUnaligned()) { |
| 1703 ASSERT(characters == 1); | 1691 ASSERT(characters == 1); |
| 1704 } | 1692 } |
| 1705 | 1693 |
| 1706 if (cp_offset != 0) { | 1694 if (cp_offset != 0) { |
| 1707 if (masm_->emit_debug_code()) { | 1695 if (masm_->emit_debug_code()) { |
| 1708 __ Mov(x10, cp_offset * char_size()); | 1696 __ Mov(x10, cp_offset * char_size()); |
| 1709 __ Add(x10, x10, Operand(current_input_offset(), SXTW)); | 1697 __ Add(x10, x10, Operand(current_input_offset(), SXTW)); |
| 1710 __ Cmp(x10, Operand(w10, SXTW)); | 1698 __ Cmp(x10, Operand(w10, SXTW)); |
| 1711 // The offset needs to fit in a W register. | 1699 // The offset needs to fit in a W register. |
| 1712 // TODO(all): Add this error code to objects.h. | 1700 __ Check(eq, kOffsetOutOfRange); |
| 1713 // __ Check(eq, kCurrentInputOffsetOutOfRange); | |
| 1714 __ Check(eq, kUnknown); | |
| 1715 } else { | 1701 } else { |
| 1716 __ Add(w10, current_input_offset(), cp_offset * char_size()); | 1702 __ Add(w10, current_input_offset(), cp_offset * char_size()); |
| 1717 } | 1703 } |
| 1718 offset = w10; | 1704 offset = w10; |
| 1719 } | 1705 } |
| 1720 | 1706 |
| 1721 if (mode_ == ASCII) { | 1707 if (mode_ == ASCII) { |
| 1722 if (characters == 4) { | 1708 if (characters == 4) { |
| 1723 __ Ldr(current_character(), MemOperand(input_end(), offset, SXTW)); | 1709 __ Ldr(current_character(), MemOperand(input_end(), offset, SXTW)); |
| 1724 } else if (characters == 2) { | 1710 } else if (characters == 2) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1736 __ Ldrh(current_character(), MemOperand(input_end(), offset, SXTW)); | 1722 __ Ldrh(current_character(), MemOperand(input_end(), offset, SXTW)); |
| 1737 } | 1723 } |
| 1738 } | 1724 } |
| 1739 } | 1725 } |
| 1740 | 1726 |
| 1741 #endif // V8_INTERPRETED_REGEXP | 1727 #endif // V8_INTERPRETED_REGEXP |
| 1742 | 1728 |
| 1743 }} // namespace v8::internal | 1729 }} // namespace v8::internal |
| 1744 | 1730 |
| 1745 #endif // V8_TARGET_ARCH_A64 | 1731 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |