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

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

Issue 1676883002: [runtime] Optimize and unify rest parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months 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
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 "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-expression-rewriter.h" 9 #include "src/ast/ast-expression-rewriter.h"
10 #include "src/ast/ast-expression-visitor.h" 10 #include "src/ast/ast-expression-visitor.h"
(...skipping 4190 matching lines...) Expand 10 before | Expand all | Expand 10 after
4201 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); 4201 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK);
4202 arity = formals.Arity(); 4202 arity = formals.Arity();
4203 Expect(Token::RPAREN, CHECK_OK); 4203 Expect(Token::RPAREN, CHECK_OK);
4204 int formals_end_position = scanner()->location().end_pos; 4204 int formals_end_position = scanner()->location().end_pos;
4205 4205
4206 CheckArityRestrictions(arity, arity_restriction, 4206 CheckArityRestrictions(arity, arity_restriction,
4207 formals.has_rest, start_position, 4207 formals.has_rest, start_position,
4208 formals_end_position, CHECK_OK); 4208 formals_end_position, CHECK_OK);
4209 Expect(Token::LBRACE, CHECK_OK); 4209 Expect(Token::LBRACE, CHECK_OK);
4210 4210
4211 // Don't include the rest parameter into the function's formal parameter
4212 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count,
4213 // which says whether we need to create an arguments adaptor frame).
4214 if (formals.has_rest) arity--;
4215
4211 // Determine if the function can be parsed lazily. Lazy parsing is different 4216 // Determine if the function can be parsed lazily. Lazy parsing is different
4212 // from lazy compilation; we need to parse more eagerly than we compile. 4217 // from lazy compilation; we need to parse more eagerly than we compile.
4213 4218
4214 // We can only parse lazily if we also compile lazily. The heuristics for 4219 // We can only parse lazily if we also compile lazily. The heuristics for
4215 // lazy compilation are: 4220 // lazy compilation are:
4216 // - It must not have been prohibited by the caller to Parse (some callers 4221 // - It must not have been prohibited by the caller to Parse (some callers
4217 // need a full AST). 4222 // need a full AST).
4218 // - The outer scope must allow lazy compilation of inner functions. 4223 // - The outer scope must allow lazy compilation of inner functions.
4219 // - The function mustn't be a function expression with an open parenthesis 4224 // - The function mustn't be a function expression with an open parenthesis
4220 // before; we consider that a hint that the function will be called 4225 // before; we consider that a hint that the function will be called
(...skipping 2104 matching lines...) Expand 10 before | Expand all | Expand 10 after
6325 6330
6326 statements->Add(get_return, zone); 6331 statements->Add(get_return, zone);
6327 statements->Add(check_return, zone); 6332 statements->Add(check_return, zone);
6328 statements->Add(call_return, zone); 6333 statements->Add(call_return, zone);
6329 statements->Add(validate_output, zone); 6334 statements->Add(validate_output, zone);
6330 } 6335 }
6331 6336
6332 6337
6333 } // namespace internal 6338 } // namespace internal
6334 } // namespace v8 6339 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698