Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: src/compiler/js-call-reducer.cc

Issue 1721103003: [turbofan] Introduce DeoptimizeIf And DeoptimizeUnless common operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-call-reducer.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 context, context, effect); 322 context, context, effect);
323 array_function = effect = graph()->NewNode( 323 array_function = effect = graph()->NewNode(
324 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), 324 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true),
325 native_context, native_context, effect); 325 native_context, native_context, effect);
326 } 326 }
327 327
328 // Check that the {target} is still the {array_function}. 328 // Check that the {target} is still the {array_function}.
329 Node* check = effect = 329 Node* check = effect =
330 graph()->NewNode(javascript()->StrictEqual(), target, array_function, 330 graph()->NewNode(javascript()->StrictEqual(), target, array_function,
331 context, effect, control); 331 context, effect, control);
332 Node* branch = 332 control = graph()->NewNode(common()->DeoptimizeUnless(), check, frame_state,
333 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); 333 effect, control);
334 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
335 Node* deoptimize =
336 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager),
337 frame_state, effect, if_false);
338 // TODO(bmeurer): This should be on the AdvancedReducer somehow.
339 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
340 Revisit(graph()->end());
341 control = graph()->NewNode(common()->IfTrue(), branch);
342 334
343 // Turn the {node} into a {JSCreateArray} call. 335 // Turn the {node} into a {JSCreateArray} call.
344 NodeProperties::ReplaceValueInput(node, array_function, 0); 336 NodeProperties::ReplaceValueInput(node, array_function, 0);
345 NodeProperties::ReplaceEffectInput(node, effect); 337 NodeProperties::ReplaceEffectInput(node, effect);
346 NodeProperties::ReplaceControlInput(node, control); 338 NodeProperties::ReplaceControlInput(node, control);
347 return ReduceArrayConstructor(node); 339 return ReduceArrayConstructor(node);
348 } else if (feedback->IsWeakCell()) { 340 } else if (feedback->IsWeakCell()) {
349 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); 341 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback);
350 if (cell->value()->IsJSFunction()) { 342 if (cell->value()->IsJSFunction()) {
351 Node* target_function = 343 Node* target_function =
352 jsgraph()->Constant(handle(cell->value(), isolate())); 344 jsgraph()->Constant(handle(cell->value(), isolate()));
353 345
354 // Check that the {target} is still the {target_function}. 346 // Check that the {target} is still the {target_function}.
355 Node* check = effect = 347 Node* check = effect =
356 graph()->NewNode(javascript()->StrictEqual(), target, target_function, 348 graph()->NewNode(javascript()->StrictEqual(), target, target_function,
357 context, effect, control); 349 context, effect, control);
358 Node* branch = 350 control = graph()->NewNode(common()->DeoptimizeUnless(), check,
359 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); 351 frame_state, effect, control);
360 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
361 Node* deoptimize =
362 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager),
363 frame_state, effect, if_false);
364 // TODO(bmeurer): This should be on the AdvancedReducer somehow.
365 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
366 Revisit(graph()->end());
367 control = graph()->NewNode(common()->IfTrue(), branch);
368 352
369 // Specialize the JSCallFunction node to the {target_function}. 353 // Specialize the JSCallFunction node to the {target_function}.
370 NodeProperties::ReplaceValueInput(node, target_function, 0); 354 NodeProperties::ReplaceValueInput(node, target_function, 0);
371 NodeProperties::ReplaceEffectInput(node, effect); 355 NodeProperties::ReplaceEffectInput(node, effect);
372 NodeProperties::ReplaceControlInput(node, control); 356 NodeProperties::ReplaceControlInput(node, control);
373 357
374 // Try to further reduce the JSCallFunction {node}. 358 // Try to further reduce the JSCallFunction {node}.
375 Reduction const reduction = ReduceJSCallFunction(node); 359 Reduction const reduction = ReduceJSCallFunction(node);
376 return reduction.Changed() ? reduction : Changed(node); 360 return reduction.Changed() ? reduction : Changed(node);
377 } 361 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 context, context, effect); 450 context, context, effect);
467 array_function = effect = graph()->NewNode( 451 array_function = effect = graph()->NewNode(
468 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), 452 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true),
469 native_context, native_context, effect); 453 native_context, native_context, effect);
470 } 454 }
471 455
472 // Check that the {target} is still the {array_function}. 456 // Check that the {target} is still the {array_function}.
473 Node* check = effect = 457 Node* check = effect =
474 graph()->NewNode(javascript()->StrictEqual(), target, array_function, 458 graph()->NewNode(javascript()->StrictEqual(), target, array_function,
475 context, effect, control); 459 context, effect, control);
476 Node* branch = 460 control = graph()->NewNode(common()->DeoptimizeUnless(), check, frame_state,
477 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); 461 effect, control);
478 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
479 Node* deoptimize =
480 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager),
481 frame_state, effect, if_false);
482 // TODO(bmeurer): This should be on the AdvancedReducer somehow.
483 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
484 Revisit(graph()->end());
485 control = graph()->NewNode(common()->IfTrue(), branch);
486 462
487 // Turn the {node} into a {JSCreateArray} call. 463 // Turn the {node} into a {JSCreateArray} call.
488 NodeProperties::ReplaceEffectInput(node, effect); 464 NodeProperties::ReplaceEffectInput(node, effect);
489 NodeProperties::ReplaceControlInput(node, control); 465 NodeProperties::ReplaceControlInput(node, control);
490 NodeProperties::RemoveFrameStateInput(node, 1); 466 NodeProperties::RemoveFrameStateInput(node, 1);
491 for (int i = arity; i > 0; --i) { 467 for (int i = arity; i > 0; --i) {
492 NodeProperties::ReplaceValueInput( 468 NodeProperties::ReplaceValueInput(
493 node, NodeProperties::GetValueInput(node, i), i + 1); 469 node, NodeProperties::GetValueInput(node, i), i + 1);
494 } 470 }
495 NodeProperties::ReplaceValueInput(node, new_target, 1); 471 NodeProperties::ReplaceValueInput(node, new_target, 1);
496 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); 472 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
497 return Changed(node); 473 return Changed(node);
498 } else if (feedback->IsWeakCell()) { 474 } else if (feedback->IsWeakCell()) {
499 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); 475 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback);
500 if (cell->value()->IsJSFunction()) { 476 if (cell->value()->IsJSFunction()) {
501 Node* target_function = 477 Node* target_function =
502 jsgraph()->Constant(handle(cell->value(), isolate())); 478 jsgraph()->Constant(handle(cell->value(), isolate()));
503 479
504 // Check that the {target} is still the {target_function}. 480 // Check that the {target} is still the {target_function}.
505 Node* check = effect = 481 Node* check = effect =
506 graph()->NewNode(javascript()->StrictEqual(), target, target_function, 482 graph()->NewNode(javascript()->StrictEqual(), target, target_function,
507 context, effect, control); 483 context, effect, control);
508 Node* branch = 484 control = graph()->NewNode(common()->DeoptimizeUnless(), check,
509 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); 485 frame_state, effect, control);
510 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
511 Node* deoptimize =
512 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager),
513 frame_state, effect, if_false);
514 // TODO(bmeurer): This should be on the AdvancedReducer somehow.
515 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
516 Revisit(graph()->end());
517 control = graph()->NewNode(common()->IfTrue(), branch);
518 486
519 // Specialize the JSCallConstruct node to the {target_function}. 487 // Specialize the JSCallConstruct node to the {target_function}.
520 NodeProperties::ReplaceValueInput(node, target_function, 0); 488 NodeProperties::ReplaceValueInput(node, target_function, 0);
521 NodeProperties::ReplaceEffectInput(node, effect); 489 NodeProperties::ReplaceEffectInput(node, effect);
522 NodeProperties::ReplaceControlInput(node, control); 490 NodeProperties::ReplaceControlInput(node, control);
523 if (target == new_target) { 491 if (target == new_target) {
524 NodeProperties::ReplaceValueInput(node, target_function, arity + 1); 492 NodeProperties::ReplaceValueInput(node, target_function, arity + 1);
525 } 493 }
526 494
527 // Try to further reduce the JSCallConstruct {node}. 495 // Try to further reduce the JSCallConstruct {node}.
(...skipping 24 matching lines...) Expand all
552 } 520 }
553 521
554 522
555 JSOperatorBuilder* JSCallReducer::javascript() const { 523 JSOperatorBuilder* JSCallReducer::javascript() const {
556 return jsgraph()->javascript(); 524 return jsgraph()->javascript();
557 } 525 }
558 526
559 } // namespace compiler 527 } // namespace compiler
560 } // namespace internal 528 } // namespace internal
561 } // namespace v8 529 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-call-reducer.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698