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/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" |
11 #include "src/compiler/operator.h" | 11 #include "src/compiler/operator.h" |
12 #include "src/handles-inl.h" | 12 #include "src/handles-inl.h" |
13 #include "src/zone/zone.h" | 13 #include "src/zone/zone.h" |
14 | 14 |
15 namespace std { | |
16 template <typename T, typename S> | |
17 ostream& operator<<(ostream& o, const pair<T, S>& p) { | |
18 return o << "(" << p.first << ", " << p.second << ")"; | |
19 } | |
20 } | |
21 | |
15 namespace v8 { | 22 namespace v8 { |
16 namespace internal { | 23 namespace internal { |
17 namespace compiler { | 24 namespace compiler { |
18 | 25 |
19 std::ostream& operator<<(std::ostream& os, BranchHint hint) { | 26 std::ostream& operator<<(std::ostream& os, BranchHint hint) { |
20 switch (hint) { | 27 switch (hint) { |
21 case BranchHint::kNone: | 28 case BranchHint::kNone: |
22 return os << "None"; | 29 return os << "None"; |
23 case BranchHint::kTrue: | 30 case BranchHint::kTrue: |
24 return os << "True"; | 31 return os << "True"; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 } | 238 } |
232 | 239 |
233 OsrGuardType OsrGuardTypeOf(Operator const* op) { | 240 OsrGuardType OsrGuardTypeOf(Operator const* op) { |
234 DCHECK_EQ(IrOpcode::kOsrGuard, op->opcode()); | 241 DCHECK_EQ(IrOpcode::kOsrGuard, op->opcode()); |
235 return OpParameter<OsrGuardType>(op); | 242 return OpParameter<OsrGuardType>(op); |
236 } | 243 } |
237 | 244 |
238 ZoneVector<MachineType> const* MachineTypesOf(Operator const* op) { | 245 ZoneVector<MachineType> const* MachineTypesOf(Operator const* op) { |
239 DCHECK(op->opcode() == IrOpcode::kTypedObjectState || | 246 DCHECK(op->opcode() == IrOpcode::kTypedObjectState || |
240 op->opcode() == IrOpcode::kTypedStateValues); | 247 op->opcode() == IrOpcode::kTypedStateValues); |
248 | |
249 if (op->opcode() == IrOpcode::kTypedStateValues) { | |
250 const ZoneVector<MachineType>* types = | |
251 OpParameter<std::pair<const ZoneVector<MachineType>*, uint32_t>>(op) | |
252 .first; | |
Jarin
2016/11/16 15:32:42
This is confusing - where is 'types' used?
Should
Leszek Swirski
2016/11/17 09:23:04
Whoops, yes it should. Bad rebase. I think the bel
| |
253 } | |
241 return OpParameter<const ZoneVector<MachineType>*>(op); | 254 return OpParameter<const ZoneVector<MachineType>*>(op); |
242 } | 255 } |
243 | 256 |
244 #define CACHED_OP_LIST(V) \ | 257 #define CACHED_OP_LIST(V) \ |
245 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \ | 258 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \ |
246 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 259 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
247 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 260 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
248 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 261 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
249 V(IfException, Operator::kKontrol, 0, 1, 1, 1, 1, 1) \ | 262 V(IfException, Operator::kKontrol, 0, 1, 1, 1, 1, 1) \ |
250 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 263 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 "Projection", // name | 594 "Projection", // name |
582 1, 0, 1, 1, 0, 0, // counts, | 595 1, 0, 1, 1, 0, 0, // counts, |
583 kIndex) {} // parameter | 596 kIndex) {} // parameter |
584 }; | 597 }; |
585 #define CACHED_PROJECTION(index) \ | 598 #define CACHED_PROJECTION(index) \ |
586 ProjectionOperator<index> kProjection##index##Operator; | 599 ProjectionOperator<index> kProjection##index##Operator; |
587 CACHED_PROJECTION_LIST(CACHED_PROJECTION) | 600 CACHED_PROJECTION_LIST(CACHED_PROJECTION) |
588 #undef CACHED_PROJECTION | 601 #undef CACHED_PROJECTION |
589 | 602 |
590 template <int kInputCount> | 603 template <int kInputCount> |
591 struct StateValuesOperator final : public Operator { | 604 struct StateValuesOperator final : public Operator1<uint32_t> { |
592 StateValuesOperator() | 605 StateValuesOperator() |
593 : Operator( // -- | 606 : Operator1<uint32_t>( // -- |
594 IrOpcode::kStateValues, // opcode | 607 IrOpcode::kStateValues, // opcode |
595 Operator::kPure, // flags | 608 Operator::kPure, // flags |
596 "StateValues", // name | 609 "StateValues", // name |
597 kInputCount, 0, 0, 1, 0, 0) {} // counts | 610 kInputCount, 0, 0, 1, 0, 0, // counts |
611 0) {} // parameter | |
598 }; | 612 }; |
599 #define CACHED_STATE_VALUES(input_count) \ | 613 #define CACHED_STATE_VALUES(input_count) \ |
600 StateValuesOperator<input_count> kStateValues##input_count##Operator; | 614 StateValuesOperator<input_count> kStateValues##input_count##Operator; |
601 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES) | 615 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES) |
602 #undef CACHED_STATE_VALUES | 616 #undef CACHED_STATE_VALUES |
603 }; | 617 }; |
604 | 618 |
605 | 619 |
606 static base::LazyInstance<CommonOperatorGlobalCache>::type kCache = | 620 static base::LazyInstance<CommonOperatorGlobalCache>::type kCache = |
607 LAZY_INSTANCE_INITIALIZER; | 621 LAZY_INSTANCE_INITIALIZER; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
993 switch (region_observability) { | 1007 switch (region_observability) { |
994 case RegionObservability::kObservable: | 1008 case RegionObservability::kObservable: |
995 return &cache_.kBeginRegionObservableOperator; | 1009 return &cache_.kBeginRegionObservableOperator; |
996 case RegionObservability::kNotObservable: | 1010 case RegionObservability::kNotObservable: |
997 return &cache_.kBeginRegionNotObservableOperator; | 1011 return &cache_.kBeginRegionNotObservableOperator; |
998 } | 1012 } |
999 UNREACHABLE(); | 1013 UNREACHABLE(); |
1000 return nullptr; | 1014 return nullptr; |
1001 } | 1015 } |
1002 | 1016 |
1003 const Operator* CommonOperatorBuilder::StateValues(int arguments) { | 1017 const Operator* CommonOperatorBuilder::StateValues(int arguments, |
1004 switch (arguments) { | 1018 uint32_t bitmask) { |
1019 if (bitmask == 0) { | |
1020 switch (arguments) { | |
1005 #define CACHED_STATE_VALUES(arguments) \ | 1021 #define CACHED_STATE_VALUES(arguments) \ |
1006 case arguments: \ | 1022 case arguments: \ |
1007 return &cache_.kStateValues##arguments##Operator; | 1023 return &cache_.kStateValues##arguments##Operator; |
1008 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES) | 1024 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES) |
1009 #undef CACHED_STATE_VALUES | 1025 #undef CACHED_STATE_VALUES |
1010 default: | 1026 default: |
1011 break; | 1027 break; |
1028 } | |
1012 } | 1029 } |
1030 | |
1013 // Uncached. | 1031 // Uncached. |
1014 return new (zone()) Operator( // -- | 1032 return new (zone()) Operator1<uint32_t>( // -- |
1015 IrOpcode::kStateValues, Operator::kPure, // opcode | 1033 IrOpcode::kStateValues, Operator::kPure, // opcode |
1016 "StateValues", // name | 1034 "StateValues", // name |
1017 arguments, 0, 0, 1, 0, 0); // counts | 1035 arguments, 0, 0, 1, 0, 0, // counts |
1036 bitmask); // parameter | |
1018 } | 1037 } |
1019 | 1038 |
1020 const Operator* CommonOperatorBuilder::TypedStateValues( | 1039 const Operator* CommonOperatorBuilder::TypedStateValues( |
1021 const ZoneVector<MachineType>* types) { | 1040 const ZoneVector<MachineType>* types, uint32_t bitmask) { |
1022 return new (zone()) Operator1<const ZoneVector<MachineType>*>( // -- | 1041 return new (zone()) |
1023 IrOpcode::kTypedStateValues, Operator::kPure, // opcode | 1042 Operator1<std::pair<const ZoneVector<MachineType>*, uint32_t>>( // -- |
1024 "TypedStateValues", // name | 1043 IrOpcode::kTypedStateValues, Operator::kPure, // opcode |
1025 static_cast<int>(types->size()), 0, 0, 1, 0, 0, // counts | 1044 "TypedStateValues", // name |
1026 types); // parameter | 1045 static_cast<int>(types->size()), 0, 0, 1, 0, 0, // counts |
1046 std::make_pair(types, bitmask)); // parameters | |
1027 } | 1047 } |
1028 | 1048 |
1029 const Operator* CommonOperatorBuilder::ObjectState(int pointer_slots) { | 1049 const Operator* CommonOperatorBuilder::ObjectState(int pointer_slots) { |
1030 return new (zone()) Operator1<int>( // -- | 1050 return new (zone()) Operator1<int>( // -- |
1031 IrOpcode::kObjectState, Operator::kPure, // opcode | 1051 IrOpcode::kObjectState, Operator::kPure, // opcode |
1032 "ObjectState", // name | 1052 "ObjectState", // name |
1033 pointer_slots, 0, 0, 1, 0, 0, // counts | 1053 pointer_slots, 0, 0, 1, 0, 0, // counts |
1034 pointer_slots); // parameter | 1054 pointer_slots); // parameter |
1035 } | 1055 } |
1036 | 1056 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1136 CommonOperatorBuilder::CreateFrameStateFunctionInfo( | 1156 CommonOperatorBuilder::CreateFrameStateFunctionInfo( |
1137 FrameStateType type, int parameter_count, int local_count, | 1157 FrameStateType type, int parameter_count, int local_count, |
1138 Handle<SharedFunctionInfo> shared_info) { | 1158 Handle<SharedFunctionInfo> shared_info) { |
1139 return new (zone()->New(sizeof(FrameStateFunctionInfo))) | 1159 return new (zone()->New(sizeof(FrameStateFunctionInfo))) |
1140 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); | 1160 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); |
1141 } | 1161 } |
1142 | 1162 |
1143 } // namespace compiler | 1163 } // namespace compiler |
1144 } // namespace internal | 1164 } // namespace internal |
1145 } // namespace v8 | 1165 } // namespace v8 |
OLD | NEW |