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 #include "src/compiler/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/js-typed-lowering.h" | 7 #include "src/compiler/js-typed-lowering.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 509 |
510 | 510 |
511 Reduction JSTypedLowering::ReduceJSUnaryNot(Node* node) { | 511 Reduction JSTypedLowering::ReduceJSUnaryNot(Node* node) { |
512 Node* input = node->InputAt(0); | 512 Node* input = node->InputAt(0); |
513 Type* input_type = NodeProperties::GetBounds(input).upper; | 513 Type* input_type = NodeProperties::GetBounds(input).upper; |
514 if (input_type->Is(Type::Boolean())) { | 514 if (input_type->Is(Type::Boolean())) { |
515 // JSUnaryNot(x:boolean,context) => BooleanNot(x) | 515 // JSUnaryNot(x:boolean,context) => BooleanNot(x) |
516 node->set_op(simplified()->BooleanNot()); | 516 node->set_op(simplified()->BooleanNot()); |
517 node->TrimInputCount(1); | 517 node->TrimInputCount(1); |
518 return Changed(node); | 518 return Changed(node); |
| 519 } else if (input_type->Is(Type::OrderedNumber())) { |
| 520 // JSUnaryNot(x:number,context) => NumberEqual(x,#0) |
| 521 node->set_op(simplified()->NumberEqual()); |
| 522 node->ReplaceInput(1, jsgraph()->ZeroConstant()); |
| 523 DCHECK_EQ(2, node->InputCount()); |
| 524 return Changed(node); |
519 } | 525 } |
520 // JSUnaryNot(x,context) => BooleanNot(AnyToBoolean(x)) | 526 // JSUnaryNot(x,context) => BooleanNot(AnyToBoolean(x)) |
521 node->set_op(simplified()->BooleanNot()); | 527 node->set_op(simplified()->BooleanNot()); |
522 node->ReplaceInput(0, graph()->NewNode(simplified()->AnyToBoolean(), input)); | 528 node->ReplaceInput(0, graph()->NewNode(simplified()->AnyToBoolean(), input)); |
523 node->TrimInputCount(1); | 529 node->TrimInputCount(1); |
524 return Changed(node); | 530 return Changed(node); |
525 } | 531 } |
526 | 532 |
527 | 533 |
528 Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) { | 534 Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 } | 1030 } |
1025 | 1031 |
1026 | 1032 |
1027 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1033 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1028 return jsgraph()->machine(); | 1034 return jsgraph()->machine(); |
1029 } | 1035 } |
1030 | 1036 |
1031 } // namespace compiler | 1037 } // namespace compiler |
1032 } // namespace internal | 1038 } // namespace internal |
1033 } // namespace v8 | 1039 } // namespace v8 |
OLD | NEW |