| 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/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
| (...skipping 3245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3256 } | 3256 } |
| 3257 | 3257 |
| 3258 Parser::LazyParsingResult Parser::SkipLazyFunctionBody( | 3258 Parser::LazyParsingResult Parser::SkipLazyFunctionBody( |
| 3259 int* materialized_literal_count, int* expected_property_count, | 3259 int* materialized_literal_count, int* expected_property_count, |
| 3260 bool may_abort, bool* ok) { | 3260 bool may_abort, bool* ok) { |
| 3261 if (produce_cached_parse_data()) CHECK(log_); | 3261 if (produce_cached_parse_data()) CHECK(log_); |
| 3262 | 3262 |
| 3263 int function_block_pos = position(); | 3263 int function_block_pos = position(); |
| 3264 DeclarationScope* scope = this->scope()->AsDeclarationScope(); | 3264 DeclarationScope* scope = this->scope()->AsDeclarationScope(); |
| 3265 DCHECK(scope->is_function_scope()); | 3265 DCHECK(scope->is_function_scope()); |
| 3266 scope->set_is_lazily_parsed(true); |
| 3266 if (consume_cached_parse_data() && !cached_parse_data_->rejected()) { | 3267 if (consume_cached_parse_data() && !cached_parse_data_->rejected()) { |
| 3267 // If we have cached data, we use it to skip parsing the function body. The | 3268 // If we have cached data, we use it to skip parsing the function body. The |
| 3268 // data contains the information we need to construct the lazy function. | 3269 // data contains the information we need to construct the lazy function. |
| 3269 FunctionEntry entry = | 3270 FunctionEntry entry = |
| 3270 cached_parse_data_->GetFunctionEntry(function_block_pos); | 3271 cached_parse_data_->GetFunctionEntry(function_block_pos); |
| 3271 // Check that cached data is valid. If not, mark it as invalid (the embedder | 3272 // Check that cached data is valid. If not, mark it as invalid (the embedder |
| 3272 // handles it). Note that end position greater than end of stream is safe, | 3273 // handles it). Note that end position greater than end of stream is safe, |
| 3273 // and hard to check. | 3274 // and hard to check. |
| 3274 if (entry.is_valid() && entry.end_pos() > function_block_pos) { | 3275 if (entry.is_valid() && entry.end_pos() > function_block_pos) { |
| 3275 scanner()->SeekForward(entry.end_pos() - 1); | 3276 scanner()->SeekForward(entry.end_pos() - 1); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3286 } | 3287 } |
| 3287 cached_parse_data_->Reject(); | 3288 cached_parse_data_->Reject(); |
| 3288 } | 3289 } |
| 3289 // With no cached data, we partially parse the function, without building an | 3290 // With no cached data, we partially parse the function, without building an |
| 3290 // AST. This gathers the data needed to build a lazy function. | 3291 // AST. This gathers the data needed to build a lazy function. |
| 3291 SingletonLogger logger; | 3292 SingletonLogger logger; |
| 3292 PreParser::PreParseResult result = | 3293 PreParser::PreParseResult result = |
| 3293 ParseLazyFunctionBodyWithPreParser(&logger, may_abort); | 3294 ParseLazyFunctionBodyWithPreParser(&logger, may_abort); |
| 3294 // Return immediately if pre-parser decided to abort parsing. | 3295 // Return immediately if pre-parser decided to abort parsing. |
| 3295 if (result == PreParser::kPreParseAbort) { | 3296 if (result == PreParser::kPreParseAbort) { |
| 3297 scope->set_is_lazily_parsed(false); |
| 3296 return kLazyParsingAborted; | 3298 return kLazyParsingAborted; |
| 3297 } | 3299 } |
| 3298 if (result == PreParser::kPreParseStackOverflow) { | 3300 if (result == PreParser::kPreParseStackOverflow) { |
| 3299 // Propagate stack overflow. | 3301 // Propagate stack overflow. |
| 3300 set_stack_overflow(); | 3302 set_stack_overflow(); |
| 3301 *ok = false; | 3303 *ok = false; |
| 3302 return kLazyParsingComplete; | 3304 return kLazyParsingComplete; |
| 3303 } | 3305 } |
| 3304 if (logger.has_error()) { | 3306 if (logger.has_error()) { |
| 3305 ReportMessageAt(Scanner::Location(logger.start(), logger.end()), | 3307 ReportMessageAt(Scanner::Location(logger.start(), logger.end()), |
| (...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5912 node->Print(Isolate::Current()); | 5914 node->Print(Isolate::Current()); |
| 5913 } | 5915 } |
| 5914 #endif // DEBUG | 5916 #endif // DEBUG |
| 5915 | 5917 |
| 5916 #undef CHECK_OK | 5918 #undef CHECK_OK |
| 5917 #undef CHECK_OK_VOID | 5919 #undef CHECK_OK_VOID |
| 5918 #undef CHECK_FAILED | 5920 #undef CHECK_FAILED |
| 5919 | 5921 |
| 5920 } // namespace internal | 5922 } // namespace internal |
| 5921 } // namespace v8 | 5923 } // namespace v8 |
| OLD | NEW |