OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 Drop(); | 234 Drop(); |
235 BranchOrBacktrack(no_condition, on_equal); | 235 BranchOrBacktrack(no_condition, on_equal); |
236 __ bind(&fallthrough); | 236 __ bind(&fallthrough); |
237 } | 237 } |
238 | 238 |
239 | 239 |
240 void RegExpMacroAssemblerX64::CheckNotBackReferenceIgnoreCase( | 240 void RegExpMacroAssemblerX64::CheckNotBackReferenceIgnoreCase( |
241 int start_reg, | 241 int start_reg, |
242 Label* on_no_match) { | 242 Label* on_no_match) { |
243 Label fallthrough; | 243 Label fallthrough; |
244 __ movq(rdx, register_location(start_reg)); // Offset of start of capture | 244 ReadPositionFromRegister(rdx, start_reg); // Offset of start of capture |
245 __ movq(rbx, register_location(start_reg + 1)); // Offset of end of capture | 245 ReadPositionFromRegister(rbx, start_reg + 1); // Offset of end of capture |
246 __ subp(rbx, rdx); // Length of capture. | 246 __ subp(rbx, rdx); // Length of capture. |
247 | 247 |
248 // ----------------------- | 248 // ----------------------- |
249 // rdx = Start offset of capture. | 249 // rdx = Start offset of capture. |
250 // rbx = Length of capture | 250 // rbx = Length of capture |
251 | 251 |
252 // If length is negative, this code will fail (it's a symptom of a partial or | 252 // If length is negative, this code will fail (it's a symptom of a partial or |
253 // illegal capture where start of capture after end of capture). | 253 // illegal capture where start of capture after end of capture). |
254 // This must not happen (no back-reference can reference a capture that wasn't | 254 // This must not happen (no back-reference can reference a capture that wasn't |
255 // closed before in the reg-exp, and we must not generate code that can cause | 255 // closed before in the reg-exp, and we must not generate code that can cause |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 __ bind(&fallthrough); | 383 __ bind(&fallthrough); |
384 } | 384 } |
385 | 385 |
386 | 386 |
387 void RegExpMacroAssemblerX64::CheckNotBackReference( | 387 void RegExpMacroAssemblerX64::CheckNotBackReference( |
388 int start_reg, | 388 int start_reg, |
389 Label* on_no_match) { | 389 Label* on_no_match) { |
390 Label fallthrough; | 390 Label fallthrough; |
391 | 391 |
392 // Find length of back-referenced capture. | 392 // Find length of back-referenced capture. |
393 __ movq(rdx, register_location(start_reg)); | 393 ReadPositionFromRegister(rdx, start_reg); // Offset of start of capture |
394 __ movq(rax, register_location(start_reg + 1)); | 394 ReadPositionFromRegister(rax, start_reg + 1); // Offset of end of capture |
395 __ subp(rax, rdx); // Length to check. | 395 __ subp(rax, rdx); // Length to check. |
396 | 396 |
397 // Fail on partial or illegal capture (start of capture after end of capture). | 397 // Fail on partial or illegal capture (start of capture after end of capture). |
398 // This must not happen (no back-reference can reference a capture that wasn't | 398 // This must not happen (no back-reference can reference a capture that wasn't |
399 // closed before in the reg-exp). | 399 // closed before in the reg-exp). |
400 __ Check(greater_equal, kInvalidCaptureReferenced); | 400 __ Check(greater_equal, kInvalidCaptureReferenced); |
401 | 401 |
402 // Succeed on empty capture (including non-participating capture) | 402 // Succeed on empty capture (including non-participating capture) |
403 __ j(equal, &fallthrough); | 403 __ j(equal, &fallthrough); |
404 | 404 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 740 |
741 __ bind(&stack_ok); | 741 __ bind(&stack_ok); |
742 | 742 |
743 // Allocate space on stack for registers. | 743 // Allocate space on stack for registers. |
744 __ subp(rsp, Immediate(num_registers_ * kPointerSize)); | 744 __ subp(rsp, Immediate(num_registers_ * kPointerSize)); |
745 // Load string length. | 745 // Load string length. |
746 __ movp(rsi, Operand(rbp, kInputEnd)); | 746 __ movp(rsi, Operand(rbp, kInputEnd)); |
747 // Load input position. | 747 // Load input position. |
748 __ movp(rdi, Operand(rbp, kInputStart)); | 748 __ movp(rdi, Operand(rbp, kInputStart)); |
749 // Set up rdi to be negative offset from string end. | 749 // Set up rdi to be negative offset from string end. |
750 __ subp(rdi, rsi); | 750 __ subq(rdi, rsi); |
751 // Set rax to address of char before start of the string | 751 // Set rax to address of char before start of the string |
752 // (effectively string position -1). | 752 // (effectively string position -1). |
753 __ movp(rbx, Operand(rbp, kStartIndex)); | 753 __ movp(rbx, Operand(rbp, kStartIndex)); |
754 __ negq(rbx); | 754 __ negq(rbx); |
755 if (mode_ == UC16) { | 755 if (mode_ == UC16) { |
756 __ leap(rax, Operand(rdi, rbx, times_2, -char_size())); | 756 __ leap(rax, Operand(rdi, rbx, times_2, -char_size())); |
757 } else { | 757 } else { |
758 __ leap(rax, Operand(rdi, rbx, times_1, -char_size())); | 758 __ leap(rax, Operand(rdi, rbx, times_1, -char_size())); |
759 } | 759 } |
760 // Store this value in a local variable, for use when clearing | 760 // Store this value in a local variable, for use when clearing |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 __ movp(rdx, Operand(rbp, kStartIndex)); | 824 __ movp(rdx, Operand(rbp, kStartIndex)); |
825 __ movp(rbx, Operand(rbp, kRegisterOutput)); | 825 __ movp(rbx, Operand(rbp, kRegisterOutput)); |
826 __ movp(rcx, Operand(rbp, kInputEnd)); | 826 __ movp(rcx, Operand(rbp, kInputEnd)); |
827 __ subp(rcx, Operand(rbp, kInputStart)); | 827 __ subp(rcx, Operand(rbp, kInputStart)); |
828 if (mode_ == UC16) { | 828 if (mode_ == UC16) { |
829 __ leap(rcx, Operand(rcx, rdx, times_2, 0)); | 829 __ leap(rcx, Operand(rcx, rdx, times_2, 0)); |
830 } else { | 830 } else { |
831 __ addp(rcx, rdx); | 831 __ addp(rcx, rdx); |
832 } | 832 } |
833 for (int i = 0; i < num_saved_registers_; i++) { | 833 for (int i = 0; i < num_saved_registers_; i++) { |
834 __ movq(rax, register_location(i)); | 834 __ movp(rax, register_location(i)); |
835 if (i == 0 && global_with_zero_length_check()) { | 835 if (i == 0 && global_with_zero_length_check()) { |
836 // Keep capture start in rdx for the zero-length check later. | 836 // Keep capture start in rdx for the zero-length check later. |
837 __ movp(rdx, rax); | 837 __ movp(rdx, rax); |
838 } | 838 } |
839 __ addp(rax, rcx); // Convert to index from start, not end. | 839 __ addp(rax, rcx); // Convert to index from start, not end. |
840 if (mode_ == UC16) { | 840 if (mode_ == UC16) { |
841 __ sarp(rax, Immediate(1)); // Convert byte index to character index. | 841 __ sarp(rax, Immediate(1)); // Convert byte index to character index. |
842 } | 842 } |
843 __ movl(Operand(rbx, i * kIntSize), rax); | 843 __ movl(Operand(rbx, i * kIntSize), rax); |
844 } | 844 } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 | 1077 |
1078 | 1078 |
1079 void RegExpMacroAssemblerX64::PushRegister(int register_index, | 1079 void RegExpMacroAssemblerX64::PushRegister(int register_index, |
1080 StackCheckFlag check_stack_limit) { | 1080 StackCheckFlag check_stack_limit) { |
1081 __ movp(rax, register_location(register_index)); | 1081 __ movp(rax, register_location(register_index)); |
1082 Push(rax); | 1082 Push(rax); |
1083 if (check_stack_limit) CheckStackLimit(); | 1083 if (check_stack_limit) CheckStackLimit(); |
1084 } | 1084 } |
1085 | 1085 |
1086 | 1086 |
| 1087 STATIC_ASSERT(kPointerSize == kInt64Size || kPointerSize == kInt32Size); |
| 1088 |
| 1089 |
1087 void RegExpMacroAssemblerX64::ReadCurrentPositionFromRegister(int reg) { | 1090 void RegExpMacroAssemblerX64::ReadCurrentPositionFromRegister(int reg) { |
1088 __ movq(rdi, register_location(reg)); | 1091 if (kPointerSize == kInt64Size) { |
| 1092 __ movq(rdi, register_location(reg)); |
| 1093 } else { |
| 1094 // Need sign extension for x32 as rdi might be used as an index register. |
| 1095 __ movsxlq(rdi, register_location(reg)); |
| 1096 } |
| 1097 } |
| 1098 |
| 1099 |
| 1100 void RegExpMacroAssemblerX64::ReadPositionFromRegister(Register dst, int reg) { |
| 1101 if (kPointerSize == kInt64Size) { |
| 1102 __ movq(dst, register_location(reg)); |
| 1103 } else { |
| 1104 // Need sign extension for x32 as dst might be used as an index register. |
| 1105 __ movsxlq(dst, register_location(reg)); |
| 1106 } |
1089 } | 1107 } |
1090 | 1108 |
1091 | 1109 |
1092 void RegExpMacroAssemblerX64::ReadStackPointerFromRegister(int reg) { | 1110 void RegExpMacroAssemblerX64::ReadStackPointerFromRegister(int reg) { |
1093 __ movq(backtrack_stackpointer(), register_location(reg)); | 1111 __ movp(backtrack_stackpointer(), register_location(reg)); |
1094 __ addp(backtrack_stackpointer(), Operand(rbp, kStackHighEnd)); | 1112 __ addp(backtrack_stackpointer(), Operand(rbp, kStackHighEnd)); |
1095 } | 1113 } |
1096 | 1114 |
1097 | 1115 |
1098 void RegExpMacroAssemblerX64::SetCurrentPositionFromEnd(int by) { | 1116 void RegExpMacroAssemblerX64::SetCurrentPositionFromEnd(int by) { |
1099 Label after_position; | 1117 Label after_position; |
1100 __ cmpp(rdi, Immediate(-by * char_size())); | 1118 __ cmpp(rdi, Immediate(-by * char_size())); |
1101 __ j(greater_equal, &after_position, Label::kNear); | 1119 __ j(greater_equal, &after_position, Label::kNear); |
1102 __ movq(rdi, Immediate(-by * char_size())); | 1120 __ movq(rdi, Immediate(-by * char_size())); |
1103 // On RegExp code entry (where this operation is used), the character before | 1121 // On RegExp code entry (where this operation is used), the character before |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 } | 1457 } |
1440 } | 1458 } |
1441 | 1459 |
1442 #undef __ | 1460 #undef __ |
1443 | 1461 |
1444 #endif // V8_INTERPRETED_REGEXP | 1462 #endif // V8_INTERPRETED_REGEXP |
1445 | 1463 |
1446 }} // namespace v8::internal | 1464 }} // namespace v8::internal |
1447 | 1465 |
1448 #endif // V8_TARGET_ARCH_X64 | 1466 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |