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

Side by Side Diff: src/ia32/regexp-macro-assembler-ia32.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: Small changes here and there, mainly arch-specific code. 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 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 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 // If not real stack overflow the stack guard was used to interrupt 1058 // If not real stack overflow the stack guard was used to interrupt
1059 // execution for another purpose. 1059 // execution for another purpose.
1060 1060
1061 // If this is a direct call from JavaScript retry the RegExp forcing the call 1061 // If this is a direct call from JavaScript retry the RegExp forcing the call
1062 // through the runtime system. Currently the direct call cannot handle a GC. 1062 // through the runtime system. Currently the direct call cannot handle a GC.
1063 if (frame_entry<int>(re_frame, kDirectCall) == 1) { 1063 if (frame_entry<int>(re_frame, kDirectCall) == 1) {
1064 return RETRY; 1064 return RETRY;
1065 } 1065 }
1066 1066
1067 // Prepare for possible GC. 1067 // Prepare for possible GC.
1068 HandleScope handles; 1068 HandleScope handles(isolate);
1069 Handle<Code> code_handle(re_code); 1069 Handle<Code> code_handle(re_code);
1070 1070
1071 Handle<String> subject(frame_entry<String*>(re_frame, kInputString)); 1071 Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
1072 Handle<String> subject_tmp = subject;
1073 int slice_offset = 0;
1074
1075 // Extract the underlying string and the slice offset.
1076 if (StringShape(*subject_tmp).IsCons()) {
1077 subject_tmp = Handle<String>(ConsString::cast(*subject_tmp)->first());
1078 } else if (StringShape(*subject_tmp).IsSliced()) {
1079 SlicedString* slice = SlicedString::cast(*subject_tmp);
1080 subject_tmp = Handle<String>(slice->parent());
1081 slice_offset = slice->offset();
1082 }
1083
1072 // Current string. 1084 // Current string.
1073 bool is_ascii = subject->IsAsciiRepresentation(); 1085 bool is_ascii = subject_tmp->IsAsciiRepresentation();
1074 1086
1075 ASSERT(re_code->instruction_start() <= *return_address); 1087 ASSERT(re_code->instruction_start() <= *return_address);
1076 ASSERT(*return_address <= 1088 ASSERT(*return_address <=
1077 re_code->instruction_start() + re_code->instruction_size()); 1089 re_code->instruction_start() + re_code->instruction_size());
1078 1090
1079 MaybeObject* result = Execution::HandleStackGuardInterrupt(); 1091 MaybeObject* result = Execution::HandleStackGuardInterrupt();
1080 1092
1081 if (*code_handle != re_code) { // Return address no longer valid 1093 if (*code_handle != re_code) { // Return address no longer valid
1082 int delta = *code_handle - re_code; 1094 int delta = *code_handle - re_code;
1083 // Overwrite the return address on the stack. 1095 // Overwrite the return address on the stack.
1084 *return_address += delta; 1096 *return_address += delta;
1085 } 1097 }
1086 1098
1087 if (result->IsException()) { 1099 if (result->IsException()) {
1088 return EXCEPTION; 1100 return EXCEPTION;
1089 } 1101 }
1090 1102
1091 // String might have changed. 1103 // String might have changed.
1092 if (subject->IsAsciiRepresentation() != is_ascii) { 1104 if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
antonm 2011/08/25 16:02:45 if string might have changed, shouldn't you refetc
1093 // If we changed between an ASCII and an UC16 string, the specialized 1105 // If we changed between an ASCII and an UC16 string, the specialized
1094 // code cannot be used, and we need to restart regexp matching from 1106 // code cannot be used, and we need to restart regexp matching from
1095 // scratch (including, potentially, compiling a new version of the code). 1107 // scratch (including, potentially, compiling a new version of the code).
1096 return RETRY; 1108 return RETRY;
1097 } 1109 }
1098 1110
1099 // Otherwise, the content of the string might have moved. It must still 1111 // Otherwise, the content of the string might have moved. It must still
1100 // be a sequential or external string with the same content. 1112 // be a sequential or external string with the same content.
1101 // Update the start and end pointers in the stack frame to the current 1113 // Update the start and end pointers in the stack frame to the current
1102 // location (whether it has actually moved or not). 1114 // location (whether it has actually moved or not).
1103 ASSERT(StringShape(*subject).IsSequential() || 1115 ASSERT(StringShape(*subject_tmp).IsSequential() ||
1104 StringShape(*subject).IsExternal()); 1116 StringShape(*subject_tmp).IsExternal());
1105 1117
1106 // The original start address of the characters to match. 1118 // The original start address of the characters to match.
1107 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart); 1119 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart);
1108 1120
1109 // Find the current start address of the same character at the current string 1121 // Find the current start address of the same character at the current string
1110 // position. 1122 // position.
1111 int start_index = frame_entry<int>(re_frame, kStartIndex); 1123 int start_index = frame_entry<int>(re_frame, kStartIndex);
1112 const byte* new_address = StringCharacterPosition(*subject, start_index); 1124 const byte* new_address = StringCharacterPosition(*subject_tmp,
1125 start_index + slice_offset);
1113 1126
1114 if (start_address != new_address) { 1127 if (start_address != new_address) {
1115 // If there is a difference, update the object pointer and start and end 1128 // If there is a difference, update the object pointer and start and end
1116 // addresses in the RegExp stack frame to match the new value. 1129 // addresses in the RegExp stack frame to match the new value.
1117 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd); 1130 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd);
1118 int byte_length = end_address - start_address; 1131 int byte_length = static_cast<int>(end_address - start_address);
1119 frame_entry<const String*>(re_frame, kInputString) = *subject; 1132 frame_entry<const String*>(re_frame, kInputString) = *subject;
1120 frame_entry<const byte*>(re_frame, kInputStart) = new_address; 1133 frame_entry<const byte*>(re_frame, kInputStart) = new_address;
1121 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length; 1134 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length;
1122 } 1135 }
1123 1136
1124 return 0; 1137 return 0;
1125 } 1138 }
1126 1139
1127 1140
1128 Operand RegExpMacroAssemblerIA32::register_location(int register_index) { 1141 Operand RegExpMacroAssemblerIA32::register_location(int register_index) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 } 1267 }
1255 1268
1256 1269
1257 #undef __ 1270 #undef __
1258 1271
1259 #endif // V8_INTERPRETED_REGEXP 1272 #endif // V8_INTERPRETED_REGEXP
1260 1273
1261 }} // namespace v8::internal 1274 }} // namespace v8::internal
1262 1275
1263 #endif // V8_TARGET_ARCH_IA32 1276 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698