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

Side by Side 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 unified diff | 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 »
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/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/compiler/ast-loop-assignment-analyzer.h" 9 #include "src/compiler/ast-loop-assignment-analyzer.h"
10 #include "src/compiler/control-builders.h" 10 #include "src/compiler/control-builders.h"
(...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 1930
1931 // The array is expected on the operand stack during computation of the 1931 // The array is expected on the operand stack during computation of the
1932 // element values. 1932 // element values.
1933 environment()->Push(literal); 1933 environment()->Push(literal);
1934 1934
1935 // Create nodes to evaluate all the non-constant subexpressions and to store 1935 // Create nodes to evaluate all the non-constant subexpressions and to store
1936 // them into the newly cloned array. 1936 // them into the newly cloned array.
1937 int array_index = 0; 1937 int array_index = 0;
1938 for (; array_index < expr->values()->length(); array_index++) { 1938 for (; array_index < expr->values()->length(); array_index++) {
1939 Expression* subexpr = expr->values()->at(array_index); 1939 Expression* subexpr = expr->values()->at(array_index);
1940 if (subexpr->IsSpread()) break; 1940 DCHECK(!subexpr->IsSpread());
1941 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1941 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1942 1942
1943 VisitForValue(subexpr); 1943 VisitForValue(subexpr);
1944 { 1944 {
1945 FrameStateBeforeAndAfter states(this, subexpr->id()); 1945 FrameStateBeforeAndAfter states(this, subexpr->id());
1946 VectorSlotPair pair = CreateVectorSlotPair(expr->LiteralFeedbackSlot()); 1946 VectorSlotPair pair = CreateVectorSlotPair(expr->LiteralFeedbackSlot());
1947 Node* value = environment()->Pop(); 1947 Node* value = environment()->Pop();
1948 Node* index = jsgraph()->Constant(array_index); 1948 Node* index = jsgraph()->Constant(array_index);
1949 Node* literal = environment()->Top(); 1949 Node* literal = environment()->Top();
1950 Node* store = BuildKeyedStore(literal, index, value, pair); 1950 Node* store = BuildKeyedStore(literal, index, value, pair);
1951 states.AddToNode(store, expr->GetIdForElement(array_index), 1951 states.AddToNode(store, expr->GetIdForElement(array_index),
1952 OutputFrameStateCombine::Ignore()); 1952 OutputFrameStateCombine::Ignore());
1953 } 1953 }
1954 } 1954 }
1955 1955
1956 // In case the array literal contains spread expressions it has two parts. The 1956 // In case the array literal contains spread expressions it has two parts. The
1957 // first part is the "static" array which has a literal index is handled 1957 // first part is the "static" array which has a literal index is handled
1958 // above. The second part is the part after the first spread expression 1958 // above. The second part is the part after the first spread expression
1959 // (inclusive) and these elements gets appended to the array. Note that the 1959 // (inclusive) and these elements gets appended to the array. Note that the
1960 // number elements an iterable produces is unknown ahead of time. 1960 // number elements an iterable produces is unknown ahead of time.
1961 for (; array_index < expr->values()->length(); array_index++) { 1961 for (; array_index < expr->values()->length(); array_index++) {
1962 Expression* subexpr = expr->values()->at(array_index); 1962 Expression* subexpr = expr->values()->at(array_index);
1963 Node* result; 1963 DCHECK(!subexpr->IsSpread());
1964 1964
1965 if (subexpr->IsSpread()) { 1965 VisitForValue(subexpr);
1966 VisitForValue(subexpr->AsSpread()->expression()); 1966 {
1967 FrameStateBeforeAndAfter states(this,
1968 subexpr->AsSpread()->expression()->id());
1969 Node* iterable = environment()->Pop();
1970 Node* array = environment()->Pop();
1971 Node* function = BuildLoadNativeContextField(
1972 Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX);
1973 result = NewNode(javascript()->CallFunction(3, language_mode()), function,
1974 array, iterable);
1975 states.AddToNode(result, expr->GetIdForElement(array_index));
1976 } else {
1977 VisitForValue(subexpr);
1978 Node* value = environment()->Pop(); 1967 Node* value = environment()->Pop();
1979 Node* array = environment()->Pop(); 1968 Node* array = environment()->Pop();
1980 const Operator* op = javascript()->CallRuntime(Runtime::kAppendElement); 1969 const Operator* op = javascript()->CallRuntime(Runtime::kAppendElement);
1981 result = NewNode(op, array, value); 1970 Node* result = NewNode(op, array, value);
1982 PrepareFrameState(result, expr->GetIdForElement(array_index)); 1971 PrepareFrameState(result, expr->GetIdForElement(array_index));
1972 environment()->Push(result);
1983 } 1973 }
1984
1985 environment()->Push(result);
1986 } 1974 }
1987 1975
1988 ast_context()->ProduceValue(environment()->Pop()); 1976 ast_context()->ProduceValue(environment()->Pop());
1989 } 1977 }
1990 1978
1991 1979
1992 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value, 1980 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
1993 const VectorSlotPair& feedback, 1981 const VectorSlotPair& feedback,
1994 BailoutId bailout_id_before, 1982 BailoutId bailout_id_before,
1995 BailoutId bailout_id_after) { 1983 BailoutId bailout_id_after) {
(...skipping 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after
4350 // Phi does not exist yet, introduce one. 4338 // Phi does not exist yet, introduce one.
4351 value = NewPhi(inputs, value, control); 4339 value = NewPhi(inputs, value, control);
4352 value->ReplaceInput(inputs - 1, other); 4340 value->ReplaceInput(inputs - 1, other);
4353 } 4341 }
4354 return value; 4342 return value;
4355 } 4343 }
4356 4344
4357 } // namespace compiler 4345 } // namespace compiler
4358 } // namespace internal 4346 } // namespace internal
4359 } // namespace v8 4347 } // namespace v8
OLDNEW
« 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