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

Unified Diff: src/parsing/parser.cc

Issue 2629363002: [Ignition/turbo] Add a CallWithSpread bytecode. (Closed)
Patch Set: refactor OnlyLastArgIsSpread 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 side-by-side diff with in-line comments
Download patch
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index cabede50d3c5c72ee205ec7f2f34f2e118408d52..f224dfe8b513c97b0c16f0f7cd74c28c4ca8dc80 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -3754,24 +3754,28 @@ ZoneList<Expression*>* Parser::PrepareSpreadArguments(
UNREACHABLE();
}
+namespace {
+
+bool OnlyLastArgIsSpread(ZoneList<Expression*>* args) {
+ for (int i = 0; i < args->length() - 1; i++) {
+ if (args->at(i)->IsSpread()) {
+ return false;
+ }
+ }
+ return args->at(args->length() - 1)->IsSpread();
+}
+
+} // namespace
+
Expression* Parser::SpreadCall(Expression* function,
- ZoneList<Expression*>* args, int pos) {
+ ZoneList<Expression*>* args, int pos,
+ Call::PossiblyEval is_possibly_eval) {
if (function->IsSuperCallReference()) {
// Super calls
// $super_constructor = %_GetSuperConstructor(<this-function>)
// %reflect_construct($super_constructor, args, new.target)
- bool only_last_arg_is_spread = false;
- for (int i = 0; i < args->length(); i++) {
- if (args->at(i)->IsSpread()) {
- if (i == args->length() - 1) {
- only_last_arg_is_spread = true;
- }
- break;
- }
- }
-
- if (only_last_arg_is_spread) {
+ if (OnlyLastArgIsSpread(args)) {
// Handle in BytecodeGenerator.
Expression* super_call_ref = NewSuperCallReference(pos);
return factory()->NewCall(super_call_ref, args, pos);
@@ -3786,6 +3790,11 @@ Expression* Parser::SpreadCall(Expression* function,
return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args,
pos);
} else {
+ if (OnlyLastArgIsSpread(args)) {
+ // Handle in BytecodeGenerator.
+ return factory()->NewCall(function, args, pos, is_possibly_eval);
+ }
+
args = PrepareSpreadArguments(args);
if (function->IsProperty()) {
// Method calls

Powered by Google App Engine
This is Rietveld 408576698