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 #ifndef V8_COMPILER_INSTRUCTION_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_H_ |
6 #define V8_COMPILER_INSTRUCTION_H_ | 6 #define V8_COMPILER_INSTRUCTION_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <map> | 10 #include <map> |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1115 }; | 1115 }; |
1116 | 1116 |
1117 | 1117 |
1118 std::ostream& operator<<(std::ostream& os, const Constant& constant); | 1118 std::ostream& operator<<(std::ostream& os, const Constant& constant); |
1119 | 1119 |
1120 | 1120 |
1121 // Forward declarations. | 1121 // Forward declarations. |
1122 class FrameStateDescriptor; | 1122 class FrameStateDescriptor; |
1123 | 1123 |
1124 enum class StateValueKind : uint8_t { | 1124 enum class StateValueKind : uint8_t { |
1125 kArguments, | 1125 kArgumentsElements, |
1126 kPlain, | 1126 kPlain, |
1127 kOptimizedOut, | 1127 kOptimizedOut, |
1128 kNested, | 1128 kNested, |
1129 kDuplicate | 1129 kDuplicate |
1130 }; | 1130 }; |
1131 | 1131 |
1132 class StateValueDescriptor { | 1132 class StateValueDescriptor { |
1133 public: | 1133 public: |
1134 StateValueDescriptor() | 1134 StateValueDescriptor() |
1135 : kind_(StateValueKind::kPlain), | 1135 : kind_(StateValueKind::kPlain), type_(MachineType::AnyTagged()) {} |
1136 type_(MachineType::AnyTagged()), | |
1137 id_(0) {} | |
1138 | 1136 |
1139 static StateValueDescriptor Arguments() { | 1137 static StateValueDescriptor ArgumentsElements(bool is_rest) { |
1140 return StateValueDescriptor(StateValueKind::kArguments, | 1138 StateValueDescriptor descr(StateValueKind::kArgumentsElements, |
1141 MachineType::AnyTagged(), 0); | 1139 MachineType::AnyTagged()); |
1140 descr.is_rest_ = is_rest; | |
1141 return descr; | |
1142 } | 1142 } |
1143 static StateValueDescriptor Plain(MachineType type) { | 1143 static StateValueDescriptor Plain(MachineType type) { |
1144 return StateValueDescriptor(StateValueKind::kPlain, type, 0); | 1144 return StateValueDescriptor(StateValueKind::kPlain, type); |
1145 } | 1145 } |
1146 static StateValueDescriptor OptimizedOut() { | 1146 static StateValueDescriptor OptimizedOut() { |
1147 return StateValueDescriptor(StateValueKind::kOptimizedOut, | 1147 return StateValueDescriptor(StateValueKind::kOptimizedOut, |
1148 MachineType::AnyTagged(), 0); | 1148 MachineType::AnyTagged()); |
1149 } | 1149 } |
1150 static StateValueDescriptor Recursive(size_t id) { | 1150 static StateValueDescriptor Recursive(size_t id) { |
1151 return StateValueDescriptor(StateValueKind::kNested, | 1151 StateValueDescriptor descr(StateValueKind::kNested, |
1152 MachineType::AnyTagged(), id); | 1152 MachineType::AnyTagged()); |
1153 descr.id_ = id; | |
1154 return descr; | |
1153 } | 1155 } |
1154 static StateValueDescriptor Duplicate(size_t id) { | 1156 static StateValueDescriptor Duplicate(size_t id) { |
1155 return StateValueDescriptor(StateValueKind::kDuplicate, | 1157 StateValueDescriptor descr(StateValueKind::kDuplicate, |
1156 MachineType::AnyTagged(), id); | 1158 MachineType::AnyTagged()); |
1159 descr.id_ = id; | |
1160 return descr; | |
1157 } | 1161 } |
1158 | 1162 |
1159 bool IsArguments() const { return kind_ == StateValueKind::kArguments; } | 1163 bool IsArgumentsElements() const { |
1164 return kind_ == StateValueKind::kArgumentsElements; | |
1165 } | |
1160 bool IsPlain() const { return kind_ == StateValueKind::kPlain; } | 1166 bool IsPlain() const { return kind_ == StateValueKind::kPlain; } |
1161 bool IsOptimizedOut() const { return kind_ == StateValueKind::kOptimizedOut; } | 1167 bool IsOptimizedOut() const { return kind_ == StateValueKind::kOptimizedOut; } |
1162 bool IsNested() const { return kind_ == StateValueKind::kNested; } | 1168 bool IsNested() const { return kind_ == StateValueKind::kNested; } |
1163 bool IsDuplicate() const { return kind_ == StateValueKind::kDuplicate; } | 1169 bool IsDuplicate() const { return kind_ == StateValueKind::kDuplicate; } |
1164 MachineType type() const { return type_; } | 1170 MachineType type() const { return type_; } |
1165 size_t id() const { return id_; } | 1171 size_t id() const { |
1172 DCHECK(kind_ == StateValueKind::kDuplicate || | |
1173 kind_ == StateValueKind::kNested); | |
1174 return id_; | |
1175 } | |
1176 int is_rest() const { | |
1177 DCHECK(kind_ == StateValueKind::kArgumentsElements); | |
1178 return is_rest_; | |
1179 } | |
1166 | 1180 |
1167 private: | 1181 private: |
1168 StateValueDescriptor(StateValueKind kind, MachineType type, size_t id) | 1182 StateValueDescriptor(StateValueKind kind, MachineType type) |
1169 : kind_(kind), type_(type), id_(id) {} | 1183 : kind_(kind), type_(type) {} |
1170 | 1184 |
1171 StateValueKind kind_; | 1185 StateValueKind kind_; |
1172 MachineType type_; | 1186 MachineType type_; |
1173 size_t id_; | 1187 union { |
1188 size_t id_; | |
1189 bool is_rest_; | |
1190 }; | |
1174 }; | 1191 }; |
1175 | 1192 |
1176 class StateValueList { | 1193 class StateValueList { |
1177 public: | 1194 public: |
1178 explicit StateValueList(Zone* zone) : fields_(zone), nested_(zone) {} | 1195 explicit StateValueList(Zone* zone) : fields_(zone), nested_(zone) {} |
1179 | 1196 |
1180 size_t size() { return fields_.size(); } | 1197 size_t size() { return fields_.size(); } |
1181 | 1198 |
1182 struct Value { | 1199 struct Value { |
1183 StateValueDescriptor* desc; | 1200 StateValueDescriptor* desc; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 | 1239 |
1223 void ReserveSize(size_t size) { fields_.reserve(size); } | 1240 void ReserveSize(size_t size) { fields_.reserve(size); } |
1224 | 1241 |
1225 StateValueList* PushRecursiveField(Zone* zone, size_t id) { | 1242 StateValueList* PushRecursiveField(Zone* zone, size_t id) { |
1226 fields_.push_back(StateValueDescriptor::Recursive(id)); | 1243 fields_.push_back(StateValueDescriptor::Recursive(id)); |
1227 StateValueList* nested = | 1244 StateValueList* nested = |
1228 new (zone->New(sizeof(StateValueList))) StateValueList(zone); | 1245 new (zone->New(sizeof(StateValueList))) StateValueList(zone); |
1229 nested_.push_back(nested); | 1246 nested_.push_back(nested); |
1230 return nested; | 1247 return nested; |
1231 } | 1248 } |
1232 void PushArguments() { fields_.push_back(StateValueDescriptor::Arguments()); } | 1249 void PushArgumentsElements(int skip) { |
Jarin
2017/02/27 13:24:34
How about
int skip ==> bool is_rest
?
| |
1250 fields_.push_back(StateValueDescriptor::ArgumentsElements(skip)); | |
1251 } | |
1233 void PushDuplicate(size_t id) { | 1252 void PushDuplicate(size_t id) { |
1234 fields_.push_back(StateValueDescriptor::Duplicate(id)); | 1253 fields_.push_back(StateValueDescriptor::Duplicate(id)); |
1235 } | 1254 } |
1236 void PushPlain(MachineType type) { | 1255 void PushPlain(MachineType type) { |
1237 fields_.push_back(StateValueDescriptor::Plain(type)); | 1256 fields_.push_back(StateValueDescriptor::Plain(type)); |
1238 } | 1257 } |
1239 void PushOptimizedOut() { | 1258 void PushOptimizedOut() { |
1240 fields_.push_back(StateValueDescriptor::OptimizedOut()); | 1259 fields_.push_back(StateValueDescriptor::OptimizedOut()); |
1241 } | 1260 } |
1242 | 1261 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1636 }; | 1655 }; |
1637 | 1656 |
1638 V8_EXPORT_PRIVATE std::ostream& operator<<( | 1657 V8_EXPORT_PRIVATE std::ostream& operator<<( |
1639 std::ostream& os, const PrintableInstructionSequence& code); | 1658 std::ostream& os, const PrintableInstructionSequence& code); |
1640 | 1659 |
1641 } // namespace compiler | 1660 } // namespace compiler |
1642 } // namespace internal | 1661 } // namespace internal |
1643 } // namespace v8 | 1662 } // namespace v8 |
1644 | 1663 |
1645 #endif // V8_COMPILER_INSTRUCTION_H_ | 1664 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |