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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/compilation-cache.h" | 9 #include "src/compilation-cache.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 Handle<Object> result; | 147 Handle<Object> result; |
148 if (in_cache) { | 148 if (in_cache) { |
149 re->set_data(*cached); | 149 re->set_data(*cached); |
150 return re; | 150 return re; |
151 } | 151 } |
152 pattern = String::Flatten(pattern); | 152 pattern = String::Flatten(pattern); |
153 PostponeInterruptsScope postpone(isolate); | 153 PostponeInterruptsScope postpone(isolate); |
154 RegExpCompileData parse_result; | 154 RegExpCompileData parse_result; |
155 FlatStringReader reader(isolate, pattern); | 155 FlatStringReader reader(isolate, pattern); |
156 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), | 156 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), |
157 &parse_result, &zone)) { | 157 flags.is_unicode(), &parse_result, &zone)) { |
158 // Throw an exception if we fail to parse the pattern. | 158 // Throw an exception if we fail to parse the pattern. |
159 return ThrowRegExpException(re, | 159 return ThrowRegExpException(re, |
160 pattern, | 160 pattern, |
161 parse_result.error, | 161 parse_result.error, |
162 "malformed_regexp"); | 162 "malformed_regexp"); |
163 } | 163 } |
164 | 164 |
165 bool has_been_compiled = false; | 165 bool has_been_compiled = false; |
166 | 166 |
167 if (parse_result.simple && | 167 if (parse_result.simple && |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 return false; | 394 return false; |
395 } | 395 } |
396 | 396 |
397 JSRegExp::Flags flags = re->GetFlags(); | 397 JSRegExp::Flags flags = re->GetFlags(); |
398 | 398 |
399 Handle<String> pattern(re->Pattern()); | 399 Handle<String> pattern(re->Pattern()); |
400 pattern = String::Flatten(pattern); | 400 pattern = String::Flatten(pattern); |
401 RegExpCompileData compile_data; | 401 RegExpCompileData compile_data; |
402 FlatStringReader reader(isolate, pattern); | 402 FlatStringReader reader(isolate, pattern); |
403 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), | 403 if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), |
404 &compile_data, | 404 flags.is_unicode(), &compile_data, &zone)) { |
405 &zone)) { | |
406 // Throw an exception if we fail to parse the pattern. | 405 // Throw an exception if we fail to parse the pattern. |
407 // THIS SHOULD NOT HAPPEN. We already pre-parsed it successfully once. | 406 // THIS SHOULD NOT HAPPEN. We already pre-parsed it successfully once. |
408 USE(ThrowRegExpException(re, | 407 USE(ThrowRegExpException(re, |
409 pattern, | 408 pattern, |
410 compile_data.error, | 409 compile_data.error, |
411 "malformed_regexp")); | 410 "malformed_regexp")); |
412 return false; | 411 return false; |
413 } | 412 } |
414 RegExpEngine::CompilationResult result = RegExpEngine::Compile( | 413 RegExpEngine::CompilationResult result = RegExpEngine::Compile( |
415 &compile_data, flags.is_ignore_case(), flags.is_global(), | 414 &compile_data, flags.is_ignore_case(), flags.is_global(), |
(...skipping 5727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6143 Heap* heap = pattern->GetHeap(); | 6142 Heap* heap = pattern->GetHeap(); |
6144 bool too_much = pattern->length() > RegExpImpl::kRegExpTooLargeToOptimize; | 6143 bool too_much = pattern->length() > RegExpImpl::kRegExpTooLargeToOptimize; |
6145 if (heap->total_regexp_code_generated() > RegExpImpl::kRegExpCompiledLimit && | 6144 if (heap->total_regexp_code_generated() > RegExpImpl::kRegExpCompiledLimit && |
6146 heap->isolate()->memory_allocator()->SizeExecutable() > | 6145 heap->isolate()->memory_allocator()->SizeExecutable() > |
6147 RegExpImpl::kRegExpExecutableMemoryLimit) { | 6146 RegExpImpl::kRegExpExecutableMemoryLimit) { |
6148 too_much = true; | 6147 too_much = true; |
6149 } | 6148 } |
6150 return too_much; | 6149 return too_much; |
6151 } | 6150 } |
6152 }} // namespace v8::internal | 6151 }} // namespace v8::internal |
OLD | NEW |