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

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

Issue 2509623002: [turbofan] Sparse representation for state values (Closed)
Patch Set: Add missing operator declarations 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 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/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 6
7 #include "src/assembler.h" 7 #include "src/assembler.h"
8 #include "src/base/lazy-instance.h" 8 #include "src/base/lazy-instance.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/opcodes.h" 10 #include "src/compiler/opcodes.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 size_t hash_value(RelocatablePtrConstantInfo const& p) { 165 size_t hash_value(RelocatablePtrConstantInfo const& p) {
166 return base::hash_combine(p.value(), p.rmode(), p.type()); 166 return base::hash_combine(p.value(), p.rmode(), p.type());
167 } 167 }
168 168
169 std::ostream& operator<<(std::ostream& os, 169 std::ostream& operator<<(std::ostream& os,
170 RelocatablePtrConstantInfo const& p) { 170 RelocatablePtrConstantInfo const& p) {
171 return os << p.value() << "|" << p.rmode() << "|" << p.type(); 171 return os << p.value() << "|" << p.rmode() << "|" << p.type();
172 } 172 }
173 173
174 bool operator==(TypedStateValueInfo const& lhs,
175 TypedStateValueInfo const& rhs) {
176 return lhs.machine_types() == rhs.machine_types() && lhs.mask() == rhs.mask();
177 }
178
179 bool operator!=(TypedStateValueInfo const& lhs,
180 TypedStateValueInfo const& rhs) {
181 return !(lhs == rhs);
182 }
183
184 size_t hash_value(TypedStateValueInfo const& p) {
185 return base::hash_combine(p.machine_types(), p.mask());
186 }
187
188 std::ostream& operator<<(std::ostream& os, TypedStateValueInfo const& p) {
189 return os << p.machine_types() << "|" << p.mask();
Jarin 2016/12/07 08:56:20 Please update the printing to print something huma
Leszek Swirski 2016/12/08 15:44:30 Done.
190 }
191
174 size_t hash_value(RegionObservability observability) { 192 size_t hash_value(RegionObservability observability) {
175 return static_cast<size_t>(observability); 193 return static_cast<size_t>(observability);
176 } 194 }
177 195
178 std::ostream& operator<<(std::ostream& os, RegionObservability observability) { 196 std::ostream& operator<<(std::ostream& os, RegionObservability observability) {
179 switch (observability) { 197 switch (observability) {
180 case RegionObservability::kObservable: 198 case RegionObservability::kObservable:
181 return os << "observable"; 199 return os << "observable";
182 case RegionObservability::kNotObservable: 200 case RegionObservability::kNotObservable:
183 return os << "not-observable"; 201 return os << "not-observable";
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 249 }
232 250
233 OsrGuardType OsrGuardTypeOf(Operator const* op) { 251 OsrGuardType OsrGuardTypeOf(Operator const* op) {
234 DCHECK_EQ(IrOpcode::kOsrGuard, op->opcode()); 252 DCHECK_EQ(IrOpcode::kOsrGuard, op->opcode());
235 return OpParameter<OsrGuardType>(op); 253 return OpParameter<OsrGuardType>(op);
236 } 254 }
237 255
238 ZoneVector<MachineType> const* MachineTypesOf(Operator const* op) { 256 ZoneVector<MachineType> const* MachineTypesOf(Operator const* op) {
239 DCHECK(op->opcode() == IrOpcode::kTypedObjectState || 257 DCHECK(op->opcode() == IrOpcode::kTypedObjectState ||
240 op->opcode() == IrOpcode::kTypedStateValues); 258 op->opcode() == IrOpcode::kTypedStateValues);
259
260 if (op->opcode() == IrOpcode::kTypedStateValues) {
261 return OpParameter<TypedStateValueInfo>(op).machine_types();
262 }
241 return OpParameter<const ZoneVector<MachineType>*>(op); 263 return OpParameter<const ZoneVector<MachineType>*>(op);
242 } 264 }
243 265
244 #define CACHED_OP_LIST(V) \ 266 #define CACHED_OP_LIST(V) \
245 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \ 267 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \
246 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ 268 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
247 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ 269 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
248 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ 270 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
249 V(IfException, Operator::kKontrol, 0, 1, 1, 1, 1, 1) \ 271 V(IfException, Operator::kKontrol, 0, 1, 1, 1, 1, 1) \
250 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ 272 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 "Projection", // name 603 "Projection", // name
582 1, 0, 1, 1, 0, 0, // counts, 604 1, 0, 1, 1, 0, 0, // counts,
583 kIndex) {} // parameter 605 kIndex) {} // parameter
584 }; 606 };
585 #define CACHED_PROJECTION(index) \ 607 #define CACHED_PROJECTION(index) \
586 ProjectionOperator<index> kProjection##index##Operator; 608 ProjectionOperator<index> kProjection##index##Operator;
587 CACHED_PROJECTION_LIST(CACHED_PROJECTION) 609 CACHED_PROJECTION_LIST(CACHED_PROJECTION)
588 #undef CACHED_PROJECTION 610 #undef CACHED_PROJECTION
589 611
590 template <int kInputCount> 612 template <int kInputCount>
591 struct StateValuesOperator final : public Operator { 613 struct StateValuesOperator final : public Operator1<uint32_t> {
Jarin 2016/12/07 08:56:19 To get a good printing, it would be better to intr
Leszek Swirski 2016/12/08 15:44:30 Done.
592 StateValuesOperator() 614 StateValuesOperator()
593 : Operator( // -- 615 : Operator1<uint32_t>( // --
594 IrOpcode::kStateValues, // opcode 616 IrOpcode::kStateValues, // opcode
595 Operator::kPure, // flags 617 Operator::kPure, // flags
596 "StateValues", // name 618 "StateValues", // name
597 kInputCount, 0, 0, 1, 0, 0) {} // counts 619 kInputCount, 0, 0, 1, 0, 0, // counts
620 0) {} // parameter
598 }; 621 };
599 #define CACHED_STATE_VALUES(input_count) \ 622 #define CACHED_STATE_VALUES(input_count) \
600 StateValuesOperator<input_count> kStateValues##input_count##Operator; 623 StateValuesOperator<input_count> kStateValues##input_count##Operator;
601 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES) 624 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
602 #undef CACHED_STATE_VALUES 625 #undef CACHED_STATE_VALUES
603 }; 626 };
604 627
605 628
606 static base::LazyInstance<CommonOperatorGlobalCache>::type kCache = 629 static base::LazyInstance<CommonOperatorGlobalCache>::type kCache =
607 LAZY_INSTANCE_INITIALIZER; 630 LAZY_INSTANCE_INITIALIZER;
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 switch (region_observability) { 1016 switch (region_observability) {
994 case RegionObservability::kObservable: 1017 case RegionObservability::kObservable:
995 return &cache_.kBeginRegionObservableOperator; 1018 return &cache_.kBeginRegionObservableOperator;
996 case RegionObservability::kNotObservable: 1019 case RegionObservability::kNotObservable:
997 return &cache_.kBeginRegionNotObservableOperator; 1020 return &cache_.kBeginRegionNotObservableOperator;
998 } 1021 }
999 UNREACHABLE(); 1022 UNREACHABLE();
1000 return nullptr; 1023 return nullptr;
1001 } 1024 }
1002 1025
1003 const Operator* CommonOperatorBuilder::StateValues(int arguments) { 1026 const Operator* CommonOperatorBuilder::StateValues(int arguments,
1004 switch (arguments) { 1027 uint32_t bitmask) {
1028 if (bitmask == 0) {
1029 switch (arguments) {
1005 #define CACHED_STATE_VALUES(arguments) \ 1030 #define CACHED_STATE_VALUES(arguments) \
1006 case arguments: \ 1031 case arguments: \
1007 return &cache_.kStateValues##arguments##Operator; 1032 return &cache_.kStateValues##arguments##Operator;
1008 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES) 1033 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
1009 #undef CACHED_STATE_VALUES 1034 #undef CACHED_STATE_VALUES
1010 default: 1035 default:
1011 break; 1036 break;
1037 }
1012 } 1038 }
1039
1013 // Uncached. 1040 // Uncached.
1014 return new (zone()) Operator( // -- 1041 return new (zone()) Operator1<uint32_t>( // --
1015 IrOpcode::kStateValues, Operator::kPure, // opcode 1042 IrOpcode::kStateValues, Operator::kPure, // opcode
1016 "StateValues", // name 1043 "StateValues", // name
1017 arguments, 0, 0, 1, 0, 0); // counts 1044 arguments, 0, 0, 1, 0, 0, // counts
1045 bitmask); // parameter
1018 } 1046 }
1019 1047
1020 const Operator* CommonOperatorBuilder::TypedStateValues( 1048 const Operator* CommonOperatorBuilder::TypedStateValues(
1021 const ZoneVector<MachineType>* types) { 1049 const ZoneVector<MachineType>* types, uint32_t bitmask) {
1022 return new (zone()) Operator1<const ZoneVector<MachineType>*>( // -- 1050 return new (zone()) Operator1<TypedStateValueInfo>( // --
1023 IrOpcode::kTypedStateValues, Operator::kPure, // opcode 1051 IrOpcode::kTypedStateValues, Operator::kPure, // opcode
1024 "TypedStateValues", // name 1052 "TypedStateValues", // name
1025 static_cast<int>(types->size()), 0, 0, 1, 0, 0, // counts 1053 static_cast<int>(types->size()), 0, 0, 1, 0, 0, // counts
1026 types); // parameter 1054 TypedStateValueInfo(types, bitmask)); // parameters
1027 } 1055 }
1028 1056
1029 const Operator* CommonOperatorBuilder::ObjectState(int pointer_slots) { 1057 const Operator* CommonOperatorBuilder::ObjectState(int pointer_slots) {
1030 return new (zone()) Operator1<int>( // -- 1058 return new (zone()) Operator1<int>( // --
1031 IrOpcode::kObjectState, Operator::kPure, // opcode 1059 IrOpcode::kObjectState, Operator::kPure, // opcode
1032 "ObjectState", // name 1060 "ObjectState", // name
1033 pointer_slots, 0, 0, 1, 0, 0, // counts 1061 pointer_slots, 0, 0, 1, 0, 0, // counts
1034 pointer_slots); // parameter 1062 pointer_slots); // parameter
1035 } 1063 }
1036 1064
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 CommonOperatorBuilder::CreateFrameStateFunctionInfo( 1164 CommonOperatorBuilder::CreateFrameStateFunctionInfo(
1137 FrameStateType type, int parameter_count, int local_count, 1165 FrameStateType type, int parameter_count, int local_count,
1138 Handle<SharedFunctionInfo> shared_info) { 1166 Handle<SharedFunctionInfo> shared_info) {
1139 return new (zone()->New(sizeof(FrameStateFunctionInfo))) 1167 return new (zone()->New(sizeof(FrameStateFunctionInfo)))
1140 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); 1168 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info);
1141 } 1169 }
1142 1170
1143 } // namespace compiler 1171 } // namespace compiler
1144 } // namespace internal 1172 } // namespace internal
1145 } // namespace v8 1173 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698