| 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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 RepresentationSelector selector(jsgraph(), zone_, &changer, | 1164 RepresentationSelector selector(jsgraph(), zone_, &changer, |
| 1165 source_positions_); | 1165 source_positions_); |
| 1166 selector.Run(this); | 1166 selector.Run(this); |
| 1167 } | 1167 } |
| 1168 | 1168 |
| 1169 | 1169 |
| 1170 namespace { | 1170 namespace { |
| 1171 | 1171 |
| 1172 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, | 1172 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, |
| 1173 MachineType representation, | 1173 MachineType representation, |
| 1174 Type* type) { | 1174 Type* field_type, Type* input_type) { |
| 1175 if (type->Is(Type::TaggedSigned())) { | 1175 if (field_type->Is(Type::TaggedSigned()) || |
| 1176 input_type->Is(Type::TaggedSigned())) { |
| 1176 // Write barriers are only for writes of heap objects. | 1177 // Write barriers are only for writes of heap objects. |
| 1177 return kNoWriteBarrier; | 1178 return kNoWriteBarrier; |
| 1178 } | 1179 } |
| 1179 if (base_is_tagged == kTaggedBase && | 1180 if (base_is_tagged == kTaggedBase && |
| 1180 RepresentationOf(representation) == kRepTagged) { | 1181 RepresentationOf(representation) == kRepTagged) { |
| 1181 // Write barriers are only for writes into heap objects (i.e. tagged base). | 1182 // Write barriers are only for writes into heap objects (i.e. tagged base). |
| 1182 return kFullWriteBarrier; | 1183 return kFullWriteBarrier; |
| 1183 } | 1184 } |
| 1184 return kNoWriteBarrier; | 1185 return kNoWriteBarrier; |
| 1185 } | 1186 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 const FieldAccess& access = FieldAccessOf(node->op()); | 1223 const FieldAccess& access = FieldAccessOf(node->op()); |
| 1223 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); | 1224 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); |
| 1224 node->InsertInput(graph()->zone(), 1, offset); | 1225 node->InsertInput(graph()->zone(), 1, offset); |
| 1225 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type)); | 1226 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type)); |
| 1226 } | 1227 } |
| 1227 | 1228 |
| 1228 | 1229 |
| 1229 void SimplifiedLowering::DoStoreField(Node* node) { | 1230 void SimplifiedLowering::DoStoreField(Node* node) { |
| 1230 const FieldAccess& access = FieldAccessOf(node->op()); | 1231 const FieldAccess& access = FieldAccessOf(node->op()); |
| 1231 Type* type = NodeProperties::GetType(node->InputAt(1)); | 1232 Type* type = NodeProperties::GetType(node->InputAt(1)); |
| 1232 WriteBarrierKind kind = | 1233 WriteBarrierKind kind = ComputeWriteBarrierKind( |
| 1233 ComputeWriteBarrierKind(access.base_is_tagged, access.machine_type, type); | 1234 access.base_is_tagged, access.machine_type, access.type, type); |
| 1234 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); | 1235 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); |
| 1235 node->InsertInput(graph()->zone(), 1, offset); | 1236 node->InsertInput(graph()->zone(), 1, offset); |
| 1236 NodeProperties::ChangeOp( | 1237 NodeProperties::ChangeOp( |
| 1237 node, machine()->Store(StoreRepresentation(access.machine_type, kind))); | 1238 node, machine()->Store(StoreRepresentation(access.machine_type, kind))); |
| 1238 } | 1239 } |
| 1239 | 1240 |
| 1240 | 1241 |
| 1241 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, | 1242 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, |
| 1242 Node* const key) { | 1243 Node* const key) { |
| 1243 Node* index = key; | 1244 Node* index = key; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 1332 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
| 1332 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type)); | 1333 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type)); |
| 1333 } | 1334 } |
| 1334 | 1335 |
| 1335 | 1336 |
| 1336 void SimplifiedLowering::DoStoreElement(Node* node) { | 1337 void SimplifiedLowering::DoStoreElement(Node* node) { |
| 1337 const ElementAccess& access = ElementAccessOf(node->op()); | 1338 const ElementAccess& access = ElementAccessOf(node->op()); |
| 1338 Type* type = NodeProperties::GetType(node->InputAt(2)); | 1339 Type* type = NodeProperties::GetType(node->InputAt(2)); |
| 1339 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 1340 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
| 1340 NodeProperties::ChangeOp( | 1341 NodeProperties::ChangeOp( |
| 1341 node, machine()->Store(StoreRepresentation( | 1342 node, |
| 1342 access.machine_type, | 1343 machine()->Store(StoreRepresentation( |
| 1343 ComputeWriteBarrierKind(access.base_is_tagged, | 1344 access.machine_type, |
| 1344 access.machine_type, type)))); | 1345 ComputeWriteBarrierKind(access.base_is_tagged, access.machine_type, |
| 1346 access.type, type)))); |
| 1345 } | 1347 } |
| 1346 | 1348 |
| 1347 | 1349 |
| 1348 void SimplifiedLowering::DoObjectIsNumber(Node* node) { | 1350 void SimplifiedLowering::DoObjectIsNumber(Node* node) { |
| 1349 Node* input = NodeProperties::GetValueInput(node, 0); | 1351 Node* input = NodeProperties::GetValueInput(node, 0); |
| 1350 // TODO(bmeurer): Optimize somewhat based on input type. | 1352 // TODO(bmeurer): Optimize somewhat based on input type. |
| 1351 Node* check = | 1353 Node* check = |
| 1352 graph()->NewNode(machine()->WordEqual(), | 1354 graph()->NewNode(machine()->WordEqual(), |
| 1353 graph()->NewNode(machine()->WordAnd(), input, | 1355 graph()->NewNode(machine()->WordAnd(), input, |
| 1354 jsgraph()->IntPtrConstant(kSmiTagMask)), | 1356 jsgraph()->IntPtrConstant(kSmiTagMask)), |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 ReplaceEffectUses(node, comparison); | 1700 ReplaceEffectUses(node, comparison); |
| 1699 node->ReplaceInput(0, comparison); | 1701 node->ReplaceInput(0, comparison); |
| 1700 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1702 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
| 1701 node->TrimInputCount(2); | 1703 node->TrimInputCount(2); |
| 1702 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); | 1704 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); |
| 1703 } | 1705 } |
| 1704 | 1706 |
| 1705 } // namespace compiler | 1707 } // namespace compiler |
| 1706 } // namespace internal | 1708 } // namespace internal |
| 1707 } // namespace v8 | 1709 } // namespace v8 |
| OLD | NEW |