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/js-operator.h" | 5 #include "src/compiler/js-operator.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/lazy-instance.h" | 9 #include "src/base/lazy-instance.h" |
10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 << access.context_access(); | 198 << access.context_access(); |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 DynamicContextAccess const& DynamicContextAccessOf(Operator const* op) { | 202 DynamicContextAccess const& DynamicContextAccessOf(Operator const* op) { |
203 DCHECK_EQ(IrOpcode::kJSLoadDynamicContext, op->opcode()); | 203 DCHECK_EQ(IrOpcode::kJSLoadDynamicContext, op->opcode()); |
204 return OpParameter<DynamicContextAccess>(op); | 204 return OpParameter<DynamicContextAccess>(op); |
205 } | 205 } |
206 | 206 |
207 | 207 |
208 bool operator==(LoadNamedParameters const& lhs, | 208 bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) { |
209 LoadNamedParameters const& rhs) { | |
210 return lhs.name().location() == rhs.name().location() && | 209 return lhs.name().location() == rhs.name().location() && |
211 lhs.language_mode() == rhs.language_mode() && | 210 lhs.language_mode() == rhs.language_mode() && |
212 lhs.feedback() == rhs.feedback(); | 211 lhs.feedback() == rhs.feedback(); |
213 } | 212 } |
214 | 213 |
215 | 214 |
216 bool operator!=(LoadNamedParameters const& lhs, | 215 bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) { |
217 LoadNamedParameters const& rhs) { | |
218 return !(lhs == rhs); | 216 return !(lhs == rhs); |
219 } | 217 } |
220 | 218 |
221 | 219 |
222 size_t hash_value(LoadNamedParameters const& p) { | 220 size_t hash_value(NamedAccess const& p) { |
223 return base::hash_combine(p.name().location(), p.language_mode(), | 221 return base::hash_combine(p.name().location(), p.language_mode(), |
224 p.feedback()); | 222 p.feedback()); |
225 } | 223 } |
226 | 224 |
227 | 225 |
228 std::ostream& operator<<(std::ostream& os, LoadNamedParameters const& p) { | 226 std::ostream& operator<<(std::ostream& os, NamedAccess const& p) { |
229 return os << Brief(*p.name()) << ", " << p.language_mode(); | 227 return os << Brief(*p.name()) << ", " << p.language_mode(); |
230 } | 228 } |
231 | 229 |
232 | 230 |
233 std::ostream& operator<<(std::ostream& os, LoadPropertyParameters const& p) { | 231 NamedAccess const& NamedAccessOf(const Operator* op) { |
| 232 DCHECK(op->opcode() == IrOpcode::kJSLoadNamed || |
| 233 op->opcode() == IrOpcode::kJSStoreNamed); |
| 234 return OpParameter<NamedAccess>(op); |
| 235 } |
| 236 |
| 237 |
| 238 std::ostream& operator<<(std::ostream& os, PropertyAccess const& p) { |
234 return os << p.language_mode(); | 239 return os << p.language_mode(); |
235 } | 240 } |
236 | 241 |
237 | 242 |
238 bool operator==(LoadPropertyParameters const& lhs, | 243 bool operator==(PropertyAccess const& lhs, PropertyAccess const& rhs) { |
239 LoadPropertyParameters const& rhs) { | |
240 return lhs.language_mode() == rhs.language_mode() && | 244 return lhs.language_mode() == rhs.language_mode() && |
241 lhs.feedback() == rhs.feedback(); | 245 lhs.feedback() == rhs.feedback(); |
242 } | 246 } |
243 | 247 |
244 | 248 |
245 bool operator!=(LoadPropertyParameters const& lhs, | 249 bool operator!=(PropertyAccess const& lhs, PropertyAccess const& rhs) { |
246 LoadPropertyParameters const& rhs) { | |
247 return !(lhs == rhs); | 250 return !(lhs == rhs); |
248 } | 251 } |
249 | 252 |
250 | 253 |
251 const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op) { | 254 PropertyAccess const& PropertyAccessOf(const Operator* op) { |
252 DCHECK_EQ(IrOpcode::kJSLoadProperty, op->opcode()); | 255 DCHECK(op->opcode() == IrOpcode::kJSLoadProperty || |
253 return OpParameter<LoadPropertyParameters>(op); | 256 op->opcode() == IrOpcode::kJSStoreProperty); |
| 257 return OpParameter<PropertyAccess>(op); |
254 } | 258 } |
255 | 259 |
256 | 260 |
257 size_t hash_value(LoadPropertyParameters const& p) { | 261 size_t hash_value(PropertyAccess const& p) { |
258 return base::hash_combine(p.language_mode(), p.feedback()); | 262 return base::hash_combine(p.language_mode(), p.feedback()); |
259 } | 263 } |
260 | 264 |
261 | 265 |
262 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { | |
263 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); | |
264 return OpParameter<LoadNamedParameters>(op); | |
265 } | |
266 | |
267 | |
268 bool operator==(LoadGlobalParameters const& lhs, | 266 bool operator==(LoadGlobalParameters const& lhs, |
269 LoadGlobalParameters const& rhs) { | 267 LoadGlobalParameters const& rhs) { |
270 return lhs.name().location() == rhs.name().location() && | 268 return lhs.name().location() == rhs.name().location() && |
271 lhs.feedback() == rhs.feedback() && | 269 lhs.feedback() == rhs.feedback() && |
272 lhs.typeof_mode() == rhs.typeof_mode() && | 270 lhs.typeof_mode() == rhs.typeof_mode() && |
273 lhs.slot_index() == rhs.slot_index(); | 271 lhs.slot_index() == rhs.slot_index(); |
274 } | 272 } |
275 | 273 |
276 | 274 |
277 bool operator!=(LoadGlobalParameters const& lhs, | 275 bool operator!=(LoadGlobalParameters const& lhs, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 << ", slot: " << p.slot_index(); | 322 << ", slot: " << p.slot_index(); |
325 } | 323 } |
326 | 324 |
327 | 325 |
328 const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) { | 326 const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) { |
329 DCHECK_EQ(IrOpcode::kJSStoreGlobal, op->opcode()); | 327 DCHECK_EQ(IrOpcode::kJSStoreGlobal, op->opcode()); |
330 return OpParameter<StoreGlobalParameters>(op); | 328 return OpParameter<StoreGlobalParameters>(op); |
331 } | 329 } |
332 | 330 |
333 | 331 |
334 bool operator==(StoreNamedParameters const& lhs, | |
335 StoreNamedParameters const& rhs) { | |
336 return lhs.language_mode() == rhs.language_mode() && | |
337 lhs.name().location() == rhs.name().location() && | |
338 lhs.feedback() == rhs.feedback(); | |
339 } | |
340 | |
341 | |
342 bool operator!=(StoreNamedParameters const& lhs, | |
343 StoreNamedParameters const& rhs) { | |
344 return !(lhs == rhs); | |
345 } | |
346 | |
347 | |
348 size_t hash_value(StoreNamedParameters const& p) { | |
349 return base::hash_combine(p.language_mode(), p.name().location(), | |
350 p.feedback()); | |
351 } | |
352 | |
353 | |
354 std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) { | |
355 return os << p.language_mode() << ", " << Brief(*p.name()); | |
356 } | |
357 | |
358 | |
359 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { | |
360 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); | |
361 return OpParameter<StoreNamedParameters>(op); | |
362 } | |
363 | |
364 | |
365 bool operator==(StorePropertyParameters const& lhs, | |
366 StorePropertyParameters const& rhs) { | |
367 return lhs.language_mode() == rhs.language_mode() && | |
368 lhs.feedback() == rhs.feedback(); | |
369 } | |
370 | |
371 | |
372 bool operator!=(StorePropertyParameters const& lhs, | |
373 StorePropertyParameters const& rhs) { | |
374 return !(lhs == rhs); | |
375 } | |
376 | |
377 | |
378 size_t hash_value(StorePropertyParameters const& p) { | |
379 return base::hash_combine(p.language_mode(), p.feedback()); | |
380 } | |
381 | |
382 | |
383 std::ostream& operator<<(std::ostream& os, StorePropertyParameters const& p) { | |
384 return os << p.language_mode(); | |
385 } | |
386 | |
387 | |
388 const StorePropertyParameters& StorePropertyParametersOf(const Operator* op) { | |
389 DCHECK_EQ(IrOpcode::kJSStoreProperty, op->opcode()); | |
390 return OpParameter<StorePropertyParameters>(op); | |
391 } | |
392 | |
393 | |
394 bool operator==(CreateArgumentsParameters const& lhs, | 332 bool operator==(CreateArgumentsParameters const& lhs, |
395 CreateArgumentsParameters const& rhs) { | 333 CreateArgumentsParameters const& rhs) { |
396 return lhs.type() == rhs.type() && lhs.start_index() == rhs.start_index(); | 334 return lhs.type() == rhs.type() && lhs.start_index() == rhs.start_index(); |
397 } | 335 } |
398 | 336 |
399 | 337 |
400 bool operator!=(CreateArgumentsParameters const& lhs, | 338 bool operator!=(CreateArgumentsParameters const& lhs, |
401 CreateArgumentsParameters const& rhs) { | 339 CreateArgumentsParameters const& rhs) { |
402 return !(lhs == rhs); | 340 return !(lhs == rhs); |
403 } | 341 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 | 531 |
594 const Operator* JSOperatorBuilder::CallConstruct(int arguments) { | 532 const Operator* JSOperatorBuilder::CallConstruct(int arguments) { |
595 return new (zone()) Operator1<int>( // -- | 533 return new (zone()) Operator1<int>( // -- |
596 IrOpcode::kJSCallConstruct, Operator::kNoProperties, // opcode | 534 IrOpcode::kJSCallConstruct, Operator::kNoProperties, // opcode |
597 "JSCallConstruct", // name | 535 "JSCallConstruct", // name |
598 arguments, 1, 1, 1, 1, 2, // counts | 536 arguments, 1, 1, 1, 1, 2, // counts |
599 arguments); // parameter | 537 arguments); // parameter |
600 } | 538 } |
601 | 539 |
602 | 540 |
603 const Operator* JSOperatorBuilder::LoadNamed(const Handle<Name>& name, | 541 const Operator* JSOperatorBuilder::LoadNamed(LanguageMode language_mode, |
604 const VectorSlotPair& feedback, | 542 Handle<Name> name, |
605 LanguageMode language_mode) { | 543 const VectorSlotPair& feedback) { |
606 LoadNamedParameters parameters(name, feedback, language_mode); | 544 NamedAccess access(language_mode, name, feedback); |
607 return new (zone()) Operator1<LoadNamedParameters>( // -- | 545 return new (zone()) Operator1<NamedAccess>( // -- |
608 IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode | 546 IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode |
609 "JSLoadNamed", // name | 547 "JSLoadNamed", // name |
610 2, 1, 1, 1, 1, 2, // counts | 548 2, 1, 1, 1, 1, 2, // counts |
611 parameters); // parameter | 549 access); // parameter |
612 } | 550 } |
613 | 551 |
614 | 552 |
615 const Operator* JSOperatorBuilder::LoadProperty(const VectorSlotPair& feedback, | 553 const Operator* JSOperatorBuilder::LoadProperty( |
616 LanguageMode language_mode) { | 554 LanguageMode language_mode, VectorSlotPair const& feedback) { |
617 LoadPropertyParameters parameters(feedback, language_mode); | 555 PropertyAccess access(language_mode, feedback); |
618 return new (zone()) Operator1<LoadPropertyParameters>( // -- | 556 return new (zone()) Operator1<PropertyAccess>( // -- |
619 IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode | 557 IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode |
620 "JSLoadProperty", // name | 558 "JSLoadProperty", // name |
621 3, 1, 1, 1, 1, 2, // counts | 559 3, 1, 1, 1, 1, 2, // counts |
622 parameters); // parameter | 560 access); // parameter |
623 } | 561 } |
624 | 562 |
625 | 563 |
626 const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode, | 564 const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode, |
627 const Handle<Name>& name, | 565 Handle<Name> name, |
628 const VectorSlotPair& feedback) { | 566 VectorSlotPair const& feedback) { |
629 StoreNamedParameters parameters(language_mode, feedback, name); | 567 NamedAccess access(language_mode, name, feedback); |
630 return new (zone()) Operator1<StoreNamedParameters>( // -- | 568 return new (zone()) Operator1<NamedAccess>( // -- |
631 IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode | 569 IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode |
632 "JSStoreNamed", // name | 570 "JSStoreNamed", // name |
633 3, 1, 1, 0, 1, 2, // counts | 571 3, 1, 1, 0, 1, 2, // counts |
634 parameters); // parameter | 572 access); // parameter |
635 } | 573 } |
636 | 574 |
637 | 575 |
638 const Operator* JSOperatorBuilder::StoreProperty( | 576 const Operator* JSOperatorBuilder::StoreProperty( |
639 LanguageMode language_mode, const VectorSlotPair& feedback) { | 577 LanguageMode language_mode, VectorSlotPair const& feedback) { |
640 StorePropertyParameters parameters(language_mode, feedback); | 578 PropertyAccess access(language_mode, feedback); |
641 return new (zone()) Operator1<StorePropertyParameters>( // -- | 579 return new (zone()) Operator1<PropertyAccess>( // -- |
642 IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode | 580 IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode |
643 "JSStoreProperty", // name | 581 "JSStoreProperty", // name |
644 4, 1, 1, 0, 1, 2, // counts | 582 4, 1, 1, 0, 1, 2, // counts |
645 parameters); // parameter | 583 access); // parameter |
646 } | 584 } |
647 | 585 |
648 | 586 |
649 const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { | 587 const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { |
650 return new (zone()) Operator1<LanguageMode>( // -- | 588 return new (zone()) Operator1<LanguageMode>( // -- |
651 IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode | 589 IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode |
652 "JSDeleteProperty", // name | 590 "JSDeleteProperty", // name |
653 2, 1, 1, 1, 1, 2, // counts | 591 2, 1, 1, 1, 1, 2, // counts |
654 language_mode); // parameter | 592 language_mode); // parameter |
655 } | 593 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 Handle<ScopeInfo>::hash>( // -- | 745 Handle<ScopeInfo>::hash>( // -- |
808 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode | 746 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode |
809 "JSCreateScriptContext", // name | 747 "JSCreateScriptContext", // name |
810 1, 1, 1, 1, 1, 2, // counts | 748 1, 1, 1, 1, 1, 2, // counts |
811 scpope_info); // parameter | 749 scpope_info); // parameter |
812 } | 750 } |
813 | 751 |
814 } // namespace compiler | 752 } // namespace compiler |
815 } // namespace internal | 753 } // namespace internal |
816 } // namespace v8 | 754 } // namespace v8 |
OLD | NEW |