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 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 NodeInfo* GetInfo(Node* node) { | 1146 NodeInfo* GetInfo(Node* node) { |
1147 DCHECK(node->id() >= 0); | 1147 DCHECK(node->id() >= 0); |
1148 DCHECK(node->id() < count_); | 1148 DCHECK(node->id() < count_); |
1149 return &info_[node->id()]; | 1149 return &info_[node->id()]; |
1150 } | 1150 } |
1151 | 1151 |
1152 MachineTypeUnion GetUseInfo(Node* node) { return GetInfo(node)->use; } | 1152 MachineTypeUnion GetUseInfo(Node* node) { return GetInfo(node)->use; } |
1153 }; | 1153 }; |
1154 | 1154 |
1155 | 1155 |
1156 Node* SimplifiedLowering::IsTagged(Node* node) { | |
1157 // TODO(titzer): factor this out to a TaggingScheme abstraction. | |
1158 STATIC_ASSERT(kSmiTagMask == 1); // Only works if tag is the low bit. | |
1159 return graph()->NewNode(machine()->WordAnd(), node, | |
1160 jsgraph()->Int32Constant(kSmiTagMask)); | |
1161 } | |
1162 | |
1163 | |
1164 SimplifiedLowering::SimplifiedLowering(JSGraph* jsgraph, Zone* zone, | 1156 SimplifiedLowering::SimplifiedLowering(JSGraph* jsgraph, Zone* zone, |
1165 SourcePositionTable* source_positions) | 1157 SourcePositionTable* source_positions) |
1166 : jsgraph_(jsgraph), | 1158 : jsgraph_(jsgraph), |
1167 zone_(zone), | 1159 zone_(zone), |
1168 zero_thirtyone_range_(Type::Range(0, 31, zone)), | 1160 zero_thirtyone_range_(Type::Range(0, 31, zone)), |
1169 source_positions_(source_positions) {} | 1161 source_positions_(source_positions) {} |
1170 | 1162 |
1171 | 1163 |
1172 void SimplifiedLowering::LowerAllNodes() { | 1164 void SimplifiedLowering::LowerAllNodes() { |
1173 RepresentationChanger changer(jsgraph(), jsgraph()->isolate()); | 1165 RepresentationChanger changer(jsgraph(), jsgraph()->isolate()); |
1174 RepresentationSelector selector(jsgraph(), zone_, &changer, | 1166 RepresentationSelector selector(jsgraph(), zone_, &changer, |
1175 source_positions_); | 1167 source_positions_); |
1176 selector.Run(this); | 1168 selector.Run(this); |
1177 } | 1169 } |
1178 | 1170 |
1179 | 1171 |
1180 Node* SimplifiedLowering::Untag(Node* node) { | |
1181 // TODO(titzer): factor this out to a TaggingScheme abstraction. | |
1182 Node* shift_amount = jsgraph()->Int32Constant(kSmiTagSize + kSmiShiftSize); | |
1183 return graph()->NewNode(machine()->WordSar(), node, shift_amount); | |
1184 } | |
1185 | |
1186 | |
1187 Node* SimplifiedLowering::SmiTag(Node* node) { | |
1188 // TODO(titzer): factor this out to a TaggingScheme abstraction. | |
1189 Node* shift_amount = jsgraph()->Int32Constant(kSmiTagSize + kSmiShiftSize); | |
1190 return graph()->NewNode(machine()->WordShl(), node, shift_amount); | |
1191 } | |
1192 | |
1193 | |
1194 Node* SimplifiedLowering::OffsetMinusTagConstant(int32_t offset) { | |
1195 return jsgraph()->Int32Constant(offset - kHeapObjectTag); | |
1196 } | |
1197 | |
1198 | |
1199 namespace { | 1172 namespace { |
1200 | 1173 |
1201 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, | 1174 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, |
1202 MachineType representation, | 1175 MachineType representation, |
1203 Type* type) { | 1176 Type* type) { |
1204 if (type->Is(Type::TaggedSigned())) { | 1177 if (type->Is(Type::TaggedSigned())) { |
1205 // Write barriers are only for writes of heap objects. | 1178 // Write barriers are only for writes of heap objects. |
1206 return kNoWriteBarrier; | 1179 return kNoWriteBarrier; |
1207 } | 1180 } |
1208 if (base_is_tagged == kTaggedBase && | 1181 if (base_is_tagged == kTaggedBase && |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 ReplaceEffectUses(node, comparison); | 1664 ReplaceEffectUses(node, comparison); |
1692 node->ReplaceInput(0, comparison); | 1665 node->ReplaceInput(0, comparison); |
1693 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1666 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1694 node->TrimInputCount(2); | 1667 node->TrimInputCount(2); |
1695 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); | 1668 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); |
1696 } | 1669 } |
1697 | 1670 |
1698 } // namespace compiler | 1671 } // namespace compiler |
1699 } // namespace internal | 1672 } // namespace internal |
1700 } // namespace v8 | 1673 } // namespace v8 |
OLD | NEW |