Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: src/parsing/parser.cc

Issue 2522223002: Fix zone in which temp-zone parsed data is allocated for the function scope on the boundary. (Closed)
Patch Set: Also free map_ Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/base/hashmap.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 bool use_temp_zone = 2619 bool use_temp_zone =
2620 (FLAG_lazy_inner_functions 2620 (FLAG_lazy_inner_functions
2621 ? can_preparse 2621 ? can_preparse
2622 : (is_lazy_top_level_function || 2622 : (is_lazy_top_level_function ||
2623 (allow_lazy_ && function_type == FunctionLiteral::kDeclaration && 2623 (allow_lazy_ && function_type == FunctionLiteral::kDeclaration &&
2624 eager_compile_hint == FunctionLiteral::kShouldLazyCompile))) && 2624 eager_compile_hint == FunctionLiteral::kShouldLazyCompile))) &&
2625 !(FLAG_validate_asm && scope()->IsAsmModule()); 2625 !(FLAG_validate_asm && scope()->IsAsmModule());
2626 bool is_lazy_inner_function = 2626 bool is_lazy_inner_function =
2627 use_temp_zone && FLAG_lazy_inner_functions && !is_lazy_top_level_function; 2627 use_temp_zone && FLAG_lazy_inner_functions && !is_lazy_top_level_function;
2628 2628
2629 // This Scope lives in the main zone. We'll migrate data into that zone later.
2630 DeclarationScope* scope = NewFunctionScope(kind);
2631 SetLanguageMode(scope, language_mode);
2632 #ifdef DEBUG
2633 scope->SetScopeName(function_name);
2634 #endif
2635
2636 ZoneList<Statement*>* body = nullptr; 2629 ZoneList<Statement*>* body = nullptr;
2637 int materialized_literal_count = -1; 2630 int materialized_literal_count = -1;
2638 int expected_property_count = -1; 2631 int expected_property_count = -1;
2639 bool should_be_used_once_hint = false; 2632 bool should_be_used_once_hint = false;
2640 int num_parameters = -1; 2633 int num_parameters = -1;
2641 int function_length = -1; 2634 int function_length = -1;
2642 bool has_duplicate_parameters = false; 2635 bool has_duplicate_parameters = false;
2643 2636
2644 Expect(Token::LPAREN, CHECK_OK); 2637 Zone* outer_zone = zone();
2645 scope->set_start_position(scanner()->location().beg_pos); 2638 DeclarationScope* scope;
2646 2639
2647 { 2640 {
2648 // Temporary zones can nest. When we migrate free variables (see below), we 2641 // Temporary zones can nest. When we migrate free variables (see below), we
2649 // need to recreate them in the previous Zone. 2642 // need to recreate them in the previous Zone.
2650 AstNodeFactory previous_zone_ast_node_factory(ast_value_factory()); 2643 AstNodeFactory previous_zone_ast_node_factory(ast_value_factory());
2651 previous_zone_ast_node_factory.set_zone(zone()); 2644 previous_zone_ast_node_factory.set_zone(zone());
2652 2645
2653 // Open a new zone scope, which sets our AstNodeFactory to allocate in the 2646 // Open a new zone scope, which sets our AstNodeFactory to allocate in the
2654 // new temporary zone if the preconditions are satisfied, and ensures that 2647 // new temporary zone if the preconditions are satisfied, and ensures that
2655 // the previous zone is always restored after parsing the body. To be able 2648 // the previous zone is always restored after parsing the body. To be able
2656 // to do scope analysis correctly after full parsing, we migrate needed 2649 // to do scope analysis correctly after full parsing, we migrate needed
2657 // information when the function is parsed. 2650 // information when the function is parsed.
2658 Zone temp_zone(zone()->allocator(), ZONE_NAME); 2651 Zone temp_zone(zone()->allocator(), ZONE_NAME);
2659 DiscardableZoneScope zone_scope(this, &temp_zone, use_temp_zone); 2652 DiscardableZoneScope zone_scope(this, &temp_zone, use_temp_zone);
2653
2654 // This Scope lives in the main zone. We'll migrate data into that zone
2655 // later.
2656 scope = NewFunctionScope(kind, outer_zone);
2657 SetLanguageMode(scope, language_mode);
2660 #ifdef DEBUG 2658 #ifdef DEBUG
2659 scope->SetScopeName(function_name);
2661 if (use_temp_zone) scope->set_needs_migration(); 2660 if (use_temp_zone) scope->set_needs_migration();
2662 #endif 2661 #endif
2663 2662
2663 Expect(Token::LPAREN, CHECK_OK);
2664 scope->set_start_position(scanner()->location().beg_pos);
2665
2664 // Eager or lazy parse? If is_lazy_top_level_function, we'll parse 2666 // Eager or lazy parse? If is_lazy_top_level_function, we'll parse
2665 // lazily. We'll call SkipFunction, which may decide to 2667 // lazily. We'll call SkipFunction, which may decide to
2666 // abort lazy parsing if it suspects that wasn't a good idea. If so (in 2668 // abort lazy parsing if it suspects that wasn't a good idea. If so (in
2667 // which case the parser is expected to have backtracked), or if we didn't 2669 // which case the parser is expected to have backtracked), or if we didn't
2668 // try to lazy parse in the first place, we'll have to parse eagerly. 2670 // try to lazy parse in the first place, we'll have to parse eagerly.
2669 if (is_lazy_top_level_function || is_lazy_inner_function) { 2671 if (is_lazy_top_level_function || is_lazy_inner_function) {
2670 Scanner::BookmarkScope bookmark(scanner()); 2672 Scanner::BookmarkScope bookmark(scanner());
2671 bookmark.Set(); 2673 bookmark.Set();
2672 LazyParsingResult result = 2674 LazyParsingResult result =
2673 SkipFunction(kind, scope, &num_parameters, &function_length, 2675 SkipFunction(kind, scope, &num_parameters, &function_length,
(...skipping 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after
5470 5472
5471 return final_loop; 5473 return final_loop;
5472 } 5474 }
5473 5475
5474 #undef CHECK_OK 5476 #undef CHECK_OK
5475 #undef CHECK_OK_VOID 5477 #undef CHECK_OK_VOID
5476 #undef CHECK_FAILED 5478 #undef CHECK_FAILED
5477 5479
5478 } // namespace internal 5480 } // namespace internal
5479 } // namespace v8 5481 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/hashmap.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698