Index: src/compiler/effect-control-linearizer.cc |
diff --git a/src/compiler/effect-control-linearizer.cc b/src/compiler/effect-control-linearizer.cc |
index 763aaea84199243a391e2f3e47f4f67a35115e52..11fee09f9b7f84ccb67d8844d35c0ae068703c34 100644 |
--- a/src/compiler/effect-control-linearizer.cc |
+++ b/src/compiler/effect-control-linearizer.cc |
@@ -346,6 +346,12 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node, Node** effect, |
Node** control) { |
ValueEffectControl state(nullptr, nullptr, nullptr); |
switch (node->opcode()) { |
+ case IrOpcode::kChangeBitToTagged: |
+ state = LowerChangeBitToTagged(node, *effect, *control); |
+ break; |
+ case IrOpcode::kChangeInt31ToTaggedSigned: |
+ state = LowerChangeInt31ToTaggedSigned(node, *effect, *control); |
+ break; |
case IrOpcode::kChangeInt32ToTagged: |
state = LowerChangeInt32ToTagged(node, *effect, *control); |
break; |
@@ -355,6 +361,12 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node, Node** effect, |
case IrOpcode::kChangeFloat64ToTagged: |
state = LowerChangeFloat64ToTagged(node, *effect, *control); |
break; |
+ case IrOpcode::kChangeTaggedSignedToInt32: |
+ state = LowerChangeTaggedSignedToInt32(node, *effect, *control); |
+ break; |
+ case IrOpcode::kChangeTaggedToBit: |
+ state = LowerChangeTaggedToBit(node, *effect, *control); |
+ break; |
case IrOpcode::kChangeTaggedToInt32: |
state = LowerChangeTaggedToInt32(node, *effect, *control); |
break; |
@@ -376,6 +388,9 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node, Node** effect, |
case IrOpcode::kObjectIsReceiver: |
state = LowerObjectIsReceiver(node, *effect, *control); |
break; |
+ case IrOpcode::kObjectIsSmi: |
+ state = LowerObjectIsSmi(node, *effect, *control); |
+ break; |
case IrOpcode::kObjectIsString: |
state = LowerObjectIsString(node, *effect, *control); |
break; |
@@ -461,6 +476,35 @@ EffectControlLinearizer::LowerChangeFloat64ToTagged(Node* node, Node* effect, |
} |
EffectControlLinearizer::ValueEffectControl |
+EffectControlLinearizer::LowerChangeBitToTagged(Node* node, Node* effect, |
+ Node* control) { |
+ Node* value = node->InputAt(0); |
+ |
+ Node* branch = graph()->NewNode(common()->Branch(), value, control); |
+ |
+ Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
+ Node* vtrue = jsgraph()->TrueConstant(); |
+ |
+ Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
+ Node* vfalse = jsgraph()->FalseConstant(); |
+ |
+ control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
+ value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
+ vtrue, vfalse, control); |
+ |
+ return ValueEffectControl(value, effect, control); |
+} |
+ |
+EffectControlLinearizer::ValueEffectControl |
+EffectControlLinearizer::LowerChangeInt31ToTaggedSigned(Node* node, |
+ Node* effect, |
+ Node* control) { |
+ Node* value = node->InputAt(0); |
+ value = ChangeInt32ToSmi(value); |
+ return ValueEffectControl(value, effect, control); |
+} |
+ |
+EffectControlLinearizer::ValueEffectControl |
EffectControlLinearizer::LowerChangeInt32ToTagged(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
@@ -518,18 +562,35 @@ EffectControlLinearizer::LowerChangeUint32ToTagged(Node* node, Node* effect, |
} |
EffectControlLinearizer::ValueEffectControl |
+EffectControlLinearizer::LowerChangeTaggedSignedToInt32(Node* node, |
+ Node* effect, |
+ Node* control) { |
+ Node* value = node->InputAt(0); |
+ value = ChangeSmiToInt32(value); |
+ return ValueEffectControl(value, effect, control); |
+} |
+ |
+EffectControlLinearizer::ValueEffectControl |
+EffectControlLinearizer::LowerChangeTaggedToBit(Node* node, Node* effect, |
+ Node* control) { |
+ Node* value = node->InputAt(0); |
+ value = graph()->NewNode(machine()->WordEqual(), value, |
+ jsgraph()->TrueConstant()); |
+ return ValueEffectControl(value, effect, control); |
+} |
+ |
+EffectControlLinearizer::ValueEffectControl |
EffectControlLinearizer::LowerChangeTaggedToInt32(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
- Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
+ Node* check = ObjectIsSmi(value); |
Node* branch = |
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
Node* etrue = effect; |
- Node* vtrue = |
- graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); |
+ Node* vtrue = ChangeSmiToInt32(value); |
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
Node* efalse = effect; |
@@ -555,14 +616,13 @@ EffectControlLinearizer::LowerChangeTaggedToUint32(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
- Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
+ Node* check = ObjectIsSmi(value); |
Node* branch = |
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
Node* etrue = effect; |
- Node* vtrue = |
- graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); |
+ Node* vtrue = ChangeSmiToInt32(value); |
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
Node* efalse = effect; |
@@ -588,7 +648,7 @@ EffectControlLinearizer::LowerChangeTaggedToFloat64(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
- Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
+ Node* check = ObjectIsSmi(value); |
Node* branch = |
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
@@ -596,7 +656,7 @@ EffectControlLinearizer::LowerChangeTaggedToFloat64(Node* node, Node* effect, |
Node* etrue = effect; |
Node* vtrue; |
{ |
- vtrue = graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); |
+ vtrue = ChangeSmiToInt32(value); |
vtrue = graph()->NewNode(machine()->ChangeInt32ToFloat64(), vtrue); |
} |
@@ -623,14 +683,13 @@ EffectControlLinearizer::LowerTruncateTaggedToWord32(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
- Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
+ Node* check = ObjectIsSmi(value); |
Node* branch = |
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
Node* etrue = effect; |
- Node* vtrue = |
- graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value); |
+ Node* vtrue = ChangeSmiToInt32(value); |
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
Node* efalse = effect; |
@@ -656,7 +715,7 @@ EffectControlLinearizer::LowerObjectIsCallable(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
- Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
+ Node* check = ObjectIsSmi(value); |
Node* branch = |
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
@@ -696,7 +755,7 @@ EffectControlLinearizer::LowerObjectIsNumber(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
- Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
+ Node* check = ObjectIsSmi(value); |
Node* branch = graph()->NewNode(common()->Branch(), check, control); |
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
@@ -727,7 +786,7 @@ EffectControlLinearizer::LowerObjectIsReceiver(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
- Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
+ Node* check = ObjectIsSmi(value); |
Node* branch = |
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
@@ -760,11 +819,19 @@ EffectControlLinearizer::LowerObjectIsReceiver(Node* node, Node* effect, |
} |
EffectControlLinearizer::ValueEffectControl |
+EffectControlLinearizer::LowerObjectIsSmi(Node* node, Node* effect, |
+ Node* control) { |
+ Node* value = node->InputAt(0); |
+ value = ObjectIsSmi(value); |
+ return ValueEffectControl(value, effect, control); |
+} |
+ |
+EffectControlLinearizer::ValueEffectControl |
EffectControlLinearizer::LowerObjectIsString(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
- Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
+ Node* check = ObjectIsSmi(value); |
Node* branch = |
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
@@ -799,7 +866,7 @@ EffectControlLinearizer::LowerObjectIsUndetectable(Node* node, Node* effect, |
Node* control) { |
Node* value = node->InputAt(0); |
- Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
+ Node* check = ObjectIsSmi(value); |
Node* branch = |
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
@@ -874,6 +941,22 @@ Node* EffectControlLinearizer::ChangeUint32ToFloat64(Node* value) { |
return graph()->NewNode(machine()->ChangeUint32ToFloat64(), value); |
} |
+Node* EffectControlLinearizer::ChangeSmiToInt32(Node* value) { |
+ value = graph()->NewNode(machine()->WordSar(), value, SmiShiftBitsConstant()); |
+ if (machine()->Is64()) { |
+ value = graph()->NewNode(machine()->TruncateInt64ToInt32(), value); |
+ } |
+ return value; |
+} |
+ |
+Node* EffectControlLinearizer::ObjectIsSmi(Node* value) { |
+ return graph()->NewNode( |
+ machine()->WordEqual(), |
+ graph()->NewNode(machine()->WordAnd(), value, |
+ jsgraph()->IntPtrConstant(kSmiTagMask)), |
+ jsgraph()->IntPtrConstant(kSmiTag)); |
+} |
+ |
Node* EffectControlLinearizer::SmiMaxValueConstant() { |
return jsgraph()->Int32Constant(Smi::kMaxValue); |
} |