@@ -171,21 +171,6 @@ void ReplaceEffectControlUses(Node* node, Node* effect, Node* control) {
171
171
}
172
172
}
173
173
174
- void ChangeToPureOp (Node* node, const Operator* new_op) {
175
- DCHECK (new_op->HasProperty (Operator::kPure ));
176
- if (node->op ()->EffectInputCount () > 0 ) {
177
- DCHECK_LT (0 , node->op ()->ControlInputCount ());
178
- // Disconnect the node from effect and control chains.
179
- Node* control = NodeProperties::GetControlInput (node);
180
- Node* effect = NodeProperties::GetEffectInput (node);
181
- ReplaceEffectControlUses (node, effect, control);
182
- node->TrimInputCount (new_op->ValueInputCount ());
183
- } else {
184
- DCHECK_EQ (0 , node->op ()->ControlInputCount ());
185
- }
186
- NodeProperties::ChangeOp (node, new_op);
187
- }
188
-
189
174
#ifdef DEBUG
190
175
// Helpers for monotonicity checking.
191
176
class InputUseInfos {
@@ -750,6 +735,31 @@ class RepresentationSelector {
750
735
!GetUpperBound (node->InputAt (1 )).Maybe (type);
751
736
}
752
737
738
+ void ChangeToPureOp (Node* node, const Operator* new_op) {
739
+ DCHECK (new_op->HasProperty (Operator::kPure ));
740
+ if (node->op ()->EffectInputCount () > 0 ) {
741
+ DCHECK_LT (0 , node->op ()->ControlInputCount ());
742
+ Node* control = NodeProperties::GetControlInput (node);
743
+ Node* effect = NodeProperties::GetEffectInput (node);
744
+ if (TypeOf (node).IsNone ()) {
745
+ // If the node is unreachable, insert an Unreachable node and mark the
746
+ // value dead.
747
+ // TODO(jarin,tebbi) Find a way to unify/merge this insertion with
748
+ // InsertUnreachableIfNecessary.
749
+ Node* unreachable = effect = graph ()->NewNode (
750
+ jsgraph_->common ()->Unreachable (), effect, control);
751
+ new_op = jsgraph_->common ()->DeadValue (GetInfo (node)->representation ());
752
+ node->ReplaceInput (0 , unreachable);
753
+ }
754
+ // Rewire the effect and control chains.
755
+ node->TrimInputCount (new_op->ValueInputCount ());
756
+ ReplaceEffectControlUses (node, effect, control);
757
+ } else {
758
+ DCHECK_EQ (0 , node->op ()->ControlInputCount ());
759
+ }
760
+ NodeProperties::ChangeOp (node, new_op);
761
+ }
762
+
753
763
// Converts input {index} of {node} according to given UseInfo {use},
754
764
// assuming the type of the input is {input_type}. If {input_type} is null,
755
765
// it takes the input from the input node {TypeOf(node->InputAt(index))}.
@@ -1052,6 +1062,15 @@ class RepresentationSelector {
1052
1062
}
1053
1063
}
1054
1064
1065
+ void MaskShiftOperand (Node* node, Type rhs_type) {
1066
+ if (!rhs_type.Is (type_cache_.kZeroToThirtyOne )) {
1067
+ Node* const rhs = NodeProperties::GetValueInput (node, 1 );
1068
+ node->ReplaceInput (1 ,
1069
+ graph ()->NewNode (jsgraph_->machine ()->Word32And (), rhs,
1070
+ jsgraph_->Int32Constant (0x1F )));
1071
+ }
1072
+ }
1073
+
1055
1074
static MachineSemantic DeoptValueSemanticOf (Type type) {
1056
1075
// We only need signedness to do deopt correctly.
1057
1076
if (type.Is (Type::Signed32 ())) {
@@ -1996,7 +2015,8 @@ class RepresentationSelector {
1996
2015
VisitBinop (node, UseInfo::TruncatingWord32 (),
1997
2016
UseInfo::TruncatingWord32 (), MachineRepresentation::kWord32 );
1998
2017
if (lower ()) {
1999
- lowering->DoShift (node, lowering->machine ()->Word32Shl (), rhs_type);
2018
+ MaskShiftOperand (node, rhs_type);
2019
+ ChangeToPureOp (node, lowering->machine ()->Word32Shl ());
2000
2020
}
2001
2021
return ;
2002
2022
}
@@ -2007,7 +2027,8 @@ class RepresentationSelector {
2007
2027
UseInfo::TruncatingWord32 (),
2008
2028
MachineRepresentation::kWord32 );
2009
2029
if (lower ()) {
2010
- lowering->DoShift (node, lowering->machine ()->Word32Shl (), rhs_type);
2030
+ MaskShiftOperand (node, rhs_type);
2031
+ ChangeToPureOp (node, lowering->machine ()->Word32Shl ());
2011
2032
}
2012
2033
return ;
2013
2034
}
@@ -2016,7 +2037,8 @@ class RepresentationSelector {
2016
2037
VisitBinop (node, CheckedUseInfoAsWord32FromHint (hint),
2017
2038
MachineRepresentation::kWord32 , Type::Signed32 ());
2018
2039
if (lower ()) {
2019
- lowering->DoShift (node, lowering->machine ()->Word32Shl (), rhs_type);
2040
+ MaskShiftOperand (node, rhs_type);
2041
+ ChangeToPureOp (node, lowering->machine ()->Word32Shl ());
2020
2042
}
2021
2043
return ;
2022
2044
}
@@ -2025,7 +2047,8 @@ class RepresentationSelector {
2025
2047
VisitBinop (node, UseInfo::TruncatingWord32 (),
2026
2048
UseInfo::TruncatingWord32 (), MachineRepresentation::kWord32 );
2027
2049
if (lower ()) {
2028
- lowering->DoShift (node, lowering->machine ()->Word32Sar (), rhs_type);
2050
+ MaskShiftOperand (node, rhs_type);
2051
+ ChangeToPureOp (node, lowering->machine ()->Word32Sar ());
2029
2052
}
2030
2053
return ;
2031
2054
}
@@ -2036,7 +2059,8 @@ class RepresentationSelector {
2036
2059
UseInfo::TruncatingWord32 (),
2037
2060
MachineRepresentation::kWord32 );
2038
2061
if (lower ()) {
2039
- lowering->DoShift (node, lowering->machine ()->Word32Sar (), rhs_type);
2062
+ MaskShiftOperand (node, rhs_type);
2063
+ ChangeToPureOp (node, lowering->machine ()->Word32Sar ());
2040
2064
}
2041
2065
return ;
2042
2066
}
@@ -2045,7 +2069,8 @@ class RepresentationSelector {
2045
2069
VisitBinop (node, CheckedUseInfoAsWord32FromHint (hint),
2046
2070
MachineRepresentation::kWord32 , Type::Signed32 ());
2047
2071
if (lower ()) {
2048
- lowering->DoShift (node, lowering->machine ()->Word32Sar (), rhs_type);
2072
+ MaskShiftOperand (node, rhs_type);
2073
+ ChangeToPureOp (node, lowering->machine ()->Word32Sar ());
2049
2074
}
2050
2075
return ;
2051
2076
}
@@ -2054,7 +2079,8 @@ class RepresentationSelector {
2054
2079
VisitBinop (node, UseInfo::TruncatingWord32 (),
2055
2080
UseInfo::TruncatingWord32 (), MachineRepresentation::kWord32 );
2056
2081
if (lower ()) {
2057
- lowering->DoShift (node, lowering->machine ()->Word32Shr (), rhs_type);
2082
+ MaskShiftOperand (node, rhs_type);
2083
+ ChangeToPureOp (node, lowering->machine ()->Word32Shr ());
2058
2084
}
2059
2085
return ;
2060
2086
}
@@ -2083,14 +2109,16 @@ class RepresentationSelector {
2083
2109
UseInfo::TruncatingWord32 (),
2084
2110
MachineRepresentation::kWord32 );
2085
2111
if (lower ()) {
2086
- lowering->DoShift (node, lowering->machine ()->Word32Shr (), rhs_type);
2112
+ MaskShiftOperand (node, rhs_type);
2113
+ ChangeToPureOp (node, lowering->machine ()->Word32Shr ());
2087
2114
}
2088
2115
return ;
2089
2116
}
2090
2117
VisitBinop (node, CheckedUseInfoAsWord32FromHint (hint),
2091
2118
MachineRepresentation::kWord32 , Type::Unsigned32 ());
2092
2119
if (lower ()) {
2093
- lowering->DoShift (node, lowering->machine ()->Word32Shr (), rhs_type);
2120
+ MaskShiftOperand (node, rhs_type);
2121
+ ChangeToPureOp (node, lowering->machine ()->Word32Shr ());
2094
2122
}
2095
2123
return ;
2096
2124
}
@@ -3787,16 +3815,6 @@ void SimplifiedLowering::DoMin(Node* node, Operator const* op,
3787
3815
NodeProperties::ChangeOp (node, common ()->Select (rep));
3788
3816
}
3789
3817
3790
- void SimplifiedLowering::DoShift (Node* node, Operator const * op,
3791
- Type rhs_type) {
3792
- if (!rhs_type.Is (type_cache_.kZeroToThirtyOne )) {
3793
- Node* const rhs = NodeProperties::GetValueInput (node, 1 );
3794
- node->ReplaceInput (1 , graph ()->NewNode (machine ()->Word32And (), rhs,
3795
- jsgraph ()->Int32Constant (0x1F )));
3796
- }
3797
- ChangeToPureOp (node, op);
3798
- }
3799
-
3800
3818
void SimplifiedLowering::DoIntegral32ToBit (Node* node) {
3801
3819
Node* const input = node->InputAt (0 );
3802
3820
Node* const zero = jsgraph ()->Int32Constant (0 );
0 commit comments