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 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 | 2531 |
2532 // Create node to perform the construct call. | 2532 // Create node to perform the construct call. |
2533 const Operator* call = javascript()->CallConstruct(args->length() + 2); | 2533 const Operator* call = javascript()->CallConstruct(args->length() + 2); |
2534 Node* value = ProcessArguments(call, args->length() + 2); | 2534 Node* value = ProcessArguments(call, args->length() + 2); |
2535 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 2535 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
2536 ast_context()->ProduceValue(value); | 2536 ast_context()->ProduceValue(value); |
2537 } | 2537 } |
2538 | 2538 |
2539 | 2539 |
2540 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { | 2540 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { |
2541 Handle<String> name = expr->name(); | |
2542 | |
2543 // The callee and the receiver both have to be pushed onto the operand stack | 2541 // The callee and the receiver both have to be pushed onto the operand stack |
2544 // before arguments are being evaluated. | 2542 // before arguments are being evaluated. |
2545 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; | 2543 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; |
2546 Node* receiver_value = BuildLoadBuiltinsObject(); | 2544 Node* global = BuildLoadGlobalObject(); |
2547 VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot()); | 2545 Node* native_context = |
2548 // TODO(jarin): bailout ids for runtime calls. | 2546 BuildLoadObjectField(global, GlobalObject::kNativeContextOffset); |
2549 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 2547 Node* callee_value = |
2550 Node* callee_value = BuildNamedLoad(receiver_value, name, pair); | 2548 NewNode(javascript()->LoadContext(0, expr->context_index(), true), |
2551 states.AddToNode(callee_value, BailoutId::None(), | 2549 native_context); |
2552 OutputFrameStateCombine::Push()); | 2550 Node* receiver_value = jsgraph()->UndefinedConstant(); |
| 2551 |
2553 environment()->Push(callee_value); | 2552 environment()->Push(callee_value); |
2554 environment()->Push(receiver_value); | 2553 environment()->Push(receiver_value); |
2555 | 2554 |
2556 // Evaluate all arguments to the JS runtime call. | 2555 // Evaluate all arguments to the JS runtime call. |
2557 ZoneList<Expression*>* args = expr->arguments(); | 2556 ZoneList<Expression*>* args = expr->arguments(); |
2558 VisitForValues(args); | 2557 VisitForValues(args); |
2559 | 2558 |
2560 // Create node to perform the JS runtime call. | 2559 // Create node to perform the JS runtime call. |
2561 const Operator* call = | 2560 const Operator* call = |
2562 javascript()->CallFunction(args->length() + 2, flags, language_mode()); | 2561 javascript()->CallFunction(args->length() + 2, flags, language_mode()); |
2563 Node* value = ProcessArguments(call, args->length() + 2); | 2562 Node* value = ProcessArguments(call, args->length() + 2); |
2564 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 2563 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
2565 ast_context()->ProduceValue(value); | 2564 ast_context()->ProduceValue(value); |
2566 } | 2565 } |
2567 | 2566 |
2568 | 2567 |
2569 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) { | 2568 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) { |
2570 const Runtime::Function* function = expr->function(); | |
2571 | |
2572 // Handle calls to runtime functions implemented in JavaScript separately as | 2569 // Handle calls to runtime functions implemented in JavaScript separately as |
2573 // the call follows JavaScript ABI and the callee is statically unknown. | 2570 // the call follows JavaScript ABI and the callee is statically unknown. |
2574 if (expr->is_jsruntime()) { | 2571 if (expr->is_jsruntime()) { |
2575 DCHECK(function == NULL && expr->name()->length() > 0); | |
2576 return VisitCallJSRuntime(expr); | 2572 return VisitCallJSRuntime(expr); |
2577 } | 2573 } |
2578 | 2574 |
| 2575 const Runtime::Function* function = expr->function(); |
| 2576 |
2579 // TODO(mstarzinger): This bailout is a gigantic hack, the owner is ashamed. | 2577 // TODO(mstarzinger): This bailout is a gigantic hack, the owner is ashamed. |
2580 if (function->function_id == Runtime::kInlineGeneratorNext || | 2578 if (function->function_id == Runtime::kInlineGeneratorNext || |
2581 function->function_id == Runtime::kInlineGeneratorThrow) { | 2579 function->function_id == Runtime::kInlineGeneratorThrow) { |
2582 ast_context()->ProduceValue(jsgraph()->TheHoleConstant()); | 2580 ast_context()->ProduceValue(jsgraph()->TheHoleConstant()); |
2583 return SetStackOverflow(); | 2581 return SetStackOverflow(); |
2584 } | 2582 } |
2585 | 2583 |
2586 // Evaluate all arguments to the runtime call. | 2584 // Evaluate all arguments to the runtime call. |
2587 ZoneList<Expression*>* args = expr->arguments(); | 2585 ZoneList<Expression*>* args = expr->arguments(); |
2588 VisitForValues(args); | 2586 VisitForValues(args); |
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4303 // Phi does not exist yet, introduce one. | 4301 // Phi does not exist yet, introduce one. |
4304 value = NewPhi(inputs, value, control); | 4302 value = NewPhi(inputs, value, control); |
4305 value->ReplaceInput(inputs - 1, other); | 4303 value->ReplaceInput(inputs - 1, other); |
4306 } | 4304 } |
4307 return value; | 4305 return value; |
4308 } | 4306 } |
4309 | 4307 |
4310 } // namespace compiler | 4308 } // namespace compiler |
4311 } // namespace internal | 4309 } // namespace internal |
4312 } // namespace v8 | 4310 } // namespace v8 |
OLD | NEW |