OLD | NEW |
1 // Copyright 2008-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2008-2009 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 int start_reg, | 298 int start_reg, |
299 Label* on_no_match) { | 299 Label* on_no_match) { |
300 Label fallthrough; | 300 Label fallthrough; |
301 __ mov(edx, register_location(start_reg)); // Index of start of capture | 301 __ mov(edx, register_location(start_reg)); // Index of start of capture |
302 __ mov(ebx, register_location(start_reg + 1)); // Index of end of capture | 302 __ mov(ebx, register_location(start_reg + 1)); // Index of end of capture |
303 __ sub(ebx, Operand(edx)); // Length of capture. | 303 __ sub(ebx, Operand(edx)); // Length of capture. |
304 | 304 |
305 // The length of a capture should not be negative. This can only happen | 305 // The length of a capture should not be negative. This can only happen |
306 // if the end of the capture is unrecorded, or at a point earlier than | 306 // if the end of the capture is unrecorded, or at a point earlier than |
307 // the start of the capture. | 307 // the start of the capture. |
308 BranchOrBacktrack(less, on_no_match, not_taken); | 308 BranchOrBacktrack(less, on_no_match); |
309 | 309 |
310 // If length is zero, either the capture is empty or it is completely | 310 // If length is zero, either the capture is empty or it is completely |
311 // uncaptured. In either case succeed immediately. | 311 // uncaptured. In either case succeed immediately. |
312 __ j(equal, &fallthrough); | 312 __ j(equal, &fallthrough); |
313 | 313 |
314 if (mode_ == ASCII) { | 314 if (mode_ == ASCII) { |
315 Label success; | 315 Label success; |
316 Label fail; | 316 Label fail; |
317 Label loop_increment; | 317 Label loop_increment; |
318 // Save register contents to make the registers available below. | 318 // Save register contents to make the registers available below. |
(...skipping 22 matching lines...) Expand all Loading... |
341 | 341 |
342 __ cmp(eax, Operand(ecx)); | 342 __ cmp(eax, Operand(ecx)); |
343 __ j(not_equal, &fail); | 343 __ j(not_equal, &fail); |
344 | 344 |
345 __ bind(&loop_increment); | 345 __ bind(&loop_increment); |
346 // Increment pointers into match and capture strings. | 346 // Increment pointers into match and capture strings. |
347 __ add(Operand(edx), Immediate(1)); | 347 __ add(Operand(edx), Immediate(1)); |
348 __ add(Operand(edi), Immediate(1)); | 348 __ add(Operand(edi), Immediate(1)); |
349 // Compare to end of match, and loop if not done. | 349 // Compare to end of match, and loop if not done. |
350 __ cmp(edi, Operand(ebx)); | 350 __ cmp(edi, Operand(ebx)); |
351 __ j(below, &loop, taken); | 351 __ j(below, &loop); |
352 __ jmp(&success); | 352 __ jmp(&success); |
353 | 353 |
354 __ bind(&fail); | 354 __ bind(&fail); |
355 // Restore original values before failing. | 355 // Restore original values before failing. |
356 __ pop(backtrack_stackpointer()); | 356 __ pop(backtrack_stackpointer()); |
357 __ pop(edi); | 357 __ pop(edi); |
358 BranchOrBacktrack(no_condition, on_no_match); | 358 BranchOrBacktrack(no_condition, on_no_match); |
359 | 359 |
360 __ bind(&success); | 360 __ bind(&success); |
361 // Restore original value before continuing. | 361 // Restore original value before continuing. |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 | 680 |
681 // Check if we have space on the stack for registers. | 681 // Check if we have space on the stack for registers. |
682 Label stack_limit_hit; | 682 Label stack_limit_hit; |
683 Label stack_ok; | 683 Label stack_ok; |
684 | 684 |
685 ExternalReference stack_limit = | 685 ExternalReference stack_limit = |
686 ExternalReference::address_of_stack_limit(masm_->isolate()); | 686 ExternalReference::address_of_stack_limit(masm_->isolate()); |
687 __ mov(ecx, esp); | 687 __ mov(ecx, esp); |
688 __ sub(ecx, Operand::StaticVariable(stack_limit)); | 688 __ sub(ecx, Operand::StaticVariable(stack_limit)); |
689 // Handle it if the stack pointer is already below the stack limit. | 689 // Handle it if the stack pointer is already below the stack limit. |
690 __ j(below_equal, &stack_limit_hit, not_taken); | 690 __ j(below_equal, &stack_limit_hit); |
691 // Check if there is room for the variable number of registers above | 691 // Check if there is room for the variable number of registers above |
692 // the stack limit. | 692 // the stack limit. |
693 __ cmp(ecx, num_registers_ * kPointerSize); | 693 __ cmp(ecx, num_registers_ * kPointerSize); |
694 __ j(above_equal, &stack_ok, taken); | 694 __ j(above_equal, &stack_ok); |
695 // Exit with OutOfMemory exception. There is not enough space on the stack | 695 // Exit with OutOfMemory exception. There is not enough space on the stack |
696 // for our working registers. | 696 // for our working registers. |
697 __ mov(eax, EXCEPTION); | 697 __ mov(eax, EXCEPTION); |
698 __ jmp(&exit_label_); | 698 __ jmp(&exit_label_); |
699 | 699 |
700 __ bind(&stack_limit_hit); | 700 __ bind(&stack_limit_hit); |
701 CallCheckStackGuardState(ebx); | 701 CallCheckStackGuardState(ebx); |
702 __ or_(eax, Operand(eax)); | 702 __ or_(eax, Operand(eax)); |
703 // If returned value is non-zero, we exit with the returned value as result. | 703 // If returned value is non-zero, we exit with the returned value as result. |
704 __ j(not_zero, &exit_label_); | 704 __ j(not_zero, &exit_label_); |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 | 1135 |
1136 | 1136 |
1137 void RegExpMacroAssemblerIA32::CheckPosition(int cp_offset, | 1137 void RegExpMacroAssemblerIA32::CheckPosition(int cp_offset, |
1138 Label* on_outside_input) { | 1138 Label* on_outside_input) { |
1139 __ cmp(edi, -cp_offset * char_size()); | 1139 __ cmp(edi, -cp_offset * char_size()); |
1140 BranchOrBacktrack(greater_equal, on_outside_input); | 1140 BranchOrBacktrack(greater_equal, on_outside_input); |
1141 } | 1141 } |
1142 | 1142 |
1143 | 1143 |
1144 void RegExpMacroAssemblerIA32::BranchOrBacktrack(Condition condition, | 1144 void RegExpMacroAssemblerIA32::BranchOrBacktrack(Condition condition, |
1145 Label* to, | 1145 Label* to) { |
1146 Hint hint) { | |
1147 if (condition < 0) { // No condition | 1146 if (condition < 0) { // No condition |
1148 if (to == NULL) { | 1147 if (to == NULL) { |
1149 Backtrack(); | 1148 Backtrack(); |
1150 return; | 1149 return; |
1151 } | 1150 } |
1152 __ jmp(to); | 1151 __ jmp(to); |
1153 return; | 1152 return; |
1154 } | 1153 } |
1155 if (to == NULL) { | 1154 if (to == NULL) { |
1156 __ j(condition, &backtrack_label_, hint); | 1155 __ j(condition, &backtrack_label_); |
1157 return; | 1156 return; |
1158 } | 1157 } |
1159 __ j(condition, to, hint); | 1158 __ j(condition, to); |
1160 } | 1159 } |
1161 | 1160 |
1162 | 1161 |
1163 void RegExpMacroAssemblerIA32::SafeCall(Label* to) { | 1162 void RegExpMacroAssemblerIA32::SafeCall(Label* to) { |
1164 Label return_to; | 1163 Label return_to; |
1165 __ push(Immediate::CodeRelativeOffset(&return_to)); | 1164 __ push(Immediate::CodeRelativeOffset(&return_to)); |
1166 __ jmp(to); | 1165 __ jmp(to); |
1167 __ bind(&return_to); | 1166 __ bind(&return_to); |
1168 } | 1167 } |
1169 | 1168 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 __ add(Operand(backtrack_stackpointer()), Immediate(kPointerSize)); | 1201 __ add(Operand(backtrack_stackpointer()), Immediate(kPointerSize)); |
1203 } | 1202 } |
1204 | 1203 |
1205 | 1204 |
1206 void RegExpMacroAssemblerIA32::CheckPreemption() { | 1205 void RegExpMacroAssemblerIA32::CheckPreemption() { |
1207 // Check for preemption. | 1206 // Check for preemption. |
1208 Label no_preempt; | 1207 Label no_preempt; |
1209 ExternalReference stack_limit = | 1208 ExternalReference stack_limit = |
1210 ExternalReference::address_of_stack_limit(masm_->isolate()); | 1209 ExternalReference::address_of_stack_limit(masm_->isolate()); |
1211 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 1210 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
1212 __ j(above, &no_preempt, taken); | 1211 __ j(above, &no_preempt); |
1213 | 1212 |
1214 SafeCall(&check_preempt_label_); | 1213 SafeCall(&check_preempt_label_); |
1215 | 1214 |
1216 __ bind(&no_preempt); | 1215 __ bind(&no_preempt); |
1217 } | 1216 } |
1218 | 1217 |
1219 | 1218 |
1220 void RegExpMacroAssemblerIA32::CheckStackLimit() { | 1219 void RegExpMacroAssemblerIA32::CheckStackLimit() { |
1221 Label no_stack_overflow; | 1220 Label no_stack_overflow; |
1222 ExternalReference stack_limit = | 1221 ExternalReference stack_limit = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 } | 1254 } |
1256 | 1255 |
1257 | 1256 |
1258 #undef __ | 1257 #undef __ |
1259 | 1258 |
1260 #endif // V8_INTERPRETED_REGEXP | 1259 #endif // V8_INTERPRETED_REGEXP |
1261 | 1260 |
1262 }} // namespace v8::internal | 1261 }} // namespace v8::internal |
1263 | 1262 |
1264 #endif // V8_TARGET_ARCH_IA32 | 1263 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |