OLD | NEW |
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 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
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 |
| 1042 String* subject_ptr = *subject; |
| 1043 int slice_offset = 0; |
| 1044 |
| 1045 // Extract the underlying string and the slice offset. |
| 1046 if (StringShape(subject_ptr).IsCons()) { |
| 1047 subject_ptr = ConsString::cast(subject_ptr)->first(); |
| 1048 } else if (StringShape(subject_ptr).IsSliced()) { |
| 1049 SlicedString* slice = SlicedString::cast(subject_ptr); |
| 1050 subject_ptr = slice->parent(); |
| 1051 slice_offset = slice->offset(); |
| 1052 } |
| 1053 |
1041 // Current string. | 1054 // Current string. |
1042 bool is_ascii = subject->IsAsciiRepresentation(); | 1055 bool is_ascii = subject_ptr->IsAsciiRepresentation(); |
1043 | 1056 |
1044 ASSERT(re_code->instruction_start() <= *return_address); | 1057 ASSERT(re_code->instruction_start() <= *return_address); |
1045 ASSERT(*return_address <= | 1058 ASSERT(*return_address <= |
1046 re_code->instruction_start() + re_code->instruction_size()); | 1059 re_code->instruction_start() + re_code->instruction_size()); |
1047 | 1060 |
1048 MaybeObject* result = Execution::HandleStackGuardInterrupt(); | 1061 MaybeObject* result = Execution::HandleStackGuardInterrupt(); |
1049 | 1062 |
1050 if (*code_handle != re_code) { // Return address no longer valid | 1063 if (*code_handle != re_code) { // Return address no longer valid |
1051 int delta = *code_handle - re_code; | 1064 int delta = *code_handle - re_code; |
1052 // Overwrite the return address on the stack. | 1065 // Overwrite the return address on the stack. |
1053 *return_address += delta; | 1066 *return_address += delta; |
1054 } | 1067 } |
1055 | 1068 |
1056 if (result->IsException()) { | 1069 if (result->IsException()) { |
1057 return EXCEPTION; | 1070 return EXCEPTION; |
1058 } | 1071 } |
1059 | 1072 |
1060 // String might have changed. | 1073 // String might have changed. |
1061 if (subject->IsAsciiRepresentation() != is_ascii) { | 1074 if (subject_ptr->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_ptr).IsSequential() || |
1073 StringShape(*subject).IsExternal()); | 1086 StringShape(subject_ptr).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_ptr, |
| 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 = 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 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |