| 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/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
| 7 #include "src/compiler/js-builtin-reducer.h" | 7 #include "src/compiler/js-builtin-reducer.h" |
| 8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
| 9 #include "src/compiler/node-aux-data-inl.h" | 9 #include "src/compiler/node-aux-data-inl.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 // TODO(jarin): Propagate frame state input from non-primitive input node to | 292 // TODO(jarin): Propagate frame state input from non-primitive input node to |
| 293 // JSToNumber node. | 293 // JSToNumber node. |
| 294 r.ConvertInputsToNumber(); | 294 r.ConvertInputsToNumber(); |
| 295 return r.ChangeToPureOperator(simplified()->NumberMultiply()); | 295 return r.ChangeToPureOperator(simplified()->NumberMultiply()); |
| 296 } | 296 } |
| 297 // TODO(turbofan): relax/remove the effects of this operator in other cases. | 297 // TODO(turbofan): relax/remove the effects of this operator in other cases. |
| 298 return NoChange(); | 298 return NoChange(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 | 301 |
| 302 Reduction JSTypedLowering::ReduceJSModulus(Node* node) { |
| 303 JSBinopReduction r(this, node); |
| 304 if (r.left_type()->Is(NodeProperties::GetBounds(node).upper)) { |
| 305 RelaxEffects(node); |
| 306 return Replace(r.left()); |
| 307 } |
| 308 if (r.BothInputsAre(Type::Primitive())) { |
| 309 r.ConvertInputsToNumber(); |
| 310 return r.ChangeToPureOperator(simplified()->NumberModulus()); |
| 311 } |
| 312 // TODO(turbofan): relax/remove the effects of this operator in other cases. |
| 313 return NoChange(); |
| 314 } |
| 315 |
| 316 |
| 302 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, | 317 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, |
| 303 const Operator* numberOp) { | 318 const Operator* numberOp) { |
| 304 JSBinopReduction r(this, node); | 319 JSBinopReduction r(this, node); |
| 305 if (r.BothInputsAre(Type::Primitive())) { | 320 if (r.BothInputsAre(Type::Primitive())) { |
| 306 r.ConvertInputsToNumber(); | 321 r.ConvertInputsToNumber(); |
| 307 return r.ChangeToPureOperator(numberOp); | 322 return r.ChangeToPureOperator(numberOp); |
| 308 } | 323 } |
| 309 #if 0 | 324 #if 0 |
| 310 // TODO(turbofan): General ToNumber disabled for now because: | 325 // TODO(turbofan): General ToNumber disabled for now because: |
| 311 // a) The inserted ToNumber operation screws up observability of valueOf. | 326 // a) The inserted ToNumber operation screws up observability of valueOf. |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 return ReduceI32Shift(node, false, machine()->Word32Shr()); | 765 return ReduceI32Shift(node, false, machine()->Word32Shr()); |
| 751 case IrOpcode::kJSAdd: | 766 case IrOpcode::kJSAdd: |
| 752 return ReduceJSAdd(node); | 767 return ReduceJSAdd(node); |
| 753 case IrOpcode::kJSSubtract: | 768 case IrOpcode::kJSSubtract: |
| 754 return ReduceNumberBinop(node, simplified()->NumberSubtract()); | 769 return ReduceNumberBinop(node, simplified()->NumberSubtract()); |
| 755 case IrOpcode::kJSMultiply: | 770 case IrOpcode::kJSMultiply: |
| 756 return ReduceJSMultiply(node); | 771 return ReduceJSMultiply(node); |
| 757 case IrOpcode::kJSDivide: | 772 case IrOpcode::kJSDivide: |
| 758 return ReduceNumberBinop(node, simplified()->NumberDivide()); | 773 return ReduceNumberBinop(node, simplified()->NumberDivide()); |
| 759 case IrOpcode::kJSModulus: | 774 case IrOpcode::kJSModulus: |
| 760 return ReduceNumberBinop(node, simplified()->NumberModulus()); | 775 return ReduceJSModulus(node); |
| 761 case IrOpcode::kJSUnaryNot: { | 776 case IrOpcode::kJSUnaryNot: { |
| 762 Reduction result = ReduceJSToBooleanInput(node->InputAt(0)); | 777 Reduction result = ReduceJSToBooleanInput(node->InputAt(0)); |
| 763 Node* value; | 778 Node* value; |
| 764 if (result.Changed()) { | 779 if (result.Changed()) { |
| 765 // JSUnaryNot(x:boolean) => BooleanNot(x) | 780 // JSUnaryNot(x:boolean) => BooleanNot(x) |
| 766 value = | 781 value = |
| 767 graph()->NewNode(simplified()->BooleanNot(), result.replacement()); | 782 graph()->NewNode(simplified()->BooleanNot(), result.replacement()); |
| 768 NodeProperties::ReplaceWithValue(node, value); | 783 NodeProperties::ReplaceWithValue(node, value); |
| 769 return Changed(value); | 784 return Changed(value); |
| 770 } else { | 785 } else { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 794 return JSBuiltinReducer(jsgraph()).Reduce(node); | 809 return JSBuiltinReducer(jsgraph()).Reduce(node); |
| 795 default: | 810 default: |
| 796 break; | 811 break; |
| 797 } | 812 } |
| 798 return NoChange(); | 813 return NoChange(); |
| 799 } | 814 } |
| 800 | 815 |
| 801 } // namespace compiler | 816 } // namespace compiler |
| 802 } // namespace internal | 817 } // namespace internal |
| 803 } // namespace v8 | 818 } // namespace v8 |
| OLD | NEW |