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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 return os << p.pretenure() << ", " << Brief(*p.shared_info()); | 403 return os << p.pretenure() << ", " << Brief(*p.shared_info()); |
404 } | 404 } |
405 | 405 |
406 | 406 |
407 const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) { | 407 const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) { |
408 DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode()); | 408 DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode()); |
409 return OpParameter<CreateClosureParameters>(op); | 409 return OpParameter<CreateClosureParameters>(op); |
410 } | 410 } |
411 | 411 |
412 | 412 |
| 413 bool operator==(CreateLiteralParameters const& lhs, |
| 414 CreateLiteralParameters const& rhs) { |
| 415 return lhs.constants().location() == rhs.constants().location() && |
| 416 lhs.flags() == rhs.flags() && lhs.index() == rhs.index(); |
| 417 } |
| 418 |
| 419 |
| 420 bool operator!=(CreateLiteralParameters const& lhs, |
| 421 CreateLiteralParameters const& rhs) { |
| 422 return !(lhs == rhs); |
| 423 } |
| 424 |
| 425 |
| 426 size_t hash_value(CreateLiteralParameters const& p) { |
| 427 return base::hash_combine(p.constants().location(), p.flags(), p.index()); |
| 428 } |
| 429 |
| 430 |
| 431 std::ostream& operator<<(std::ostream& os, CreateLiteralParameters const& p) { |
| 432 return os << Brief(*p.constants()) << ", " << p.flags() << ", " << p.index(); |
| 433 } |
| 434 |
| 435 |
| 436 const CreateLiteralParameters& CreateLiteralParametersOf(const Operator* op) { |
| 437 DCHECK(op->opcode() == IrOpcode::kJSCreateLiteralArray || |
| 438 op->opcode() == IrOpcode::kJSCreateLiteralObject); |
| 439 return OpParameter<CreateLiteralParameters>(op); |
| 440 } |
| 441 |
| 442 |
413 #define CACHED_OP_LIST(V) \ | 443 #define CACHED_OP_LIST(V) \ |
414 V(Equal, Operator::kNoProperties, 2, 1) \ | 444 V(Equal, Operator::kNoProperties, 2, 1) \ |
415 V(NotEqual, Operator::kNoProperties, 2, 1) \ | 445 V(NotEqual, Operator::kNoProperties, 2, 1) \ |
416 V(StrictEqual, Operator::kNoThrow, 2, 1) \ | 446 V(StrictEqual, Operator::kNoThrow, 2, 1) \ |
417 V(StrictNotEqual, Operator::kNoThrow, 2, 1) \ | 447 V(StrictNotEqual, Operator::kNoThrow, 2, 1) \ |
418 V(UnaryNot, Operator::kEliminatable, 1, 1) \ | 448 V(UnaryNot, Operator::kEliminatable, 1, 1) \ |
419 V(ToBoolean, Operator::kEliminatable, 1, 1) \ | 449 V(ToBoolean, Operator::kEliminatable, 1, 1) \ |
420 V(ToNumber, Operator::kNoProperties, 1, 1) \ | 450 V(ToNumber, Operator::kNoProperties, 1, 1) \ |
421 V(ToString, Operator::kNoProperties, 1, 1) \ | 451 V(ToString, Operator::kNoProperties, 1, 1) \ |
422 V(ToName, Operator::kNoProperties, 1, 1) \ | 452 V(ToName, Operator::kNoProperties, 1, 1) \ |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { | 746 Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { |
717 CreateClosureParameters parameters(shared_info, pretenure); | 747 CreateClosureParameters parameters(shared_info, pretenure); |
718 return new (zone()) Operator1<CreateClosureParameters>( // -- | 748 return new (zone()) Operator1<CreateClosureParameters>( // -- |
719 IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode | 749 IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode |
720 "JSCreateClosure", // name | 750 "JSCreateClosure", // name |
721 0, 1, 1, 1, 1, 0, // counts | 751 0, 1, 1, 1, 1, 0, // counts |
722 parameters); // parameter | 752 parameters); // parameter |
723 } | 753 } |
724 | 754 |
725 | 755 |
726 const Operator* JSOperatorBuilder::CreateLiteralArray(int literal_flags) { | 756 const Operator* JSOperatorBuilder::CreateLiteralArray( |
727 return new (zone()) Operator1<int>( // -- | 757 Handle<FixedArray> constant_elements, int literal_flags, |
| 758 int literal_index) { |
| 759 CreateLiteralParameters parameters(constant_elements, literal_flags, |
| 760 literal_index); |
| 761 return new (zone()) Operator1<CreateLiteralParameters>( // -- |
728 IrOpcode::kJSCreateLiteralArray, Operator::kNoProperties, // opcode | 762 IrOpcode::kJSCreateLiteralArray, Operator::kNoProperties, // opcode |
729 "JSCreateLiteralArray", // name | 763 "JSCreateLiteralArray", // name |
730 3, 1, 1, 1, 1, 2, // counts | 764 1, 1, 1, 1, 1, 2, // counts |
731 literal_flags); // parameter | 765 parameters); // parameter |
732 } | 766 } |
733 | 767 |
734 | 768 |
735 const Operator* JSOperatorBuilder::CreateLiteralObject(int literal_flags) { | 769 const Operator* JSOperatorBuilder::CreateLiteralObject( |
736 return new (zone()) Operator1<int>( // -- | 770 Handle<FixedArray> constant_properties, int literal_flags, |
| 771 int literal_index) { |
| 772 CreateLiteralParameters parameters(constant_properties, literal_flags, |
| 773 literal_index); |
| 774 return new (zone()) Operator1<CreateLiteralParameters>( // -- |
737 IrOpcode::kJSCreateLiteralObject, Operator::kNoProperties, // opcode | 775 IrOpcode::kJSCreateLiteralObject, Operator::kNoProperties, // opcode |
738 "JSCreateLiteralObject", // name | 776 "JSCreateLiteralObject", // name |
739 3, 1, 1, 1, 1, 2, // counts | 777 1, 1, 1, 1, 1, 2, // counts |
740 literal_flags); // parameter | 778 parameters); // parameter |
741 } | 779 } |
742 | 780 |
743 | 781 |
744 const Operator* JSOperatorBuilder::CreateFunctionContext(int slot_count) { | 782 const Operator* JSOperatorBuilder::CreateFunctionContext(int slot_count) { |
745 return new (zone()) Operator1<int>( // -- | 783 return new (zone()) Operator1<int>( // -- |
746 IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode | 784 IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode |
747 "JSCreateFunctionContext", // name | 785 "JSCreateFunctionContext", // name |
748 1, 1, 1, 1, 1, 2, // counts | 786 1, 1, 1, 1, 1, 2, // counts |
749 slot_count); // parameter | 787 slot_count); // parameter |
750 } | 788 } |
(...skipping 24 matching lines...) Expand all Loading... |
775 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- | 813 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- |
776 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode | 814 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode |
777 "JSCreateScriptContext", // name | 815 "JSCreateScriptContext", // name |
778 1, 1, 1, 1, 1, 2, // counts | 816 1, 1, 1, 1, 1, 2, // counts |
779 scpope_info); // parameter | 817 scpope_info); // parameter |
780 } | 818 } |
781 | 819 |
782 } // namespace compiler | 820 } // namespace compiler |
783 } // namespace internal | 821 } // namespace internal |
784 } // namespace v8 | 822 } // namespace v8 |
OLD | NEW |