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

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: 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 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
1072 // Current string. 1073 // Current string.
1073 bool is_ascii = subject->IsAsciiRepresentation(); 1074 bool is_ascii = subject->IsAsciiRepresentationUnderneath();
1074 1075
1075 ASSERT(re_code->instruction_start() <= *return_address); 1076 ASSERT(re_code->instruction_start() <= *return_address);
1076 ASSERT(*return_address <= 1077 ASSERT(*return_address <=
1077 re_code->instruction_start() + re_code->instruction_size()); 1078 re_code->instruction_start() + re_code->instruction_size());
1078 1079
1079 MaybeObject* result = Execution::HandleStackGuardInterrupt(); 1080 MaybeObject* result = Execution::HandleStackGuardInterrupt();
1080 1081
1081 if (*code_handle != re_code) { // Return address no longer valid 1082 if (*code_handle != re_code) { // Return address no longer valid
1082 int delta = *code_handle - re_code; 1083 int delta = *code_handle - re_code;
1083 // Overwrite the return address on the stack. 1084 // Overwrite the return address on the stack.
1084 *return_address += delta; 1085 *return_address += delta;
1085 } 1086 }
1086 1087
1087 if (result->IsException()) { 1088 if (result->IsException()) {
1088 return EXCEPTION; 1089 return EXCEPTION;
1089 } 1090 }
1090 1091
1092 Handle<String> subject_tmp = subject;
1093 int slice_offset = 0;
1094
1095 // Extract the underlying string and the slice offset.
1096 if (StringShape(*subject_tmp).IsCons()) {
1097 subject_tmp = Handle<String>(ConsString::cast(*subject_tmp)->first());
1098 } else if (StringShape(*subject_tmp).IsSliced()) {
1099 SlicedString* slice = SlicedString::cast(*subject_tmp);
1100 subject_tmp = Handle<String>(slice->parent());
1101 slice_offset = slice->offset();
1102 }
1103
1091 // String might have changed. 1104 // String might have changed.
1092 if (subject->IsAsciiRepresentation() != is_ascii) { 1105 if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
1093 // If we changed between an ASCII and an UC16 string, the specialized 1106 // 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 1107 // code cannot be used, and we need to restart regexp matching from
1095 // scratch (including, potentially, compiling a new version of the code). 1108 // scratch (including, potentially, compiling a new version of the code).
1096 return RETRY; 1109 return RETRY;
1097 } 1110 }
1098 1111
1099 // Otherwise, the content of the string might have moved. It must still 1112 // Otherwise, the content of the string might have moved. It must still
1100 // be a sequential or external string with the same content. 1113 // be a sequential or external string with the same content.
1101 // Update the start and end pointers in the stack frame to the current 1114 // Update the start and end pointers in the stack frame to the current
1102 // location (whether it has actually moved or not). 1115 // location (whether it has actually moved or not).
1103 ASSERT(StringShape(*subject).IsSequential() || 1116 ASSERT(StringShape(*subject_tmp).IsSequential() ||
1104 StringShape(*subject).IsExternal()); 1117 StringShape(*subject_tmp).IsExternal());
1105 1118
1106 // The original start address of the characters to match. 1119 // The original start address of the characters to match.
1107 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart); 1120 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart);
1108 1121
1109 // Find the current start address of the same character at the current string 1122 // Find the current start address of the same character at the current string
1110 // position. 1123 // position.
1111 int start_index = frame_entry<int>(re_frame, kStartIndex); 1124 int start_index = frame_entry<int>(re_frame, kStartIndex);
1112 const byte* new_address = StringCharacterPosition(*subject, start_index); 1125 const byte* new_address = StringCharacterPosition(*subject_tmp,
1126 start_index + slice_offset);
1113 1127
1114 if (start_address != new_address) { 1128 if (start_address != new_address) {
1115 // If there is a difference, update the object pointer and start and end 1129 // 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. 1130 // addresses in the RegExp stack frame to match the new value.
1117 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd); 1131 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd);
1118 int byte_length = end_address - start_address; 1132 int byte_length = static_cast<int>(end_address - start_address);
1119 frame_entry<const String*>(re_frame, kInputString) = *subject; 1133 frame_entry<const String*>(re_frame, kInputString) = *subject;
1120 frame_entry<const byte*>(re_frame, kInputStart) = new_address; 1134 frame_entry<const byte*>(re_frame, kInputStart) = new_address;
1121 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length; 1135 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length;
1122 } 1136 }
1123 1137
1124 return 0; 1138 return 0;
1125 } 1139 }
1126 1140
1127 1141
1128 Operand RegExpMacroAssemblerIA32::register_location(int register_index) { 1142 Operand RegExpMacroAssemblerIA32::register_location(int register_index) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 } 1268 }
1255 1269
1256 1270
1257 #undef __ 1271 #undef __
1258 1272
1259 #endif // V8_INTERPRETED_REGEXP 1273 #endif // V8_INTERPRETED_REGEXP
1260 1274
1261 }} // namespace v8::internal 1275 }} // namespace v8::internal
1262 1276
1263 #endif // V8_TARGET_ARCH_IA32 1277 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698