| 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 case IrOpcode::kStringLessThanOrEqual: { | 776 case IrOpcode::kStringLessThanOrEqual: { |
| 777 VisitBinop(node, kMachAnyTagged, kRepBit); | 777 VisitBinop(node, kMachAnyTagged, kRepBit); |
| 778 if (lower()) lowering->DoStringLessThanOrEqual(node); | 778 if (lower()) lowering->DoStringLessThanOrEqual(node); |
| 779 break; | 779 break; |
| 780 } | 780 } |
| 781 case IrOpcode::kStringAdd: { | 781 case IrOpcode::kStringAdd: { |
| 782 VisitBinop(node, kMachAnyTagged, kMachAnyTagged); | 782 VisitBinop(node, kMachAnyTagged, kMachAnyTagged); |
| 783 if (lower()) lowering->DoStringAdd(node); | 783 if (lower()) lowering->DoStringAdd(node); |
| 784 break; | 784 break; |
| 785 } | 785 } |
| 786 case IrOpcode::kAllocate: { |
| 787 ProcessInput(node, 0, kMachAnyTagged); |
| 788 ProcessRemainingInputs(node, 1); |
| 789 SetOutput(node, kMachAnyTagged); |
| 790 if (lower()) lowering->DoAllocate(node); |
| 791 break; |
| 792 } |
| 786 case IrOpcode::kLoadField: { | 793 case IrOpcode::kLoadField: { |
| 787 FieldAccess access = FieldAccessOf(node->op()); | 794 FieldAccess access = FieldAccessOf(node->op()); |
| 788 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); | 795 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); |
| 789 ProcessRemainingInputs(node, 1); | 796 ProcessRemainingInputs(node, 1); |
| 790 SetOutput(node, access.machine_type); | 797 SetOutput(node, access.machine_type); |
| 791 if (lower()) lowering->DoLoadField(node); | 798 if (lower()) lowering->DoLoadField(node); |
| 792 break; | 799 break; |
| 793 } | 800 } |
| 794 case IrOpcode::kStoreField: { | 801 case IrOpcode::kStoreField: { |
| 795 FieldAccess access = FieldAccessOf(node->op()); | 802 FieldAccess access = FieldAccessOf(node->op()); |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 RepresentationOf(representation) == kRepTagged) { | 1159 RepresentationOf(representation) == kRepTagged) { |
| 1153 // Write barriers are only for writes into heap objects (i.e. tagged base). | 1160 // Write barriers are only for writes into heap objects (i.e. tagged base). |
| 1154 return kFullWriteBarrier; | 1161 return kFullWriteBarrier; |
| 1155 } | 1162 } |
| 1156 return kNoWriteBarrier; | 1163 return kNoWriteBarrier; |
| 1157 } | 1164 } |
| 1158 | 1165 |
| 1159 } // namespace | 1166 } // namespace |
| 1160 | 1167 |
| 1161 | 1168 |
| 1169 void SimplifiedLowering::DoAllocate(Node* node) { |
| 1170 PretenureFlag pretenure = OpParameter<PretenureFlag>(node->op()); |
| 1171 AllocationSpace space = pretenure == TENURED ? OLD_SPACE : NEW_SPACE; |
| 1172 Runtime::FunctionId f = Runtime::kAllocateInTargetSpace; |
| 1173 Operator::Properties props = node->op()->properties(); |
| 1174 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(zone(), f, 2, props); |
| 1175 node->set_op(common()->Call(desc)); |
| 1176 ExternalReference ref(f, jsgraph()->isolate()); |
| 1177 int32_t flags = AllocateTargetSpace::encode(space); |
| 1178 node->InsertInput(graph()->zone(), 0, jsgraph()->CEntryStubConstant(1)); |
| 1179 node->InsertInput(graph()->zone(), 2, jsgraph()->SmiConstant(flags)); |
| 1180 node->InsertInput(graph()->zone(), 3, jsgraph()->ExternalConstant(ref)); |
| 1181 node->InsertInput(graph()->zone(), 4, jsgraph()->Int32Constant(2)); |
| 1182 node->InsertInput(graph()->zone(), 5, jsgraph()->NoContextConstant()); |
| 1183 } |
| 1184 |
| 1185 |
| 1162 void SimplifiedLowering::DoLoadField(Node* node) { | 1186 void SimplifiedLowering::DoLoadField(Node* node) { |
| 1163 const FieldAccess& access = FieldAccessOf(node->op()); | 1187 const FieldAccess& access = FieldAccessOf(node->op()); |
| 1164 node->set_op(machine()->Load(access.machine_type)); | 1188 node->set_op(machine()->Load(access.machine_type)); |
| 1165 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); | 1189 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); |
| 1166 node->InsertInput(graph()->zone(), 1, offset); | 1190 node->InsertInput(graph()->zone(), 1, offset); |
| 1167 } | 1191 } |
| 1168 | 1192 |
| 1169 | 1193 |
| 1170 void SimplifiedLowering::DoStoreField(Node* node) { | 1194 void SimplifiedLowering::DoStoreField(Node* node) { |
| 1171 const FieldAccess& access = FieldAccessOf(node->op()); | 1195 const FieldAccess& access = FieldAccessOf(node->op()); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 node->set_op(common()->Call(desc)); | 1320 node->set_op(common()->Call(desc)); |
| 1297 node->InsertInput(graph()->zone(), 0, | 1321 node->InsertInput(graph()->zone(), 0, |
| 1298 jsgraph()->HeapConstant(callable.code())); | 1322 jsgraph()->HeapConstant(callable.code())); |
| 1299 node->AppendInput(graph()->zone(), jsgraph()->UndefinedConstant()); | 1323 node->AppendInput(graph()->zone(), jsgraph()->UndefinedConstant()); |
| 1300 node->AppendInput(graph()->zone(), graph()->start()); | 1324 node->AppendInput(graph()->zone(), graph()->start()); |
| 1301 node->AppendInput(graph()->zone(), graph()->start()); | 1325 node->AppendInput(graph()->zone(), graph()->start()); |
| 1302 } | 1326 } |
| 1303 | 1327 |
| 1304 | 1328 |
| 1305 Node* SimplifiedLowering::StringComparison(Node* node, bool requires_ordering) { | 1329 Node* SimplifiedLowering::StringComparison(Node* node, bool requires_ordering) { |
| 1306 CEntryStub stub(jsgraph()->isolate(), 1); | |
| 1307 Runtime::FunctionId f = | 1330 Runtime::FunctionId f = |
| 1308 requires_ordering ? Runtime::kStringCompareRT : Runtime::kStringEquals; | 1331 requires_ordering ? Runtime::kStringCompareRT : Runtime::kStringEquals; |
| 1309 ExternalReference ref(f, jsgraph()->isolate()); | 1332 ExternalReference ref(f, jsgraph()->isolate()); |
| 1310 Operator::Properties props = node->op()->properties(); | 1333 Operator::Properties props = node->op()->properties(); |
| 1311 // TODO(mstarzinger): We should call StringCompareStub here instead, once an | 1334 // TODO(mstarzinger): We should call StringCompareStub here instead, once an |
| 1312 // interface descriptor is available for it. | 1335 // interface descriptor is available for it. |
| 1313 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(zone(), f, 2, props); | 1336 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(zone(), f, 2, props); |
| 1314 return graph()->NewNode(common()->Call(desc), | 1337 return graph()->NewNode(common()->Call(desc), |
| 1315 jsgraph()->HeapConstant(stub.GetCode()), | 1338 jsgraph()->CEntryStubConstant(1), |
| 1316 NodeProperties::GetValueInput(node, 0), | 1339 NodeProperties::GetValueInput(node, 0), |
| 1317 NodeProperties::GetValueInput(node, 1), | 1340 NodeProperties::GetValueInput(node, 1), |
| 1318 jsgraph()->ExternalConstant(ref), | 1341 jsgraph()->ExternalConstant(ref), |
| 1319 jsgraph()->Int32Constant(2), | 1342 jsgraph()->Int32Constant(2), |
| 1320 jsgraph()->UndefinedConstant()); | 1343 jsgraph()->NoContextConstant()); |
| 1321 } | 1344 } |
| 1322 | 1345 |
| 1323 | 1346 |
| 1324 Node* SimplifiedLowering::Int32Div(Node* const node) { | 1347 Node* SimplifiedLowering::Int32Div(Node* const node) { |
| 1325 Int32BinopMatcher m(node); | 1348 Int32BinopMatcher m(node); |
| 1326 Node* const zero = jsgraph()->Int32Constant(0); | 1349 Node* const zero = jsgraph()->Int32Constant(0); |
| 1327 Node* const minus_one = jsgraph()->Int32Constant(-1); | 1350 Node* const minus_one = jsgraph()->Int32Constant(-1); |
| 1328 Node* const lhs = m.left().node(); | 1351 Node* const lhs = m.left().node(); |
| 1329 Node* const rhs = m.right().node(); | 1352 Node* const rhs = m.right().node(); |
| 1330 | 1353 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 | 1609 |
| 1587 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1610 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
| 1588 node->set_op(machine()->IntLessThanOrEqual()); | 1611 node->set_op(machine()->IntLessThanOrEqual()); |
| 1589 node->ReplaceInput(0, StringComparison(node, true)); | 1612 node->ReplaceInput(0, StringComparison(node, true)); |
| 1590 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1613 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
| 1591 } | 1614 } |
| 1592 | 1615 |
| 1593 } // namespace compiler | 1616 } // namespace compiler |
| 1594 } // namespace internal | 1617 } // namespace internal |
| 1595 } // namespace v8 | 1618 } // namespace v8 |
| OLD | NEW |