OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 V(BitwiseBinaryOperation) \ | 58 V(BitwiseBinaryOperation) \ |
59 V(ControlInstruction) \ | 59 V(ControlInstruction) \ |
60 V(Instruction) \ | 60 V(Instruction) \ |
61 | 61 |
62 | 62 |
63 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ | 63 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ |
64 V(AbnormalExit) \ | 64 V(AbnormalExit) \ |
65 V(AccessArgumentsAt) \ | 65 V(AccessArgumentsAt) \ |
66 V(Add) \ | 66 V(Add) \ |
67 V(Allocate) \ | 67 V(Allocate) \ |
68 V(AllocateObject) \ | |
69 V(ApplyArguments) \ | 68 V(ApplyArguments) \ |
70 V(ArgumentsElements) \ | 69 V(ArgumentsElements) \ |
71 V(ArgumentsLength) \ | 70 V(ArgumentsLength) \ |
72 V(ArgumentsObject) \ | 71 V(ArgumentsObject) \ |
73 V(Bitwise) \ | 72 V(Bitwise) \ |
74 V(BitNot) \ | 73 V(BitNot) \ |
75 V(BlockEntry) \ | 74 V(BlockEntry) \ |
76 V(BoundsCheck) \ | 75 V(BoundsCheck) \ |
77 V(BoundsCheckBaseIndexInformation) \ | 76 V(BoundsCheckBaseIndexInformation) \ |
78 V(Branch) \ | 77 V(Branch) \ |
(...skipping 4713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4792 } | 4791 } |
4793 | 4792 |
4794 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) | 4793 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) |
4795 | 4794 |
4796 private: | 4795 private: |
4797 Handle<Object> name_; | 4796 Handle<Object> name_; |
4798 bool for_typeof_; | 4797 bool for_typeof_; |
4799 }; | 4798 }; |
4800 | 4799 |
4801 | 4800 |
4802 class HAllocateObject: public HTemplateInstruction<1> { | |
4803 public: | |
4804 HAllocateObject(HValue* context, Handle<JSFunction> constructor) | |
4805 : constructor_(constructor) { | |
4806 SetOperandAt(0, context); | |
4807 set_representation(Representation::Tagged()); | |
4808 SetGVNFlag(kChangesNewSpacePromotion); | |
4809 constructor_initial_map_ = constructor->has_initial_map() | |
4810 ? Handle<Map>(constructor->initial_map()) | |
4811 : Handle<Map>::null(); | |
4812 // If slack tracking finished, the instance size and property counts | |
4813 // remain unchanged so that we can allocate memory for the object. | |
4814 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); | |
4815 } | |
4816 | |
4817 // Maximum instance size for which allocations will be inlined. | |
4818 static const int kMaxSize = 64 * kPointerSize; | |
4819 | |
4820 HValue* context() { return OperandAt(0); } | |
4821 Handle<JSFunction> constructor() { return constructor_; } | |
4822 Handle<Map> constructor_initial_map() { return constructor_initial_map_; } | |
4823 | |
4824 virtual Representation RequiredInputRepresentation(int index) { | |
4825 return Representation::Tagged(); | |
4826 } | |
4827 virtual Handle<Map> GetMonomorphicJSObjectMap() { | |
4828 ASSERT(!constructor_initial_map_.is_null()); | |
4829 return constructor_initial_map_; | |
4830 } | |
4831 virtual HType CalculateInferredType(); | |
4832 | |
4833 DECLARE_CONCRETE_INSTRUCTION(AllocateObject) | |
4834 | |
4835 private: | |
4836 // TODO(svenpanne) Might be safe, but leave it out until we know for sure. | |
4837 // virtual bool IsDeletable() const { return true; } | |
4838 | |
4839 Handle<JSFunction> constructor_; | |
4840 Handle<Map> constructor_initial_map_; | |
4841 }; | |
4842 | |
4843 | |
4844 class HAllocate: public HTemplateInstruction<2> { | 4801 class HAllocate: public HTemplateInstruction<2> { |
4845 public: | 4802 public: |
4846 enum Flags { | 4803 enum Flags { |
4847 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, | 4804 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, |
4848 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, | 4805 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, |
4849 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, | 4806 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, |
4850 ALLOCATE_DOUBLE_ALIGNED = 1 << 3 | 4807 ALLOCATE_DOUBLE_ALIGNED = 1 << 3 |
4851 }; | 4808 }; |
4852 | 4809 |
4853 HAllocate(HValue* context, HValue* size, HType type, Flags flags) | 4810 HAllocate(HValue* context, HValue* size, HType type, Flags flags) |
4854 : type_(type), | 4811 : type_(type), |
4855 flags_(flags) { | 4812 flags_(flags) { |
4856 SetOperandAt(0, context); | 4813 SetOperandAt(0, context); |
4857 SetOperandAt(1, size); | 4814 SetOperandAt(1, size); |
4858 set_representation(Representation::Tagged()); | 4815 set_representation(Representation::Tagged()); |
4859 SetGVNFlag(kChangesNewSpacePromotion); | 4816 SetGVNFlag(kChangesNewSpacePromotion); |
4860 } | 4817 } |
4861 | 4818 |
| 4819 // Maximum instance size for which allocations will be inlined. |
| 4820 static const int kMaxInlineSize = 64 * kPointerSize; |
| 4821 |
4862 static Flags DefaultFlags() { | 4822 static Flags DefaultFlags() { |
4863 return CAN_ALLOCATE_IN_NEW_SPACE; | 4823 return CAN_ALLOCATE_IN_NEW_SPACE; |
4864 } | 4824 } |
4865 | 4825 |
4866 static Flags DefaultFlags(ElementsKind kind) { | 4826 static Flags DefaultFlags(ElementsKind kind) { |
4867 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE; | 4827 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE; |
4868 if (IsFastDoubleElementsKind(kind)) { | 4828 if (IsFastDoubleElementsKind(kind)) { |
4869 flags = static_cast<HAllocate::Flags>( | 4829 flags = static_cast<HAllocate::Flags>( |
4870 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); | 4830 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); |
4871 } | 4831 } |
4872 return flags; | 4832 return flags; |
4873 } | 4833 } |
4874 | 4834 |
4875 HValue* context() { return OperandAt(0); } | 4835 HValue* context() { return OperandAt(0); } |
4876 HValue* size() { return OperandAt(1); } | 4836 HValue* size() { return OperandAt(1); } |
4877 | 4837 |
4878 virtual Representation RequiredInputRepresentation(int index) { | 4838 virtual Representation RequiredInputRepresentation(int index) { |
4879 if (index == 0) { | 4839 if (index == 0) { |
4880 return Representation::Tagged(); | 4840 return Representation::Tagged(); |
4881 } else { | 4841 } else { |
4882 return Representation::Integer32(); | 4842 return Representation::Integer32(); |
4883 } | 4843 } |
4884 } | 4844 } |
4885 | 4845 |
| 4846 virtual Handle<Map> GetMonomorphicJSObjectMap() { |
| 4847 return known_initial_map_; |
| 4848 } |
| 4849 |
| 4850 void set_known_initial_map(Handle<Map> known_initial_map) { |
| 4851 known_initial_map_ = known_initial_map; |
| 4852 } |
| 4853 |
4886 virtual HType CalculateInferredType(); | 4854 virtual HType CalculateInferredType(); |
4887 | 4855 |
4888 bool CanAllocateInNewSpace() const { | 4856 bool CanAllocateInNewSpace() const { |
4889 return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; | 4857 return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; |
4890 } | 4858 } |
4891 | 4859 |
4892 bool CanAllocateInOldDataSpace() const { | 4860 bool CanAllocateInOldDataSpace() const { |
4893 return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0; | 4861 return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0; |
4894 } | 4862 } |
4895 | 4863 |
(...skipping 14 matching lines...) Expand all Loading... |
4910 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0; | 4878 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0; |
4911 } | 4879 } |
4912 | 4880 |
4913 virtual void PrintDataTo(StringStream* stream); | 4881 virtual void PrintDataTo(StringStream* stream); |
4914 | 4882 |
4915 DECLARE_CONCRETE_INSTRUCTION(Allocate) | 4883 DECLARE_CONCRETE_INSTRUCTION(Allocate) |
4916 | 4884 |
4917 private: | 4885 private: |
4918 HType type_; | 4886 HType type_; |
4919 Flags flags_; | 4887 Flags flags_; |
| 4888 Handle<Map> known_initial_map_; |
4920 }; | 4889 }; |
4921 | 4890 |
4922 | 4891 |
4923 class HInnerAllocatedObject: public HTemplateInstruction<1> { | 4892 class HInnerAllocatedObject: public HTemplateInstruction<1> { |
4924 public: | 4893 public: |
4925 HInnerAllocatedObject(HValue* value, int offset) | 4894 HInnerAllocatedObject(HValue* value, int offset) |
4926 : offset_(offset) { | 4895 : offset_(offset) { |
4927 ASSERT(value->IsAllocate()); | 4896 ASSERT(value->IsAllocate()); |
4928 SetOperandAt(0, value); | 4897 SetOperandAt(0, value); |
4929 set_representation(Representation::Tagged()); | 4898 set_representation(Representation::Tagged()); |
(...skipping 23 matching lines...) Expand all Loading... |
4953 | 4922 |
4954 | 4923 |
4955 inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, | 4924 inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, |
4956 HValue* new_space_dominator) { | 4925 HValue* new_space_dominator) { |
4957 if (object->IsInnerAllocatedObject()) { | 4926 if (object->IsInnerAllocatedObject()) { |
4958 return ReceiverObjectNeedsWriteBarrier( | 4927 return ReceiverObjectNeedsWriteBarrier( |
4959 HInnerAllocatedObject::cast(object)->base_object(), | 4928 HInnerAllocatedObject::cast(object)->base_object(), |
4960 new_space_dominator); | 4929 new_space_dominator); |
4961 } | 4930 } |
4962 if (object != new_space_dominator) return true; | 4931 if (object != new_space_dominator) return true; |
4963 if (object->IsAllocateObject()) return false; | |
4964 if (object->IsAllocate()) { | 4932 if (object->IsAllocate()) { |
4965 return !HAllocate::cast(object)->GuaranteedInNewSpace(); | 4933 return !HAllocate::cast(object)->GuaranteedInNewSpace(); |
4966 } | 4934 } |
4967 return true; | 4935 return true; |
4968 } | 4936 } |
4969 | 4937 |
4970 | 4938 |
4971 class HStoreGlobalCell: public HUnaryOperation { | 4939 class HStoreGlobalCell: public HUnaryOperation { |
4972 public: | 4940 public: |
4973 HStoreGlobalCell(HValue* value, | 4941 HStoreGlobalCell(HValue* value, |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6500 virtual bool IsDeletable() const { return true; } | 6468 virtual bool IsDeletable() const { return true; } |
6501 }; | 6469 }; |
6502 | 6470 |
6503 | 6471 |
6504 #undef DECLARE_INSTRUCTION | 6472 #undef DECLARE_INSTRUCTION |
6505 #undef DECLARE_CONCRETE_INSTRUCTION | 6473 #undef DECLARE_CONCRETE_INSTRUCTION |
6506 | 6474 |
6507 } } // namespace v8::internal | 6475 } } // namespace v8::internal |
6508 | 6476 |
6509 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6477 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |