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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 case IrOpcode::kStoreElement: { | 914 case IrOpcode::kStoreElement: { |
915 ElementAccess access = ElementAccessOf(node->op()); | 915 ElementAccess access = ElementAccessOf(node->op()); |
916 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); // base | 916 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); // base |
917 ProcessInput(node, 1, kMachInt32); // index | 917 ProcessInput(node, 1, kMachInt32); // index |
918 ProcessInput(node, 2, access.machine_type); // value | 918 ProcessInput(node, 2, access.machine_type); // value |
919 ProcessRemainingInputs(node, 3); | 919 ProcessRemainingInputs(node, 3); |
920 SetOutput(node, 0); | 920 SetOutput(node, 0); |
921 if (lower()) lowering->DoStoreElement(node); | 921 if (lower()) lowering->DoStoreElement(node); |
922 break; | 922 break; |
923 } | 923 } |
| 924 case IrOpcode::kObjectIsNumber: { |
| 925 ProcessInput(node, 0, kMachAnyTagged); |
| 926 SetOutput(node, kRepBit | kTypeBool); |
| 927 if (lower()) lowering->DoObjectIsNumber(node); |
| 928 break; |
| 929 } |
924 case IrOpcode::kObjectIsSmi: { | 930 case IrOpcode::kObjectIsSmi: { |
925 ProcessInput(node, 0, kMachAnyTagged); | 931 ProcessInput(node, 0, kMachAnyTagged); |
926 SetOutput(node, kRepBit | kTypeBool); | 932 SetOutput(node, kRepBit | kTypeBool); |
927 if (lower()) { | 933 if (lower()) lowering->DoObjectIsSmi(node); |
928 Node* is_tagged = jsgraph_->graph()->NewNode( | |
929 jsgraph_->machine()->WordAnd(), node->InputAt(0), | |
930 jsgraph_->IntPtrConstant(kSmiTagMask)); | |
931 Node* is_smi = jsgraph_->graph()->NewNode( | |
932 jsgraph_->machine()->WordEqual(), is_tagged, | |
933 jsgraph_->IntPtrConstant(kSmiTag)); | |
934 DeferReplacement(node, is_smi); | |
935 } | |
936 break; | 934 break; |
937 } | 935 } |
938 | 936 |
939 //------------------------------------------------------------------ | 937 //------------------------------------------------------------------ |
940 // Machine-level operators. | 938 // Machine-level operators. |
941 //------------------------------------------------------------------ | 939 //------------------------------------------------------------------ |
942 case IrOpcode::kLoad: { | 940 case IrOpcode::kLoad: { |
943 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? | 941 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? |
944 MachineTypeUnion tBase = kRepTagged | kMachPtr; | 942 MachineTypeUnion tBase = kRepTagged | kMachPtr; |
945 LoadRepresentation rep = OpParameter<LoadRepresentation>(node); | 943 LoadRepresentation rep = OpParameter<LoadRepresentation>(node); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 Type* type = NodeProperties::GetType(node->InputAt(2)); | 1338 Type* type = NodeProperties::GetType(node->InputAt(2)); |
1341 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 1339 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
1342 NodeProperties::ChangeOp( | 1340 NodeProperties::ChangeOp( |
1343 node, machine()->Store(StoreRepresentation( | 1341 node, machine()->Store(StoreRepresentation( |
1344 access.machine_type, | 1342 access.machine_type, |
1345 ComputeWriteBarrierKind(access.base_is_tagged, | 1343 ComputeWriteBarrierKind(access.base_is_tagged, |
1346 access.machine_type, type)))); | 1344 access.machine_type, type)))); |
1347 } | 1345 } |
1348 | 1346 |
1349 | 1347 |
| 1348 void SimplifiedLowering::DoObjectIsNumber(Node* node) { |
| 1349 Node* input = NodeProperties::GetValueInput(node, 0); |
| 1350 // TODO(bmeurer): Optimize somewhat based on input type. |
| 1351 Node* check = |
| 1352 graph()->NewNode(machine()->WordEqual(), |
| 1353 graph()->NewNode(machine()->WordAnd(), input, |
| 1354 jsgraph()->IntPtrConstant(kSmiTagMask)), |
| 1355 jsgraph()->IntPtrConstant(kSmiTag)); |
| 1356 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
| 1357 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 1358 Node* vtrue = jsgraph()->Int32Constant(1); |
| 1359 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 1360 Node* vfalse = graph()->NewNode( |
| 1361 machine()->WordEqual(), |
| 1362 graph()->NewNode( |
| 1363 machine()->Load(kMachAnyTagged), input, |
| 1364 jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), |
| 1365 graph()->start(), if_false), |
| 1366 jsgraph()->HeapConstant(isolate()->factory()->heap_number_map())); |
| 1367 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 1368 node->ReplaceInput(0, vtrue); |
| 1369 node->AppendInput(graph()->zone(), vfalse); |
| 1370 node->AppendInput(graph()->zone(), control); |
| 1371 NodeProperties::ChangeOp(node, common()->Phi(kMachBool, 2)); |
| 1372 } |
| 1373 |
| 1374 |
| 1375 void SimplifiedLowering::DoObjectIsSmi(Node* node) { |
| 1376 node->ReplaceInput(0, |
| 1377 graph()->NewNode(machine()->WordAnd(), node->InputAt(0), |
| 1378 jsgraph()->IntPtrConstant(kSmiTagMask))); |
| 1379 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag)); |
| 1380 NodeProperties::ChangeOp(node, machine()->WordEqual()); |
| 1381 } |
| 1382 |
| 1383 |
1350 Node* SimplifiedLowering::StringComparison(Node* node) { | 1384 Node* SimplifiedLowering::StringComparison(Node* node) { |
1351 Operator::Properties properties = node->op()->properties(); | 1385 Operator::Properties properties = node->op()->properties(); |
1352 Callable callable = CodeFactory::StringCompare(isolate()); | 1386 Callable callable = CodeFactory::StringCompare(isolate()); |
1353 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; | 1387 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; |
1354 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 1388 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
1355 isolate(), zone(), callable.descriptor(), 0, flags, properties); | 1389 isolate(), zone(), callable.descriptor(), 0, flags, properties); |
1356 return graph()->NewNode( | 1390 return graph()->NewNode( |
1357 common()->Call(desc), jsgraph()->HeapConstant(callable.code()), | 1391 common()->Call(desc), jsgraph()->HeapConstant(callable.code()), |
1358 NodeProperties::GetValueInput(node, 0), | 1392 NodeProperties::GetValueInput(node, 0), |
1359 NodeProperties::GetValueInput(node, 1), jsgraph()->NoContextConstant(), | 1393 NodeProperties::GetValueInput(node, 1), jsgraph()->NoContextConstant(), |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 ReplaceEffectUses(node, comparison); | 1698 ReplaceEffectUses(node, comparison); |
1665 node->ReplaceInput(0, comparison); | 1699 node->ReplaceInput(0, comparison); |
1666 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1700 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1667 node->TrimInputCount(2); | 1701 node->TrimInputCount(2); |
1668 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); | 1702 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); |
1669 } | 1703 } |
1670 | 1704 |
1671 } // namespace compiler | 1705 } // namespace compiler |
1672 } // namespace internal | 1706 } // namespace internal |
1673 } // namespace v8 | 1707 } // namespace v8 |
OLD | NEW |