OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/regexp/jsregexp.h" | 5 #include "src/regexp/jsregexp.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 // Generic RegExp methods. Dispatches to implementation specific methods. | 132 // Generic RegExp methods. Dispatches to implementation specific methods. |
133 | 133 |
134 | 134 |
135 MaybeHandle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, | 135 MaybeHandle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, |
136 Handle<String> pattern, | 136 Handle<String> pattern, |
137 JSRegExp::Flags flags) { | 137 JSRegExp::Flags flags) { |
138 Isolate* isolate = re->GetIsolate(); | 138 Isolate* isolate = re->GetIsolate(); |
139 Zone zone(isolate->allocator()); | 139 Zone zone(isolate->allocator(), ZONE_NAME); |
140 CompilationCache* compilation_cache = isolate->compilation_cache(); | 140 CompilationCache* compilation_cache = isolate->compilation_cache(); |
141 MaybeHandle<FixedArray> maybe_cached = | 141 MaybeHandle<FixedArray> maybe_cached = |
142 compilation_cache->LookupRegExp(pattern, flags); | 142 compilation_cache->LookupRegExp(pattern, flags); |
143 Handle<FixedArray> cached; | 143 Handle<FixedArray> cached; |
144 if (maybe_cached.ToHandle(&cached)) { | 144 if (maybe_cached.ToHandle(&cached)) { |
145 re->set_data(*cached); | 145 re->set_data(*cached); |
146 return re; | 146 return re; |
147 } | 147 } |
148 pattern = String::Flatten(pattern); | 148 pattern = String::Flatten(pattern); |
149 PostponeInterruptsScope postpone(isolate); | 149 PostponeInterruptsScope postpone(isolate); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 329 } |
330 return CompileIrregexp(re, sample_subject, is_one_byte); | 330 return CompileIrregexp(re, sample_subject, is_one_byte); |
331 } | 331 } |
332 | 332 |
333 | 333 |
334 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, | 334 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, |
335 Handle<String> sample_subject, | 335 Handle<String> sample_subject, |
336 bool is_one_byte) { | 336 bool is_one_byte) { |
337 // Compile the RegExp. | 337 // Compile the RegExp. |
338 Isolate* isolate = re->GetIsolate(); | 338 Isolate* isolate = re->GetIsolate(); |
339 Zone zone(isolate->allocator()); | 339 Zone zone(isolate->allocator(), ZONE_NAME); |
340 PostponeInterruptsScope postpone(isolate); | 340 PostponeInterruptsScope postpone(isolate); |
341 // If we had a compilation error the last time this is saved at the | 341 // If we had a compilation error the last time this is saved at the |
342 // saved code index. | 342 // saved code index. |
343 Object* entry = re->DataAt(JSRegExp::code_index(is_one_byte)); | 343 Object* entry = re->DataAt(JSRegExp::code_index(is_one_byte)); |
344 // When arriving here entry can only be a smi, either representing an | 344 // When arriving here entry can only be a smi, either representing an |
345 // uncompiled regexp, a previous compilation error, or code that has | 345 // uncompiled regexp, a previous compilation error, or code that has |
346 // been flushed. | 346 // been flushed. |
347 DCHECK(entry->IsSmi()); | 347 DCHECK(entry->IsSmi()); |
348 int entry_value = Smi::cast(entry)->value(); | 348 int entry_value = Smi::cast(entry)->value(); |
349 DCHECK(entry_value == JSRegExp::kUninitializedValue || | 349 DCHECK(entry_value == JSRegExp::kUninitializedValue || |
(...skipping 6521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6871 | 6871 |
6872 | 6872 |
6873 void RegExpResultsCache::Clear(FixedArray* cache) { | 6873 void RegExpResultsCache::Clear(FixedArray* cache) { |
6874 for (int i = 0; i < kRegExpResultsCacheSize; i++) { | 6874 for (int i = 0; i < kRegExpResultsCacheSize; i++) { |
6875 cache->set(i, Smi::kZero); | 6875 cache->set(i, Smi::kZero); |
6876 } | 6876 } |
6877 } | 6877 } |
6878 | 6878 |
6879 } // namespace internal | 6879 } // namespace internal |
6880 } // namespace v8 | 6880 } // namespace v8 |
OLD | NEW |