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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 true), | 512 true), |
513 scanner_(info->unicode_cache()), | 513 scanner_(info->unicode_cache()), |
514 reusable_preparser_(nullptr), | 514 reusable_preparser_(nullptr), |
515 original_scope_(nullptr), | 515 original_scope_(nullptr), |
516 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. | 516 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. |
517 target_stack_(nullptr), | 517 target_stack_(nullptr), |
518 compile_options_(info->compile_options()), | 518 compile_options_(info->compile_options()), |
519 cached_parse_data_(nullptr), | 519 cached_parse_data_(nullptr), |
520 total_preparse_skipped_(0), | 520 total_preparse_skipped_(0), |
521 temp_zoned_(false), | 521 temp_zoned_(false), |
522 log_(nullptr) { | 522 log_(nullptr), |
| 523 preparsed_scope_data_(info->preparsed_scope_data()) { |
523 // Even though we were passed ParseInfo, we should not store it in | 524 // Even though we were passed ParseInfo, we should not store it in |
524 // Parser - this makes sure that Isolate is not accidentally accessed via | 525 // Parser - this makes sure that Isolate is not accidentally accessed via |
525 // ParseInfo during background parsing. | 526 // ParseInfo during background parsing. |
526 DCHECK(!info->script().is_null() || info->source_stream() != nullptr || | 527 DCHECK(!info->script().is_null() || info->source_stream() != nullptr || |
527 info->character_stream() != nullptr); | 528 info->character_stream() != nullptr); |
528 // Determine if functions can be lazily compiled. This is necessary to | 529 // Determine if functions can be lazily compiled. This is necessary to |
529 // allow some of our builtin JS files to be lazily compiled. These | 530 // allow some of our builtin JS files to be lazily compiled. These |
530 // builtins cannot be handled lazily by the parser, since we have to know | 531 // builtins cannot be handled lazily by the parser, since we have to know |
531 // if a function uses the special natives syntax, which is something the | 532 // if a function uses the special natives syntax, which is something the |
532 // parser records. | 533 // parser records. |
(...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2678 function_name, pos, kind, function_type, scope, &num_parameters, | 2679 function_name, pos, kind, function_type, scope, &num_parameters, |
2679 &function_length, &has_duplicate_parameters, | 2680 &function_length, &has_duplicate_parameters, |
2680 &materialized_literal_count, &expected_property_count, CHECK_OK); | 2681 &materialized_literal_count, &expected_property_count, CHECK_OK); |
2681 } | 2682 } |
2682 | 2683 |
2683 DCHECK(use_temp_zone || !is_lazy_top_level_function); | 2684 DCHECK(use_temp_zone || !is_lazy_top_level_function); |
2684 if (use_temp_zone) { | 2685 if (use_temp_zone) { |
2685 // If the preconditions are correct the function body should never be | 2686 // If the preconditions are correct the function body should never be |
2686 // accessed, but do this anyway for better behaviour if they're wrong. | 2687 // accessed, but do this anyway for better behaviour if they're wrong. |
2687 body = nullptr; | 2688 body = nullptr; |
2688 scope->AnalyzePartially(&previous_zone_ast_node_factory); | 2689 scope->AnalyzePartially(&previous_zone_ast_node_factory, |
| 2690 preparsed_scope_data_); |
2689 } | 2691 } |
2690 | 2692 |
2691 DCHECK_IMPLIES(use_temp_zone, temp_zoned_); | 2693 DCHECK_IMPLIES(use_temp_zone, temp_zoned_); |
2692 if (FLAG_trace_preparse) { | 2694 if (FLAG_trace_preparse) { |
2693 PrintF(" [%s]: %i-%i %.*s\n", | 2695 PrintF(" [%s]: %i-%i %.*s\n", |
2694 is_lazy_top_level_function | 2696 is_lazy_top_level_function |
2695 ? "Preparse no-resolution" | 2697 ? "Preparse no-resolution" |
2696 : (temp_zoned_ ? "Preparse resolution" : "Full parse"), | 2698 : (temp_zoned_ ? "Preparse resolution" : "Full parse"), |
2697 scope->start_position(), scope->end_position(), | 2699 scope->start_position(), scope->end_position(), |
2698 function_name->byte_length(), function_name->raw_data()); | 2700 function_name->byte_length(), function_name->raw_data()); |
(...skipping 2336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5035 | 5037 |
5036 return final_loop; | 5038 return final_loop; |
5037 } | 5039 } |
5038 | 5040 |
5039 #undef CHECK_OK | 5041 #undef CHECK_OK |
5040 #undef CHECK_OK_VOID | 5042 #undef CHECK_OK_VOID |
5041 #undef CHECK_FAILED | 5043 #undef CHECK_FAILED |
5042 | 5044 |
5043 } // namespace internal | 5045 } // namespace internal |
5044 } // namespace v8 | 5046 } // namespace v8 |
OLD | NEW |