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

Side by Side Diff: src/arm/regexp-macro-assembler-arm.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 // If not real stack overflow the stack guard was used to interrupt 1027 // If not real stack overflow the stack guard was used to interrupt
1028 // execution for another purpose. 1028 // execution for another purpose.
1029 1029
1030 // If this is a direct call from JavaScript retry the RegExp forcing the call 1030 // If this is a direct call from JavaScript retry the RegExp forcing the call
1031 // through the runtime system. Currently the direct call cannot handle a GC. 1031 // through the runtime system. Currently the direct call cannot handle a GC.
1032 if (frame_entry<int>(re_frame, kDirectCall) == 1) { 1032 if (frame_entry<int>(re_frame, kDirectCall) == 1) {
1033 return RETRY; 1033 return RETRY;
1034 } 1034 }
1035 1035
1036 // Prepare for possible GC. 1036 // Prepare for possible GC.
1037 HandleScope handles; 1037 HandleScope handles(isolate);
1038 Handle<Code> code_handle(re_code); 1038 Handle<Code> code_handle(re_code);
1039 1039
1040 Handle<String> subject(frame_entry<String*>(re_frame, kInputString)); 1040 Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
1041
1041 // Current string. 1042 // Current string.
1042 bool is_ascii = subject->IsAsciiRepresentation(); 1043 bool is_ascii = subject->IsAsciiRepresentationUnderneath();
1043 1044
1044 ASSERT(re_code->instruction_start() <= *return_address); 1045 ASSERT(re_code->instruction_start() <= *return_address);
1045 ASSERT(*return_address <= 1046 ASSERT(*return_address <=
1046 re_code->instruction_start() + re_code->instruction_size()); 1047 re_code->instruction_start() + re_code->instruction_size());
1047 1048
1048 MaybeObject* result = Execution::HandleStackGuardInterrupt(); 1049 MaybeObject* result = Execution::HandleStackGuardInterrupt();
1049 1050
1050 if (*code_handle != re_code) { // Return address no longer valid 1051 if (*code_handle != re_code) { // Return address no longer valid
1051 int delta = *code_handle - re_code; 1052 int delta = *code_handle - re_code;
1052 // Overwrite the return address on the stack. 1053 // Overwrite the return address on the stack.
1053 *return_address += delta; 1054 *return_address += delta;
1054 } 1055 }
1055 1056
1056 if (result->IsException()) { 1057 if (result->IsException()) {
1057 return EXCEPTION; 1058 return EXCEPTION;
1058 } 1059 }
1059 1060
1061 Handle<String> subject_tmp = subject;
1062 int slice_offset = 0;
1063
1064 // Extract the underlying string and the slice offset.
1065 if (StringShape(*subject_tmp).IsCons()) {
1066 subject_tmp = Handle<String>(ConsString::cast(*subject_tmp)->first());
1067 } else if (StringShape(*subject_tmp).IsSliced()) {
1068 SlicedString* slice = SlicedString::cast(*subject_tmp);
1069 subject_tmp = Handle<String>(slice->parent());
1070 slice_offset = slice->offset();
1071 }
1072
1060 // String might have changed. 1073 // String might have changed.
1061 if (subject->IsAsciiRepresentation() != is_ascii) { 1074 if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
1062 // If we changed between an ASCII and an UC16 string, the specialized 1075 // If we changed between an ASCII and an UC16 string, the specialized
1063 // code cannot be used, and we need to restart regexp matching from 1076 // code cannot be used, and we need to restart regexp matching from
1064 // scratch (including, potentially, compiling a new version of the code). 1077 // scratch (including, potentially, compiling a new version of the code).
1065 return RETRY; 1078 return RETRY;
1066 } 1079 }
1067 1080
1068 // Otherwise, the content of the string might have moved. It must still 1081 // Otherwise, the content of the string might have moved. It must still
1069 // be a sequential or external string with the same content. 1082 // be a sequential or external string with the same content.
1070 // Update the start and end pointers in the stack frame to the current 1083 // Update the start and end pointers in the stack frame to the current
1071 // location (whether it has actually moved or not). 1084 // location (whether it has actually moved or not).
1072 ASSERT(StringShape(*subject).IsSequential() || 1085 ASSERT(StringShape(*subject_tmp).IsSequential() ||
1073 StringShape(*subject).IsExternal()); 1086 StringShape(*subject_tmp).IsExternal());
1074 1087
1075 // The original start address of the characters to match. 1088 // The original start address of the characters to match.
1076 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart); 1089 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart);
1077 1090
1078 // Find the current start address of the same character at the current string 1091 // Find the current start address of the same character at the current string
1079 // position. 1092 // position.
1080 int start_index = frame_entry<int>(re_frame, kStartIndex); 1093 int start_index = frame_entry<int>(re_frame, kStartIndex);
1081 const byte* new_address = StringCharacterPosition(*subject, start_index); 1094 const byte* new_address = StringCharacterPosition(*subject_tmp,
1095 start_index + slice_offset);
1082 1096
1083 if (start_address != new_address) { 1097 if (start_address != new_address) {
1084 // If there is a difference, update the object pointer and start and end 1098 // If there is a difference, update the object pointer and start and end
1085 // addresses in the RegExp stack frame to match the new value. 1099 // addresses in the RegExp stack frame to match the new value.
1086 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd); 1100 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd);
1087 int byte_length = end_address - start_address; 1101 int byte_length = static_cast<int>(end_address - start_address);
1088 frame_entry<const String*>(re_frame, kInputString) = *subject; 1102 frame_entry<const String*>(re_frame, kInputString) = *subject;
1089 frame_entry<const byte*>(re_frame, kInputStart) = new_address; 1103 frame_entry<const byte*>(re_frame, kInputStart) = new_address;
1090 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length; 1104 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length;
1091 } 1105 }
1092 1106
1093 return 0; 1107 return 0;
1094 } 1108 }
1095 1109
1096 1110
1097 MemOperand RegExpMacroAssemblerARM::register_location(int register_index) { 1111 MemOperand RegExpMacroAssemblerARM::register_location(int register_index) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex)); 1290 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex));
1277 } 1291 }
1278 1292
1279 #undef __ 1293 #undef __
1280 1294
1281 #endif // V8_INTERPRETED_REGEXP 1295 #endif // V8_INTERPRETED_REGEXP
1282 1296
1283 }} // namespace v8::internal 1297 }} // namespace v8::internal
1284 1298
1285 #endif // V8_TARGET_ARCH_ARM 1299 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698