| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 __ PrepareCallCFunction(argument_count, ecx); | 394 __ PrepareCallCFunction(argument_count, ecx); |
| 395 // Put arguments into allocated stack area, last argument highest on stack. | 395 // Put arguments into allocated stack area, last argument highest on stack. |
| 396 // Parameters are | 396 // Parameters are |
| 397 // Address byte_offset1 - Address captured substring's start. | 397 // Address byte_offset1 - Address captured substring's start. |
| 398 // Address byte_offset2 - Address of current character position. | 398 // Address byte_offset2 - Address of current character position. |
| 399 // size_t byte_length - length of capture in bytes(!) | 399 // size_t byte_length - length of capture in bytes(!) |
| 400 // Isolate* isolate | 400 // Isolate* isolate |
| 401 | 401 |
| 402 // Set isolate. | 402 // Set isolate. |
| 403 __ mov(Operand(esp, 3 * kPointerSize), | 403 __ mov(Operand(esp, 3 * kPointerSize), |
| 404 Immediate(ExternalReference::isolate_address())); | 404 Immediate(ExternalReference::isolate_address(isolate()))); |
| 405 // Set byte_length. | 405 // Set byte_length. |
| 406 __ mov(Operand(esp, 2 * kPointerSize), ebx); | 406 __ mov(Operand(esp, 2 * kPointerSize), ebx); |
| 407 // Set byte_offset2. | 407 // Set byte_offset2. |
| 408 // Found by adding negative string-end offset of current position (edi) | 408 // Found by adding negative string-end offset of current position (edi) |
| 409 // to end of string. | 409 // to end of string. |
| 410 __ add(edi, esi); | 410 __ add(edi, esi); |
| 411 __ mov(Operand(esp, 1 * kPointerSize), edi); | 411 __ mov(Operand(esp, 1 * kPointerSize), edi); |
| 412 // Set byte_offset1. | 412 // Set byte_offset1. |
| 413 // Start of capture, where edx already holds string-end negative offset. | 413 // Start of capture, where edx already holds string-end negative offset. |
| 414 __ add(edx, esi); | 414 __ add(edx, esi); |
| 415 __ mov(Operand(esp, 0 * kPointerSize), edx); | 415 __ mov(Operand(esp, 0 * kPointerSize), edx); |
| 416 | 416 |
| 417 { | 417 { |
| 418 AllowExternalCallThatCantCauseGC scope(masm_); | 418 AllowExternalCallThatCantCauseGC scope(masm_); |
| 419 ExternalReference compare = | 419 ExternalReference compare = |
| 420 ExternalReference::re_case_insensitive_compare_uc16(masm_->isolate()); | 420 ExternalReference::re_case_insensitive_compare_uc16(isolate()); |
| 421 __ CallCFunction(compare, argument_count); | 421 __ CallCFunction(compare, argument_count); |
| 422 } | 422 } |
| 423 // Pop original values before reacting on result value. | 423 // Pop original values before reacting on result value. |
| 424 __ pop(ebx); | 424 __ pop(ebx); |
| 425 __ pop(backtrack_stackpointer()); | 425 __ pop(backtrack_stackpointer()); |
| 426 __ pop(edi); | 426 __ pop(edi); |
| 427 __ pop(esi); | 427 __ pop(esi); |
| 428 | 428 |
| 429 // Check if function returned non-zero for success or zero for failure. | 429 // Check if function returned non-zero for success or zero for failure. |
| 430 __ or_(eax, eax); | 430 __ or_(eax, eax); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 __ push(edi); | 738 __ push(edi); |
| 739 __ push(ebx); // Callee-save on MacOS. | 739 __ push(ebx); // Callee-save on MacOS. |
| 740 __ push(Immediate(0)); // Number of successful matches in a global regexp. | 740 __ push(Immediate(0)); // Number of successful matches in a global regexp. |
| 741 __ push(Immediate(0)); // Make room for "input start - 1" constant. | 741 __ push(Immediate(0)); // Make room for "input start - 1" constant. |
| 742 | 742 |
| 743 // Check if we have space on the stack for registers. | 743 // Check if we have space on the stack for registers. |
| 744 Label stack_limit_hit; | 744 Label stack_limit_hit; |
| 745 Label stack_ok; | 745 Label stack_ok; |
| 746 | 746 |
| 747 ExternalReference stack_limit = | 747 ExternalReference stack_limit = |
| 748 ExternalReference::address_of_stack_limit(masm_->isolate()); | 748 ExternalReference::address_of_stack_limit(isolate()); |
| 749 __ mov(ecx, esp); | 749 __ mov(ecx, esp); |
| 750 __ sub(ecx, Operand::StaticVariable(stack_limit)); | 750 __ sub(ecx, Operand::StaticVariable(stack_limit)); |
| 751 // Handle it if the stack pointer is already below the stack limit. | 751 // Handle it if the stack pointer is already below the stack limit. |
| 752 __ j(below_equal, &stack_limit_hit); | 752 __ j(below_equal, &stack_limit_hit); |
| 753 // Check if there is room for the variable number of registers above | 753 // Check if there is room for the variable number of registers above |
| 754 // the stack limit. | 754 // the stack limit. |
| 755 __ cmp(ecx, num_registers_ * kPointerSize); | 755 __ cmp(ecx, num_registers_ * kPointerSize); |
| 756 __ j(above_equal, &stack_ok); | 756 __ j(above_equal, &stack_ok); |
| 757 // Exit with OutOfMemory exception. There is not enough space on the stack | 757 // Exit with OutOfMemory exception. There is not enough space on the stack |
| 758 // for our working registers. | 758 // for our working registers. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 | 965 |
| 966 Label grow_failed; | 966 Label grow_failed; |
| 967 // Save registers before calling C function | 967 // Save registers before calling C function |
| 968 __ push(esi); | 968 __ push(esi); |
| 969 __ push(edi); | 969 __ push(edi); |
| 970 | 970 |
| 971 // Call GrowStack(backtrack_stackpointer()) | 971 // Call GrowStack(backtrack_stackpointer()) |
| 972 static const int num_arguments = 3; | 972 static const int num_arguments = 3; |
| 973 __ PrepareCallCFunction(num_arguments, ebx); | 973 __ PrepareCallCFunction(num_arguments, ebx); |
| 974 __ mov(Operand(esp, 2 * kPointerSize), | 974 __ mov(Operand(esp, 2 * kPointerSize), |
| 975 Immediate(ExternalReference::isolate_address())); | 975 Immediate(ExternalReference::isolate_address(isolate()))); |
| 976 __ lea(eax, Operand(ebp, kStackHighEnd)); | 976 __ lea(eax, Operand(ebp, kStackHighEnd)); |
| 977 __ mov(Operand(esp, 1 * kPointerSize), eax); | 977 __ mov(Operand(esp, 1 * kPointerSize), eax); |
| 978 __ mov(Operand(esp, 0 * kPointerSize), backtrack_stackpointer()); | 978 __ mov(Operand(esp, 0 * kPointerSize), backtrack_stackpointer()); |
| 979 ExternalReference grow_stack = | 979 ExternalReference grow_stack = |
| 980 ExternalReference::re_grow_stack(masm_->isolate()); | 980 ExternalReference::re_grow_stack(isolate()); |
| 981 __ CallCFunction(grow_stack, num_arguments); | 981 __ CallCFunction(grow_stack, num_arguments); |
| 982 // If return NULL, we have failed to grow the stack, and | 982 // If return NULL, we have failed to grow the stack, and |
| 983 // must exit with a stack-overflow exception. | 983 // must exit with a stack-overflow exception. |
| 984 __ or_(eax, eax); | 984 __ or_(eax, eax); |
| 985 __ j(equal, &exit_with_exception); | 985 __ j(equal, &exit_with_exception); |
| 986 // Otherwise use return value as new stack pointer. | 986 // Otherwise use return value as new stack pointer. |
| 987 __ mov(backtrack_stackpointer(), eax); | 987 __ mov(backtrack_stackpointer(), eax); |
| 988 // Restore saved registers and continue. | 988 // Restore saved registers and continue. |
| 989 __ pop(edi); | 989 __ pop(edi); |
| 990 __ pop(esi); | 990 __ pop(esi); |
| 991 SafeReturn(); | 991 SafeReturn(); |
| 992 } | 992 } |
| 993 | 993 |
| 994 if (exit_with_exception.is_linked()) { | 994 if (exit_with_exception.is_linked()) { |
| 995 // If any of the code above needed to exit with an exception. | 995 // If any of the code above needed to exit with an exception. |
| 996 __ bind(&exit_with_exception); | 996 __ bind(&exit_with_exception); |
| 997 // Exit with Result EXCEPTION(-1) to signal thrown exception. | 997 // Exit with Result EXCEPTION(-1) to signal thrown exception. |
| 998 __ mov(eax, EXCEPTION); | 998 __ mov(eax, EXCEPTION); |
| 999 __ jmp(&return_eax); | 999 __ jmp(&return_eax); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 CodeDesc code_desc; | 1002 CodeDesc code_desc; |
| 1003 masm_->GetCode(&code_desc); | 1003 masm_->GetCode(&code_desc); |
| 1004 Handle<Code> code = | 1004 Handle<Code> code = |
| 1005 masm_->isolate()->factory()->NewCode(code_desc, | 1005 isolate()->factory()->NewCode(code_desc, |
| 1006 Code::ComputeFlags(Code::REGEXP), | 1006 Code::ComputeFlags(Code::REGEXP), |
| 1007 masm_->CodeObject()); | 1007 masm_->CodeObject()); |
| 1008 PROFILE(masm_->isolate(), RegExpCodeCreateEvent(*code, *source)); | 1008 PROFILE(isolate(), RegExpCodeCreateEvent(*code, *source)); |
| 1009 return Handle<HeapObject>::cast(code); | 1009 return Handle<HeapObject>::cast(code); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 | 1012 |
| 1013 void RegExpMacroAssemblerIA32::GoTo(Label* to) { | 1013 void RegExpMacroAssemblerIA32::GoTo(Label* to) { |
| 1014 BranchOrBacktrack(no_condition, to); | 1014 BranchOrBacktrack(no_condition, to); |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 | 1017 |
| 1018 void RegExpMacroAssemblerIA32::IfRegisterGE(int reg, | 1018 void RegExpMacroAssemblerIA32::IfRegisterGE(int reg, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 static const int num_arguments = 3; | 1154 static const int num_arguments = 3; |
| 1155 __ PrepareCallCFunction(num_arguments, scratch); | 1155 __ PrepareCallCFunction(num_arguments, scratch); |
| 1156 // RegExp code frame pointer. | 1156 // RegExp code frame pointer. |
| 1157 __ mov(Operand(esp, 2 * kPointerSize), ebp); | 1157 __ mov(Operand(esp, 2 * kPointerSize), ebp); |
| 1158 // Code* of self. | 1158 // Code* of self. |
| 1159 __ mov(Operand(esp, 1 * kPointerSize), Immediate(masm_->CodeObject())); | 1159 __ mov(Operand(esp, 1 * kPointerSize), Immediate(masm_->CodeObject())); |
| 1160 // Next address on the stack (will be address of return address). | 1160 // Next address on the stack (will be address of return address). |
| 1161 __ lea(eax, Operand(esp, -kPointerSize)); | 1161 __ lea(eax, Operand(esp, -kPointerSize)); |
| 1162 __ mov(Operand(esp, 0 * kPointerSize), eax); | 1162 __ mov(Operand(esp, 0 * kPointerSize), eax); |
| 1163 ExternalReference check_stack_guard = | 1163 ExternalReference check_stack_guard = |
| 1164 ExternalReference::re_check_stack_guard_state(masm_->isolate()); | 1164 ExternalReference::re_check_stack_guard_state(isolate()); |
| 1165 __ CallCFunction(check_stack_guard, num_arguments); | 1165 __ CallCFunction(check_stack_guard, num_arguments); |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 | 1168 |
| 1169 // Helper function for reading a value out of a stack frame. | 1169 // Helper function for reading a value out of a stack frame. |
| 1170 template <typename T> | 1170 template <typename T> |
| 1171 static T& frame_entry(Address re_frame, int frame_offset) { | 1171 static T& frame_entry(Address re_frame, int frame_offset) { |
| 1172 return reinterpret_cast<T&>(Memory::int32_at(re_frame + frame_offset)); | 1172 return reinterpret_cast<T&>(Memory::int32_at(re_frame + frame_offset)); |
| 1173 } | 1173 } |
| 1174 | 1174 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 __ mov(target, Operand(backtrack_stackpointer(), 0)); | 1346 __ mov(target, Operand(backtrack_stackpointer(), 0)); |
| 1347 // Notice: This updates flags, unlike normal Pop. | 1347 // Notice: This updates flags, unlike normal Pop. |
| 1348 __ add(backtrack_stackpointer(), Immediate(kPointerSize)); | 1348 __ add(backtrack_stackpointer(), Immediate(kPointerSize)); |
| 1349 } | 1349 } |
| 1350 | 1350 |
| 1351 | 1351 |
| 1352 void RegExpMacroAssemblerIA32::CheckPreemption() { | 1352 void RegExpMacroAssemblerIA32::CheckPreemption() { |
| 1353 // Check for preemption. | 1353 // Check for preemption. |
| 1354 Label no_preempt; | 1354 Label no_preempt; |
| 1355 ExternalReference stack_limit = | 1355 ExternalReference stack_limit = |
| 1356 ExternalReference::address_of_stack_limit(masm_->isolate()); | 1356 ExternalReference::address_of_stack_limit(isolate()); |
| 1357 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 1357 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
| 1358 __ j(above, &no_preempt); | 1358 __ j(above, &no_preempt); |
| 1359 | 1359 |
| 1360 SafeCall(&check_preempt_label_); | 1360 SafeCall(&check_preempt_label_); |
| 1361 | 1361 |
| 1362 __ bind(&no_preempt); | 1362 __ bind(&no_preempt); |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 | 1365 |
| 1366 void RegExpMacroAssemblerIA32::CheckStackLimit() { | 1366 void RegExpMacroAssemblerIA32::CheckStackLimit() { |
| 1367 Label no_stack_overflow; | 1367 Label no_stack_overflow; |
| 1368 ExternalReference stack_limit = | 1368 ExternalReference stack_limit = |
| 1369 ExternalReference::address_of_regexp_stack_limit(masm_->isolate()); | 1369 ExternalReference::address_of_regexp_stack_limit(isolate()); |
| 1370 __ cmp(backtrack_stackpointer(), Operand::StaticVariable(stack_limit)); | 1370 __ cmp(backtrack_stackpointer(), Operand::StaticVariable(stack_limit)); |
| 1371 __ j(above, &no_stack_overflow); | 1371 __ j(above, &no_stack_overflow); |
| 1372 | 1372 |
| 1373 SafeCall(&stack_overflow_label_); | 1373 SafeCall(&stack_overflow_label_); |
| 1374 | 1374 |
| 1375 __ bind(&no_stack_overflow); | 1375 __ bind(&no_stack_overflow); |
| 1376 } | 1376 } |
| 1377 | 1377 |
| 1378 | 1378 |
| 1379 void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset, | 1379 void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1401 } | 1401 } |
| 1402 | 1402 |
| 1403 | 1403 |
| 1404 #undef __ | 1404 #undef __ |
| 1405 | 1405 |
| 1406 #endif // V8_INTERPRETED_REGEXP | 1406 #endif // V8_INTERPRETED_REGEXP |
| 1407 | 1407 |
| 1408 }} // namespace v8::internal | 1408 }} // namespace v8::internal |
| 1409 | 1409 |
| 1410 #endif // V8_TARGET_ARCH_IA32 | 1410 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |