Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: src/ia32/regexp-macro-assembler-ia32.cc

Issue 7060010: Merge bleeding edge into the GC branch up to 7948. The asserts (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/regexp-macro-assembler-ia32.h ('k') | src/ia32/simulator-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 655 }
656 656
657 657
658 void RegExpMacroAssemblerIA32::Fail() { 658 void RegExpMacroAssemblerIA32::Fail() {
659 ASSERT(FAILURE == 0); // Return value for failure is zero. 659 ASSERT(FAILURE == 0); // Return value for failure is zero.
660 __ Set(eax, Immediate(0)); 660 __ Set(eax, Immediate(0));
661 __ jmp(&exit_label_); 661 __ jmp(&exit_label_);
662 } 662 }
663 663
664 664
665 Handle<Object> RegExpMacroAssemblerIA32::GetCode(Handle<String> source) { 665 Handle<HeapObject> RegExpMacroAssemblerIA32::GetCode(Handle<String> source) {
666 // Finalize code - write the entry point code now we know how many 666 // Finalize code - write the entry point code now we know how many
667 // registers we need. 667 // registers we need.
668 668
669 // Entry code: 669 // Entry code:
670 __ bind(&entry_label_); 670 __ bind(&entry_label_);
671 // Start new stack frame. 671 // Start new stack frame.
672 __ push(ebp); 672 __ push(ebp);
673 __ mov(ebp, esp); 673 __ mov(ebp, esp);
674 // Save callee-save registers. Order here should correspond to order of 674 // Save callee-save registers. Order here should correspond to order of
675 // kBackup_ebx etc. 675 // kBackup_ebx etc.
676 __ push(esi); 676 __ push(esi);
677 __ push(edi); 677 __ push(edi);
678 __ push(ebx); // Callee-save on MacOS. 678 __ push(ebx); // Callee-save on MacOS.
679 __ push(Immediate(0)); // Make room for "input start - 1" constant. 679 __ push(Immediate(0)); // Make room for "input start - 1" constant.
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 __ jmp(&exit_label_); 872 __ jmp(&exit_label_);
873 } 873 }
874 874
875 CodeDesc code_desc; 875 CodeDesc code_desc;
876 masm_->GetCode(&code_desc); 876 masm_->GetCode(&code_desc);
877 Handle<Code> code = 877 Handle<Code> code =
878 masm_->isolate()->factory()->NewCode(code_desc, 878 masm_->isolate()->factory()->NewCode(code_desc,
879 Code::ComputeFlags(Code::REGEXP), 879 Code::ComputeFlags(Code::REGEXP),
880 masm_->CodeObject()); 880 masm_->CodeObject());
881 PROFILE(masm_->isolate(), RegExpCodeCreateEvent(*code, *source)); 881 PROFILE(masm_->isolate(), RegExpCodeCreateEvent(*code, *source));
882 return Handle<Object>::cast(code); 882 return Handle<HeapObject>::cast(code);
883 } 883 }
884 884
885 885
886 void RegExpMacroAssemblerIA32::GoTo(Label* to) { 886 void RegExpMacroAssemblerIA32::GoTo(Label* to) {
887 BranchOrBacktrack(no_condition, to); 887 BranchOrBacktrack(no_condition, to);
888 } 888 }
889 889
890 890
891 void RegExpMacroAssemblerIA32::IfRegisterGE(int reg, 891 void RegExpMacroAssemblerIA32::IfRegisterGE(int reg,
892 int comparand, 892 int comparand,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 __ mov(edi, register_location(reg)); 964 __ mov(edi, register_location(reg));
965 } 965 }
966 966
967 967
968 void RegExpMacroAssemblerIA32::ReadStackPointerFromRegister(int reg) { 968 void RegExpMacroAssemblerIA32::ReadStackPointerFromRegister(int reg) {
969 __ mov(backtrack_stackpointer(), register_location(reg)); 969 __ mov(backtrack_stackpointer(), register_location(reg));
970 __ add(backtrack_stackpointer(), Operand(ebp, kStackHighEnd)); 970 __ add(backtrack_stackpointer(), Operand(ebp, kStackHighEnd));
971 } 971 }
972 972
973 void RegExpMacroAssemblerIA32::SetCurrentPositionFromEnd(int by) { 973 void RegExpMacroAssemblerIA32::SetCurrentPositionFromEnd(int by) {
974 NearLabel after_position; 974 Label after_position;
975 __ cmp(edi, -by * char_size()); 975 __ cmp(edi, -by * char_size());
976 __ j(greater_equal, &after_position); 976 __ j(greater_equal, &after_position, Label::kNear);
977 __ mov(edi, -by * char_size()); 977 __ mov(edi, -by * char_size());
978 // On RegExp code entry (where this operation is used), the character before 978 // On RegExp code entry (where this operation is used), the character before
979 // the current position is expected to be already loaded. 979 // the current position is expected to be already loaded.
980 // We have advanced the position, so it's safe to read backwards. 980 // We have advanced the position, so it's safe to read backwards.
981 LoadCurrentCharacterUnchecked(-1, 1); 981 LoadCurrentCharacterUnchecked(-1, 1);
982 __ bind(&after_position); 982 __ bind(&after_position);
983 } 983 }
984 984
985 void RegExpMacroAssemblerIA32::SetRegister(int register_index, int to) { 985 void RegExpMacroAssemblerIA32::SetRegister(int register_index, int to) {
986 ASSERT(register_index >= num_saved_registers_); // Reserved for positions! 986 ASSERT(register_index >= num_saved_registers_); // Reserved for positions!
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
OLDNEW
« no previous file with comments | « src/ia32/regexp-macro-assembler-ia32.h ('k') | src/ia32/simulator-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698