OLD | NEW |
---|---|
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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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; |
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 | |
1073 String* subject_ptr = *subject; | |
Vitaly Repeshko
2011/08/12 19:01:00
Should be put in a handle.
| |
1074 int slice_offset = 0; | |
1075 | |
1076 // Extract the underlying string and the slice offset. | |
1077 if (StringShape(subject_ptr).IsCons()) { | |
1078 subject_ptr = ConsString::cast(subject_ptr)->first(); | |
1079 } else if (StringShape(subject_ptr).IsSliced()) { | |
1080 SlicedString* slice = SlicedString::cast(subject_ptr); | |
1081 subject_ptr = slice->parent(); | |
1082 slice_offset = slice->offset(); | |
1083 } | |
1084 | |
1072 // Current string. | 1085 // Current string. |
1073 bool is_ascii = subject->IsAsciiRepresentation(); | 1086 bool is_ascii = subject_ptr->IsAsciiRepresentation(); |
1074 | 1087 |
1075 ASSERT(re_code->instruction_start() <= *return_address); | 1088 ASSERT(re_code->instruction_start() <= *return_address); |
1076 ASSERT(*return_address <= | 1089 ASSERT(*return_address <= |
1077 re_code->instruction_start() + re_code->instruction_size()); | 1090 re_code->instruction_start() + re_code->instruction_size()); |
1078 | 1091 |
1079 MaybeObject* result = Execution::HandleStackGuardInterrupt(); | 1092 MaybeObject* result = Execution::HandleStackGuardInterrupt(); |
1080 | 1093 |
1081 if (*code_handle != re_code) { // Return address no longer valid | 1094 if (*code_handle != re_code) { // Return address no longer valid |
1082 int delta = *code_handle - re_code; | 1095 int delta = *code_handle - re_code; |
1083 // Overwrite the return address on the stack. | 1096 // Overwrite the return address on the stack. |
1084 *return_address += delta; | 1097 *return_address += delta; |
1085 } | 1098 } |
1086 | 1099 |
1087 if (result->IsException()) { | 1100 if (result->IsException()) { |
1088 return EXCEPTION; | 1101 return EXCEPTION; |
1089 } | 1102 } |
1090 | 1103 |
1091 // String might have changed. | 1104 // String might have changed. |
1092 if (subject->IsAsciiRepresentation() != is_ascii) { | 1105 if (subject_ptr->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_ptr).IsSequential() || |
1104 StringShape(*subject).IsExternal()); | 1117 StringShape(subject_ptr).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_ptr, |
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 Loading... | |
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 |
OLD | NEW |