| 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/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
| (...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 // number elements an iterable produces is unknown ahead of time. | 1978 // number elements an iterable produces is unknown ahead of time. |
| 1979 environment()->Pop(); // Array literal index. | 1979 environment()->Pop(); // Array literal index. |
| 1980 for (; array_index < expr->values()->length(); array_index++) { | 1980 for (; array_index < expr->values()->length(); array_index++) { |
| 1981 Expression* subexpr = expr->values()->at(array_index); | 1981 Expression* subexpr = expr->values()->at(array_index); |
| 1982 Node* array = environment()->Pop(); | 1982 Node* array = environment()->Pop(); |
| 1983 Node* result; | 1983 Node* result; |
| 1984 | 1984 |
| 1985 if (subexpr->IsSpread()) { | 1985 if (subexpr->IsSpread()) { |
| 1986 VisitForValue(subexpr->AsSpread()->expression()); | 1986 VisitForValue(subexpr->AsSpread()->expression()); |
| 1987 Node* iterable = environment()->Pop(); | 1987 Node* iterable = environment()->Pop(); |
| 1988 Node* builtins = BuildLoadBuiltinsObject(); | 1988 Node* function = BuildLoadNativeContextField( |
| 1989 Node* function = BuildLoadObjectField( | 1989 Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX); |
| 1990 builtins, JSBuiltinsObject::OffsetOfFunctionWithId( | |
| 1991 Builtins::CONCAT_ITERABLE_TO_ARRAY)); | |
| 1992 result = NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS, | 1990 result = NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS, |
| 1993 language_mode()), | 1991 language_mode()), |
| 1994 function, array, iterable); | 1992 function, array, iterable); |
| 1995 } else { | 1993 } else { |
| 1996 VisitForValue(subexpr); | 1994 VisitForValue(subexpr); |
| 1997 Node* value = environment()->Pop(); | 1995 Node* value = environment()->Pop(); |
| 1998 const Operator* op = | 1996 const Operator* op = |
| 1999 javascript()->CallRuntime(Runtime::kAppendElement, 2); | 1997 javascript()->CallRuntime(Runtime::kAppendElement, 2); |
| 2000 result = NewNode(op, array, value); | 1998 result = NewNode(op, array, value); |
| 2001 } | 1999 } |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2534 Node* value = ProcessArguments(call, args->length() + 2); | 2532 Node* value = ProcessArguments(call, args->length() + 2); |
| 2535 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 2533 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
| 2536 ast_context()->ProduceValue(value); | 2534 ast_context()->ProduceValue(value); |
| 2537 } | 2535 } |
| 2538 | 2536 |
| 2539 | 2537 |
| 2540 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { | 2538 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { |
| 2541 // The callee and the receiver both have to be pushed onto the operand stack | 2539 // The callee and the receiver both have to be pushed onto the operand stack |
| 2542 // before arguments are being evaluated. | 2540 // before arguments are being evaluated. |
| 2543 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; | 2541 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; |
| 2544 Node* global = BuildLoadGlobalObject(); | 2542 Node* callee_value = BuildLoadNativeContextField(expr->context_index()); |
| 2545 Node* native_context = | |
| 2546 BuildLoadObjectField(global, GlobalObject::kNativeContextOffset); | |
| 2547 Node* callee_value = | |
| 2548 NewNode(javascript()->LoadContext(0, expr->context_index(), true), | |
| 2549 native_context); | |
| 2550 Node* receiver_value = jsgraph()->UndefinedConstant(); | 2543 Node* receiver_value = jsgraph()->UndefinedConstant(); |
| 2551 | 2544 |
| 2552 environment()->Push(callee_value); | 2545 environment()->Push(callee_value); |
| 2553 environment()->Push(receiver_value); | 2546 environment()->Push(receiver_value); |
| 2554 | 2547 |
| 2555 // Evaluate all arguments to the JS runtime call. | 2548 // Evaluate all arguments to the JS runtime call. |
| 2556 ZoneList<Expression*>* args = expr->arguments(); | 2549 ZoneList<Expression*>* args = expr->arguments(); |
| 2557 VisitForValues(args); | 2550 VisitForValues(args); |
| 2558 | 2551 |
| 2559 // Create node to perform the JS runtime call. | 2552 // Create node to perform the JS runtime call. |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3752 } | 3745 } |
| 3753 | 3746 |
| 3754 | 3747 |
| 3755 Node* AstGraphBuilder::BuildLoadGlobalObject() { | 3748 Node* AstGraphBuilder::BuildLoadGlobalObject() { |
| 3756 const Operator* load_op = | 3749 const Operator* load_op = |
| 3757 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true); | 3750 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true); |
| 3758 return NewNode(load_op, GetFunctionContext()); | 3751 return NewNode(load_op, GetFunctionContext()); |
| 3759 } | 3752 } |
| 3760 | 3753 |
| 3761 | 3754 |
| 3755 Node* AstGraphBuilder::BuildLoadNativeContextField(int index) { |
| 3756 Node* global = BuildLoadGlobalObject(); |
| 3757 Node* native_context = |
| 3758 BuildLoadObjectField(global, GlobalObject::kNativeContextOffset); |
| 3759 return NewNode(javascript()->LoadContext(0, index, true), native_context); |
| 3760 } |
| 3761 |
| 3762 |
| 3762 Node* AstGraphBuilder::BuildLoadGlobalProxy() { | 3763 Node* AstGraphBuilder::BuildLoadGlobalProxy() { |
| 3763 Node* global = BuildLoadGlobalObject(); | 3764 Node* global = BuildLoadGlobalObject(); |
| 3764 Node* proxy = | 3765 Node* proxy = |
| 3765 BuildLoadObjectField(global, JSGlobalObject::kGlobalProxyOffset); | 3766 BuildLoadObjectField(global, JSGlobalObject::kGlobalProxyOffset); |
| 3766 return proxy; | 3767 return proxy; |
| 3767 } | 3768 } |
| 3768 | 3769 |
| 3769 | 3770 |
| 3770 Node* AstGraphBuilder::BuildLoadFeedbackVector() { | 3771 Node* AstGraphBuilder::BuildLoadFeedbackVector() { |
| 3771 if (!feedback_vector_.is_set()) { | 3772 if (!feedback_vector_.is_set()) { |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4301 // Phi does not exist yet, introduce one. | 4302 // Phi does not exist yet, introduce one. |
| 4302 value = NewPhi(inputs, value, control); | 4303 value = NewPhi(inputs, value, control); |
| 4303 value->ReplaceInput(inputs - 1, other); | 4304 value->ReplaceInput(inputs - 1, other); |
| 4304 } | 4305 } |
| 4305 return value; | 4306 return value; |
| 4306 } | 4307 } |
| 4307 | 4308 |
| 4308 } // namespace compiler | 4309 } // namespace compiler |
| 4309 } // namespace internal | 4310 } // namespace internal |
| 4310 } // namespace v8 | 4311 } // namespace v8 |
| OLD | NEW |