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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 V(BitwiseBinaryOperation) \ | 59 V(BitwiseBinaryOperation) \ |
60 V(ControlInstruction) \ | 60 V(ControlInstruction) \ |
61 V(Instruction) \ | 61 V(Instruction) \ |
62 | 62 |
63 | 63 |
64 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ | 64 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ |
65 V(AbnormalExit) \ | 65 V(AbnormalExit) \ |
66 V(AccessArgumentsAt) \ | 66 V(AccessArgumentsAt) \ |
67 V(Add) \ | 67 V(Add) \ |
68 V(Allocate) \ | 68 V(Allocate) \ |
| 69 V(AllocateObject) \ |
69 V(ApplyArguments) \ | 70 V(ApplyArguments) \ |
70 V(ArgumentsElements) \ | 71 V(ArgumentsElements) \ |
71 V(ArgumentsLength) \ | 72 V(ArgumentsLength) \ |
72 V(ArgumentsObject) \ | 73 V(ArgumentsObject) \ |
73 V(Bitwise) \ | 74 V(Bitwise) \ |
74 V(BitNot) \ | 75 V(BitNot) \ |
75 V(BlockEntry) \ | 76 V(BlockEntry) \ |
76 V(BoundsCheck) \ | 77 V(BoundsCheck) \ |
77 V(BoundsCheckBaseIndexInformation) \ | 78 V(BoundsCheckBaseIndexInformation) \ |
78 V(Branch) \ | 79 V(Branch) \ |
(...skipping 4841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4920 } | 4921 } |
4921 | 4922 |
4922 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) | 4923 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) |
4923 | 4924 |
4924 private: | 4925 private: |
4925 Handle<Object> name_; | 4926 Handle<Object> name_; |
4926 bool for_typeof_; | 4927 bool for_typeof_; |
4927 }; | 4928 }; |
4928 | 4929 |
4929 | 4930 |
| 4931 class HAllocateObject: public HTemplateInstruction<1> { |
| 4932 public: |
| 4933 HAllocateObject(HValue* context, Handle<JSFunction> constructor) |
| 4934 : constructor_(constructor) { |
| 4935 SetOperandAt(0, context); |
| 4936 set_representation(Representation::Tagged()); |
| 4937 SetGVNFlag(kChangesNewSpacePromotion); |
| 4938 constructor_initial_map_ = constructor->has_initial_map() |
| 4939 ? Handle<Map>(constructor->initial_map()) |
| 4940 : Handle<Map>::null(); |
| 4941 // If slack tracking finished, the instance size and property counts |
| 4942 // remain unchanged so that we can allocate memory for the object. |
| 4943 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); |
| 4944 } |
| 4945 |
| 4946 // Maximum instance size for which allocations will be inlined. |
| 4947 static const int kMaxSize = 64 * kPointerSize; |
| 4948 |
| 4949 HValue* context() { return OperandAt(0); } |
| 4950 Handle<JSFunction> constructor() { return constructor_; } |
| 4951 Handle<Map> constructor_initial_map() { return constructor_initial_map_; } |
| 4952 |
| 4953 virtual Representation RequiredInputRepresentation(int index) { |
| 4954 return Representation::Tagged(); |
| 4955 } |
| 4956 virtual Handle<Map> GetMonomorphicJSObjectMap() { |
| 4957 ASSERT(!constructor_initial_map_.is_null()); |
| 4958 return constructor_initial_map_; |
| 4959 } |
| 4960 virtual HType CalculateInferredType(); |
| 4961 |
| 4962 DECLARE_CONCRETE_INSTRUCTION(AllocateObject) |
| 4963 |
| 4964 private: |
| 4965 // TODO(svenpanne) Might be safe, but leave it out until we know for sure. |
| 4966 // virtual bool IsDeletable() const { return true; } |
| 4967 |
| 4968 Handle<JSFunction> constructor_; |
| 4969 Handle<Map> constructor_initial_map_; |
| 4970 }; |
| 4971 |
| 4972 |
4930 class HAllocate: public HTemplateInstruction<2> { | 4973 class HAllocate: public HTemplateInstruction<2> { |
4931 public: | 4974 public: |
4932 enum Flags { | 4975 enum Flags { |
4933 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, | 4976 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, |
4934 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, | 4977 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, |
4935 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, | 4978 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, |
4936 ALLOCATE_DOUBLE_ALIGNED = 1 << 3 | 4979 ALLOCATE_DOUBLE_ALIGNED = 1 << 3 |
4937 }; | 4980 }; |
4938 | 4981 |
4939 HAllocate(HValue* context, HValue* size, HType type, Flags flags) | 4982 HAllocate(HValue* context, HValue* size, HType type, Flags flags) |
4940 : type_(type), | 4983 : type_(type), |
4941 flags_(flags) { | 4984 flags_(flags) { |
4942 SetOperandAt(0, context); | 4985 SetOperandAt(0, context); |
4943 SetOperandAt(1, size); | 4986 SetOperandAt(1, size); |
4944 set_representation(Representation::Tagged()); | 4987 set_representation(Representation::Tagged()); |
4945 SetGVNFlag(kChangesNewSpacePromotion); | 4988 SetGVNFlag(kChangesNewSpacePromotion); |
4946 } | 4989 } |
4947 | 4990 |
4948 // Maximum instance size for which allocations will be inlined. | |
4949 static const int kMaxInlineSize = 64 * kPointerSize; | |
4950 | |
4951 static Flags DefaultFlags() { | 4991 static Flags DefaultFlags() { |
4952 return CAN_ALLOCATE_IN_NEW_SPACE; | 4992 return CAN_ALLOCATE_IN_NEW_SPACE; |
4953 } | 4993 } |
4954 | 4994 |
4955 static Flags DefaultFlags(ElementsKind kind) { | 4995 static Flags DefaultFlags(ElementsKind kind) { |
4956 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE; | 4996 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE; |
4957 if (IsFastDoubleElementsKind(kind)) { | 4997 if (IsFastDoubleElementsKind(kind)) { |
4958 flags = static_cast<HAllocate::Flags>( | 4998 flags = static_cast<HAllocate::Flags>( |
4959 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); | 4999 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); |
4960 } | 5000 } |
4961 return flags; | 5001 return flags; |
4962 } | 5002 } |
4963 | 5003 |
4964 HValue* context() { return OperandAt(0); } | 5004 HValue* context() { return OperandAt(0); } |
4965 HValue* size() { return OperandAt(1); } | 5005 HValue* size() { return OperandAt(1); } |
4966 | 5006 |
4967 virtual Representation RequiredInputRepresentation(int index) { | 5007 virtual Representation RequiredInputRepresentation(int index) { |
4968 if (index == 0) { | 5008 if (index == 0) { |
4969 return Representation::Tagged(); | 5009 return Representation::Tagged(); |
4970 } else { | 5010 } else { |
4971 return Representation::Integer32(); | 5011 return Representation::Integer32(); |
4972 } | 5012 } |
4973 } | 5013 } |
4974 | 5014 |
4975 virtual Handle<Map> GetMonomorphicJSObjectMap() { | |
4976 return known_initial_map_; | |
4977 } | |
4978 | |
4979 void set_known_initial_map(Handle<Map> known_initial_map) { | |
4980 known_initial_map_ = known_initial_map; | |
4981 } | |
4982 | |
4983 virtual HType CalculateInferredType(); | 5015 virtual HType CalculateInferredType(); |
4984 | 5016 |
4985 bool CanAllocateInNewSpace() const { | 5017 bool CanAllocateInNewSpace() const { |
4986 return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; | 5018 return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; |
4987 } | 5019 } |
4988 | 5020 |
4989 bool CanAllocateInOldDataSpace() const { | 5021 bool CanAllocateInOldDataSpace() const { |
4990 return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0; | 5022 return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0; |
4991 } | 5023 } |
4992 | 5024 |
(...skipping 14 matching lines...) Expand all Loading... |
5007 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0; | 5039 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0; |
5008 } | 5040 } |
5009 | 5041 |
5010 virtual void PrintDataTo(StringStream* stream); | 5042 virtual void PrintDataTo(StringStream* stream); |
5011 | 5043 |
5012 DECLARE_CONCRETE_INSTRUCTION(Allocate) | 5044 DECLARE_CONCRETE_INSTRUCTION(Allocate) |
5013 | 5045 |
5014 private: | 5046 private: |
5015 HType type_; | 5047 HType type_; |
5016 Flags flags_; | 5048 Flags flags_; |
5017 Handle<Map> known_initial_map_; | |
5018 }; | 5049 }; |
5019 | 5050 |
5020 | 5051 |
5021 class HInnerAllocatedObject: public HTemplateInstruction<1> { | 5052 class HInnerAllocatedObject: public HTemplateInstruction<1> { |
5022 public: | 5053 public: |
5023 HInnerAllocatedObject(HValue* value, int offset) | 5054 HInnerAllocatedObject(HValue* value, int offset) |
5024 : offset_(offset) { | 5055 : offset_(offset) { |
5025 ASSERT(value->IsAllocate()); | 5056 ASSERT(value->IsAllocate()); |
5026 SetOperandAt(0, value); | 5057 SetOperandAt(0, value); |
5027 set_representation(Representation::Tagged()); | 5058 set_representation(Representation::Tagged()); |
(...skipping 23 matching lines...) Expand all Loading... |
5051 | 5082 |
5052 | 5083 |
5053 inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, | 5084 inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, |
5054 HValue* new_space_dominator) { | 5085 HValue* new_space_dominator) { |
5055 if (object->IsInnerAllocatedObject()) { | 5086 if (object->IsInnerAllocatedObject()) { |
5056 return ReceiverObjectNeedsWriteBarrier( | 5087 return ReceiverObjectNeedsWriteBarrier( |
5057 HInnerAllocatedObject::cast(object)->base_object(), | 5088 HInnerAllocatedObject::cast(object)->base_object(), |
5058 new_space_dominator); | 5089 new_space_dominator); |
5059 } | 5090 } |
5060 if (object != new_space_dominator) return true; | 5091 if (object != new_space_dominator) return true; |
| 5092 if (object->IsAllocateObject()) return false; |
5061 if (object->IsAllocate()) { | 5093 if (object->IsAllocate()) { |
5062 return !HAllocate::cast(object)->GuaranteedInNewSpace(); | 5094 return !HAllocate::cast(object)->GuaranteedInNewSpace(); |
5063 } | 5095 } |
5064 return true; | 5096 return true; |
5065 } | 5097 } |
5066 | 5098 |
5067 | 5099 |
5068 class HStoreGlobalCell: public HUnaryOperation { | 5100 class HStoreGlobalCell: public HUnaryOperation { |
5069 public: | 5101 public: |
5070 HStoreGlobalCell(HValue* value, | 5102 HStoreGlobalCell(HValue* value, |
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6608 virtual bool IsDeletable() const { return true; } | 6640 virtual bool IsDeletable() const { return true; } |
6609 }; | 6641 }; |
6610 | 6642 |
6611 | 6643 |
6612 #undef DECLARE_INSTRUCTION | 6644 #undef DECLARE_INSTRUCTION |
6613 #undef DECLARE_CONCRETE_INSTRUCTION | 6645 #undef DECLARE_CONCRETE_INSTRUCTION |
6614 | 6646 |
6615 } } // namespace v8::internal | 6647 } } // namespace v8::internal |
6616 | 6648 |
6617 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6649 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |