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

Side by Side Diff: src/compiler/effect-control-linearizer.cc

Issue 2035893004: [turbofan] Introduce a dedicated CheckBounds operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE Created 4 years, 6 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
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/effect-control-linearizer.h" 5 #include "src/compiler/effect-control-linearizer.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 break; 409 break;
410 case IrOpcode::kChangeTaggedToUint32: 410 case IrOpcode::kChangeTaggedToUint32:
411 state = LowerChangeTaggedToUint32(node, *effect, *control); 411 state = LowerChangeTaggedToUint32(node, *effect, *control);
412 break; 412 break;
413 case IrOpcode::kChangeTaggedToFloat64: 413 case IrOpcode::kChangeTaggedToFloat64:
414 state = LowerChangeTaggedToFloat64(node, *effect, *control); 414 state = LowerChangeTaggedToFloat64(node, *effect, *control);
415 break; 415 break;
416 case IrOpcode::kTruncateTaggedToFloat64: 416 case IrOpcode::kTruncateTaggedToFloat64:
417 state = LowerTruncateTaggedToFloat64(node, *effect, *control); 417 state = LowerTruncateTaggedToFloat64(node, *effect, *control);
418 break; 418 break;
419 case IrOpcode::kCheckBounds:
420 state = LowerCheckBounds(node, frame_state, *effect, *control);
421 break;
419 case IrOpcode::kCheckedUint32ToInt32: 422 case IrOpcode::kCheckedUint32ToInt32:
420 state = LowerCheckedUint32ToInt32(node, frame_state, *effect, *control); 423 state = LowerCheckedUint32ToInt32(node, frame_state, *effect, *control);
421 break; 424 break;
422 case IrOpcode::kCheckedFloat64ToInt32: 425 case IrOpcode::kCheckedFloat64ToInt32:
423 state = LowerCheckedFloat64ToInt32(node, frame_state, *effect, *control); 426 state = LowerCheckedFloat64ToInt32(node, frame_state, *effect, *control);
424 break; 427 break;
425 case IrOpcode::kCheckedTaggedToInt32: 428 case IrOpcode::kCheckedTaggedToInt32:
426 state = LowerCheckedTaggedToInt32(node, frame_state, *effect, *control); 429 state = LowerCheckedTaggedToInt32(node, frame_state, *effect, *control);
427 break; 430 break;
428 case IrOpcode::kCheckedTaggedToFloat64: 431 case IrOpcode::kCheckedTaggedToFloat64:
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 761
759 control = graph()->NewNode(common()->Merge(2), if_true, if_false); 762 control = graph()->NewNode(common()->Merge(2), if_true, if_false);
760 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); 763 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
761 value = graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), 764 value = graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2),
762 vtrue, vfalse, control); 765 vtrue, vfalse, control);
763 766
764 return ValueEffectControl(value, effect, control); 767 return ValueEffectControl(value, effect, control);
765 } 768 }
766 769
767 EffectControlLinearizer::ValueEffectControl 770 EffectControlLinearizer::ValueEffectControl
771 EffectControlLinearizer::LowerCheckBounds(Node* node, Node* frame_state,
772 Node* effect, Node* control) {
773 Node* index = node->InputAt(0);
774 Node* limit = node->InputAt(1);
775
776 Node* check = graph()->NewNode(machine()->Uint32LessThan(), index, limit);
777 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), check,
778 frame_state, effect, control);
779
780 // Make sure the lowered node does not appear in any use lists.
781 node->TrimInputCount(0);
782
783 return ValueEffectControl(index, effect, control);
784 }
785
786 EffectControlLinearizer::ValueEffectControl
768 EffectControlLinearizer::LowerCheckedUint32ToInt32(Node* node, 787 EffectControlLinearizer::LowerCheckedUint32ToInt32(Node* node,
769 Node* frame_state, 788 Node* frame_state,
770 Node* effect, 789 Node* effect,
771 Node* control) { 790 Node* control) {
772 Node* value = node->InputAt(0); 791 Node* value = node->InputAt(0);
773 Node* max_int = jsgraph()->Int32Constant(std::numeric_limits<int32_t>::max()); 792 Node* max_int = jsgraph()->Int32Constant(std::numeric_limits<int32_t>::max());
774 Node* is_safe = 793 Node* is_safe =
775 graph()->NewNode(machine()->Uint32LessThanOrEqual(), value, max_int); 794 graph()->NewNode(machine()->Uint32LessThanOrEqual(), value, max_int);
776 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), is_safe, 795 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), is_safe,
777 frame_state, effect, control); 796 frame_state, effect, control);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 Node* branch = 864 Node* branch =
846 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); 865 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
847 866
848 // In the Smi case, just convert to int32. 867 // In the Smi case, just convert to int32.
849 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 868 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
850 Node* etrue = effect; 869 Node* etrue = effect;
851 Node* vtrue = ChangeSmiToInt32(value); 870 Node* vtrue = ChangeSmiToInt32(value);
852 871
853 // In the non-Smi case, check the heap numberness, load the number and convert 872 // In the non-Smi case, check the heap numberness, load the number and convert
854 // to int32. 873 // to int32.
855 // TODO(jarin) Propagate/handle possible truncations here.
856 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); 874 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
857 ValueEffectControl number_state = BuildCheckedHeapNumberOrOddballToFloat64( 875 Node* efalse = effect;
858 value, frame_state, effect, if_false); 876 Node* vfalse;
859 number_state = 877 {
860 BuildCheckedFloat64ToInt32(number_state.value, frame_state, 878 Node* value_map = efalse =
861 number_state.effect, number_state.control); 879 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()),
880 value, efalse, if_false);
881 Node* check = graph()->NewNode(machine()->WordEqual(), value_map,
882 jsgraph()->HeapNumberMapConstant());
883 if_false = efalse = graph()->NewNode(common()->DeoptimizeUnless(), check,
884 frame_state, efalse, if_false);
885 vfalse = efalse = graph()->NewNode(
886 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value,
887 efalse, if_false);
888 ValueEffectControl state =
889 BuildCheckedFloat64ToInt32(vfalse, frame_state, efalse, if_false);
890 if_false = state.control;
891 efalse = state.effect;
892 vfalse = state.value;
893 }
862 894
863 Node* merge = 895 control = graph()->NewNode(common()->Merge(2), if_true, if_false);
864 graph()->NewNode(common()->Merge(2), if_true, number_state.control); 896 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
865 Node* effect_phi = graph()->NewNode(common()->EffectPhi(2), etrue, 897 value = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2),
866 number_state.effect, merge); 898 vtrue, vfalse, control);
867 Node* result =
868 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), vtrue,
869 number_state.value, merge);
870 899
871 // Make sure the lowered node does not appear in any use lists. 900 // Make sure the lowered node does not appear in any use lists.
872 node->TrimInputCount(0); 901 node->TrimInputCount(0);
873 902
874 return ValueEffectControl(result, effect_phi, merge); 903 return ValueEffectControl(value, effect, control);
875 } 904 }
876 905
877 EffectControlLinearizer::ValueEffectControl 906 EffectControlLinearizer::ValueEffectControl
878 EffectControlLinearizer::BuildCheckedHeapNumberOrOddballToFloat64( 907 EffectControlLinearizer::BuildCheckedHeapNumberOrOddballToFloat64(
879 Node* value, Node* frame_state, Node* effect, Node* control) { 908 Node* value, Node* frame_state, Node* effect, Node* control) {
880 Node* value_map = effect = graph()->NewNode( 909 Node* value_map = effect = graph()->NewNode(
881 simplified()->LoadField(AccessBuilder::ForMap()), value, effect, control); 910 simplified()->LoadField(AccessBuilder::ForMap()), value, effect, control);
882 Node* check_number = graph()->NewNode(machine()->WordEqual(), value_map, 911 Node* check_number = graph()->NewNode(machine()->WordEqual(), value_map,
883 jsgraph()->HeapNumberMapConstant()); 912 jsgraph()->HeapNumberMapConstant());
884 913
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 1574 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
1546 Operator::kNoThrow); 1575 Operator::kNoThrow);
1547 to_number_operator_.set(common()->Call(desc)); 1576 to_number_operator_.set(common()->Call(desc));
1548 } 1577 }
1549 return to_number_operator_.get(); 1578 return to_number_operator_.get();
1550 } 1579 }
1551 1580
1552 } // namespace compiler 1581 } // namespace compiler
1553 } // namespace internal 1582 } // namespace internal
1554 } // namespace v8 1583 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/effect-control-linearizer.h ('k') | src/compiler/js-native-context-specialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698