| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 // Compute new value of character position after the matched part. | 324 // Compute new value of character position after the matched part. |
| 325 __ sub(edi, Operand(esi)); | 325 __ sub(edi, Operand(esi)); |
| 326 } else { | 326 } else { |
| 327 ASSERT(mode_ == UC16); | 327 ASSERT(mode_ == UC16); |
| 328 // Save registers before calling C function. | 328 // Save registers before calling C function. |
| 329 __ push(esi); | 329 __ push(esi); |
| 330 __ push(edi); | 330 __ push(edi); |
| 331 __ push(backtrack_stackpointer()); | 331 __ push(backtrack_stackpointer()); |
| 332 __ push(ebx); | 332 __ push(ebx); |
| 333 const int four_arguments = 4; | 333 const int four_arguments = 4; |
| 334 FrameAlign(four_arguments); | 334 FrameAlign(four_arguments, ecx); |
| 335 // Put arguments into allocated stack area. | 335 // Put arguments into allocated stack area. |
| 336 __ mov(Operand(esp, 3 * kPointerSize), ebx); | 336 __ mov(Operand(esp, 3 * kPointerSize), ebx); |
| 337 __ mov(ecx, Operand(ebp, kInputEndOffset)); | 337 __ mov(ecx, Operand(ebp, kInputEndOffset)); |
| 338 __ add(edi, Operand(ecx)); | 338 __ add(edi, Operand(ecx)); |
| 339 __ mov(Operand(esp, 2 * kPointerSize), edi); | 339 __ mov(Operand(esp, 2 * kPointerSize), edi); |
| 340 __ add(eax, Operand(ecx)); | 340 __ add(eax, Operand(ecx)); |
| 341 __ mov(Operand(esp, 1 * kPointerSize), eax); | 341 __ mov(Operand(esp, 1 * kPointerSize), eax); |
| 342 __ mov(eax, Operand(ebp, kInputBuffer)); | 342 __ mov(eax, Operand(ebp, kInputBuffer)); |
| 343 __ mov(Operand(esp, 0 * kPointerSize), eax); | 343 __ mov(Operand(esp, 0 * kPointerSize), eax); |
| 344 Address function_address = FUNCTION_ADDR(&CaseInsensitiveCompareUC16); | 344 Address function_address = FUNCTION_ADDR(&CaseInsensitiveCompareUC16); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 // Check if there is room for the variable number of registers above | 639 // Check if there is room for the variable number of registers above |
| 640 // the stack limit. | 640 // the stack limit. |
| 641 __ cmp(ecx, num_registers_ * kPointerSize); | 641 __ cmp(ecx, num_registers_ * kPointerSize); |
| 642 __ j(above_equal, &stack_ok, taken); | 642 __ j(above_equal, &stack_ok, taken); |
| 643 // Exit with exception. | 643 // Exit with exception. |
| 644 __ mov(eax, EXCEPTION); | 644 __ mov(eax, EXCEPTION); |
| 645 __ jmp(&exit_label_); | 645 __ jmp(&exit_label_); |
| 646 | 646 |
| 647 __ bind(&stack_limit_hit); | 647 __ bind(&stack_limit_hit); |
| 648 int num_arguments = 2; | 648 int num_arguments = 2; |
| 649 FrameAlign(num_arguments); | 649 FrameAlign(num_arguments, ebx); |
| 650 __ mov(Operand(esp, 1 * kPointerSize), Immediate(self_)); | 650 __ mov(Operand(esp, 1 * kPointerSize), Immediate(self_)); |
| 651 __ lea(eax, Operand(esp, -kPointerSize)); | 651 __ lea(eax, Operand(esp, -kPointerSize)); |
| 652 __ mov(Operand(esp, 0 * kPointerSize), eax); | 652 __ mov(Operand(esp, 0 * kPointerSize), eax); |
| 653 CallCFunction(FUNCTION_ADDR(&CheckStackGuardState), num_arguments); | 653 CallCFunction(FUNCTION_ADDR(&CheckStackGuardState), num_arguments); |
| 654 __ or_(eax, Operand(eax)); | 654 __ or_(eax, Operand(eax)); |
| 655 // If returned value is non-zero, the stack guard reports the actual | 655 // If returned value is non-zero, the stack guard reports the actual |
| 656 // stack limit being hit and an exception has already been raised. | 656 // stack limit being hit and an exception has already been raised. |
| 657 // Otherwise it was a preemption and we just check the limit again. | 657 // Otherwise it was a preemption and we just check the limit again. |
| 658 __ j(equal, &retry_stack_check); | 658 __ j(equal, &retry_stack_check); |
| 659 // Return value was non-zero. Exit with exception. | 659 // Return value was non-zero. Exit with exception. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 if (check_preempt_label_.is_linked()) { | 762 if (check_preempt_label_.is_linked()) { |
| 763 __ bind(&check_preempt_label_); | 763 __ bind(&check_preempt_label_); |
| 764 | 764 |
| 765 __ push(backtrack_stackpointer()); | 765 __ push(backtrack_stackpointer()); |
| 766 __ push(edi); | 766 __ push(edi); |
| 767 | 767 |
| 768 Label retry; | 768 Label retry; |
| 769 | 769 |
| 770 __ bind(&retry); | 770 __ bind(&retry); |
| 771 int num_arguments = 2; | 771 int num_arguments = 2; |
| 772 FrameAlign(num_arguments); | 772 FrameAlign(num_arguments, ebx); |
| 773 __ mov(Operand(esp, 1 * kPointerSize), Immediate(self_)); | 773 __ mov(Operand(esp, 1 * kPointerSize), Immediate(self_)); |
| 774 __ lea(eax, Operand(esp, -kPointerSize)); | 774 __ lea(eax, Operand(esp, -kPointerSize)); |
| 775 __ mov(Operand(esp, 0 * kPointerSize), eax); | 775 __ mov(Operand(esp, 0 * kPointerSize), eax); |
| 776 CallCFunction(FUNCTION_ADDR(&CheckStackGuardState), num_arguments); | 776 CallCFunction(FUNCTION_ADDR(&CheckStackGuardState), num_arguments); |
| 777 // Return value must be zero. We cannot have a stack overflow at | 777 // Return value must be zero. We cannot have a stack overflow at |
| 778 // this point, since we checked the stack on entry and haven't | 778 // this point, since we checked the stack on entry and haven't |
| 779 // pushed anything since, that we haven't also popped again. | 779 // pushed anything since, that we haven't also popped again. |
| 780 | 780 |
| 781 ExternalReference stack_guard_limit = | 781 ExternalReference stack_guard_limit = |
| 782 ExternalReference::address_of_stack_guard_limit(); | 782 ExternalReference::address_of_stack_guard_limit(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 798 __ bind(&stack_overflow_label_); | 798 __ bind(&stack_overflow_label_); |
| 799 // Reached if the backtrack-stack limit has been hit. | 799 // Reached if the backtrack-stack limit has been hit. |
| 800 | 800 |
| 801 Label grow_failed; | 801 Label grow_failed; |
| 802 // Save registers before calling C function | 802 // Save registers before calling C function |
| 803 __ push(esi); | 803 __ push(esi); |
| 804 __ push(edi); | 804 __ push(edi); |
| 805 | 805 |
| 806 // Call GrowStack(backtrack_stackpointer()) | 806 // Call GrowStack(backtrack_stackpointer()) |
| 807 int num_arguments = 1; | 807 int num_arguments = 1; |
| 808 FrameAlign(num_arguments); | 808 FrameAlign(num_arguments, ebx); |
| 809 __ mov(Operand(esp, 0), backtrack_stackpointer()); | 809 __ mov(Operand(esp, 0), backtrack_stackpointer()); |
| 810 CallCFunction(FUNCTION_ADDR(&GrowStack), num_arguments); | 810 CallCFunction(FUNCTION_ADDR(&GrowStack), num_arguments); |
| 811 // If return NULL, we have failed to grow the stack, and | 811 // If return NULL, we have failed to grow the stack, and |
| 812 // must exit with a stack-overflow exception. | 812 // must exit with a stack-overflow exception. |
| 813 __ or_(eax, Operand(eax)); | 813 __ or_(eax, Operand(eax)); |
| 814 __ j(equal, &exit_with_exception); | 814 __ j(equal, &exit_with_exception); |
| 815 // Otherwise use return value as new stack pointer. | 815 // Otherwise use return value as new stack pointer. |
| 816 __ mov(backtrack_stackpointer(), eax); | 816 __ mov(backtrack_stackpointer(), eax); |
| 817 // Restore saved registers and continue. | 817 // Restore saved registers and continue. |
| 818 __ pop(edi); | 818 __ pop(edi); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 __ cmp(backtrack_stackpointer(), Operand::StaticVariable(stack_limit)); | 1162 __ cmp(backtrack_stackpointer(), Operand::StaticVariable(stack_limit)); |
| 1163 __ j(above, &no_stack_overflow); | 1163 __ j(above, &no_stack_overflow); |
| 1164 | 1164 |
| 1165 SafeCall(&stack_overflow_label_); | 1165 SafeCall(&stack_overflow_label_); |
| 1166 | 1166 |
| 1167 __ bind(&no_stack_overflow); | 1167 __ bind(&no_stack_overflow); |
| 1168 } | 1168 } |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 | 1171 |
| 1172 void RegExpMacroAssemblerIA32::FrameAlign(int num_arguments) { | 1172 void RegExpMacroAssemblerIA32::FrameAlign(int num_arguments, Register scratch) { |
| 1173 int frameAlignment = OS::ActivationFrameAlignment(); | 1173 int frameAlignment = OS::ActivationFrameAlignment(); |
| 1174 if (frameAlignment != 0) { | 1174 if (frameAlignment != 0) { |
| 1175 // Make stack end at alignment and make room for num_arguments words | 1175 // Make stack end at alignment and make room for num_arguments words |
| 1176 // and the original value of esp. | 1176 // and the original value of esp. |
| 1177 __ mov(ebx, esp); | 1177 __ mov(scratch, esp); |
| 1178 __ sub(Operand(esp), Immediate((num_arguments + 1) * kPointerSize)); | 1178 __ sub(Operand(esp), Immediate((num_arguments + 1) * kPointerSize)); |
| 1179 ASSERT(IsPowerOf2(frameAlignment)); | 1179 ASSERT(IsPowerOf2(frameAlignment)); |
| 1180 __ and_(esp, -frameAlignment); | 1180 __ and_(esp, -frameAlignment); |
| 1181 __ mov(Operand(esp, num_arguments * kPointerSize), ebx); | 1181 __ mov(Operand(esp, num_arguments * kPointerSize), scratch); |
| 1182 } else { | 1182 } else { |
| 1183 __ sub(Operand(esp), Immediate(num_arguments * kPointerSize)); | 1183 __ sub(Operand(esp), Immediate(num_arguments * kPointerSize)); |
| 1184 } | 1184 } |
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 | 1187 |
| 1188 void RegExpMacroAssemblerIA32::CallCFunction(Address function_address, | 1188 void RegExpMacroAssemblerIA32::CallCFunction(Address function_address, |
| 1189 int num_arguments) { | 1189 int num_arguments) { |
| 1190 __ mov(Operand(eax), Immediate(reinterpret_cast<int32_t>(function_address))); | 1190 __ mov(Operand(eax), Immediate(reinterpret_cast<int32_t>(function_address))); |
| 1191 __ call(Operand(eax)); | 1191 __ call(Operand(eax)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 | 1223 |
| 1224 | 1224 |
| 1225 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, | 1225 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, |
| 1226 ArraySlice* buffer) { | 1226 ArraySlice* buffer) { |
| 1227 __ mov(reg, buffer->array()); | 1227 __ mov(reg, buffer->array()); |
| 1228 __ add(Operand(reg), Immediate(buffer->base_offset())); | 1228 __ add(Operand(reg), Immediate(buffer->base_offset())); |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 #undef __ | 1231 #undef __ |
| 1232 }} // namespace v8::internal | 1232 }} // namespace v8::internal |
| OLD | NEW |