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/machine-operator.h" | 5 #include "src/compiler/machine-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/v8.h" |
| 11 #include "src/zone-inl.h" |
10 | 12 |
11 namespace v8 { | 13 namespace v8 { |
12 namespace internal { | 14 namespace internal { |
13 namespace compiler { | 15 namespace compiler { |
14 | 16 |
15 std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) { | 17 std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) { |
16 switch (kind) { | 18 switch (kind) { |
17 case kNoWriteBarrier: | 19 case kNoWriteBarrier: |
18 return os << "NoWriteBarrier"; | 20 return os << "NoWriteBarrier"; |
19 case kFullWriteBarrier: | 21 case kFullWriteBarrier: |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 Store##Type##FullWriteBarrier##Operator k##Store##Type##FullWriteBarrier; | 191 Store##Type##FullWriteBarrier##Operator k##Store##Type##FullWriteBarrier; |
190 MACHINE_TYPE_LIST(STORE) | 192 MACHINE_TYPE_LIST(STORE) |
191 #undef STORE | 193 #undef STORE |
192 }; | 194 }; |
193 | 195 |
194 | 196 |
195 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = | 197 static base::LazyInstance<MachineOperatorGlobalCache>::type kCache = |
196 LAZY_INSTANCE_INITIALIZER; | 198 LAZY_INSTANCE_INITIALIZER; |
197 | 199 |
198 | 200 |
199 MachineOperatorBuilder::MachineOperatorBuilder(MachineType word, Flags flags) | 201 MachineOperatorBuilder::MachineOperatorBuilder(Zone* zone, MachineType word, |
200 : cache_(kCache.Get()), word_(word), flags_(flags) { | 202 Flags flags) |
| 203 : zone_(zone), cache_(kCache.Get()), word_(word), flags_(flags) { |
201 DCHECK(word == kRepWord32 || word == kRepWord64); | 204 DCHECK(word == kRepWord32 || word == kRepWord64); |
202 } | 205 } |
203 | 206 |
204 | 207 |
205 #define PURE(Name, properties, value_input_count, control_input_count, \ | 208 #define PURE(Name, properties, value_input_count, control_input_count, \ |
206 output_count) \ | 209 output_count) \ |
207 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } | 210 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } |
208 PURE_OP_LIST(PURE) | 211 PURE_OP_LIST(PURE) |
209 #undef PURE | 212 #undef PURE |
210 | 213 |
211 | 214 |
212 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { | 215 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { |
213 switch (rep) { | 216 switch (rep) { |
214 #define LOAD(Type) \ | 217 #define LOAD(Type) \ |
215 case k##Type: \ | 218 case k##Type: \ |
216 return &cache_.k##Load##Type; | 219 return &cache_.k##Load##Type; |
217 MACHINE_TYPE_LIST(LOAD) | 220 MACHINE_TYPE_LIST(LOAD) |
218 #undef LOAD | 221 #undef LOAD |
219 | 222 |
220 default: | 223 default: |
221 break; | 224 break; |
222 } | 225 } |
223 UNREACHABLE(); | 226 // Uncached. |
224 return NULL; | 227 return new (zone_) Operator1<LoadRepresentation>( // -- |
| 228 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, "Load", 2, 1, 1, |
| 229 1, 1, 0, rep); |
225 } | 230 } |
226 | 231 |
227 | 232 |
228 const Operator* MachineOperatorBuilder::Store(StoreRepresentation rep) { | 233 const Operator* MachineOperatorBuilder::Store(StoreRepresentation rep) { |
229 switch (rep.machine_type()) { | 234 switch (rep.machine_type()) { |
230 #define STORE(Type) \ | 235 #define STORE(Type) \ |
231 case k##Type: \ | 236 case k##Type: \ |
232 switch (rep.write_barrier_kind()) { \ | 237 switch (rep.write_barrier_kind()) { \ |
233 case kNoWriteBarrier: \ | 238 case kNoWriteBarrier: \ |
234 return &cache_.k##Store##Type##NoWriteBarrier; \ | 239 return &cache_.k##Store##Type##NoWriteBarrier; \ |
235 case kFullWriteBarrier: \ | 240 case kFullWriteBarrier: \ |
236 return &cache_.k##Store##Type##FullWriteBarrier; \ | 241 return &cache_.k##Store##Type##FullWriteBarrier; \ |
237 } \ | 242 } \ |
238 break; | 243 break; |
239 MACHINE_TYPE_LIST(STORE) | 244 MACHINE_TYPE_LIST(STORE) |
240 #undef STORE | 245 #undef STORE |
241 | 246 |
242 default: | 247 default: |
243 break; | 248 break; |
244 } | 249 } |
245 UNREACHABLE(); | 250 // Uncached. |
246 return NULL; | 251 return new (zone_) Operator1<StoreRepresentation>( // -- |
| 252 IrOpcode::kStore, Operator::kNoRead | Operator::kNoThrow, "Store", 3, 1, |
| 253 1, 0, 1, 0, rep); |
247 } | 254 } |
248 } // namespace compiler | 255 } // namespace compiler |
249 } // namespace internal | 256 } // namespace internal |
250 } // namespace v8 | 257 } // namespace v8 |
OLD | NEW |