Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: src/compiler/simplified-operator.cc

Issue 2431563002: [turbofan] Track multiple maps for LoadElimination. (Closed)
Patch Set: REBASE Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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-operator.h" 5 #include "src/compiler/simplified-operator.h"
6 6
7 #include "src/base/lazy-instance.h" 7 #include "src/base/lazy-instance.h"
8 #include "src/compiler/opcodes.h" 8 #include "src/compiler/opcodes.h"
9 #include "src/compiler/operator.h" 9 #include "src/compiler/operator.h"
10 #include "src/compiler/types.h" 10 #include "src/compiler/types.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 switch (mode) { 222 switch (mode) {
223 case CheckForMinusZeroMode::kCheckForMinusZero: 223 case CheckForMinusZeroMode::kCheckForMinusZero:
224 return os << "check-for-minus-zero"; 224 return os << "check-for-minus-zero";
225 case CheckForMinusZeroMode::kDontCheckForMinusZero: 225 case CheckForMinusZeroMode::kDontCheckForMinusZero:
226 return os << "dont-check-for-minus-zero"; 226 return os << "dont-check-for-minus-zero";
227 } 227 }
228 UNREACHABLE(); 228 UNREACHABLE();
229 return os; 229 return os;
230 } 230 }
231 231
232 bool operator==(CheckMapsParameters const& lhs,
233 CheckMapsParameters const& rhs) {
234 return lhs.maps() == rhs.maps();
235 }
236
237 bool operator!=(CheckMapsParameters const& lhs,
238 CheckMapsParameters const& rhs) {
239 return !(lhs == rhs);
240 }
241
242 size_t hash_value(CheckMapsParameters const& p) { return hash_value(p.maps()); }
243
244 std::ostream& operator<<(std::ostream& os, CheckMapsParameters const& p) {
245 ZoneHandleSet<Map> const& maps = p.maps();
246 for (size_t i = 0; i < maps.size(); ++i) {
247 if (i != 0) os << ", ";
248 os << Brief(*maps[i]);
249 }
250 return os;
251 }
252
253 CheckMapsParameters const& CheckMapsParametersOf(Operator const* op) {
254 DCHECK_EQ(IrOpcode::kCheckMaps, op->opcode());
255 return OpParameter<CheckMapsParameters>(op);
256 }
257
232 size_t hash_value(CheckTaggedInputMode mode) { 258 size_t hash_value(CheckTaggedInputMode mode) {
233 return static_cast<size_t>(mode); 259 return static_cast<size_t>(mode);
234 } 260 }
235 261
236 std::ostream& operator<<(std::ostream& os, CheckTaggedInputMode mode) { 262 std::ostream& operator<<(std::ostream& os, CheckTaggedInputMode mode) {
237 switch (mode) { 263 switch (mode) {
238 case CheckTaggedInputMode::kNumber: 264 case CheckTaggedInputMode::kNumber:
239 return os << "Number"; 265 return os << "Number";
240 case CheckTaggedInputMode::kNumberOrOddball: 266 case CheckTaggedInputMode::kNumberOrOddball:
241 return os << "NumberOrOddball"; 267 return os << "NumberOrOddball";
(...skipping 25 matching lines...) Expand all
267 } 293 }
268 if (empty) os << "None"; 294 if (empty) os << "None";
269 return os; 295 return os;
270 } 296 }
271 297
272 GrowFastElementsFlags GrowFastElementsFlagsOf(const Operator* op) { 298 GrowFastElementsFlags GrowFastElementsFlagsOf(const Operator* op) {
273 DCHECK_EQ(IrOpcode::kMaybeGrowFastElements, op->opcode()); 299 DCHECK_EQ(IrOpcode::kMaybeGrowFastElements, op->opcode());
274 return OpParameter<GrowFastElementsFlags>(op); 300 return OpParameter<GrowFastElementsFlags>(op);
275 } 301 }
276 302
303 bool operator==(ElementsTransition const& lhs, ElementsTransition const& rhs) {
304 return lhs.mode() == rhs.mode() &&
305 lhs.source().address() == rhs.source().address() &&
306 lhs.target().address() == rhs.target().address();
307 }
308
309 bool operator!=(ElementsTransition const& lhs, ElementsTransition const& rhs) {
310 return !(lhs == rhs);
311 }
312
277 size_t hash_value(ElementsTransition transition) { 313 size_t hash_value(ElementsTransition transition) {
278 return static_cast<uint8_t>(transition); 314 return base::hash_combine(static_cast<uint8_t>(transition.mode()),
315 transition.source().address(),
316 transition.target().address());
279 } 317 }
280 318
281 std::ostream& operator<<(std::ostream& os, ElementsTransition transition) { 319 std::ostream& operator<<(std::ostream& os, ElementsTransition transition) {
282 switch (transition) { 320 switch (transition.mode()) {
283 case ElementsTransition::kFastTransition: 321 case ElementsTransition::kFastTransition:
284 return os << "fast-transition"; 322 return os << "fast-transition from " << Brief(*transition.source())
323 << " to " << Brief(*transition.target());
285 case ElementsTransition::kSlowTransition: 324 case ElementsTransition::kSlowTransition:
286 return os << "slow-transition"; 325 return os << "slow-transition from " << Brief(*transition.source())
326 << " to " << Brief(*transition.target());
287 } 327 }
288 UNREACHABLE(); 328 UNREACHABLE();
289 return os; 329 return os;
290 } 330 }
291 331
292 ElementsTransition ElementsTransitionOf(const Operator* op) { 332 ElementsTransition const& ElementsTransitionOf(const Operator* op) {
293 DCHECK_EQ(IrOpcode::kTransitionElementsKind, op->opcode()); 333 DCHECK_EQ(IrOpcode::kTransitionElementsKind, op->opcode());
294 return OpParameter<ElementsTransition>(op); 334 return OpParameter<ElementsTransition>(op);
295 } 335 }
296 336
297 std::ostream& operator<<(std::ostream& os, NumberOperationHint hint) { 337 std::ostream& operator<<(std::ostream& os, NumberOperationHint hint) {
298 switch (hint) { 338 switch (hint) {
299 case NumberOperationHint::kSignedSmall: 339 case NumberOperationHint::kSignedSmall:
300 return os << "SignedSmall"; 340 return os << "SignedSmall";
301 case NumberOperationHint::kSigned32: 341 case NumberOperationHint::kSigned32:
302 return os << "Signed32"; 342 return os << "Signed32";
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 switch (mode) { 729 switch (mode) {
690 case CheckTaggedInputMode::kNumber: 730 case CheckTaggedInputMode::kNumber:
691 return &cache_.kCheckedTaggedToFloat64NumberOperator; 731 return &cache_.kCheckedTaggedToFloat64NumberOperator;
692 case CheckTaggedInputMode::kNumberOrOddball: 732 case CheckTaggedInputMode::kNumberOrOddball:
693 return &cache_.kCheckedTaggedToFloat64NumberOrOddballOperator; 733 return &cache_.kCheckedTaggedToFloat64NumberOrOddballOperator;
694 } 734 }
695 UNREACHABLE(); 735 UNREACHABLE();
696 return nullptr; 736 return nullptr;
697 } 737 }
698 738
699 const Operator* SimplifiedOperatorBuilder::CheckMaps(int map_input_count) { 739 const Operator* SimplifiedOperatorBuilder::CheckMaps(ZoneHandleSet<Map> maps) {
700 // TODO(bmeurer): Cache the most important versions of this operator. 740 CheckMapsParameters const parameters(maps);
701 DCHECK_LT(0, map_input_count); 741 return new (zone()) Operator1<CheckMapsParameters>( // --
702 int const value_input_count = 1 + map_input_count; 742 IrOpcode::kCheckMaps, // opcode
703 return new (zone()) Operator1<int>( // -- 743 Operator::kNoThrow | Operator::kNoWrite, // flags
704 IrOpcode::kCheckMaps, // opcode 744 "CheckMaps", // name
705 Operator::kNoThrow | Operator::kNoWrite, // flags 745 1, 1, 1, 0, 1, 0, // counts
706 "CheckMaps", // name 746 parameters); // parameter
707 value_input_count, 1, 1, 0, 1, 0, // counts
708 map_input_count); // parameter
709 } 747 }
710 748
711 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole( 749 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole(
712 CheckFloat64HoleMode mode) { 750 CheckFloat64HoleMode mode) {
713 switch (mode) { 751 switch (mode) {
714 case CheckFloat64HoleMode::kAllowReturnHole: 752 case CheckFloat64HoleMode::kAllowReturnHole:
715 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator; 753 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator;
716 case CheckFloat64HoleMode::kNeverReturnHole: 754 case CheckFloat64HoleMode::kNeverReturnHole:
717 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator; 755 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator;
718 } 756 }
(...skipping 14 matching lines...) Expand all
733 4, 1, 1, 1, 1, 0, // counts 771 4, 1, 1, 1, 1, 0, // counts
734 flags); // parameter 772 flags); // parameter
735 } 773 }
736 774
737 const Operator* SimplifiedOperatorBuilder::TransitionElementsKind( 775 const Operator* SimplifiedOperatorBuilder::TransitionElementsKind(
738 ElementsTransition transition) { 776 ElementsTransition transition) {
739 return new (zone()) Operator1<ElementsTransition>( // -- 777 return new (zone()) Operator1<ElementsTransition>( // --
740 IrOpcode::kTransitionElementsKind, // opcode 778 IrOpcode::kTransitionElementsKind, // opcode
741 Operator::kNoDeopt | Operator::kNoThrow, // flags 779 Operator::kNoDeopt | Operator::kNoThrow, // flags
742 "TransitionElementsKind", // name 780 "TransitionElementsKind", // name
743 3, 1, 1, 0, 1, 0, // counts 781 1, 1, 1, 0, 1, 0, // counts
744 transition); // parameter 782 transition); // parameter
745 } 783 }
746 784
747 const Operator* SimplifiedOperatorBuilder::NewUnmappedArgumentsElements( 785 const Operator* SimplifiedOperatorBuilder::NewUnmappedArgumentsElements(
748 int parameter_count) { 786 int parameter_count) {
749 return new (zone()) Operator1<int>( // -- 787 return new (zone()) Operator1<int>( // --
750 IrOpcode::kNewUnmappedArgumentsElements, // opcode 788 IrOpcode::kNewUnmappedArgumentsElements, // opcode
751 Operator::kEliminatable, // flags 789 Operator::kEliminatable, // flags
752 "NewUnmappedArgumentsElements", // name 790 "NewUnmappedArgumentsElements", // name
753 0, 1, 0, 1, 1, 0, // counts 791 0, 1, 0, 1, 1, 0, // counts
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 Operator::kNoDeopt | Operator::kNoThrow | properties, \ 885 Operator::kNoDeopt | Operator::kNoThrow | properties, \
848 #Name, value_input_count, 1, control_input_count, \ 886 #Name, value_input_count, 1, control_input_count, \
849 output_count, 1, 0, access); \ 887 output_count, 1, 0, access); \
850 } 888 }
851 ACCESS_OP_LIST(ACCESS) 889 ACCESS_OP_LIST(ACCESS)
852 #undef ACCESS 890 #undef ACCESS
853 891
854 } // namespace compiler 892 } // namespace compiler
855 } // namespace internal 893 } // namespace internal
856 } // namespace v8 894 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698