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

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

Issue 7477045: Tentative implementation of string slices (hidden under the flag --string-slices). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some more suggested changes. Created 9 years, 3 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 // If not real stack overflow the stack guard was used to interrupt 1163 // If not real stack overflow the stack guard was used to interrupt
1164 // execution for another purpose. 1164 // execution for another purpose.
1165 1165
1166 // If this is a direct call from JavaScript retry the RegExp forcing the call 1166 // If this is a direct call from JavaScript retry the RegExp forcing the call
1167 // through the runtime system. Currently the direct call cannot handle a GC. 1167 // through the runtime system. Currently the direct call cannot handle a GC.
1168 if (frame_entry<int>(re_frame, kDirectCall) == 1) { 1168 if (frame_entry<int>(re_frame, kDirectCall) == 1) {
1169 return RETRY; 1169 return RETRY;
1170 } 1170 }
1171 1171
1172 // Prepare for possible GC. 1172 // Prepare for possible GC.
1173 HandleScope handles; 1173 HandleScope handles(isolate);
1174 Handle<Code> code_handle(re_code); 1174 Handle<Code> code_handle(re_code);
1175 1175
1176 Handle<String> subject(frame_entry<String*>(re_frame, kInputString)); 1176 Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
1177
1177 // Current string. 1178 // Current string.
1178 bool is_ascii = subject->IsAsciiRepresentation(); 1179 bool is_ascii = subject->IsAsciiRepresentationUnderneath();
1179 1180
1180 ASSERT(re_code->instruction_start() <= *return_address); 1181 ASSERT(re_code->instruction_start() <= *return_address);
1181 ASSERT(*return_address <= 1182 ASSERT(*return_address <=
1182 re_code->instruction_start() + re_code->instruction_size()); 1183 re_code->instruction_start() + re_code->instruction_size());
1183 1184
1184 MaybeObject* result = Execution::HandleStackGuardInterrupt(); 1185 MaybeObject* result = Execution::HandleStackGuardInterrupt();
1185 1186
1186 if (*code_handle != re_code) { // Return address no longer valid 1187 if (*code_handle != re_code) { // Return address no longer valid
1187 intptr_t delta = *code_handle - re_code; 1188 int delta = *code_handle - re_code;
1188 // Overwrite the return address on the stack. 1189 // Overwrite the return address on the stack.
1189 *return_address += delta; 1190 *return_address += delta;
1190 } 1191 }
1191 1192
1192 if (result->IsException()) { 1193 if (result->IsException()) {
1193 return EXCEPTION; 1194 return EXCEPTION;
1194 } 1195 }
1195 1196
1197 Handle<String> subject_tmp = subject;
1198 int slice_offset = 0;
1199
1200 // Extract the underlying string and the slice offset.
1201 if (StringShape(*subject_tmp).IsCons()) {
1202 subject_tmp = Handle<String>(ConsString::cast(*subject_tmp)->first());
1203 } else if (StringShape(*subject_tmp).IsSliced()) {
1204 SlicedString* slice = SlicedString::cast(*subject_tmp);
1205 subject_tmp = Handle<String>(slice->parent());
1206 slice_offset = slice->offset();
1207 }
1208
1196 // String might have changed. 1209 // String might have changed.
1197 if (subject->IsAsciiRepresentation() != is_ascii) { 1210 if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
1198 // If we changed between an ASCII and an UC16 string, the specialized 1211 // If we changed between an ASCII and an UC16 string, the specialized
1199 // code cannot be used, and we need to restart regexp matching from 1212 // code cannot be used, and we need to restart regexp matching from
1200 // scratch (including, potentially, compiling a new version of the code). 1213 // scratch (including, potentially, compiling a new version of the code).
1201 return RETRY; 1214 return RETRY;
1202 } 1215 }
1203 1216
1204 // Otherwise, the content of the string might have moved. It must still 1217 // Otherwise, the content of the string might have moved. It must still
1205 // be a sequential or external string with the same content. 1218 // be a sequential or external string with the same content.
1206 // Update the start and end pointers in the stack frame to the current 1219 // Update the start and end pointers in the stack frame to the current
1207 // location (whether it has actually moved or not). 1220 // location (whether it has actually moved or not).
1208 ASSERT(StringShape(*subject).IsSequential() || 1221 ASSERT(StringShape(*subject_tmp).IsSequential() ||
1209 StringShape(*subject).IsExternal()); 1222 StringShape(*subject_tmp).IsExternal());
1210 1223
1211 // The original start address of the characters to match. 1224 // The original start address of the characters to match.
1212 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart); 1225 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart);
1213 1226
1214 // Find the current start address of the same character at the current string 1227 // Find the current start address of the same character at the current string
1215 // position. 1228 // position.
1216 int start_index = frame_entry<int>(re_frame, kStartIndex); 1229 int start_index = frame_entry<int>(re_frame, kStartIndex);
1217 const byte* new_address = StringCharacterPosition(*subject, start_index); 1230 const byte* new_address = StringCharacterPosition(*subject_tmp,
1231 start_index + slice_offset);
1218 1232
1219 if (start_address != new_address) { 1233 if (start_address != new_address) {
1220 // If there is a difference, update the object pointer and start and end 1234 // If there is a difference, update the object pointer and start and end
1221 // addresses in the RegExp stack frame to match the new value. 1235 // addresses in the RegExp stack frame to match the new value.
1222 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd); 1236 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd);
1223 int byte_length = static_cast<int>(end_address - start_address); 1237 int byte_length = static_cast<int>(end_address - start_address);
1224 frame_entry<const String*>(re_frame, kInputString) = *subject; 1238 frame_entry<const String*>(re_frame, kInputString) = *subject;
1225 frame_entry<const byte*>(re_frame, kInputStart) = new_address; 1239 frame_entry<const byte*>(re_frame, kInputStart) = new_address;
1226 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length; 1240 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length;
1227 } 1241 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 } 1401 }
1388 } 1402 }
1389 1403
1390 #undef __ 1404 #undef __
1391 1405
1392 #endif // V8_INTERPRETED_REGEXP 1406 #endif // V8_INTERPRETED_REGEXP
1393 1407
1394 }} // namespace v8::internal 1408 }} // namespace v8::internal
1395 1409
1396 #endif // V8_TARGET_ARCH_X64 1410 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698