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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return true; | 128 return true; |
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 DCHECK(pattern->IsFlat()); |
| 139 |
138 Isolate* isolate = re->GetIsolate(); | 140 Isolate* isolate = re->GetIsolate(); |
139 Zone zone(isolate->allocator(), ZONE_NAME); | 141 Zone zone(isolate->allocator(), ZONE_NAME); |
140 CompilationCache* compilation_cache = isolate->compilation_cache(); | 142 CompilationCache* compilation_cache = isolate->compilation_cache(); |
141 MaybeHandle<FixedArray> maybe_cached = | 143 MaybeHandle<FixedArray> maybe_cached = |
142 compilation_cache->LookupRegExp(pattern, flags); | 144 compilation_cache->LookupRegExp(pattern, flags); |
143 Handle<FixedArray> cached; | 145 Handle<FixedArray> cached; |
144 if (maybe_cached.ToHandle(&cached)) { | 146 if (maybe_cached.ToHandle(&cached)) { |
145 re->set_data(*cached); | 147 re->set_data(*cached); |
146 return re; | 148 return re; |
147 } | 149 } |
148 pattern = String::Flatten(pattern); | 150 |
149 PostponeInterruptsScope postpone(isolate); | 151 PostponeInterruptsScope postpone(isolate); |
150 RegExpCompileData parse_result; | 152 RegExpCompileData parse_result; |
151 FlatStringReader reader(isolate, pattern); | 153 FlatStringReader reader(isolate, pattern); |
152 if (!RegExpParser::ParseRegExp(re->GetIsolate(), &zone, &reader, flags, | 154 if (!RegExpParser::ParseRegExp(re->GetIsolate(), &zone, &reader, flags, |
153 &parse_result)) { | 155 &parse_result)) { |
154 // Throw an exception if we fail to parse the pattern. | 156 // Throw an exception if we fail to parse the pattern. |
155 return ThrowRegExpException(re, pattern, parse_result.error); | 157 return ThrowRegExpException(re, pattern, parse_result.error); |
156 } | 158 } |
157 | 159 |
158 bool has_been_compiled = false; | 160 bool has_been_compiled = false; |
(...skipping 6763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6922 | 6924 |
6923 | 6925 |
6924 void RegExpResultsCache::Clear(FixedArray* cache) { | 6926 void RegExpResultsCache::Clear(FixedArray* cache) { |
6925 for (int i = 0; i < kRegExpResultsCacheSize; i++) { | 6927 for (int i = 0; i < kRegExpResultsCacheSize; i++) { |
6926 cache->set(i, Smi::kZero); | 6928 cache->set(i, Smi::kZero); |
6927 } | 6929 } |
6928 } | 6930 } |
6929 | 6931 |
6930 } // namespace internal | 6932 } // namespace internal |
6931 } // namespace v8 | 6933 } // namespace v8 |
OLD | NEW |