Chromium Code Reviews| Index: src/compiler/representation-change.h |
| diff --git a/src/compiler/representation-change.h b/src/compiler/representation-change.h |
| index 3b6f183056fe57e4433f772b62e20b60df60f117..5e7a8d04c687fe8152a92e2484d9c20336e23e4d 100644 |
| --- a/src/compiler/representation-change.h |
| +++ b/src/compiler/representation-change.h |
| @@ -216,6 +216,37 @@ class RepresentationChanger { |
| } |
| } |
| + Node* GetTruncatedWord32For(Node* node, MachineTypeUnion output_type) { |
| + // Eagerly fold truncations for constants. |
| + switch (node->opcode()) { |
| + case IrOpcode::kInt32Constant: |
| + return node; // No change necessary. |
| + case IrOpcode::kFloat32Constant: |
| + return jsgraph()->Int32Constant( |
| + DoubleToInt32(OpParameter<float>(node))); |
| + case IrOpcode::kNumberConstant: |
| + case IrOpcode::kFloat64Constant: |
| + return jsgraph()->Int32Constant( |
| + DoubleToInt32(OpParameter<double>(node))); |
| + default: |
| + break; |
| + } |
| + // Select the correct X -> Word32 truncation operator. |
| + const Operator* op = NULL; |
| + if (output_type & kRepFloat64) { |
| + op = machine()->TruncateFloat64ToInt32(); |
|
Benedikt Meurer
2014/10/23 10:33:26
The op is always the same in the end, probably no
Jarin
2014/10/23 11:14:52
While that's true, I would prefer to keep this sep
|
| + } else if (output_type & kRepFloat32) { |
| + node = InsertChangeFloat32ToFloat64(node); |
| + op = machine()->TruncateFloat64ToInt32(); |
| + } else if (output_type & kRepTagged) { |
| + node = InsertChangeTaggedToFloat64(node); |
| + op = machine()->TruncateFloat64ToInt32(); |
| + } else { |
| + return TypeError(node, output_type, kRepWord32); |
| + } |
| + return jsgraph()->graph()->NewNode(op, node); |
| + } |
| + |
| Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type, |
| bool use_unsigned) { |
| // Eagerly fold representation changes for constants. |
| @@ -421,6 +452,11 @@ class RepresentationChanger { |
| node); |
| } |
| + Node* InsertChangeTaggedToFloat64(Node* node) { |
| + return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), |
| + node); |
| + } |
| + |
| JSGraph* jsgraph() { return jsgraph_; } |
| Isolate* isolate() { return isolate_; } |
| SimplifiedOperatorBuilder* simplified() { return simplified_; } |