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/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 MachineType use_type = | 348 MachineType use_type = |
349 static_cast<MachineType>((use & kTypeMask) | propagate); | 349 static_cast<MachineType>((use & kTypeMask) | propagate); |
350 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); | 350 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); |
351 ++iter, --values) { | 351 ++iter, --values) { |
352 // TODO(titzer): it'd be nice to have distinguished edge kinds here. | 352 // TODO(titzer): it'd be nice to have distinguished edge kinds here. |
353 ProcessInput(node, iter.index(), values > 0 ? use_type : 0); | 353 ProcessInput(node, iter.index(), values > 0 ? use_type : 0); |
354 } | 354 } |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
| 358 void VisitIsSmi(Node* node) { |
| 359 ProcessInput(node, 0, kMachAnyTagged); |
| 360 if (lower()) { |
| 361 Node* is_tagged = jsgraph_->graph()->NewNode( |
| 362 jsgraph_->machine()->WordAnd(), node->InputAt(0), |
| 363 jsgraph_->Int32Constant(static_cast<int>(kSmiTagMask))); |
| 364 Node* is_smi = jsgraph_->graph()->NewNode( |
| 365 jsgraph_->machine()->WordEqual(), is_tagged, |
| 366 jsgraph_->Int32Constant(kSmiTag)); |
| 367 DeferReplacement(node, is_smi); |
| 368 } |
| 369 SetOutput(node, kRepBit | kTypeBool); |
| 370 } |
| 371 |
| 372 void VisitIsNonNegativeSmi(Node* node) { |
| 373 ProcessInput(node, 0, kMachAnyTagged); |
| 374 if (lower()) { |
| 375 Node* is_tagged = jsgraph_->graph()->NewNode( |
| 376 jsgraph_->machine()->WordAnd(), node->InputAt(0), |
| 377 jsgraph_->Int32Constant(static_cast<int>(kSmiTagMask))); |
| 378 Node* is_smi = jsgraph_->graph()->NewNode( |
| 379 jsgraph_->machine()->WordEqual(), is_tagged, |
| 380 jsgraph_->Int32Constant(kSmiTag)); |
| 381 Node* is_non_neg = jsgraph_->graph()->NewNode( |
| 382 jsgraph_->machine()->Is32() |
| 383 ? jsgraph_->machine()->Int32LessThanOrEqual() |
| 384 : jsgraph_->machine()->Int64LessThanOrEqual(), |
| 385 jsgraph_->Int32Constant(0), node->InputAt(0)); |
| 386 Node* is_non_neg_smi = jsgraph_->graph()->NewNode( |
| 387 jsgraph_->machine()->Word32And(), is_smi, is_non_neg); |
| 388 DeferReplacement(node, is_non_neg_smi); |
| 389 } |
| 390 SetOutput(node, kRepBit | kTypeBool); |
| 391 } |
| 392 |
358 const Operator* Int32Op(Node* node) { | 393 const Operator* Int32Op(Node* node) { |
359 return changer_->Int32OperatorFor(node->opcode()); | 394 return changer_->Int32OperatorFor(node->opcode()); |
360 } | 395 } |
361 | 396 |
362 const Operator* Uint32Op(Node* node) { | 397 const Operator* Uint32Op(Node* node) { |
363 return changer_->Uint32OperatorFor(node->opcode()); | 398 return changer_->Uint32OperatorFor(node->opcode()); |
364 } | 399 } |
365 | 400 |
366 const Operator* Float64Op(Node* node) { | 401 const Operator* Float64Op(Node* node) { |
367 return changer_->Float64OperatorFor(node->opcode()); | 402 return changer_->Float64OperatorFor(node->opcode()); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 case IrOpcode::kFloat64LessThanOrEqual: | 861 case IrOpcode::kFloat64LessThanOrEqual: |
827 return VisitFloat64Cmp(node); | 862 return VisitFloat64Cmp(node); |
828 case IrOpcode::kLoadStackPointer: | 863 case IrOpcode::kLoadStackPointer: |
829 return VisitLeaf(node, kMachPtr); | 864 return VisitLeaf(node, kMachPtr); |
830 case IrOpcode::kStateValues: | 865 case IrOpcode::kStateValues: |
831 for (int i = 0; i < node->InputCount(); i++) { | 866 for (int i = 0; i < node->InputCount(); i++) { |
832 ProcessInput(node, i, kTypeAny); | 867 ProcessInput(node, i, kTypeAny); |
833 } | 868 } |
834 SetOutput(node, kMachAnyTagged); | 869 SetOutput(node, kMachAnyTagged); |
835 break; | 870 break; |
| 871 case IrOpcode::kIsSmi: |
| 872 return VisitIsSmi(node); |
| 873 case IrOpcode::kIsNonNegativeSmi: |
| 874 return VisitIsNonNegativeSmi(node); |
836 default: | 875 default: |
837 VisitInputs(node); | 876 VisitInputs(node); |
838 break; | 877 break; |
839 } | 878 } |
840 } | 879 } |
841 | 880 |
842 void DeferReplacement(Node* node, Node* replacement) { | 881 void DeferReplacement(Node* node, Node* replacement) { |
843 if (FLAG_trace_representation) { | 882 if (FLAG_trace_representation) { |
844 TRACE(("defer replacement #%d:%s with #%d:%s\n", node->id(), | 883 TRACE(("defer replacement #%d:%s with #%d:%s\n", node->id(), |
845 node->op()->mnemonic(), replacement->id(), | 884 node->op()->mnemonic(), replacement->id(), |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 } | 979 } |
941 return kNoWriteBarrier; | 980 return kNoWriteBarrier; |
942 } | 981 } |
943 | 982 |
944 | 983 |
945 void SimplifiedLowering::DoLoadField(Node* node) { | 984 void SimplifiedLowering::DoLoadField(Node* node) { |
946 const FieldAccess& access = FieldAccessOf(node->op()); | 985 const FieldAccess& access = FieldAccessOf(node->op()); |
947 node->set_op(machine()->Load(access.machine_type)); | 986 node->set_op(machine()->Load(access.machine_type)); |
948 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); | 987 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); |
949 node->InsertInput(zone(), 1, offset); | 988 node->InsertInput(zone(), 1, offset); |
950 node->AppendInput(zone(), graph()->start()); | |
951 } | 989 } |
952 | 990 |
953 | 991 |
954 void SimplifiedLowering::DoStoreField(Node* node) { | 992 void SimplifiedLowering::DoStoreField(Node* node) { |
955 const FieldAccess& access = FieldAccessOf(node->op()); | 993 const FieldAccess& access = FieldAccessOf(node->op()); |
956 WriteBarrierKind kind = ComputeWriteBarrierKind( | 994 WriteBarrierKind kind = ComputeWriteBarrierKind( |
957 access.base_is_tagged, access.machine_type, access.type); | 995 access.base_is_tagged, access.machine_type, access.type); |
958 node->set_op( | 996 node->set_op( |
959 machine()->Store(StoreRepresentation(access.machine_type, kind))); | 997 machine()->Store(StoreRepresentation(access.machine_type, kind))); |
960 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); | 998 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1172 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
1135 node->set_op(machine()->IntLessThanOrEqual()); | 1173 node->set_op(machine()->IntLessThanOrEqual()); |
1136 node->ReplaceInput(0, StringComparison(node, true)); | 1174 node->ReplaceInput(0, StringComparison(node, true)); |
1137 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1175 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1138 } | 1176 } |
1139 | 1177 |
1140 | 1178 |
1141 } // namespace compiler | 1179 } // namespace compiler |
1142 } // namespace internal | 1180 } // namespace internal |
1143 } // namespace v8 | 1181 } // namespace v8 |
OLD | NEW |