OLD | NEW |
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/types.h" | 10 #include "src/types.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 namespace compiler { | 14 namespace compiler { |
15 | 15 |
16 size_t hash_value(BaseTaggedness base_taggedness) { | |
17 return static_cast<uint8_t>(base_taggedness); | |
18 } | |
19 | |
20 std::ostream& operator<<(std::ostream& os, BaseTaggedness base_taggedness) { | 16 std::ostream& operator<<(std::ostream& os, BaseTaggedness base_taggedness) { |
21 switch (base_taggedness) { | 17 switch (base_taggedness) { |
22 case kUntaggedBase: | 18 case kUntaggedBase: |
23 return os << "untagged base"; | 19 return os << "untagged base"; |
24 case kTaggedBase: | 20 case kTaggedBase: |
25 return os << "tagged base"; | 21 return os << "tagged base"; |
26 } | 22 } |
27 UNREACHABLE(); | 23 UNREACHABLE(); |
28 return os; | 24 return os; |
29 } | 25 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 77 |
82 | 78 |
83 BufferAccess const BufferAccessOf(const Operator* op) { | 79 BufferAccess const BufferAccessOf(const Operator* op) { |
84 DCHECK(op->opcode() == IrOpcode::kLoadBuffer || | 80 DCHECK(op->opcode() == IrOpcode::kLoadBuffer || |
85 op->opcode() == IrOpcode::kStoreBuffer); | 81 op->opcode() == IrOpcode::kStoreBuffer); |
86 return OpParameter<BufferAccess>(op); | 82 return OpParameter<BufferAccess>(op); |
87 } | 83 } |
88 | 84 |
89 | 85 |
90 bool operator==(FieldAccess const& lhs, FieldAccess const& rhs) { | 86 bool operator==(FieldAccess const& lhs, FieldAccess const& rhs) { |
91 // On purpose we don't include the write barrier kind here, as this method is | |
92 // really only relevant for eliminating loads and they don't care about the | |
93 // write barrier mode. | |
94 return lhs.base_is_tagged == rhs.base_is_tagged && lhs.offset == rhs.offset && | 87 return lhs.base_is_tagged == rhs.base_is_tagged && lhs.offset == rhs.offset && |
95 lhs.machine_type == rhs.machine_type; | 88 lhs.machine_type == rhs.machine_type; |
96 } | 89 } |
97 | 90 |
98 | 91 |
99 bool operator!=(FieldAccess const& lhs, FieldAccess const& rhs) { | 92 bool operator!=(FieldAccess const& lhs, FieldAccess const& rhs) { |
100 return !(lhs == rhs); | 93 return !(lhs == rhs); |
101 } | 94 } |
102 | 95 |
103 | 96 |
104 size_t hash_value(FieldAccess const& access) { | 97 size_t hash_value(FieldAccess const& access) { |
105 // On purpose we don't include the write barrier kind here, as this method is | |
106 // really only relevant for eliminating loads and they don't care about the | |
107 // write barrier mode. | |
108 return base::hash_combine(access.base_is_tagged, access.offset, | 98 return base::hash_combine(access.base_is_tagged, access.offset, |
109 access.machine_type); | 99 access.machine_type); |
110 } | 100 } |
111 | 101 |
112 | 102 |
113 std::ostream& operator<<(std::ostream& os, FieldAccess const& access) { | 103 std::ostream& operator<<(std::ostream& os, FieldAccess const& access) { |
114 os << "[" << access.base_is_tagged << ", " << access.offset << ", "; | 104 os << "[" << access.base_is_tagged << ", " << access.offset << ", "; |
115 #ifdef OBJECT_PRINT | 105 #ifdef OBJECT_PRINT |
116 Handle<Name> name; | 106 Handle<Name> name; |
117 if (access.name.ToHandle(&name)) { | 107 if (access.name.ToHandle(&name)) { |
118 name->Print(os); | 108 name->Print(os); |
119 os << ", "; | 109 os << ", "; |
120 } | 110 } |
121 #endif | 111 #endif |
122 access.type->PrintTo(os); | 112 access.type->PrintTo(os); |
123 os << ", " << access.machine_type << ", " << access.write_barrier_kind << "]"; | 113 os << ", " << access.machine_type << "]"; |
124 return os; | 114 return os; |
125 } | 115 } |
126 | 116 |
127 | 117 |
128 bool operator==(ElementAccess const& lhs, ElementAccess const& rhs) { | 118 bool operator==(ElementAccess const& lhs, ElementAccess const& rhs) { |
129 // On purpose we don't include the write barrier kind here, as this method is | |
130 // really only relevant for eliminating loads and they don't care about the | |
131 // write barrier mode. | |
132 return lhs.base_is_tagged == rhs.base_is_tagged && | 119 return lhs.base_is_tagged == rhs.base_is_tagged && |
133 lhs.header_size == rhs.header_size && | 120 lhs.header_size == rhs.header_size && |
134 lhs.machine_type == rhs.machine_type; | 121 lhs.machine_type == rhs.machine_type; |
135 } | 122 } |
136 | 123 |
137 | 124 |
138 bool operator!=(ElementAccess const& lhs, ElementAccess const& rhs) { | 125 bool operator!=(ElementAccess const& lhs, ElementAccess const& rhs) { |
139 return !(lhs == rhs); | 126 return !(lhs == rhs); |
140 } | 127 } |
141 | 128 |
142 | 129 |
143 size_t hash_value(ElementAccess const& access) { | 130 size_t hash_value(ElementAccess const& access) { |
144 // On purpose we don't include the write barrier kind here, as this method is | |
145 // really only relevant for eliminating loads and they don't care about the | |
146 // write barrier mode. | |
147 return base::hash_combine(access.base_is_tagged, access.header_size, | 131 return base::hash_combine(access.base_is_tagged, access.header_size, |
148 access.machine_type); | 132 access.machine_type); |
149 } | 133 } |
150 | 134 |
151 | 135 |
152 std::ostream& operator<<(std::ostream& os, ElementAccess const& access) { | 136 std::ostream& operator<<(std::ostream& os, ElementAccess const& access) { |
153 os << access.base_is_tagged << ", " << access.header_size << ", "; | 137 os << access.base_is_tagged << ", " << access.header_size << ", "; |
154 access.type->PrintTo(os); | 138 access.type->PrintTo(os); |
155 os << ", " << access.machine_type << ", " << access.write_barrier_kind; | 139 os << ", " << access.machine_type; |
156 return os; | 140 return os; |
157 } | 141 } |
158 | 142 |
159 | 143 |
160 const FieldAccess& FieldAccessOf(const Operator* op) { | 144 const FieldAccess& FieldAccessOf(const Operator* op) { |
161 DCHECK_NOT_NULL(op); | 145 DCHECK_NOT_NULL(op); |
162 DCHECK(op->opcode() == IrOpcode::kLoadField || | 146 DCHECK(op->opcode() == IrOpcode::kLoadField || |
163 op->opcode() == IrOpcode::kStoreField); | 147 op->opcode() == IrOpcode::kStoreField); |
164 return OpParameter<FieldAccess>(op); | 148 return OpParameter<FieldAccess>(op); |
165 } | 149 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ | 318 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ |
335 #Name, value_input_count, 1, control_input_count, \ | 319 #Name, value_input_count, 1, control_input_count, \ |
336 output_count, 1, 0, access); \ | 320 output_count, 1, 0, access); \ |
337 } | 321 } |
338 ACCESS_OP_LIST(ACCESS) | 322 ACCESS_OP_LIST(ACCESS) |
339 #undef ACCESS | 323 #undef ACCESS |
340 | 324 |
341 } // namespace compiler | 325 } // namespace compiler |
342 } // namespace internal | 326 } // namespace internal |
343 } // namespace v8 | 327 } // namespace v8 |
OLD | NEW |