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

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

Issue 18744: * Irregexp: Handle backtrack past look-ahead. (Closed)
Patch Set: Created 11 years, 10 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
« no previous file with comments | « src/regexp-macro-assembler-ia32.h ('k') | src/regexp-macro-assembler-irregexp.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 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, ecx); 334 FrameAlign(four_arguments, ecx);
335 // Put arguments into allocated stack area. 335 // Put arguments into allocated stack area, last argument highest on stack.
336 // Parameters are
337 // UC16** buffer - really the String** of the input string
338 // int byte_offset1 - byte offset from *buffer of start of capture
339 // int byte_offset2 - byte offset from *buffer of current position
340 // size_t byte_length - length of capture in bytes(!)
341
342 // Set byte_length.
336 __ mov(Operand(esp, 3 * kPointerSize), ebx); 343 __ mov(Operand(esp, 3 * kPointerSize), ebx);
344 // Set byte_offset2.
345 // Found by adding negative string-end offset of current position (edi)
346 // to String** offset of end of string.
337 __ mov(ecx, Operand(ebp, kInputEndOffset)); 347 __ mov(ecx, Operand(ebp, kInputEndOffset));
338 __ add(edi, Operand(ecx)); 348 __ add(edi, Operand(ecx));
339 __ mov(Operand(esp, 2 * kPointerSize), edi); 349 __ mov(Operand(esp, 2 * kPointerSize), edi);
350 // Set byte_offset1.
351 // Start of capture, where eax already holds string-end negative offset.
340 __ add(eax, Operand(ecx)); 352 __ add(eax, Operand(ecx));
341 __ mov(Operand(esp, 1 * kPointerSize), eax); 353 __ mov(Operand(esp, 1 * kPointerSize), eax);
354 // Set buffer. Original String** parameter to regexp code.
342 __ mov(eax, Operand(ebp, kInputBuffer)); 355 __ mov(eax, Operand(ebp, kInputBuffer));
343 __ mov(Operand(esp, 0 * kPointerSize), eax); 356 __ mov(Operand(esp, 0 * kPointerSize), eax);
357
344 Address function_address = FUNCTION_ADDR(&CaseInsensitiveCompareUC16); 358 Address function_address = FUNCTION_ADDR(&CaseInsensitiveCompareUC16);
345 CallCFunction(function_address, four_arguments); 359 CallCFunction(function_address, four_arguments);
346 // Pop original values before reacting on result value. 360 // Pop original values before reacting on result value.
347 __ pop(ebx); 361 __ pop(ebx);
348 __ pop(backtrack_stackpointer()); 362 __ pop(backtrack_stackpointer());
349 __ pop(edi); 363 __ pop(edi);
350 __ pop(esi); 364 __ pop(esi);
351 365
352 // Check if function returned non-zero for success or zero for failure. 366 // Check if function returned non-zero for success or zero for failure.
353 __ or_(eax, Operand(eax)); 367 __ or_(eax, Operand(eax));
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 int cp_offset) { 953 int cp_offset) {
940 if (cp_offset == 0) { 954 if (cp_offset == 0) {
941 __ mov(register_location(reg), edi); 955 __ mov(register_location(reg), edi);
942 } else { 956 } else {
943 __ lea(eax, Operand(edi, cp_offset * char_size())); 957 __ lea(eax, Operand(edi, cp_offset * char_size()));
944 __ mov(register_location(reg), eax); 958 __ mov(register_location(reg), eax);
945 } 959 }
946 } 960 }
947 961
948 962
949 void RegExpMacroAssemblerIA32::ClearRegister(int reg) { 963 void RegExpMacroAssemblerIA32::ClearRegisters(int reg_from, int reg_to) {
964 ASSERT(reg_from <= reg_to);
950 __ mov(eax, Operand(ebp, kInputStartMinusOne)); 965 __ mov(eax, Operand(ebp, kInputStartMinusOne));
951 __ mov(register_location(reg), eax); 966 for (int reg = reg_from; reg <= reg_to; reg++) {
967 __ mov(register_location(reg), eax);
968 }
952 } 969 }
953 970
954 971
955 void RegExpMacroAssemblerIA32::WriteStackPointerToRegister(int reg) { 972 void RegExpMacroAssemblerIA32::WriteStackPointerToRegister(int reg) {
956 __ mov(register_location(reg), backtrack_stackpointer()); 973 __ mov(register_location(reg), backtrack_stackpointer());
957 } 974 }
958 975
959 976
960 // Private methods: 977 // Private methods:
961 978
(...skipping 18 matching lines...) Expand all
980 void* stack_top = RegExpStack::stack_top(); 997 void* stack_top = RegExpStack::stack_top();
981 998
982 int result = matcher_func(input, 999 int result = matcher_func(input,
983 start_offset, 1000 start_offset,
984 end_offset, 1001 end_offset,
985 output, 1002 output,
986 at_start_val, 1003 at_start_val,
987 stack_top); 1004 stack_top);
988 1005
989 if (result < 0 && !Top::has_pending_exception()) { 1006 if (result < 0 && !Top::has_pending_exception()) {
990 // We detected a stack overflow in RegExp code, but haven't created 1007 // We detected a stack overflow (on the backtrack stack) in RegExp code,
991 // the exception yet. 1008 // but haven't created the exception yet.
992 Top::StackOverflow(); 1009 Top::StackOverflow();
993 } 1010 }
994 return (result < 0) ? EXCEPTION : (result ? SUCCESS : FAILURE); 1011 return (result < 0) ? EXCEPTION : (result ? SUCCESS : FAILURE);
995 } 1012 }
996 1013
997 1014
998 int RegExpMacroAssemblerIA32::CaseInsensitiveCompareUC16(uc16** buffer, 1015 int RegExpMacroAssemblerIA32::CaseInsensitiveCompareUC16(uc16** buffer,
999 int byte_offset1, 1016 int byte_offset1,
1000 int byte_offset2, 1017 int byte_offset2,
1001 size_t byte_length) { 1018 size_t byte_length) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 __ j(above, &no_stack_overflow); 1180 __ j(above, &no_stack_overflow);
1164 1181
1165 SafeCall(&stack_overflow_label_); 1182 SafeCall(&stack_overflow_label_);
1166 1183
1167 __ bind(&no_stack_overflow); 1184 __ bind(&no_stack_overflow);
1168 } 1185 }
1169 } 1186 }
1170 1187
1171 1188
1172 void RegExpMacroAssemblerIA32::FrameAlign(int num_arguments, Register scratch) { 1189 void RegExpMacroAssemblerIA32::FrameAlign(int num_arguments, Register scratch) {
1190 // TODO(lrn): Since we no longer use the system stack arbitrarily, we
1191 // know the current stack alignment - esp points to the last regexp register.
1192 // We can do this simpler then.
1173 int frameAlignment = OS::ActivationFrameAlignment(); 1193 int frameAlignment = OS::ActivationFrameAlignment();
1174 if (frameAlignment != 0) { 1194 if (frameAlignment != 0) {
1175 // Make stack end at alignment and make room for num_arguments words 1195 // Make stack end at alignment and make room for num_arguments words
1176 // and the original value of esp. 1196 // and the original value of esp.
1177 __ mov(scratch, esp); 1197 __ mov(scratch, esp);
1178 __ sub(Operand(esp), Immediate((num_arguments + 1) * kPointerSize)); 1198 __ sub(Operand(esp), Immediate((num_arguments + 1) * kPointerSize));
1179 ASSERT(IsPowerOf2(frameAlignment)); 1199 ASSERT(IsPowerOf2(frameAlignment));
1180 __ and_(esp, -frameAlignment); 1200 __ and_(esp, -frameAlignment);
1181 __ mov(Operand(esp, num_arguments * kPointerSize), scratch); 1201 __ mov(Operand(esp, num_arguments * kPointerSize), scratch);
1182 } else { 1202 } else {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1243
1224 1244
1225 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, 1245 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg,
1226 ArraySlice* buffer) { 1246 ArraySlice* buffer) {
1227 __ mov(reg, buffer->array()); 1247 __ mov(reg, buffer->array());
1228 __ add(Operand(reg), Immediate(buffer->base_offset())); 1248 __ add(Operand(reg), Immediate(buffer->base_offset()));
1229 } 1249 }
1230 1250
1231 #undef __ 1251 #undef __
1232 }} // namespace v8::internal 1252 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/regexp-macro-assembler-ia32.h ('k') | src/regexp-macro-assembler-irregexp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698