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/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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 Node* value = node->InputAt(0); | 906 Node* value = node->InputAt(0); |
907 value = graph()->NewNode(machine()->WordEqual(), value, | 907 value = graph()->NewNode(machine()->WordEqual(), value, |
908 jsgraph()->TrueConstant()); | 908 jsgraph()->TrueConstant()); |
909 return ValueEffectControl(value, effect, control); | 909 return ValueEffectControl(value, effect, control); |
910 } | 910 } |
911 | 911 |
912 EffectControlLinearizer::ValueEffectControl | 912 EffectControlLinearizer::ValueEffectControl |
913 EffectControlLinearizer::LowerTruncateTaggedToBit(Node* node, Node* effect, | 913 EffectControlLinearizer::LowerTruncateTaggedToBit(Node* node, Node* effect, |
914 Node* control) { | 914 Node* control) { |
915 Node* value = node->InputAt(0); | 915 Node* value = node->InputAt(0); |
916 Node* one = jsgraph()->Int32Constant(1); | |
917 Node* zero = jsgraph()->Int32Constant(0); | 916 Node* zero = jsgraph()->Int32Constant(0); |
918 Node* fzero = jsgraph()->Float64Constant(0.0); | 917 Node* fzero = jsgraph()->Float64Constant(0.0); |
919 | 918 |
920 // Collect effect/control/value triples. | 919 // Collect effect/control/value triples. |
921 int count = 0; | 920 int count = 0; |
922 Node* values[7]; | 921 Node* values[6]; |
923 Node* effects[7]; | 922 Node* effects[6]; |
924 Node* controls[6]; | 923 Node* controls[5]; |
925 | 924 |
926 // Check if {value} is a Smi. | 925 // Check if {value} is a Smi. |
927 Node* check_smi = ObjectIsSmi(value); | 926 Node* check_smi = ObjectIsSmi(value); |
928 Node* branch_smi = graph()->NewNode(common()->Branch(BranchHint::kFalse), | 927 Node* branch_smi = graph()->NewNode(common()->Branch(BranchHint::kFalse), |
929 check_smi, control); | 928 check_smi, control); |
930 | 929 |
931 // If {value} is a Smi, then we only need to check that it's not zero. | 930 // If {value} is a Smi, then we only need to check that it's not zero. |
932 Node* if_smi = graph()->NewNode(common()->IfTrue(), branch_smi); | 931 Node* if_smi = graph()->NewNode(common()->IfTrue(), branch_smi); |
933 Node* esmi = effect; | 932 Node* esmi = effect; |
934 { | 933 { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 | 1004 |
1006 // For HeapNumber {value}, just check that its value is not 0.0, -0.0 or NaN. | 1005 // For HeapNumber {value}, just check that its value is not 0.0, -0.0 or NaN. |
1007 Node* if_heapnumber = graph()->NewNode(common()->IfTrue(), branch_heapnumber); | 1006 Node* if_heapnumber = graph()->NewNode(common()->IfTrue(), branch_heapnumber); |
1008 Node* eheapnumber = effect; | 1007 Node* eheapnumber = effect; |
1009 { | 1008 { |
1010 // Load the raw value of {value}. | 1009 // Load the raw value of {value}. |
1011 Node* value_value = eheapnumber = graph()->NewNode( | 1010 Node* value_value = eheapnumber = graph()->NewNode( |
1012 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, | 1011 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), value, |
1013 eheapnumber, if_heapnumber); | 1012 eheapnumber, if_heapnumber); |
1014 | 1013 |
1015 // Check if {value} is either less than 0.0 or greater than 0.0. | 1014 // Check if {value} is not one of 0, -0, or NaN. |
1016 Node* check = | 1015 controls[count] = if_heapnumber; |
1017 graph()->NewNode(machine()->Float64LessThan(), fzero, value_value); | |
1018 Node* branch = graph()->NewNode(common()->Branch(), check, if_heapnumber); | |
1019 | |
1020 controls[count] = graph()->NewNode(common()->IfTrue(), branch); | |
1021 effects[count] = eheapnumber; | 1016 effects[count] = eheapnumber; |
1022 values[count] = one; | 1017 values[count] = graph()->NewNode( |
1023 count++; | 1018 machine()->Float64LessThan(), fzero, |
1024 | 1019 graph()->NewNode(machine()->Float64Abs(), value_value)); |
1025 controls[count] = graph()->NewNode(common()->IfFalse(), branch); | |
1026 effects[count] = eheapnumber; | |
1027 values[count] = | |
1028 graph()->NewNode(machine()->Float64LessThan(), value_value, fzero); | |
1029 count++; | 1020 count++; |
1030 } | 1021 } |
1031 control = graph()->NewNode(common()->IfFalse(), branch_heapnumber); | 1022 control = graph()->NewNode(common()->IfFalse(), branch_heapnumber); |
1032 | 1023 |
1033 // The {value} is either a JSReceiver, a Symbol or some Simd128Value. In | 1024 // The {value} is either a JSReceiver, a Symbol or some Simd128Value. In |
1034 // those cases we can just the undetectable bit on the map, which will only | 1025 // those cases we can just the undetectable bit on the map, which will only |
1035 // be set for certain JSReceivers, i.e. document.all. | 1026 // be set for certain JSReceivers, i.e. document.all. |
1036 { | 1027 { |
1037 // Load the {value} map bit field. | 1028 // Load the {value} map bit field. |
1038 Node* value_map_bitfield = effect = graph()->NewNode( | 1029 Node* value_map_bitfield = effect = graph()->NewNode( |
(...skipping 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3656 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3647 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3657 Operator::kEliminatable); | 3648 Operator::kEliminatable); |
3658 to_number_operator_.set(common()->Call(desc)); | 3649 to_number_operator_.set(common()->Call(desc)); |
3659 } | 3650 } |
3660 return to_number_operator_.get(); | 3651 return to_number_operator_.get(); |
3661 } | 3652 } |
3662 | 3653 |
3663 } // namespace compiler | 3654 } // namespace compiler |
3664 } // namespace internal | 3655 } // namespace internal |
3665 } // namespace v8 | 3656 } // namespace v8 |
OLD | NEW |