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