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

Unified Diff: src/compiler/effect-control-linearizer.cc

Issue 2191503002: [turbofan] Add the CheckedTruncateTaggedToWord32 opcode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/effect-control-linearizer.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/effect-control-linearizer.cc
diff --git a/src/compiler/effect-control-linearizer.cc b/src/compiler/effect-control-linearizer.cc
index 6ad238e6ada1d5a1e58ddfbf09cbaf36a981d5ee..0528a5ef12b9be645603737f36d54484b5223978 100644
--- a/src/compiler/effect-control-linearizer.cc
+++ b/src/compiler/effect-control-linearizer.cc
@@ -673,6 +673,10 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kTruncateTaggedToWord32:
state = LowerTruncateTaggedToWord32(node, *effect, *control);
break;
+ case IrOpcode::kCheckedTruncateTaggedToWord32:
+ state = LowerCheckedTruncateTaggedToWord32(node, frame_state, *effect,
+ *control);
+ break;
case IrOpcode::kObjectIsCallable:
state = LowerObjectIsCallable(node, *effect, *control);
break;
@@ -1620,6 +1624,41 @@ EffectControlLinearizer::LowerTruncateTaggedToWord32(Node* node, Node* effect,
}
EffectControlLinearizer::ValueEffectControl
+EffectControlLinearizer::LowerCheckedTruncateTaggedToWord32(Node* node,
+ Node* frame_state,
+ Node* effect,
+ Node* control) {
+ Node* value = node->InputAt(0);
+
+ Node* check = ObjectIsSmi(value);
+ Node* branch =
+ graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
+
+ // In the Smi case, just convert to int32.
+ Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
+ Node* etrue = effect;
+ Node* vtrue = ChangeSmiToInt32(value);
+
+ // Otherwise, check that it's a heap number or oddball and truncate the value
+ // to int32.
+ Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
+ ValueEffectControl false_state = BuildCheckedHeapNumberOrOddballToFloat64(
+ value, frame_state, effect, if_false);
+ false_state.value =
+ graph()->NewNode(machine()->TruncateFloat64ToWord32(), false_state.value);
+
+ Node* merge =
+ graph()->NewNode(common()->Merge(2), if_true, false_state.control);
+ Node* effect_phi = graph()->NewNode(common()->EffectPhi(2), etrue,
+ false_state.effect, merge);
+ Node* result =
+ graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), vtrue,
+ false_state.value, merge);
+
+ return ValueEffectControl(result, effect_phi, merge);
+}
+
+EffectControlLinearizer::ValueEffectControl
EffectControlLinearizer::LowerObjectIsCallable(Node* node, Node* effect,
Node* control) {
Node* value = node->InputAt(0);
« no previous file with comments | « src/compiler/effect-control-linearizer.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698