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

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 corrections. Offsets are set to 0 by default now. Created 9 years, 4 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 Handle<String> subject_tmp = subject;
1178 int slice_offset = 0;
1179
1180 // Extract the underlying string and the slice offset.
1181 if (StringShape(*subject_tmp).IsCons()) {
1182 subject_tmp = Handle<String>(ConsString::cast(*subject_tmp)->first());
1183 } else if (StringShape(*subject_tmp).IsSliced()) {
1184 SlicedString* slice = SlicedString::cast(*subject_tmp);
1185 subject_tmp = Handle<String>(slice->parent());
1186 slice_offset = slice->offset();
1187 }
1188
1177 // Current string. 1189 // Current string.
1178 bool is_ascii = subject->IsAsciiRepresentation(); 1190 bool is_ascii = subject_tmp->IsAsciiRepresentation();
1179 1191
1180 ASSERT(re_code->instruction_start() <= *return_address); 1192 ASSERT(re_code->instruction_start() <= *return_address);
1181 ASSERT(*return_address <= 1193 ASSERT(*return_address <=
1182 re_code->instruction_start() + re_code->instruction_size()); 1194 re_code->instruction_start() + re_code->instruction_size());
1183 1195
1184 MaybeObject* result = Execution::HandleStackGuardInterrupt(); 1196 MaybeObject* result = Execution::HandleStackGuardInterrupt();
1185 1197
1186 if (*code_handle != re_code) { // Return address no longer valid 1198 if (*code_handle != re_code) { // Return address no longer valid
1187 intptr_t delta = *code_handle - re_code; 1199 int delta = *code_handle - re_code;
1188 // Overwrite the return address on the stack. 1200 // Overwrite the return address on the stack.
1189 *return_address += delta; 1201 *return_address += delta;
1190 } 1202 }
1191 1203
1192 if (result->IsException()) { 1204 if (result->IsException()) {
1193 return EXCEPTION; 1205 return EXCEPTION;
1194 } 1206 }
1195 1207
1196 // String might have changed. 1208 // String might have changed.
1197 if (subject->IsAsciiRepresentation() != is_ascii) { 1209 if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
1198 // If we changed between an ASCII and an UC16 string, the specialized 1210 // 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 1211 // code cannot be used, and we need to restart regexp matching from
1200 // scratch (including, potentially, compiling a new version of the code). 1212 // scratch (including, potentially, compiling a new version of the code).
1201 return RETRY; 1213 return RETRY;
1202 } 1214 }
1203 1215
1204 // Otherwise, the content of the string might have moved. It must still 1216 // Otherwise, the content of the string might have moved. It must still
1205 // be a sequential or external string with the same content. 1217 // be a sequential or external string with the same content.
1206 // Update the start and end pointers in the stack frame to the current 1218 // Update the start and end pointers in the stack frame to the current
1207 // location (whether it has actually moved or not). 1219 // location (whether it has actually moved or not).
1208 ASSERT(StringShape(*subject).IsSequential() || 1220 ASSERT(StringShape(*subject_tmp).IsSequential() ||
1209 StringShape(*subject).IsExternal()); 1221 StringShape(*subject_tmp).IsExternal());
1210 1222
1211 // The original start address of the characters to match. 1223 // The original start address of the characters to match.
1212 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart); 1224 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart);
1213 1225
1214 // Find the current start address of the same character at the current string 1226 // Find the current start address of the same character at the current string
1215 // position. 1227 // position.
1216 int start_index = frame_entry<int>(re_frame, kStartIndex); 1228 int start_index = frame_entry<int>(re_frame, kStartIndex);
1217 const byte* new_address = StringCharacterPosition(*subject, start_index); 1229 const byte* new_address = StringCharacterPosition(*subject_tmp,
1230 start_index + slice_offset);
1218 1231
1219 if (start_address != new_address) { 1232 if (start_address != new_address) {
1220 // If there is a difference, update the object pointer and start and end 1233 // 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. 1234 // addresses in the RegExp stack frame to match the new value.
1222 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd); 1235 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd);
1223 int byte_length = static_cast<int>(end_address - start_address); 1236 int byte_length = static_cast<int>(end_address - start_address);
1224 frame_entry<const String*>(re_frame, kInputString) = *subject; 1237 frame_entry<const String*>(re_frame, kInputString) = *subject;
1225 frame_entry<const byte*>(re_frame, kInputStart) = new_address; 1238 frame_entry<const byte*>(re_frame, kInputStart) = new_address;
1226 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length; 1239 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length;
1227 } 1240 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 } 1400 }
1388 } 1401 }
1389 1402
1390 #undef __ 1403 #undef __
1391 1404
1392 #endif // V8_INTERPRETED_REGEXP 1405 #endif // V8_INTERPRETED_REGEXP
1393 1406
1394 }} // namespace v8::internal 1407 }} // namespace v8::internal
1395 1408
1396 #endif // V8_TARGET_ARCH_X64 1409 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698