OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_ | 5 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_ |
6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_ | 6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_ |
7 | 7 |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 289 } |
290 | 290 |
291 Node* GetBitRepresentationFor(Node* node, MachineTypeUnion output_type) { | 291 Node* GetBitRepresentationFor(Node* node, MachineTypeUnion output_type) { |
292 // Eagerly fold representation changes for constants. | 292 // Eagerly fold representation changes for constants. |
293 switch (node->opcode()) { | 293 switch (node->opcode()) { |
294 case IrOpcode::kInt32Constant: { | 294 case IrOpcode::kInt32Constant: { |
295 int32_t value = OpParameter<int32_t>(node); | 295 int32_t value = OpParameter<int32_t>(node); |
296 if (value == 0 || value == 1) return node; | 296 if (value == 0 || value == 1) return node; |
297 return jsgraph()->Int32Constant(1); // value != 0 | 297 return jsgraph()->Int32Constant(1); // value != 0 |
298 } | 298 } |
| 299 case IrOpcode::kNumberConstant: { |
| 300 double value = OpParameter<double>(node); |
| 301 if (std::isnan(value) || value == 0.0) { |
| 302 return jsgraph()->Int32Constant(0); |
| 303 } |
| 304 return jsgraph()->Int32Constant(1); |
| 305 } |
299 case IrOpcode::kHeapConstant: { | 306 case IrOpcode::kHeapConstant: { |
300 Handle<Object> handle = OpParameter<Unique<Object> >(node).handle(); | 307 Handle<Object> handle = OpParameter<Unique<Object> >(node).handle(); |
301 DCHECK(*handle == isolate()->heap()->true_value() || | 308 DCHECK(*handle == isolate()->heap()->true_value() || |
302 *handle == isolate()->heap()->false_value()); | 309 *handle == isolate()->heap()->false_value()); |
303 return jsgraph()->Int32Constant( | 310 return jsgraph()->Int32Constant( |
304 *handle == isolate()->heap()->true_value() ? 1 : 0); | 311 *handle == isolate()->heap()->true_value() ? 1 : 0); |
305 } | 312 } |
306 default: | 313 default: |
307 break; | 314 break; |
308 } | 315 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 Isolate* isolate() { return isolate_; } | 468 Isolate* isolate() { return isolate_; } |
462 SimplifiedOperatorBuilder* simplified() { return simplified_; } | 469 SimplifiedOperatorBuilder* simplified() { return simplified_; } |
463 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } | 470 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } |
464 }; | 471 }; |
465 | 472 |
466 } // namespace compiler | 473 } // namespace compiler |
467 } // namespace internal | 474 } // namespace internal |
468 } // namespace v8 | 475 } // namespace v8 |
469 | 476 |
470 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ | 477 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ |
OLD | NEW |