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

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 1592713002: Clean up dead code after spread desugaring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix bug that visited dead AST node in for/of Created 4 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
« no previous file with comments | « src/bailout-reason.h ('k') | src/compiler/ast-loop-assignment-analyzer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index a95e6d818656ce0b849ba5f619afd385c885c31f..ceea7890b46837ed1fd6ceeaf0d9966fefeb5ce4 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1937,7 +1937,7 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
int array_index = 0;
for (; array_index < expr->values()->length(); array_index++) {
Expression* subexpr = expr->values()->at(array_index);
- if (subexpr->IsSpread()) break;
+ DCHECK(!subexpr->IsSpread());
if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
VisitForValue(subexpr);
@@ -1960,29 +1960,17 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
// number elements an iterable produces is unknown ahead of time.
for (; array_index < expr->values()->length(); array_index++) {
Expression* subexpr = expr->values()->at(array_index);
- Node* result;
+ DCHECK(!subexpr->IsSpread());
- if (subexpr->IsSpread()) {
- VisitForValue(subexpr->AsSpread()->expression());
- FrameStateBeforeAndAfter states(this,
- subexpr->AsSpread()->expression()->id());
- Node* iterable = environment()->Pop();
- Node* array = environment()->Pop();
- Node* function = BuildLoadNativeContextField(
- Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX);
- result = NewNode(javascript()->CallFunction(3, language_mode()), function,
- array, iterable);
- states.AddToNode(result, expr->GetIdForElement(array_index));
- } else {
- VisitForValue(subexpr);
+ VisitForValue(subexpr);
+ {
Node* value = environment()->Pop();
Node* array = environment()->Pop();
const Operator* op = javascript()->CallRuntime(Runtime::kAppendElement);
- result = NewNode(op, array, value);
+ Node* result = NewNode(op, array, value);
PrepareFrameState(result, expr->GetIdForElement(array_index));
+ environment()->Push(result);
}
-
- environment()->Push(result);
}
ast_context()->ProduceValue(environment()->Pop());
« no previous file with comments | « src/bailout-reason.h ('k') | src/compiler/ast-loop-assignment-analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698