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

Side by Side Diff: src/parsing/parser-base.h

Issue 2411793003: Preparse lazy function parameters (Closed)
Patch Set: rebased Created 4 years, 1 month 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/parsing/parser.cc ('k') | src/parsing/preparse-data.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 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 3937 matching lines...) Expand 10 before | Expand all | Expand 10 after
3948 3948
3949 function_state.SkipMaterializedLiterals( 3949 function_state.SkipMaterializedLiterals(
3950 formal_parameters.materialized_literals_count); 3950 formal_parameters.materialized_literals_count);
3951 3951
3952 impl()->ReindexLiterals(formal_parameters); 3952 impl()->ReindexLiterals(formal_parameters);
3953 3953
3954 Expect(Token::ARROW, CHECK_OK); 3954 Expect(Token::ARROW, CHECK_OK);
3955 3955
3956 if (peek() == Token::LBRACE) { 3956 if (peek() == Token::LBRACE) {
3957 // Multiple statement body 3957 // Multiple statement body
3958 Consume(Token::LBRACE);
3959 DCHECK_EQ(scope(), formal_parameters.scope); 3958 DCHECK_EQ(scope(), formal_parameters.scope);
3960 if (is_lazy_top_level_function) { 3959 if (is_lazy_top_level_function) {
3960 // FIXME(marja): Arrow function parameters will be parsed even if the
3961 // body is preparsed; move relevant parts of parameter handling to
3962 // simulate consistent parameter handling.
3961 Scanner::BookmarkScope bookmark(scanner()); 3963 Scanner::BookmarkScope bookmark(scanner());
3962 bookmark.Set(); 3964 bookmark.Set();
3963 LazyParsingResult result = impl()->SkipLazyFunctionBody( 3965 // For arrow functions, we don't need to retrieve data about function
3966 // parameters.
3967 int dummy_num_parameters = -1;
3968 int dummy_function_length = -1;
3969 bool dummy_has_duplicate_parameters = false;
3970 DCHECK((kind & FunctionKind::kArrowFunction) != 0);
3971 LazyParsingResult result = impl()->SkipLazyFunction(
3972 kind, formal_parameters.scope, &dummy_num_parameters,
3973 &dummy_function_length, &dummy_has_duplicate_parameters,
3964 &materialized_literal_count, &expected_property_count, false, true, 3974 &materialized_literal_count, &expected_property_count, false, true,
3965 CHECK_OK); 3975 CHECK_OK);
3966 formal_parameters.scope->ResetAfterPreparsing( 3976 formal_parameters.scope->ResetAfterPreparsing(
3967 ast_value_factory_, result == kLazyParsingAborted); 3977 ast_value_factory_, result == kLazyParsingAborted);
3968 3978
3969 if (formal_parameters.materialized_literals_count > 0) { 3979 if (formal_parameters.materialized_literals_count > 0) {
3970 materialized_literal_count += 3980 materialized_literal_count +=
3971 formal_parameters.materialized_literals_count; 3981 formal_parameters.materialized_literals_count;
3972 } 3982 }
3973 3983
3974 if (result == kLazyParsingAborted) { 3984 if (result == kLazyParsingAborted) {
3975 bookmark.Apply(); 3985 bookmark.Apply();
3976 // Trigger eager (re-)parsing, just below this block. 3986 // Trigger eager (re-)parsing, just below this block.
3977 is_lazy_top_level_function = false; 3987 is_lazy_top_level_function = false;
3978 3988
3979 // This is probably an initialization function. Inform the compiler it 3989 // This is probably an initialization function. Inform the compiler it
3980 // should also eager-compile this function, and that we expect it to 3990 // should also eager-compile this function, and that we expect it to
3981 // be used once. 3991 // be used once.
3982 eager_compile_hint = FunctionLiteral::kShouldEagerCompile; 3992 eager_compile_hint = FunctionLiteral::kShouldEagerCompile;
3983 should_be_used_once_hint = true; 3993 should_be_used_once_hint = true;
3984 } 3994 }
3985 } 3995 }
3986 if (!is_lazy_top_level_function) { 3996 if (!is_lazy_top_level_function) {
3997 Consume(Token::LBRACE);
3987 body = impl()->ParseEagerFunctionBody( 3998 body = impl()->ParseEagerFunctionBody(
3988 impl()->EmptyIdentifier(), kNoSourcePosition, formal_parameters, 3999 impl()->EmptyIdentifier(), kNoSourcePosition, formal_parameters,
3989 kind, FunctionLiteral::kAnonymousExpression, CHECK_OK); 4000 kind, FunctionLiteral::kAnonymousExpression, CHECK_OK);
3990 materialized_literal_count = 4001 materialized_literal_count =
3991 function_state.materialized_literal_count(); 4002 function_state.materialized_literal_count();
3992 expected_property_count = function_state.expected_property_count(); 4003 expected_property_count = function_state.expected_property_count();
3993 } 4004 }
3994 } else { 4005 } else {
3995 // Single-expression body 4006 // Single-expression body
3996 int pos = position(); 4007 int pos = position();
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
5463 has_seen_constructor_ = true; 5474 has_seen_constructor_ = true;
5464 return; 5475 return;
5465 } 5476 }
5466 } 5477 }
5467 5478
5468 5479
5469 } // namespace internal 5480 } // namespace internal
5470 } // namespace v8 5481 } // namespace v8
5471 5482
5472 #endif // V8_PARSING_PARSER_BASE_H 5483 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparse-data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698