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

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

Issue 2431563002: [turbofan] Track multiple maps for LoadElimination. (Closed)
Patch Set: REBASE. Address comment. Created 3 years, 11 months 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
« no previous file with comments | « src/compiler/simplified-operator.h ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 switch (mode) { 730 switch (mode) {
691 case CheckTaggedInputMode::kNumber: 731 case CheckTaggedInputMode::kNumber:
692 return &cache_.kCheckedTaggedToFloat64NumberOperator; 732 return &cache_.kCheckedTaggedToFloat64NumberOperator;
693 case CheckTaggedInputMode::kNumberOrOddball: 733 case CheckTaggedInputMode::kNumberOrOddball:
694 return &cache_.kCheckedTaggedToFloat64NumberOrOddballOperator; 734 return &cache_.kCheckedTaggedToFloat64NumberOrOddballOperator;
695 } 735 }
696 UNREACHABLE(); 736 UNREACHABLE();
697 return nullptr; 737 return nullptr;
698 } 738 }
699 739
700 const Operator* SimplifiedOperatorBuilder::CheckMaps(int map_input_count) { 740 const Operator* SimplifiedOperatorBuilder::CheckMaps(ZoneHandleSet<Map> maps) {
701 // TODO(bmeurer): Cache the most important versions of this operator. 741 CheckMapsParameters const parameters(maps);
702 DCHECK_LT(0, map_input_count); 742 return new (zone()) Operator1<CheckMapsParameters>( // --
703 int const value_input_count = 1 + map_input_count; 743 IrOpcode::kCheckMaps, // opcode
704 return new (zone()) Operator1<int>( // -- 744 Operator::kNoThrow | Operator::kNoWrite, // flags
705 IrOpcode::kCheckMaps, // opcode 745 "CheckMaps", // name
706 Operator::kNoThrow | Operator::kNoWrite, // flags 746 1, 1, 1, 0, 1, 0, // counts
707 "CheckMaps", // name 747 parameters); // parameter
708 value_input_count, 1, 1, 0, 1, 0, // counts
709 map_input_count); // parameter
710 } 748 }
711 749
712 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole( 750 const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole(
713 CheckFloat64HoleMode mode) { 751 CheckFloat64HoleMode mode) {
714 switch (mode) { 752 switch (mode) {
715 case CheckFloat64HoleMode::kAllowReturnHole: 753 case CheckFloat64HoleMode::kAllowReturnHole:
716 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator; 754 return &cache_.kCheckFloat64HoleAllowReturnHoleOperator;
717 case CheckFloat64HoleMode::kNeverReturnHole: 755 case CheckFloat64HoleMode::kNeverReturnHole:
718 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator; 756 return &cache_.kCheckFloat64HoleNeverReturnHoleOperator;
719 } 757 }
(...skipping 14 matching lines...) Expand all
734 4, 1, 1, 1, 1, 0, // counts 772 4, 1, 1, 1, 1, 0, // counts
735 flags); // parameter 773 flags); // parameter
736 } 774 }
737 775
738 const Operator* SimplifiedOperatorBuilder::TransitionElementsKind( 776 const Operator* SimplifiedOperatorBuilder::TransitionElementsKind(
739 ElementsTransition transition) { 777 ElementsTransition transition) {
740 return new (zone()) Operator1<ElementsTransition>( // -- 778 return new (zone()) Operator1<ElementsTransition>( // --
741 IrOpcode::kTransitionElementsKind, // opcode 779 IrOpcode::kTransitionElementsKind, // opcode
742 Operator::kNoDeopt | Operator::kNoThrow, // flags 780 Operator::kNoDeopt | Operator::kNoThrow, // flags
743 "TransitionElementsKind", // name 781 "TransitionElementsKind", // name
744 3, 1, 1, 0, 1, 0, // counts 782 1, 1, 1, 0, 1, 0, // counts
745 transition); // parameter 783 transition); // parameter
746 } 784 }
747 785
748 const Operator* SimplifiedOperatorBuilder::NewUnmappedArgumentsElements( 786 const Operator* SimplifiedOperatorBuilder::NewUnmappedArgumentsElements(
749 int parameter_count) { 787 int parameter_count) {
750 return new (zone()) Operator1<int>( // -- 788 return new (zone()) Operator1<int>( // --
751 IrOpcode::kNewUnmappedArgumentsElements, // opcode 789 IrOpcode::kNewUnmappedArgumentsElements, // opcode
752 Operator::kEliminatable, // flags 790 Operator::kEliminatable, // flags
753 "NewUnmappedArgumentsElements", // name 791 "NewUnmappedArgumentsElements", // name
754 0, 1, 0, 1, 1, 0, // counts 792 0, 1, 0, 1, 1, 0, // counts
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 Operator::kNoDeopt | Operator::kNoThrow | properties, \ 886 Operator::kNoDeopt | Operator::kNoThrow | properties, \
849 #Name, value_input_count, 1, control_input_count, \ 887 #Name, value_input_count, 1, control_input_count, \
850 output_count, 1, 0, access); \ 888 output_count, 1, 0, access); \
851 } 889 }
852 ACCESS_OP_LIST(ACCESS) 890 ACCESS_OP_LIST(ACCESS)
853 #undef ACCESS 891 #undef ACCESS
854 892
855 } // namespace compiler 893 } // namespace compiler
856 } // namespace internal 894 } // namespace internal
857 } // namespace v8 895 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-operator.h ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698