| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 __ add(r0, r0, Operand(by)); | 156 __ add(r0, r0, Operand(by)); |
| 157 __ str(r0, register_location(reg)); | 157 __ str(r0, register_location(reg)); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 | 161 |
| 162 void RegExpMacroAssemblerARM::Backtrack() { | 162 void RegExpMacroAssemblerARM::Backtrack() { |
| 163 CheckPreemption(); | 163 CheckPreemption(); |
| 164 // Pop Code* offset from backtrack stack, add Code* and jump to location. | 164 // Pop Code* offset from backtrack stack, add Code* and jump to location. |
| 165 Pop(r0); | 165 Pop(r0); |
| 166 __ add(pc, r0, Operand(r5)); | 166 __ add(pc, r0, Operand(code_pointer())); |
| 167 } | 167 } |
| 168 | 168 |
| 169 | 169 |
| 170 void RegExpMacroAssemblerARM::Bind(Label* label) { | 170 void RegExpMacroAssemblerARM::Bind(Label* label) { |
| 171 __ bind(label); | 171 __ bind(label); |
| 172 } | 172 } |
| 173 | 173 |
| 174 | 174 |
| 175 void RegExpMacroAssemblerARM::CheckCharacter(uint32_t c, Label* on_equal) { | 175 void RegExpMacroAssemblerARM::CheckCharacter(uint32_t c, Label* on_equal) { |
| 176 __ cmp(current_character(), Operand(c)); | 176 __ cmp(current_character(), Operand(c)); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 331 |
| 332 __ bind(&fail); | 332 __ bind(&fail); |
| 333 BranchOrBacktrack(al, on_no_match); | 333 BranchOrBacktrack(al, on_no_match); |
| 334 | 334 |
| 335 __ bind(&success); | 335 __ bind(&success); |
| 336 // Compute new value of character position after the matched part. | 336 // Compute new value of character position after the matched part. |
| 337 __ sub(current_input_offset(), r2, end_of_input_address()); | 337 __ sub(current_input_offset(), r2, end_of_input_address()); |
| 338 } else { | 338 } else { |
| 339 ASSERT(mode_ == UC16); | 339 ASSERT(mode_ == UC16); |
| 340 int argument_count = 3; | 340 int argument_count = 3; |
| 341 FrameAlign(argument_count, r2); | 341 __ PrepareCallCFunction(argument_count, r2); |
| 342 | 342 |
| 343 // r0 - offset of start of capture | 343 // r0 - offset of start of capture |
| 344 // r1 - length of capture | 344 // r1 - length of capture |
| 345 | 345 |
| 346 // Put arguments into arguments registers. | 346 // Put arguments into arguments registers. |
| 347 // Parameters are | 347 // Parameters are |
| 348 // r0: Address byte_offset1 - Address captured substring's start. | 348 // r0: Address byte_offset1 - Address captured substring's start. |
| 349 // r1: Address byte_offset2 - Address of current character position. | 349 // r1: Address byte_offset2 - Address of current character position. |
| 350 // r2: size_t byte_length - length of capture in bytes(!) | 350 // r2: size_t byte_length - length of capture in bytes(!) |
| 351 | 351 |
| 352 // Address of start of capture. | 352 // Address of start of capture. |
| 353 __ add(r0, r0, Operand(end_of_input_address())); | 353 __ add(r0, r0, Operand(end_of_input_address())); |
| 354 // Length of capture. | 354 // Length of capture. |
| 355 __ mov(r2, Operand(r1)); | 355 __ mov(r2, Operand(r1)); |
| 356 // Save length in callee-save register for use on return. | 356 // Save length in callee-save register for use on return. |
| 357 __ mov(r4, Operand(r1)); | 357 __ mov(r4, Operand(r1)); |
| 358 // Address of current input position. | 358 // Address of current input position. |
| 359 __ add(r1, current_input_offset(), Operand(end_of_input_address())); | 359 __ add(r1, current_input_offset(), Operand(end_of_input_address())); |
| 360 | 360 |
| 361 ExternalReference function = | 361 ExternalReference function = |
| 362 ExternalReference::re_case_insensitive_compare_uc16(); | 362 ExternalReference::re_case_insensitive_compare_uc16(); |
| 363 CallCFunction(function, argument_count); | 363 __ CallCFunction(function, argument_count); |
| 364 | 364 |
| 365 // Check if function returned non-zero for success or zero for failure. | 365 // Check if function returned non-zero for success or zero for failure. |
| 366 __ cmp(r0, Operand(0)); | 366 __ cmp(r0, Operand(0)); |
| 367 BranchOrBacktrack(eq, on_no_match); | 367 BranchOrBacktrack(eq, on_no_match); |
| 368 // On success, increment position by length of capture. | 368 // On success, increment position by length of capture. |
| 369 __ add(current_input_offset(), current_input_offset(), Operand(r4)); | 369 __ add(current_input_offset(), current_input_offset(), Operand(r4)); |
| 370 } | 370 } |
| 371 | 371 |
| 372 __ bind(&fallthrough); | 372 __ bind(&fallthrough); |
| 373 } | 373 } |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 763 |
| 764 // Backtrack stack overflow code. | 764 // Backtrack stack overflow code. |
| 765 if (stack_overflow_label_.is_linked()) { | 765 if (stack_overflow_label_.is_linked()) { |
| 766 SafeCallTarget(&stack_overflow_label_); | 766 SafeCallTarget(&stack_overflow_label_); |
| 767 // Reached if the backtrack-stack limit has been hit. | 767 // Reached if the backtrack-stack limit has been hit. |
| 768 | 768 |
| 769 Label grow_failed; | 769 Label grow_failed; |
| 770 | 770 |
| 771 // Call GrowStack(backtrack_stackpointer()) | 771 // Call GrowStack(backtrack_stackpointer()) |
| 772 static const int num_arguments = 2; | 772 static const int num_arguments = 2; |
| 773 FrameAlign(num_arguments, r0); | 773 __ PrepareCallCFunction(num_arguments, r0); |
| 774 __ mov(r0, backtrack_stackpointer()); | 774 __ mov(r0, backtrack_stackpointer()); |
| 775 __ add(r1, frame_pointer(), Operand(kStackHighEnd)); | 775 __ add(r1, frame_pointer(), Operand(kStackHighEnd)); |
| 776 ExternalReference grow_stack = | 776 ExternalReference grow_stack = |
| 777 ExternalReference::re_grow_stack(); | 777 ExternalReference::re_grow_stack(); |
| 778 CallCFunction(grow_stack, num_arguments); | 778 __ CallCFunction(grow_stack, num_arguments); |
| 779 // If return NULL, we have failed to grow the stack, and | 779 // If return NULL, we have failed to grow the stack, and |
| 780 // must exit with a stack-overflow exception. | 780 // must exit with a stack-overflow exception. |
| 781 __ cmp(r0, Operand(0)); | 781 __ cmp(r0, Operand(0)); |
| 782 __ b(eq, &exit_with_exception); | 782 __ b(eq, &exit_with_exception); |
| 783 // Otherwise use return value as new stack pointer. | 783 // Otherwise use return value as new stack pointer. |
| 784 __ mov(backtrack_stackpointer(), r0); | 784 __ mov(backtrack_stackpointer(), r0); |
| 785 // Restore saved registers and continue. | 785 // Restore saved registers and continue. |
| 786 SafeReturn(); | 786 SafeReturn(); |
| 787 } | 787 } |
| 788 | 788 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 __ ldr(r1, MemOperand(frame_pointer(), kStackHighEnd)); | 964 __ ldr(r1, MemOperand(frame_pointer(), kStackHighEnd)); |
| 965 __ sub(r0, backtrack_stackpointer(), r1); | 965 __ sub(r0, backtrack_stackpointer(), r1); |
| 966 __ str(r0, register_location(reg)); | 966 __ str(r0, register_location(reg)); |
| 967 } | 967 } |
| 968 | 968 |
| 969 | 969 |
| 970 // Private methods: | 970 // Private methods: |
| 971 | 971 |
| 972 void RegExpMacroAssemblerARM::CallCheckStackGuardState(Register scratch) { | 972 void RegExpMacroAssemblerARM::CallCheckStackGuardState(Register scratch) { |
| 973 static const int num_arguments = 3; | 973 static const int num_arguments = 3; |
| 974 FrameAlign(num_arguments, scratch); | 974 __ PrepareCallCFunction(num_arguments, scratch); |
| 975 // RegExp code frame pointer. | 975 // RegExp code frame pointer. |
| 976 __ mov(r2, frame_pointer()); | 976 __ mov(r2, frame_pointer()); |
| 977 // Code* of self. | 977 // Code* of self. |
| 978 __ mov(r1, Operand(masm_->CodeObject())); | 978 __ mov(r1, Operand(masm_->CodeObject())); |
| 979 // r0 becomes return address pointer. | 979 // r0 becomes return address pointer. |
| 980 ExternalReference stack_guard_check = | 980 ExternalReference stack_guard_check = |
| 981 ExternalReference::re_check_stack_guard_state(); | 981 ExternalReference::re_check_stack_guard_state(); |
| 982 CallCFunctionUsingStub(stack_guard_check, num_arguments); | 982 CallCFunctionUsingStub(stack_guard_check, num_arguments); |
| 983 } | 983 } |
| 984 | 984 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 __ jmp(&new_pool_skip); | 1176 __ jmp(&new_pool_skip); |
| 1177 EmitBacktrackConstantPool(); | 1177 EmitBacktrackConstantPool(); |
| 1178 __ bind(&new_pool_skip); | 1178 __ bind(&new_pool_skip); |
| 1179 int offset = backtrack_constant_pool_offset_; | 1179 int offset = backtrack_constant_pool_offset_; |
| 1180 backtrack_constant_pool_offset_ += kPointerSize; | 1180 backtrack_constant_pool_offset_ += kPointerSize; |
| 1181 backtrack_constant_pool_capacity_--; | 1181 backtrack_constant_pool_capacity_--; |
| 1182 return offset; | 1182 return offset; |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 | 1185 |
| 1186 void RegExpMacroAssemblerARM::FrameAlign(int num_arguments, Register scratch) { | |
| 1187 int frameAlignment = OS::ActivationFrameAlignment(); | |
| 1188 // Up to four simple arguments are passed in registers r0..r3. | |
| 1189 int stack_passed_arguments = (num_arguments <= 4) ? 0 : num_arguments - 4; | |
| 1190 if (frameAlignment != 0) { | |
| 1191 // Make stack end at alignment and make room for num_arguments - 4 words | |
| 1192 // and the original value of sp. | |
| 1193 __ mov(scratch, sp); | |
| 1194 __ sub(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize)); | |
| 1195 ASSERT(IsPowerOf2(frameAlignment)); | |
| 1196 __ and_(sp, sp, Operand(-frameAlignment)); | |
| 1197 __ str(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); | |
| 1198 } else { | |
| 1199 __ sub(sp, sp, Operand(stack_passed_arguments * kPointerSize)); | |
| 1200 } | |
| 1201 } | |
| 1202 | |
| 1203 | |
| 1204 void RegExpMacroAssemblerARM::CallCFunction(ExternalReference function, | |
| 1205 int num_arguments) { | |
| 1206 __ mov(r5, Operand(function)); | |
| 1207 // Just call directly. The function called cannot cause a GC, or | |
| 1208 // allow preemption, so the return address in the link register | |
| 1209 // stays correct. | |
| 1210 __ Call(r5); | |
| 1211 int stack_passed_arguments = (num_arguments <= 4) ? 0 : num_arguments - 4; | |
| 1212 if (OS::ActivationFrameAlignment() > kIntSize) { | |
| 1213 __ ldr(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); | |
| 1214 } else { | |
| 1215 __ add(sp, sp, Operand(stack_passed_arguments * sizeof(kPointerSize))); | |
| 1216 } | |
| 1217 __ mov(code_pointer(), Operand(masm_->CodeObject())); | |
| 1218 } | |
| 1219 | |
| 1220 | |
| 1221 void RegExpMacroAssemblerARM::CallCFunctionUsingStub( | 1186 void RegExpMacroAssemblerARM::CallCFunctionUsingStub( |
| 1222 ExternalReference function, | 1187 ExternalReference function, |
| 1223 int num_arguments) { | 1188 int num_arguments) { |
| 1224 // Must pass all arguments in registers. The stub pushes on the stack. | 1189 // Must pass all arguments in registers. The stub pushes on the stack. |
| 1225 ASSERT(num_arguments <= 4); | 1190 ASSERT(num_arguments <= 4); |
| 1226 __ mov(r5, Operand(function)); | 1191 __ mov(code_pointer(), Operand(function)); |
| 1227 RegExpCEntryStub stub; | 1192 RegExpCEntryStub stub; |
| 1228 __ CallStub(&stub); | 1193 __ CallStub(&stub); |
| 1229 if (OS::ActivationFrameAlignment() != 0) { | 1194 if (OS::ActivationFrameAlignment() != 0) { |
| 1230 __ ldr(sp, MemOperand(sp, 0)); | 1195 __ ldr(sp, MemOperand(sp, 0)); |
| 1231 } | 1196 } |
| 1232 __ mov(code_pointer(), Operand(masm_->CodeObject())); | 1197 __ mov(code_pointer(), Operand(masm_->CodeObject())); |
| 1233 } | 1198 } |
| 1234 | 1199 |
| 1235 | 1200 |
| 1236 void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset, | 1201 void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1261 __ mov(r0, sp); | 1226 __ mov(r0, sp); |
| 1262 __ Call(r5); | 1227 __ Call(r5); |
| 1263 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex)); | 1228 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex)); |
| 1264 } | 1229 } |
| 1265 | 1230 |
| 1266 #undef __ | 1231 #undef __ |
| 1267 | 1232 |
| 1268 #endif // V8_NATIVE_REGEXP | 1233 #endif // V8_NATIVE_REGEXP |
| 1269 | 1234 |
| 1270 }} // namespace v8::internal | 1235 }} // namespace v8::internal |
| OLD | NEW |