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/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/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 } | 1944 } |
1945 | 1945 |
1946 // In case the array literal contains spread expressions it has two parts. The | 1946 // In case the array literal contains spread expressions it has two parts. The |
1947 // first part is the "static" array which has a literal index is handled | 1947 // first part is the "static" array which has a literal index is handled |
1948 // above. The second part is the part after the first spread expression | 1948 // above. The second part is the part after the first spread expression |
1949 // (inclusive) and these elements gets appended to the array. Note that the | 1949 // (inclusive) and these elements gets appended to the array. Note that the |
1950 // number elements an iterable produces is unknown ahead of time. | 1950 // number elements an iterable produces is unknown ahead of time. |
1951 environment()->Pop(); // Array literal index. | 1951 environment()->Pop(); // Array literal index. |
1952 for (; array_index < expr->values()->length(); array_index++) { | 1952 for (; array_index < expr->values()->length(); array_index++) { |
1953 Expression* subexpr = expr->values()->at(array_index); | 1953 Expression* subexpr = expr->values()->at(array_index); |
1954 Node* array = environment()->Pop(); | |
1955 Node* result; | 1954 Node* result; |
1956 | 1955 |
1957 if (subexpr->IsSpread()) { | 1956 if (subexpr->IsSpread()) { |
1958 VisitForValue(subexpr->AsSpread()->expression()); | 1957 VisitForValue(subexpr->AsSpread()->expression()); |
1959 FrameStateBeforeAndAfter states(this, | 1958 FrameStateBeforeAndAfter states(this, |
1960 subexpr->AsSpread()->expression()->id()); | 1959 subexpr->AsSpread()->expression()->id()); |
1961 Node* iterable = environment()->Pop(); | 1960 Node* iterable = environment()->Pop(); |
| 1961 Node* array = environment()->Pop(); |
1962 Node* function = BuildLoadNativeContextField( | 1962 Node* function = BuildLoadNativeContextField( |
1963 Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX); | 1963 Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX); |
1964 result = NewNode(javascript()->CallFunction(3, language_mode()), function, | 1964 result = NewNode(javascript()->CallFunction(3, language_mode()), function, |
1965 array, iterable); | 1965 array, iterable); |
1966 states.AddToNode(result, expr->GetIdForElement(array_index)); | 1966 states.AddToNode(result, expr->GetIdForElement(array_index)); |
1967 } else { | 1967 } else { |
1968 VisitForValue(subexpr); | 1968 VisitForValue(subexpr); |
1969 Node* value = environment()->Pop(); | 1969 Node* value = environment()->Pop(); |
| 1970 Node* array = environment()->Pop(); |
1970 const Operator* op = | 1971 const Operator* op = |
1971 javascript()->CallRuntime(Runtime::kAppendElement, 2); | 1972 javascript()->CallRuntime(Runtime::kAppendElement, 2); |
1972 result = NewNode(op, array, value); | 1973 result = NewNode(op, array, value); |
1973 PrepareFrameState(result, expr->GetIdForElement(array_index)); | 1974 PrepareFrameState(result, expr->GetIdForElement(array_index)); |
1974 } | 1975 } |
1975 | 1976 |
1976 environment()->Push(result); | 1977 environment()->Push(result); |
1977 } | 1978 } |
1978 | 1979 |
1979 ast_context()->ProduceValue(environment()->Pop()); | 1980 ast_context()->ProduceValue(environment()->Pop()); |
(...skipping 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4300 // Phi does not exist yet, introduce one. | 4301 // Phi does not exist yet, introduce one. |
4301 value = NewPhi(inputs, value, control); | 4302 value = NewPhi(inputs, value, control); |
4302 value->ReplaceInput(inputs - 1, other); | 4303 value->ReplaceInput(inputs - 1, other); |
4303 } | 4304 } |
4304 return value; | 4305 return value; |
4305 } | 4306 } |
4306 | 4307 |
4307 } // namespace compiler | 4308 } // namespace compiler |
4308 } // namespace internal | 4309 } // namespace internal |
4309 } // namespace v8 | 4310 } // namespace v8 |
OLD | NEW |