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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1154873002: [turbofan] Simplify handling of spreads in array literals. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_graph-builder-computed-property-names-deopt
Patch Set: Created 5 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 Node* value = environment()->Pop(); 1989 Node* value = environment()->Pop();
1990 Node* index = jsgraph()->Constant(array_index); 1990 Node* index = jsgraph()->Constant(array_index);
1991 Node* store = 1991 Node* store =
1992 BuildKeyedStore(literal, index, value, TypeFeedbackId::None()); 1992 BuildKeyedStore(literal, index, value, TypeFeedbackId::None());
1993 states.AddToNode(store, expr->GetIdForElement(array_index), 1993 states.AddToNode(store, expr->GetIdForElement(array_index),
1994 OutputFrameStateCombine::Ignore()); 1994 OutputFrameStateCombine::Ignore());
1995 } 1995 }
1996 } 1996 }
1997 1997
1998 // In case the array literal contains spread expressions it has two parts. The 1998 // In case the array literal contains spread expressions it has two parts. The
1999 // first part is the "static" array which has a literal index is handled 1999 // first part is the "static" array which has a literal index is handled
2000 // above. The second part is the part after the first spread expression 2000 // above. The second part is the part after the first spread expression
2001 // (inclusive) and these elements gets appended to the array. Note that the 2001 // (inclusive) and these elements gets appended to the array. Note that the
2002 // number elements an iterable produces is unknown ahead of time. 2002 // number elements an iterable produces is unknown ahead of time.
2003 bool has_spread = array_index < expr->values()->length(); 2003 environment()->Pop(); // Array literal index.
2004 if (has_spread) {
2005 environment()->Pop(); // Array literal index.
2006 }
2007
2008 for (; array_index < expr->values()->length(); array_index++) { 2004 for (; array_index < expr->values()->length(); array_index++) {
2009 Expression* subexpr = expr->values()->at(array_index); 2005 Expression* subexpr = expr->values()->at(array_index);
2010 Node* array = environment()->Pop(); 2006 Node* array = environment()->Pop();
2011 Node* result; 2007 Node* result;
2012 2008
2013 if (subexpr->IsSpread()) { 2009 if (subexpr->IsSpread()) {
2014 VisitForValue(subexpr->AsSpread()->expression()); 2010 VisitForValue(subexpr->AsSpread()->expression());
2015 Node* iterable = environment()->Pop(); 2011 Node* iterable = environment()->Pop();
2016 Node* builtins = BuildLoadBuiltinsObject(); 2012 Node* builtins = BuildLoadBuiltinsObject();
2017 Node* function = BuildLoadObjectField( 2013 Node* function = BuildLoadObjectField(
2018 builtins, JSBuiltinsObject::OffsetOfFunctionWithId( 2014 builtins, JSBuiltinsObject::OffsetOfFunctionWithId(
2019 Builtins::CONCAT_ITERABLE_TO_ARRAY)); 2015 Builtins::CONCAT_ITERABLE_TO_ARRAY));
2020 result = NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS, 2016 result = NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS,
2021 language_mode()), 2017 language_mode()),
2022 function, array, iterable); 2018 function, array, iterable);
2023 } else { 2019 } else {
2024 VisitForValue(subexpr); 2020 VisitForValue(subexpr);
2025 Node* value = environment()->Pop(); 2021 Node* value = environment()->Pop();
2026 const Operator* op = 2022 const Operator* op =
2027 javascript()->CallRuntime(Runtime::kAppendElement, 2); 2023 javascript()->CallRuntime(Runtime::kAppendElement, 2);
2028 result = NewNode(op, array, value); 2024 result = NewNode(op, array, value);
2029 } 2025 }
2030 2026
2031 PrepareFrameState(result, expr->GetIdForElement(array_index)); 2027 PrepareFrameState(result, expr->GetIdForElement(array_index));
2032 environment()->Push(result); 2028 environment()->Push(result);
2033 } 2029 }
2034 2030
2035 if (!has_spread) {
2036 environment()->Pop(); // Array literal index.
2037 }
2038 ast_context()->ProduceValue(environment()->Pop()); 2031 ast_context()->ProduceValue(environment()->Pop());
2039 } 2032 }
2040 2033
2041 2034
2042 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value, 2035 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
2043 BailoutId bailout_id) { 2036 BailoutId bailout_id) {
2044 DCHECK(expr->IsValidReferenceExpression()); 2037 DCHECK(expr->IsValidReferenceExpression());
2045 2038
2046 // Left-hand side can only be a property, a global or a variable slot. 2039 // Left-hand side can only be a property, a global or a variable slot.
2047 Property* property = expr->AsProperty(); 2040 Property* property = expr->AsProperty();
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
3783 // Phi does not exist yet, introduce one. 3776 // Phi does not exist yet, introduce one.
3784 value = NewPhi(inputs, value, control); 3777 value = NewPhi(inputs, value, control);
3785 value->ReplaceInput(inputs - 1, other); 3778 value->ReplaceInput(inputs - 1, other);
3786 } 3779 }
3787 return value; 3780 return value;
3788 } 3781 }
3789 3782
3790 } // namespace compiler 3783 } // namespace compiler
3791 } // namespace internal 3784 } // namespace internal
3792 } // namespace v8 3785 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698