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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()); |
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 bool in_cache = maybe_cached.ToHandle(&cached); | 144 if (maybe_cached.ToHandle(&cached)) { |
145 LOG(isolate, RegExpCompileEvent(re, in_cache)); | |
146 | |
147 Handle<Object> result; | |
148 if (in_cache) { | |
149 re->set_data(*cached); | 145 re->set_data(*cached); |
150 return re; | 146 return re; |
151 } | 147 } |
152 pattern = String::Flatten(pattern); | 148 pattern = String::Flatten(pattern); |
153 PostponeInterruptsScope postpone(isolate); | 149 PostponeInterruptsScope postpone(isolate); |
154 RegExpCompileData parse_result; | 150 RegExpCompileData parse_result; |
155 FlatStringReader reader(isolate, pattern); | 151 FlatStringReader reader(isolate, pattern); |
156 if (!RegExpParser::ParseRegExp(re->GetIsolate(), &zone, &reader, flags, | 152 if (!RegExpParser::ParseRegExp(re->GetIsolate(), &zone, &reader, flags, |
157 &parse_result)) { | 153 &parse_result)) { |
158 // Throw an exception if we fail to parse the pattern. | 154 // Throw an exception if we fail to parse the pattern. |
(...skipping 6711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6870 | 6866 |
6871 | 6867 |
6872 void RegExpResultsCache::Clear(FixedArray* cache) { | 6868 void RegExpResultsCache::Clear(FixedArray* cache) { |
6873 for (int i = 0; i < kRegExpResultsCacheSize; i++) { | 6869 for (int i = 0; i < kRegExpResultsCacheSize; i++) { |
6874 cache->set(i, Smi::kZero); | 6870 cache->set(i, Smi::kZero); |
6875 } | 6871 } |
6876 } | 6872 } |
6877 | 6873 |
6878 } // namespace internal | 6874 } // namespace internal |
6879 } // namespace v8 | 6875 } // namespace v8 |
OLD | NEW |