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

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

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