| 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 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 Node* shift_amount = jsgraph()->Int32Constant(kSmiTagSize + kSmiShiftSize); | 1128 Node* shift_amount = jsgraph()->Int32Constant(kSmiTagSize + kSmiShiftSize); |
| 1129 return graph()->NewNode(machine()->WordShl(), node, shift_amount); | 1129 return graph()->NewNode(machine()->WordShl(), node, shift_amount); |
| 1130 } | 1130 } |
| 1131 | 1131 |
| 1132 | 1132 |
| 1133 Node* SimplifiedLowering::OffsetMinusTagConstant(int32_t offset) { | 1133 Node* SimplifiedLowering::OffsetMinusTagConstant(int32_t offset) { |
| 1134 return jsgraph()->Int32Constant(offset - kHeapObjectTag); | 1134 return jsgraph()->Int32Constant(offset - kHeapObjectTag); |
| 1135 } | 1135 } |
| 1136 | 1136 |
| 1137 | 1137 |
| 1138 static WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, | 1138 WriteBarrierKind SimplifiedLowering::ComputeWriteBarrierKind( |
| 1139 MachineType representation, | 1139 BaseTaggedness base_is_tagged, MachineType representation, Node* value) { |
| 1140 Type* type) { | |
| 1141 // TODO(turbofan): skip write barriers for Smis, etc. | 1140 // TODO(turbofan): skip write barriers for Smis, etc. |
| 1141 if (machine()->Is64() && value->opcode() == IrOpcode::kChangeInt32ToTagged) { |
| 1142 // TODO(bmeurer): Remove this hack once we have a way to represent "sminess" |
| 1143 // of values, either in types or representations. |
| 1144 return kNoWriteBarrier; |
| 1145 } |
| 1142 if (base_is_tagged == kTaggedBase && | 1146 if (base_is_tagged == kTaggedBase && |
| 1143 RepresentationOf(representation) == kRepTagged) { | 1147 RepresentationOf(representation) == kRepTagged) { |
| 1144 // Write barriers are only for writes into heap objects (i.e. tagged base). | 1148 // Write barriers are only for writes into heap objects (i.e. tagged base). |
| 1145 return kFullWriteBarrier; | 1149 return kFullWriteBarrier; |
| 1146 } | 1150 } |
| 1147 return kNoWriteBarrier; | 1151 return kNoWriteBarrier; |
| 1148 } | 1152 } |
| 1149 | 1153 |
| 1150 | 1154 |
| 1151 void SimplifiedLowering::DoLoadField(Node* node) { | 1155 void SimplifiedLowering::DoLoadField(Node* node) { |
| 1152 const FieldAccess& access = FieldAccessOf(node->op()); | 1156 const FieldAccess& access = FieldAccessOf(node->op()); |
| 1153 node->set_op(machine()->Load(access.machine_type)); | 1157 node->set_op(machine()->Load(access.machine_type)); |
| 1154 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); | 1158 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); |
| 1155 node->InsertInput(graph()->zone(), 1, offset); | 1159 node->InsertInput(graph()->zone(), 1, offset); |
| 1156 } | 1160 } |
| 1157 | 1161 |
| 1158 | 1162 |
| 1159 void SimplifiedLowering::DoStoreField(Node* node) { | 1163 void SimplifiedLowering::DoStoreField(Node* node) { |
| 1160 const FieldAccess& access = FieldAccessOf(node->op()); | 1164 const FieldAccess& access = FieldAccessOf(node->op()); |
| 1161 WriteBarrierKind kind = ComputeWriteBarrierKind( | 1165 WriteBarrierKind kind = ComputeWriteBarrierKind( |
| 1162 access.base_is_tagged, access.machine_type, access.type); | 1166 access.base_is_tagged, access.machine_type, node->InputAt(1)); |
| 1163 node->set_op( | 1167 node->set_op( |
| 1164 machine()->Store(StoreRepresentation(access.machine_type, kind))); | 1168 machine()->Store(StoreRepresentation(access.machine_type, kind))); |
| 1165 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); | 1169 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); |
| 1166 node->InsertInput(graph()->zone(), 1, offset); | 1170 node->InsertInput(graph()->zone(), 1, offset); |
| 1167 } | 1171 } |
| 1168 | 1172 |
| 1169 | 1173 |
| 1170 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, | 1174 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, |
| 1171 Node* const key) { | 1175 Node* const key) { |
| 1172 Node* index = key; | 1176 Node* index = key; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 node->set_op(machine()->Load(access.machine_type)); | 1264 node->set_op(machine()->Load(access.machine_type)); |
| 1261 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 1265 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
| 1262 } | 1266 } |
| 1263 | 1267 |
| 1264 | 1268 |
| 1265 void SimplifiedLowering::DoStoreElement(Node* node) { | 1269 void SimplifiedLowering::DoStoreElement(Node* node) { |
| 1266 const ElementAccess& access = ElementAccessOf(node->op()); | 1270 const ElementAccess& access = ElementAccessOf(node->op()); |
| 1267 node->set_op(machine()->Store(StoreRepresentation( | 1271 node->set_op(machine()->Store(StoreRepresentation( |
| 1268 access.machine_type, | 1272 access.machine_type, |
| 1269 ComputeWriteBarrierKind(access.base_is_tagged, access.machine_type, | 1273 ComputeWriteBarrierKind(access.base_is_tagged, access.machine_type, |
| 1270 access.type)))); | 1274 node->InputAt(2))))); |
| 1271 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 1275 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
| 1272 } | 1276 } |
| 1273 | 1277 |
| 1274 | 1278 |
| 1275 void SimplifiedLowering::DoStringAdd(Node* node) { | 1279 void SimplifiedLowering::DoStringAdd(Node* node) { |
| 1276 Operator::Properties properties = node->op()->properties(); | 1280 Operator::Properties properties = node->op()->properties(); |
| 1277 Callable callable = CodeFactory::StringAdd( | 1281 Callable callable = CodeFactory::StringAdd( |
| 1278 jsgraph()->isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED); | 1282 jsgraph()->isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED); |
| 1279 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; | 1283 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; |
| 1280 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 1284 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 | 1577 |
| 1574 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1578 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
| 1575 node->set_op(machine()->IntLessThanOrEqual()); | 1579 node->set_op(machine()->IntLessThanOrEqual()); |
| 1576 node->ReplaceInput(0, StringComparison(node, true)); | 1580 node->ReplaceInput(0, StringComparison(node, true)); |
| 1577 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1581 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
| 1578 } | 1582 } |
| 1579 | 1583 |
| 1580 } // namespace compiler | 1584 } // namespace compiler |
| 1581 } // namespace internal | 1585 } // namespace internal |
| 1582 } // namespace v8 | 1586 } // namespace v8 |
| OLD | NEW |