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

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

Issue 7736010: MIPS: port Tentative implementation of string slices (hidden under the flag --string-slices). (Closed)
Patch Set: 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
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2010 the V8 project authors. All rights reserved. 1 // Copyright 2006-2010 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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 // If not real stack overflow the stack guard was used to interrupt 1029 // If not real stack overflow the stack guard was used to interrupt
1030 // execution for another purpose. 1030 // execution for another purpose.
1031 1031
1032 // If this is a direct call from JavaScript retry the RegExp forcing the call 1032 // If this is a direct call from JavaScript retry the RegExp forcing the call
1033 // through the runtime system. Currently the direct call cannot handle a GC. 1033 // through the runtime system. Currently the direct call cannot handle a GC.
1034 if (frame_entry<int>(re_frame, kDirectCall) == 1) { 1034 if (frame_entry<int>(re_frame, kDirectCall) == 1) {
1035 return RETRY; 1035 return RETRY;
1036 } 1036 }
1037 1037
1038 // Prepare for possible GC. 1038 // Prepare for possible GC.
1039 HandleScope handles; 1039 HandleScope handles(isolate);
1040 Handle<Code> code_handle(re_code); 1040 Handle<Code> code_handle(re_code);
1041 1041
1042 Handle<String> subject(frame_entry<String*>(re_frame, kInputString)); 1042 Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
1043 // Current string. 1043 // Current string.
1044 bool is_ascii = subject->IsAsciiRepresentation(); 1044 bool is_ascii = subject->IsAsciiRepresentationUnderneath();
1045 1045
1046 ASSERT(re_code->instruction_start() <= *return_address); 1046 ASSERT(re_code->instruction_start() <= *return_address);
1047 ASSERT(*return_address <= 1047 ASSERT(*return_address <=
1048 re_code->instruction_start() + re_code->instruction_size()); 1048 re_code->instruction_start() + re_code->instruction_size());
1049 1049
1050 MaybeObject* result = Execution::HandleStackGuardInterrupt(); 1050 MaybeObject* result = Execution::HandleStackGuardInterrupt();
1051 1051
1052 if (*code_handle != re_code) { // Return address no longer valid. 1052 if (*code_handle != re_code) { // Return address no longer valid.
1053 int delta = *code_handle - re_code; 1053 int delta = *code_handle - re_code;
1054 // Overwrite the return address on the stack. 1054 // Overwrite the return address on the stack.
1055 *return_address += delta; 1055 *return_address += delta;
1056 } 1056 }
1057 1057
1058 if (result->IsException()) { 1058 if (result->IsException()) {
1059 return EXCEPTION; 1059 return EXCEPTION;
1060 } 1060 }
1061 1061
1062 Handle<String> subject_tmp = subject;
1063 int slice_offset = 0;
1064
1065 // Extract the underlying string and the slice offset.
1066 if (StringShape(*subject_tmp).IsCons()) {
1067 subject_tmp = Handle<String>(ConsString::cast(*subject_tmp)->first());
1068 } else if (StringShape(*subject_tmp).IsSliced()) {
1069 SlicedString* slice = SlicedString::cast(*subject_tmp);
1070 subject_tmp = Handle<String>(slice->parent());
1071 slice_offset = slice->offset();
1072 }
1073
1062 // String might have changed. 1074 // String might have changed.
1063 if (subject->IsAsciiRepresentation() != is_ascii) { 1075 if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
1064 // If we changed between an ASCII and an UC16 string, the specialized 1076 // If we changed between an ASCII and an UC16 string, the specialized
1065 // code cannot be used, and we need to restart regexp matching from 1077 // code cannot be used, and we need to restart regexp matching from
1066 // scratch (including, potentially, compiling a new version of the code). 1078 // scratch (including, potentially, compiling a new version of the code).
1067 return RETRY; 1079 return RETRY;
1068 } 1080 }
1069 1081
1070 // Otherwise, the content of the string might have moved. It must still 1082 // Otherwise, the content of the string might have moved. It must still
1071 // be a sequential or external string with the same content. 1083 // be a sequential or external string with the same content.
1072 // Update the start and end pointers in the stack frame to the current 1084 // Update the start and end pointers in the stack frame to the current
1073 // location (whether it has actually moved or not). 1085 // location (whether it has actually moved or not).
1074 ASSERT(StringShape(*subject).IsSequential() || 1086 ASSERT(StringShape(*subject_tmp).IsSequential() ||
1075 StringShape(*subject).IsExternal()); 1087 StringShape(*subject_tmp).IsExternal());
1076 1088
1077 // The original start address of the characters to match. 1089 // The original start address of the characters to match.
1078 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart); 1090 const byte* start_address = frame_entry<const byte*>(re_frame, kInputStart);
1079 1091
1080 // Find the current start address of the same character at the current string 1092 // Find the current start address of the same character at the current string
1081 // position. 1093 // position.
1082 int start_index = frame_entry<int>(re_frame, kStartIndex); 1094 int start_index = frame_entry<int>(re_frame, kStartIndex);
1083 const byte* new_address = StringCharacterPosition(*subject, start_index); 1095 const byte* new_address = StringCharacterPosition(*subject_tmp,
1096 start_index + slice_offset);
1084 1097
1085 if (start_address != new_address) { 1098 if (start_address != new_address) {
1086 // If there is a difference, update the object pointer and start and end 1099 // If there is a difference, update the object pointer and start and end
1087 // addresses in the RegExp stack frame to match the new value. 1100 // addresses in the RegExp stack frame to match the new value.
1088 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd); 1101 const byte* end_address = frame_entry<const byte* >(re_frame, kInputEnd);
1089 int byte_length = end_address - start_address; 1102 int byte_length = static_cast<int>(end_address - start_address);
1090 frame_entry<const String*>(re_frame, kInputString) = *subject; 1103 frame_entry<const String*>(re_frame, kInputString) = *subject;
1091 frame_entry<const byte*>(re_frame, kInputStart) = new_address; 1104 frame_entry<const byte*>(re_frame, kInputStart) = new_address;
1092 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length; 1105 frame_entry<const byte*>(re_frame, kInputEnd) = new_address + byte_length;
1093 } 1106 }
1094 1107
1095 return 0; 1108 return 0;
1096 } 1109 }
1097 1110
1098 1111
1099 MemOperand RegExpMacroAssemblerMIPS::register_location(int register_index) { 1112 MemOperand RegExpMacroAssemblerMIPS::register_location(int register_index) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1255 }
1243 1256
1244 1257
1245 #undef __ 1258 #undef __
1246 1259
1247 #endif // V8_INTERPRETED_REGEXP 1260 #endif // V8_INTERPRETED_REGEXP
1248 1261
1249 }} // namespace v8::internal 1262 }} // namespace v8::internal
1250 1263
1251 #endif // V8_TARGET_ARCH_MIPS 1264 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698