| 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 2397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2408 callee_value = | 2408 callee_value = |
| 2409 BuildKeyedSuperLoad(receiver_value, home_object, key, pair); | 2409 BuildKeyedSuperLoad(receiver_value, home_object, key, pair); |
| 2410 states.AddToNode(callee_value, property->LoadId(), | 2410 states.AddToNode(callee_value, property->LoadId(), |
| 2411 OutputFrameStateCombine::Push()); | 2411 OutputFrameStateCombine::Push()); |
| 2412 } | 2412 } |
| 2413 } | 2413 } |
| 2414 | 2414 |
| 2415 break; | 2415 break; |
| 2416 } | 2416 } |
| 2417 case Call::SUPER_CALL: | 2417 case Call::SUPER_CALL: |
| 2418 // TODO(dslomov): Implement super calls. | 2418 return VisitCallSuper(expr); |
| 2419 callee_value = jsgraph()->UndefinedConstant(); | |
| 2420 receiver_value = jsgraph()->UndefinedConstant(); | |
| 2421 SetStackOverflow(); | |
| 2422 break; | |
| 2423 case Call::POSSIBLY_EVAL_CALL: | 2419 case Call::POSSIBLY_EVAL_CALL: |
| 2424 possibly_eval = true; | 2420 possibly_eval = true; |
| 2425 if (callee->AsVariableProxy()->var()->IsLookupSlot()) { | 2421 if (callee->AsVariableProxy()->var()->IsLookupSlot()) { |
| 2426 Variable* variable = callee->AsVariableProxy()->var(); | 2422 Variable* variable = callee->AsVariableProxy()->var(); |
| 2427 Node* name = jsgraph()->Constant(variable->name()); | 2423 Node* name = jsgraph()->Constant(variable->name()); |
| 2428 const Operator* op = | 2424 const Operator* op = |
| 2429 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2); | 2425 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2); |
| 2430 Node* pair = NewNode(op, current_context(), name); | 2426 Node* pair = NewNode(op, current_context(), name); |
| 2431 callee_value = NewNode(common()->Projection(0), pair); | 2427 callee_value = NewNode(common()->Projection(0), pair); |
| 2432 receiver_value = NewNode(common()->Projection(1), pair); | 2428 receiver_value = NewNode(common()->Projection(1), pair); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 // Create node to perform the function call. | 2475 // Create node to perform the function call. |
| 2480 VectorSlotPair feedback = CreateVectorSlotPair(expr->CallFeedbackICSlot()); | 2476 VectorSlotPair feedback = CreateVectorSlotPair(expr->CallFeedbackICSlot()); |
| 2481 const Operator* call = javascript()->CallFunction(args->length() + 2, flags, | 2477 const Operator* call = javascript()->CallFunction(args->length() + 2, flags, |
| 2482 language_mode(), feedback); | 2478 language_mode(), feedback); |
| 2483 Node* value = ProcessArguments(call, args->length() + 2); | 2479 Node* value = ProcessArguments(call, args->length() + 2); |
| 2484 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 2480 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
| 2485 ast_context()->ProduceValue(value); | 2481 ast_context()->ProduceValue(value); |
| 2486 } | 2482 } |
| 2487 | 2483 |
| 2488 | 2484 |
| 2485 void AstGraphBuilder::VisitCallSuper(Call* expr) { |
| 2486 SuperCallReference* super = expr->expression()->AsSuperCallReference(); |
| 2487 DCHECK_NOT_NULL(super); |
| 2488 |
| 2489 // Prepare the callee to the super call. The super constructor is stored as |
| 2490 // the prototype of the constructor we are currently executing. |
| 2491 VisitForValue(super->this_function_var()); |
| 2492 Node* this_function = environment()->Pop(); |
| 2493 const Operator* op = javascript()->CallRuntime(Runtime::kGetPrototype, 1); |
| 2494 Node* super_function = NewNode(op, this_function); |
| 2495 // TODO(mstarzinger): This probably needs a proper bailout id. |
| 2496 PrepareFrameState(super_function, BailoutId::None()); |
| 2497 environment()->Push(super_function); |
| 2498 |
| 2499 // Evaluate all arguments to the super call. |
| 2500 ZoneList<Expression*>* args = expr->arguments(); |
| 2501 VisitForValues(args); |
| 2502 |
| 2503 // Original receiver is loaded from the {new.target} variable. |
| 2504 VisitForValue(super->new_target_var()); |
| 2505 |
| 2506 // Create node to perform the super call. |
| 2507 const Operator* call = javascript()->CallConstruct(args->length() + 2); |
| 2508 Node* value = ProcessArguments(call, args->length() + 2); |
| 2509 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
| 2510 |
| 2511 // TODO(mstarzinger): It sure would be nice if this were desugared. Also we |
| 2512 // are still missing the hole-check in the assignment below, fix that. |
| 2513 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
| 2514 BuildVariableAssignment(super->this_var()->var(), value, Token::INIT_CONST, |
| 2515 VectorSlotPair(), BailoutId::None(), states); |
| 2516 |
| 2517 // TODO(mstarzinger): Remove bailout once lowering is correct. |
| 2518 SetStackOverflow(); |
| 2519 |
| 2520 ast_context()->ProduceValue(value); |
| 2521 } |
| 2522 |
| 2523 |
| 2489 void AstGraphBuilder::VisitCallNew(CallNew* expr) { | 2524 void AstGraphBuilder::VisitCallNew(CallNew* expr) { |
| 2490 VisitForValue(expr->expression()); | 2525 VisitForValue(expr->expression()); |
| 2491 | 2526 |
| 2492 // Evaluate all arguments to the construct call. | 2527 // Evaluate all arguments to the construct call. |
| 2493 ZoneList<Expression*>* args = expr->arguments(); | 2528 ZoneList<Expression*>* args = expr->arguments(); |
| 2494 VisitForValues(args); | 2529 VisitForValues(args); |
| 2495 | 2530 |
| 2531 // Original receiver is the same as the callee. |
| 2532 environment()->Push(environment()->Peek(args->length())); |
| 2533 |
| 2496 // Create node to perform the construct call. | 2534 // Create node to perform the construct call. |
| 2497 const Operator* call = javascript()->CallConstruct(args->length() + 1); | 2535 const Operator* call = javascript()->CallConstruct(args->length() + 2); |
| 2498 Node* value = ProcessArguments(call, args->length() + 1); | 2536 Node* value = ProcessArguments(call, args->length() + 2); |
| 2499 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 2537 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
| 2500 ast_context()->ProduceValue(value); | 2538 ast_context()->ProduceValue(value); |
| 2501 } | 2539 } |
| 2502 | 2540 |
| 2503 | 2541 |
| 2504 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { | 2542 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { |
| 2505 Handle<String> name = expr->name(); | 2543 Handle<String> name = expr->name(); |
| 2506 | 2544 |
| 2507 // The callee and the receiver both have to be pushed onto the operand stack | 2545 // The callee and the receiver both have to be pushed onto the operand stack |
| 2508 // before arguments are being evaluated. | 2546 // before arguments are being evaluated. |
| (...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4238 // Phi does not exist yet, introduce one. | 4276 // Phi does not exist yet, introduce one. |
| 4239 value = NewPhi(inputs, value, control); | 4277 value = NewPhi(inputs, value, control); |
| 4240 value->ReplaceInput(inputs - 1, other); | 4278 value->ReplaceInput(inputs - 1, other); |
| 4241 } | 4279 } |
| 4242 return value; | 4280 return value; |
| 4243 } | 4281 } |
| 4244 | 4282 |
| 4245 } // namespace compiler | 4283 } // namespace compiler |
| 4246 } // namespace internal | 4284 } // namespace internal |
| 4247 } // namespace v8 | 4285 } // namespace v8 |
| OLD | NEW |