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

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

Issue 2642843002: Revert of [Ignition/turbo] Add a CallWithSpread bytecode. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.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 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2590 Scanner::Location* first_spread_arg_loc, bool maybe_arrow, bool* ok) { 2590 Scanner::Location* first_spread_arg_loc, bool maybe_arrow, bool* ok) {
2591 // Arguments :: 2591 // Arguments ::
2592 // '(' (AssignmentExpression)*[','] ')' 2592 // '(' (AssignmentExpression)*[','] ')'
2593 2593
2594 Scanner::Location spread_arg = Scanner::Location::invalid(); 2594 Scanner::Location spread_arg = Scanner::Location::invalid();
2595 ExpressionListT result = impl()->NewExpressionList(4); 2595 ExpressionListT result = impl()->NewExpressionList(4);
2596 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList)); 2596 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList));
2597 bool done = (peek() == Token::RPAREN); 2597 bool done = (peek() == Token::RPAREN);
2598 bool was_unspread = false; 2598 bool was_unspread = false;
2599 int unspread_sequences_count = 0; 2599 int unspread_sequences_count = 0;
2600 int spread_count = 0;
2601 while (!done) { 2600 while (!done) {
2602 int start_pos = peek_position(); 2601 int start_pos = peek_position();
2603 bool is_spread = Check(Token::ELLIPSIS); 2602 bool is_spread = Check(Token::ELLIPSIS);
2604 int expr_pos = peek_position(); 2603 int expr_pos = peek_position();
2605 2604
2606 ExpressionT argument = 2605 ExpressionT argument =
2607 ParseAssignmentExpression(true, CHECK_OK_CUSTOM(NullExpressionList)); 2606 ParseAssignmentExpression(true, CHECK_OK_CUSTOM(NullExpressionList));
2608 if (!maybe_arrow) { 2607 if (!maybe_arrow) {
2609 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullExpressionList)); 2608 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullExpressionList));
2610 } 2609 }
2611 if (is_spread) { 2610 if (is_spread) {
2612 if (!spread_arg.IsValid()) { 2611 if (!spread_arg.IsValid()) {
2613 spread_arg.beg_pos = start_pos; 2612 spread_arg.beg_pos = start_pos;
2614 spread_arg.end_pos = peek_position(); 2613 spread_arg.end_pos = peek_position();
2615 } 2614 }
2616 argument = factory()->NewSpread(argument, start_pos, expr_pos); 2615 argument = factory()->NewSpread(argument, start_pos, expr_pos);
2617 } 2616 }
2618 result->Add(argument, zone_); 2617 result->Add(argument, zone_);
2619 2618
2620 // unspread_sequences_count is the number of sequences of parameters which 2619 // unspread_sequences_count is the number of sequences of parameters which
2621 // are not prefixed with a spread '...' operator. 2620 // are not prefixed with a spread '...' operator.
2622 if (is_spread) { 2621 if (is_spread) {
2623 was_unspread = false; 2622 was_unspread = false;
2624 spread_count++;
2625 } else if (!was_unspread) { 2623 } else if (!was_unspread) {
2626 was_unspread = true; 2624 was_unspread = true;
2627 unspread_sequences_count++; 2625 unspread_sequences_count++;
2628 } 2626 }
2629 2627
2630 if (result->length() > Code::kMaxArguments) { 2628 if (result->length() > Code::kMaxArguments) {
2631 ReportMessage(MessageTemplate::kTooManyArguments); 2629 ReportMessage(MessageTemplate::kTooManyArguments);
2632 *ok = false; 2630 *ok = false;
2633 return impl()->NullExpressionList(); 2631 return impl()->NullExpressionList();
2634 } 2632 }
(...skipping 15 matching lines...) Expand all
2650 *first_spread_arg_loc = spread_arg; 2648 *first_spread_arg_loc = spread_arg;
2651 2649
2652 if (!maybe_arrow || peek() != Token::ARROW) { 2650 if (!maybe_arrow || peek() != Token::ARROW) {
2653 if (maybe_arrow) { 2651 if (maybe_arrow) {
2654 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullExpressionList)); 2652 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullExpressionList));
2655 } 2653 }
2656 if (spread_arg.IsValid()) { 2654 if (spread_arg.IsValid()) {
2657 // Unspread parameter sequences are translated into array literals in the 2655 // Unspread parameter sequences are translated into array literals in the
2658 // parser. Ensure that the number of materialized literals matches between 2656 // parser. Ensure that the number of materialized literals matches between
2659 // the parser and preparser 2657 // the parser and preparser
2660 if (was_unspread || spread_count > 1) { 2658 impl()->MaterializeUnspreadArgumentsLiterals(unspread_sequences_count);
2661 // There was more than one spread, or the spread was not the final
2662 // argument, so the parser will materialize literals.
2663 impl()->MaterializeUnspreadArgumentsLiterals(unspread_sequences_count);
2664 }
2665 } 2659 }
2666 } 2660 }
2667 2661
2668 return result; 2662 return result;
2669 } 2663 }
2670 2664
2671 // Precedence = 2 2665 // Precedence = 2
2672 template <typename Impl> 2666 template <typename Impl>
2673 typename ParserBase<Impl>::ExpressionT 2667 typename ParserBase<Impl>::ExpressionT
2674 ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) { 2668 ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3196 // The calls that need special treatment are the 3190 // The calls that need special treatment are the
3197 // direct eval calls. These calls are all of the form eval(...), with 3191 // direct eval calls. These calls are all of the form eval(...), with
3198 // no explicit receiver. 3192 // no explicit receiver.
3199 // These calls are marked as potentially direct eval calls. Whether 3193 // These calls are marked as potentially direct eval calls. Whether
3200 // they are actually direct calls to eval is determined at run time. 3194 // they are actually direct calls to eval is determined at run time.
3201 Call::PossiblyEval is_possibly_eval = 3195 Call::PossiblyEval is_possibly_eval =
3202 CheckPossibleEvalCall(result, scope()); 3196 CheckPossibleEvalCall(result, scope());
3203 3197
3204 bool is_super_call = result->IsSuperCallReference(); 3198 bool is_super_call = result->IsSuperCallReference();
3205 if (spread_pos.IsValid()) { 3199 if (spread_pos.IsValid()) {
3206 result = impl()->SpreadCall(result, args, pos, is_possibly_eval); 3200 result = impl()->SpreadCall(result, args, pos);
3207 } else { 3201 } else {
3208 result = factory()->NewCall(result, args, pos, is_possibly_eval); 3202 result = factory()->NewCall(result, args, pos, is_possibly_eval);
3209 } 3203 }
3210 3204
3211 // Explicit calls to the super constructor using super() perform an 3205 // Explicit calls to the super constructor using super() perform an
3212 // implicit binding assignment to the 'this' variable. 3206 // implicit binding assignment to the 'this' variable.
3213 if (is_super_call) { 3207 if (is_super_call) {
3214 ExpressionT this_expr = impl()->ThisExpression(pos); 3208 ExpressionT this_expr = impl()->ThisExpression(pos);
3215 result = 3209 result =
3216 factory()->NewAssignment(Token::INIT, this_expr, result, pos); 3210 factory()->NewAssignment(Token::INIT, this_expr, result, pos);
(...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after
5567 has_seen_constructor_ = true; 5561 has_seen_constructor_ = true;
5568 return; 5562 return;
5569 } 5563 }
5570 } 5564 }
5571 5565
5572 5566
5573 } // namespace internal 5567 } // namespace internal
5574 } // namespace v8 5568 } // namespace v8
5575 5569
5576 #endif // V8_PARSING_PARSER_BASE_H 5570 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698