| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/js-call-reducer.h" | 5 #include "src/compiler/js-call-reducer.h" |
| 6 | 6 |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 #include "src/type-feedback-vector-inl.h" | 10 #include "src/type-feedback-vector-inl.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 graph()->NewNode(javascript()->StrictEqual(), target, array_function, | 329 graph()->NewNode(javascript()->StrictEqual(), target, array_function, |
| 330 context, effect, control); | 330 context, effect, control); |
| 331 Node* branch = | 331 Node* branch = |
| 332 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 332 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 333 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 333 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 334 Node* deoptimize = | 334 Node* deoptimize = |
| 335 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | 335 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 336 frame_state, effect, if_false); | 336 frame_state, effect, if_false); |
| 337 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 337 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
| 338 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 338 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 339 Revisit(graph()->end()); |
| 339 control = graph()->NewNode(common()->IfTrue(), branch); | 340 control = graph()->NewNode(common()->IfTrue(), branch); |
| 340 | 341 |
| 341 // Turn the {node} into a {JSCreateArray} call. | 342 // Turn the {node} into a {JSCreateArray} call. |
| 342 NodeProperties::ReplaceValueInput(node, array_function, 0); | 343 NodeProperties::ReplaceValueInput(node, array_function, 0); |
| 343 NodeProperties::ReplaceEffectInput(node, effect); | 344 NodeProperties::ReplaceEffectInput(node, effect); |
| 344 NodeProperties::ReplaceControlInput(node, control); | 345 NodeProperties::ReplaceControlInput(node, control); |
| 345 return ReduceArrayConstructor(node); | 346 return ReduceArrayConstructor(node); |
| 346 } else if (feedback->IsWeakCell()) { | 347 } else if (feedback->IsWeakCell()) { |
| 347 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); | 348 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); |
| 348 if (cell->value()->IsJSFunction()) { | 349 if (cell->value()->IsJSFunction()) { |
| 349 Node* target_function = | 350 Node* target_function = |
| 350 jsgraph()->Constant(handle(cell->value(), isolate())); | 351 jsgraph()->Constant(handle(cell->value(), isolate())); |
| 351 | 352 |
| 352 // Check that the {target} is still the {target_function}. | 353 // Check that the {target} is still the {target_function}. |
| 353 Node* check = effect = | 354 Node* check = effect = |
| 354 graph()->NewNode(javascript()->StrictEqual(), target, target_function, | 355 graph()->NewNode(javascript()->StrictEqual(), target, target_function, |
| 355 context, effect, control); | 356 context, effect, control); |
| 356 Node* branch = | 357 Node* branch = |
| 357 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 358 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 358 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 359 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 359 Node* deoptimize = | 360 Node* deoptimize = |
| 360 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | 361 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 361 frame_state, effect, if_false); | 362 frame_state, effect, if_false); |
| 362 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 363 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
| 363 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 364 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 365 Revisit(graph()->end()); |
| 364 control = graph()->NewNode(common()->IfTrue(), branch); | 366 control = graph()->NewNode(common()->IfTrue(), branch); |
| 365 | 367 |
| 366 // Specialize the JSCallFunction node to the {target_function}. | 368 // Specialize the JSCallFunction node to the {target_function}. |
| 367 NodeProperties::ReplaceValueInput(node, target_function, 0); | 369 NodeProperties::ReplaceValueInput(node, target_function, 0); |
| 368 NodeProperties::ReplaceEffectInput(node, effect); | 370 NodeProperties::ReplaceEffectInput(node, effect); |
| 369 NodeProperties::ReplaceControlInput(node, control); | 371 NodeProperties::ReplaceControlInput(node, control); |
| 370 | 372 |
| 371 // Try to further reduce the JSCallFunction {node}. | 373 // Try to further reduce the JSCallFunction {node}. |
| 372 Reduction const reduction = ReduceJSCallFunction(node); | 374 Reduction const reduction = ReduceJSCallFunction(node); |
| 373 return reduction.Changed() ? reduction : Changed(node); | 375 return reduction.Changed() ? reduction : Changed(node); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 graph()->NewNode(javascript()->StrictEqual(), target, array_function, | 473 graph()->NewNode(javascript()->StrictEqual(), target, array_function, |
| 472 context, effect, control); | 474 context, effect, control); |
| 473 Node* branch = | 475 Node* branch = |
| 474 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 476 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 475 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 477 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 476 Node* deoptimize = | 478 Node* deoptimize = |
| 477 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | 479 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 478 frame_state, effect, if_false); | 480 frame_state, effect, if_false); |
| 479 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 481 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
| 480 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 482 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 483 Revisit(graph()->end()); |
| 481 control = graph()->NewNode(common()->IfTrue(), branch); | 484 control = graph()->NewNode(common()->IfTrue(), branch); |
| 482 | 485 |
| 483 // Turn the {node} into a {JSCreateArray} call. | 486 // Turn the {node} into a {JSCreateArray} call. |
| 484 NodeProperties::ReplaceEffectInput(node, effect); | 487 NodeProperties::ReplaceEffectInput(node, effect); |
| 485 NodeProperties::ReplaceControlInput(node, control); | 488 NodeProperties::ReplaceControlInput(node, control); |
| 486 NodeProperties::RemoveFrameStateInput(node, 1); | 489 NodeProperties::RemoveFrameStateInput(node, 1); |
| 487 for (int i = arity; i > 0; --i) { | 490 for (int i = arity; i > 0; --i) { |
| 488 NodeProperties::ReplaceValueInput( | 491 NodeProperties::ReplaceValueInput( |
| 489 node, NodeProperties::GetValueInput(node, i), i + 1); | 492 node, NodeProperties::GetValueInput(node, i), i + 1); |
| 490 } | 493 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 502 graph()->NewNode(javascript()->StrictEqual(), target, target_function, | 505 graph()->NewNode(javascript()->StrictEqual(), target, target_function, |
| 503 context, effect, control); | 506 context, effect, control); |
| 504 Node* branch = | 507 Node* branch = |
| 505 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 508 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 506 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 509 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 507 Node* deoptimize = | 510 Node* deoptimize = |
| 508 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | 511 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 509 frame_state, effect, if_false); | 512 frame_state, effect, if_false); |
| 510 // TODO(bmeurer): This should be on the AdvancedReducer somehow. | 513 // TODO(bmeurer): This should be on the AdvancedReducer somehow. |
| 511 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 514 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 515 Revisit(graph()->end()); |
| 512 control = graph()->NewNode(common()->IfTrue(), branch); | 516 control = graph()->NewNode(common()->IfTrue(), branch); |
| 513 | 517 |
| 514 // Specialize the JSCallConstruct node to the {target_function}. | 518 // Specialize the JSCallConstruct node to the {target_function}. |
| 515 NodeProperties::ReplaceValueInput(node, target_function, 0); | 519 NodeProperties::ReplaceValueInput(node, target_function, 0); |
| 516 NodeProperties::ReplaceEffectInput(node, effect); | 520 NodeProperties::ReplaceEffectInput(node, effect); |
| 517 NodeProperties::ReplaceControlInput(node, control); | 521 NodeProperties::ReplaceControlInput(node, control); |
| 518 if (target == new_target) { | 522 if (target == new_target) { |
| 519 NodeProperties::ReplaceValueInput(node, target_function, arity + 1); | 523 NodeProperties::ReplaceValueInput(node, target_function, arity + 1); |
| 520 } | 524 } |
| 521 | 525 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 547 } | 551 } |
| 548 | 552 |
| 549 | 553 |
| 550 JSOperatorBuilder* JSCallReducer::javascript() const { | 554 JSOperatorBuilder* JSCallReducer::javascript() const { |
| 551 return jsgraph()->javascript(); | 555 return jsgraph()->javascript(); |
| 552 } | 556 } |
| 553 | 557 |
| 554 } // namespace compiler | 558 } // namespace compiler |
| 555 } // namespace internal | 559 } // namespace internal |
| 556 } // namespace v8 | 560 } // namespace v8 |
| OLD | NEW |