OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions-inl.h" | 8 #include "src/conversions-inl.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 if (subject_length > kMinLengthToCache) { | 1129 if (subject_length > kMinLengthToCache) { |
1130 // Store the last successful match into the array for caching. | 1130 // Store the last successful match into the array for caching. |
1131 // TODO(yangguo): do not expose last match to JS and simplify caching. | 1131 // TODO(yangguo): do not expose last match to JS and simplify caching. |
1132 int capture_registers = (capture_count + 1) * 2; | 1132 int capture_registers = (capture_count + 1) * 2; |
1133 Handle<FixedArray> last_match_cache = | 1133 Handle<FixedArray> last_match_cache = |
1134 isolate->factory()->NewFixedArray(capture_registers); | 1134 isolate->factory()->NewFixedArray(capture_registers); |
1135 int32_t* last_match = global_cache.LastSuccessfulMatch(); | 1135 int32_t* last_match = global_cache.LastSuccessfulMatch(); |
1136 for (int i = 0; i < capture_registers; i++) { | 1136 for (int i = 0; i < capture_registers; i++) { |
1137 last_match_cache->set(i, Smi::FromInt(last_match[i])); | 1137 last_match_cache->set(i, Smi::FromInt(last_match[i])); |
1138 } | 1138 } |
1139 Handle<FixedArray> result_array = builder.array(); | 1139 Handle<FixedArray> result_fixed_array = builder.array(); |
1140 result_array->Shrink(builder.length()); | 1140 result_fixed_array->Shrink(builder.length()); |
1141 // Cache the result and turn the FixedArray into a COW array. | 1141 // Cache the result and turn the FixedArray into a COW array. |
1142 RegExpResultsCache::Enter( | 1142 RegExpResultsCache::Enter( |
1143 isolate, subject, handle(regexp->data(), isolate), result_array, | 1143 isolate, subject, handle(regexp->data(), isolate), result_fixed_array, |
1144 last_match_cache, RegExpResultsCache::REGEXP_MULTIPLE_INDICES); | 1144 last_match_cache, RegExpResultsCache::REGEXP_MULTIPLE_INDICES); |
1145 } | 1145 } |
1146 return *builder.ToJSArray(result_array); | 1146 return *builder.ToJSArray(result_array); |
1147 } else { | 1147 } else { |
1148 return isolate->heap()->null_value(); // No matches at all. | 1148 return isolate->heap()->null_value(); // No matches at all. |
1149 } | 1149 } |
1150 } | 1150 } |
1151 | 1151 |
1152 | 1152 |
1153 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets | 1153 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 | 1187 |
1188 | 1188 |
1189 RUNTIME_FUNCTION(Runtime_IsRegExp) { | 1189 RUNTIME_FUNCTION(Runtime_IsRegExp) { |
1190 SealHandleScope shs(isolate); | 1190 SealHandleScope shs(isolate); |
1191 DCHECK(args.length() == 1); | 1191 DCHECK(args.length() == 1); |
1192 CONVERT_ARG_CHECKED(Object, obj, 0); | 1192 CONVERT_ARG_CHECKED(Object, obj, 0); |
1193 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); | 1193 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
1194 } | 1194 } |
1195 } // namespace internal | 1195 } // namespace internal |
1196 } // namespace v8 | 1196 } // namespace v8 |
OLD | NEW |