| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 // Set byte_offset2. | 330 // Set byte_offset2. |
| 331 // Found by adding negative string-end offset of current position (edi) | 331 // Found by adding negative string-end offset of current position (edi) |
| 332 // to end of string. | 332 // to end of string. |
| 333 __ add(edi, Operand(esi)); | 333 __ add(edi, Operand(esi)); |
| 334 __ mov(Operand(esp, 1 * kPointerSize), edi); | 334 __ mov(Operand(esp, 1 * kPointerSize), edi); |
| 335 // Set byte_offset1. | 335 // Set byte_offset1. |
| 336 // Start of capture, where edx already holds string-end negative offset. | 336 // Start of capture, where edx already holds string-end negative offset. |
| 337 __ add(edx, Operand(esi)); | 337 __ add(edx, Operand(esi)); |
| 338 __ mov(Operand(esp, 0 * kPointerSize), edx); | 338 __ mov(Operand(esp, 0 * kPointerSize), edx); |
| 339 | 339 |
| 340 Address function_address = FUNCTION_ADDR(&CaseInsensitiveCompareUC16); | 340 ExternalReference compare = |
| 341 CallCFunction(function_address, argument_count); | 341 ExternalReference::re_case_insensitive_compare_uc16(); |
| 342 CallCFunction(compare, argument_count); |
| 342 // Pop original values before reacting on result value. | 343 // Pop original values before reacting on result value. |
| 343 __ pop(ebx); | 344 __ pop(ebx); |
| 344 __ pop(backtrack_stackpointer()); | 345 __ pop(backtrack_stackpointer()); |
| 345 __ pop(edi); | 346 __ pop(edi); |
| 346 __ pop(esi); | 347 __ pop(esi); |
| 347 | 348 |
| 348 // Check if function returned non-zero for success or zero for failure. | 349 // Check if function returned non-zero for success or zero for failure. |
| 349 __ or_(eax, Operand(eax)); | 350 __ or_(eax, Operand(eax)); |
| 350 BranchOrBacktrack(zero, on_no_match); | 351 BranchOrBacktrack(zero, on_no_match); |
| 351 // On success, increment position by length of capture. | 352 // On success, increment position by length of capture. |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 // Save registers before calling C function | 739 // Save registers before calling C function |
| 739 __ push(esi); | 740 __ push(esi); |
| 740 __ push(edi); | 741 __ push(edi); |
| 741 | 742 |
| 742 // Call GrowStack(backtrack_stackpointer()) | 743 // Call GrowStack(backtrack_stackpointer()) |
| 743 int num_arguments = 2; | 744 int num_arguments = 2; |
| 744 FrameAlign(num_arguments, ebx); | 745 FrameAlign(num_arguments, ebx); |
| 745 __ lea(eax, Operand(ebp, kStackHighEnd)); | 746 __ lea(eax, Operand(ebp, kStackHighEnd)); |
| 746 __ mov(Operand(esp, 1 * kPointerSize), eax); | 747 __ mov(Operand(esp, 1 * kPointerSize), eax); |
| 747 __ mov(Operand(esp, 0 * kPointerSize), backtrack_stackpointer()); | 748 __ mov(Operand(esp, 0 * kPointerSize), backtrack_stackpointer()); |
| 748 CallCFunction(FUNCTION_ADDR(&GrowStack), num_arguments); | 749 ExternalReference grow_stack = ExternalReference::re_grow_stack(); |
| 750 CallCFunction(grow_stack, num_arguments); |
| 749 // If return NULL, we have failed to grow the stack, and | 751 // If return NULL, we have failed to grow the stack, and |
| 750 // must exit with a stack-overflow exception. | 752 // must exit with a stack-overflow exception. |
| 751 __ or_(eax, Operand(eax)); | 753 __ or_(eax, Operand(eax)); |
| 752 __ j(equal, &exit_with_exception); | 754 __ j(equal, &exit_with_exception); |
| 753 // Otherwise use return value as new stack pointer. | 755 // Otherwise use return value as new stack pointer. |
| 754 __ mov(backtrack_stackpointer(), eax); | 756 __ mov(backtrack_stackpointer(), eax); |
| 755 // Restore saved registers and continue. | 757 // Restore saved registers and continue. |
| 756 __ pop(edi); | 758 __ pop(edi); |
| 757 __ pop(esi); | 759 __ pop(esi); |
| 758 SafeReturn(); | 760 SafeReturn(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 void RegExpMacroAssemblerIA32::CallCheckStackGuardState(Register scratch) { | 908 void RegExpMacroAssemblerIA32::CallCheckStackGuardState(Register scratch) { |
| 907 int num_arguments = 3; | 909 int num_arguments = 3; |
| 908 FrameAlign(num_arguments, scratch); | 910 FrameAlign(num_arguments, scratch); |
| 909 // RegExp code frame pointer. | 911 // RegExp code frame pointer. |
| 910 __ mov(Operand(esp, 2 * kPointerSize), ebp); | 912 __ mov(Operand(esp, 2 * kPointerSize), ebp); |
| 911 // Code* of self. | 913 // Code* of self. |
| 912 __ mov(Operand(esp, 1 * kPointerSize), Immediate(masm_->CodeObject())); | 914 __ mov(Operand(esp, 1 * kPointerSize), Immediate(masm_->CodeObject())); |
| 913 // Next address on the stack (will be address of return address). | 915 // Next address on the stack (will be address of return address). |
| 914 __ lea(eax, Operand(esp, -kPointerSize)); | 916 __ lea(eax, Operand(esp, -kPointerSize)); |
| 915 __ mov(Operand(esp, 0 * kPointerSize), eax); | 917 __ mov(Operand(esp, 0 * kPointerSize), eax); |
| 916 CallCFunction(FUNCTION_ADDR(&CheckStackGuardState), num_arguments); | 918 ExternalReference check_stack_guard = |
| 919 ExternalReference::re_check_stack_guard_state(); |
| 920 CallCFunction(check_stack_guard, num_arguments); |
| 917 } | 921 } |
| 918 | 922 |
| 919 | 923 |
| 920 // Helper function for reading a value out of a stack frame. | 924 // Helper function for reading a value out of a stack frame. |
| 921 template <typename T> | 925 template <typename T> |
| 922 static T& frame_entry(Address re_frame, int frame_offset) { | 926 static T& frame_entry(Address re_frame, int frame_offset) { |
| 923 return reinterpret_cast<T&>(Memory::int32_at(re_frame + frame_offset)); | 927 return reinterpret_cast<T&>(Memory::int32_at(re_frame + frame_offset)); |
| 924 } | 928 } |
| 925 | 929 |
| 926 | 930 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 int byte_length = end_address - start_address; | 993 int byte_length = end_address - start_address; |
| 990 frame_entry<const String*>(re_frame, kInputString) = *subject; | 994 frame_entry<const String*>(re_frame, kInputString) = *subject; |
| 991 frame_entry<const byte*>(re_frame, kInputStart) = new_address; | 995 frame_entry<const byte*>(re_frame, kInputStart) = new_address; |
| 992 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length; | 996 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length; |
| 993 } | 997 } |
| 994 | 998 |
| 995 return 0; | 999 return 0; |
| 996 } | 1000 } |
| 997 | 1001 |
| 998 | 1002 |
| 999 Address RegExpMacroAssemblerIA32::GrowStack(Address stack_pointer, | |
| 1000 Address* stack_base) { | |
| 1001 size_t size = RegExpStack::stack_capacity(); | |
| 1002 Address old_stack_base = RegExpStack::stack_base(); | |
| 1003 ASSERT(old_stack_base == *stack_base); | |
| 1004 ASSERT(stack_pointer <= old_stack_base); | |
| 1005 ASSERT(static_cast<size_t>(old_stack_base - stack_pointer) <= size); | |
| 1006 Address new_stack_base = RegExpStack::EnsureCapacity(size * 2); | |
| 1007 if (new_stack_base == NULL) { | |
| 1008 return NULL; | |
| 1009 } | |
| 1010 *stack_base = new_stack_base; | |
| 1011 return new_stack_base - (old_stack_base - stack_pointer); | |
| 1012 } | |
| 1013 | |
| 1014 | |
| 1015 Operand RegExpMacroAssemblerIA32::register_location(int register_index) { | 1003 Operand RegExpMacroAssemblerIA32::register_location(int register_index) { |
| 1016 ASSERT(register_index < (1<<30)); | 1004 ASSERT(register_index < (1<<30)); |
| 1017 if (num_registers_ <= register_index) { | 1005 if (num_registers_ <= register_index) { |
| 1018 num_registers_ = register_index + 1; | 1006 num_registers_ = register_index + 1; |
| 1019 } | 1007 } |
| 1020 return Operand(ebp, kRegisterZero - register_index * kPointerSize); | 1008 return Operand(ebp, kRegisterZero - register_index * kPointerSize); |
| 1021 } | 1009 } |
| 1022 | 1010 |
| 1023 | 1011 |
| 1024 void RegExpMacroAssemblerIA32::CheckPosition(int cp_offset, | 1012 void RegExpMacroAssemblerIA32::CheckPosition(int cp_offset, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 __ sub(Operand(esp), Immediate((num_arguments + 1) * kPointerSize)); | 1116 __ sub(Operand(esp), Immediate((num_arguments + 1) * kPointerSize)); |
| 1129 ASSERT(IsPowerOf2(frameAlignment)); | 1117 ASSERT(IsPowerOf2(frameAlignment)); |
| 1130 __ and_(esp, -frameAlignment); | 1118 __ and_(esp, -frameAlignment); |
| 1131 __ mov(Operand(esp, num_arguments * kPointerSize), scratch); | 1119 __ mov(Operand(esp, num_arguments * kPointerSize), scratch); |
| 1132 } else { | 1120 } else { |
| 1133 __ sub(Operand(esp), Immediate(num_arguments * kPointerSize)); | 1121 __ sub(Operand(esp), Immediate(num_arguments * kPointerSize)); |
| 1134 } | 1122 } |
| 1135 } | 1123 } |
| 1136 | 1124 |
| 1137 | 1125 |
| 1138 void RegExpMacroAssemblerIA32::CallCFunction(Address function_address, | 1126 void RegExpMacroAssemblerIA32::CallCFunction(ExternalReference function, |
| 1139 int num_arguments) { | 1127 int num_arguments) { |
| 1140 __ mov(Operand(eax), Immediate(reinterpret_cast<int32_t>(function_address))); | 1128 __ mov(Operand(eax), Immediate(function)); |
| 1141 __ call(Operand(eax)); | 1129 __ call(Operand(eax)); |
| 1142 if (OS::ActivationFrameAlignment() != 0) { | 1130 if (OS::ActivationFrameAlignment() != 0) { |
| 1143 __ mov(esp, Operand(esp, num_arguments * kPointerSize)); | 1131 __ mov(esp, Operand(esp, num_arguments * kPointerSize)); |
| 1144 } else { | 1132 } else { |
| 1145 __ add(Operand(esp), Immediate(num_arguments * sizeof(int32_t))); | 1133 __ add(Operand(esp), Immediate(num_arguments * sizeof(int32_t))); |
| 1146 } | 1134 } |
| 1147 } | 1135 } |
| 1148 | 1136 |
| 1149 | 1137 |
| 1150 void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset, | 1138 void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1165 Operand(esi, edi, times_1, cp_offset * sizeof(uc16))); | 1153 Operand(esi, edi, times_1, cp_offset * sizeof(uc16))); |
| 1166 } else { | 1154 } else { |
| 1167 ASSERT(characters == 1); | 1155 ASSERT(characters == 1); |
| 1168 __ movzx_w(current_character(), | 1156 __ movzx_w(current_character(), |
| 1169 Operand(esi, edi, times_1, cp_offset * sizeof(uc16))); | 1157 Operand(esi, edi, times_1, cp_offset * sizeof(uc16))); |
| 1170 } | 1158 } |
| 1171 } | 1159 } |
| 1172 } | 1160 } |
| 1173 | 1161 |
| 1174 | 1162 |
| 1163 void RegExpCEntryStub::Generate(MacroAssembler* masm_) { |
| 1164 __ int3(); // Unused on ia32. |
| 1165 } |
| 1166 |
| 1175 #undef __ | 1167 #undef __ |
| 1176 | 1168 |
| 1177 #endif // V8_NATIVE_REGEXP | 1169 #endif // V8_NATIVE_REGEXP |
| 1178 | 1170 |
| 1179 }} // namespace v8::internal | 1171 }} // namespace v8::internal |
| OLD | NEW |