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) \ | |
70 V(ApplyArguments) \ | 69 V(ApplyArguments) \ |
71 V(ArgumentsElements) \ | 70 V(ArgumentsElements) \ |
72 V(ArgumentsLength) \ | 71 V(ArgumentsLength) \ |
73 V(ArgumentsObject) \ | 72 V(ArgumentsObject) \ |
74 V(Bitwise) \ | 73 V(Bitwise) \ |
75 V(BitNot) \ | 74 V(BitNot) \ |
76 V(BlockEntry) \ | 75 V(BlockEntry) \ |
77 V(BoundsCheck) \ | 76 V(BoundsCheck) \ |
78 V(BoundsCheckBaseIndexInformation) \ | 77 V(BoundsCheckBaseIndexInformation) \ |
79 V(Branch) \ | 78 V(Branch) \ |
(...skipping 4865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4945 } | 4944 } |
4946 | 4945 |
4947 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) | 4946 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) |
4948 | 4947 |
4949 private: | 4948 private: |
4950 Handle<Object> name_; | 4949 Handle<Object> name_; |
4951 bool for_typeof_; | 4950 bool for_typeof_; |
4952 }; | 4951 }; |
4953 | 4952 |
4954 | 4953 |
4955 class HAllocateObject: public HTemplateInstruction<1> { | |
4956 public: | |
4957 HAllocateObject(HValue* context, Handle<JSFunction> constructor) | |
4958 : constructor_(constructor) { | |
4959 SetOperandAt(0, context); | |
4960 set_representation(Representation::Tagged()); | |
4961 SetGVNFlag(kChangesNewSpacePromotion); | |
4962 constructor_initial_map_ = constructor->has_initial_map() | |
4963 ? Handle<Map>(constructor->initial_map()) | |
4964 : Handle<Map>::null(); | |
4965 // If slack tracking finished, the instance size and property counts | |
4966 // remain unchanged so that we can allocate memory for the object. | |
4967 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); | |
4968 } | |
4969 | |
4970 // Maximum instance size for which allocations will be inlined. | |
4971 static const int kMaxSize = 64 * kPointerSize; | |
4972 | |
4973 HValue* context() { return OperandAt(0); } | |
4974 Handle<JSFunction> constructor() { return constructor_; } | |
4975 Handle<Map> constructor_initial_map() { return constructor_initial_map_; } | |
4976 | |
4977 virtual Representation RequiredInputRepresentation(int index) { | |
4978 return Representation::Tagged(); | |
4979 } | |
4980 | |
4981 virtual Handle<Map> GetMonomorphicJSObjectMap() { | |
4982 ASSERT(!constructor_initial_map_.is_null()); | |
4983 return constructor_initial_map_; | |
4984 } | |
4985 | |
4986 virtual HType CalculateInferredType(); | |
4987 | |
4988 DECLARE_CONCRETE_INSTRUCTION(AllocateObject) | |
4989 | |
4990 private: | |
4991 // TODO(svenpanne) Might be safe, but leave it out until we know for sure. | |
4992 // virtual bool IsDeletable() const { return true; } | |
4993 | |
4994 Handle<JSFunction> constructor_; | |
4995 Handle<Map> constructor_initial_map_; | |
4996 }; | |
4997 | |
4998 | |
4999 class HAllocate: public HTemplateInstruction<2> { | 4954 class HAllocate: public HTemplateInstruction<2> { |
5000 public: | 4955 public: |
5001 enum Flags { | 4956 enum Flags { |
5002 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, | 4957 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, |
5003 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, | 4958 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, |
5004 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, | 4959 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, |
5005 ALLOCATE_DOUBLE_ALIGNED = 1 << 3 | 4960 ALLOCATE_DOUBLE_ALIGNED = 1 << 3 |
5006 }; | 4961 }; |
5007 | 4962 |
5008 HAllocate(HValue* context, HValue* size, HType type, Flags flags) | 4963 HAllocate(HValue* context, HValue* size, HType type, Flags flags) |
5009 : type_(type), | 4964 : type_(type), |
5010 flags_(flags) { | 4965 flags_(flags) { |
5011 SetOperandAt(0, context); | 4966 SetOperandAt(0, context); |
5012 SetOperandAt(1, size); | 4967 SetOperandAt(1, size); |
5013 set_representation(Representation::Tagged()); | 4968 set_representation(Representation::Tagged()); |
5014 SetFlag(kTrackSideEffectDominators); | 4969 SetFlag(kTrackSideEffectDominators); |
5015 SetGVNFlag(kChangesNewSpacePromotion); | 4970 SetGVNFlag(kChangesNewSpacePromotion); |
5016 SetGVNFlag(kDependsOnNewSpacePromotion); | 4971 SetGVNFlag(kDependsOnNewSpacePromotion); |
5017 } | 4972 } |
5018 | 4973 |
| 4974 // Maximum instance size for which allocations will be inlined. |
| 4975 static const int kMaxInlineSize = 64 * kPointerSize; |
| 4976 |
5019 static Flags DefaultFlags() { | 4977 static Flags DefaultFlags() { |
5020 return CAN_ALLOCATE_IN_NEW_SPACE; | 4978 return CAN_ALLOCATE_IN_NEW_SPACE; |
5021 } | 4979 } |
5022 | 4980 |
5023 static Flags DefaultFlags(ElementsKind kind) { | 4981 static Flags DefaultFlags(ElementsKind kind) { |
5024 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE; | 4982 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE; |
5025 if (IsFastDoubleElementsKind(kind)) { | 4983 if (IsFastDoubleElementsKind(kind)) { |
5026 flags = static_cast<HAllocate::Flags>( | 4984 flags = static_cast<HAllocate::Flags>( |
5027 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); | 4985 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); |
5028 } | 4986 } |
5029 return flags; | 4987 return flags; |
5030 } | 4988 } |
5031 | 4989 |
5032 HValue* context() { return OperandAt(0); } | 4990 HValue* context() { return OperandAt(0); } |
5033 HValue* size() { return OperandAt(1); } | 4991 HValue* size() { return OperandAt(1); } |
5034 HType type() { return type_; } | 4992 HType type() { return type_; } |
5035 | 4993 |
5036 virtual Representation RequiredInputRepresentation(int index) { | 4994 virtual Representation RequiredInputRepresentation(int index) { |
5037 if (index == 0) { | 4995 if (index == 0) { |
5038 return Representation::Tagged(); | 4996 return Representation::Tagged(); |
5039 } else { | 4997 } else { |
5040 return Representation::Integer32(); | 4998 return Representation::Integer32(); |
5041 } | 4999 } |
5042 } | 5000 } |
5043 | 5001 |
| 5002 virtual Handle<Map> GetMonomorphicJSObjectMap() { |
| 5003 return known_initial_map_; |
| 5004 } |
| 5005 |
| 5006 void set_known_initial_map(Handle<Map> known_initial_map) { |
| 5007 known_initial_map_ = known_initial_map; |
| 5008 } |
| 5009 |
5044 virtual HType CalculateInferredType(); | 5010 virtual HType CalculateInferredType(); |
5045 | 5011 |
5046 bool CanAllocateInNewSpace() const { | 5012 bool CanAllocateInNewSpace() const { |
5047 return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; | 5013 return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; |
5048 } | 5014 } |
5049 | 5015 |
5050 bool CanAllocateInOldDataSpace() const { | 5016 bool CanAllocateInOldDataSpace() const { |
5051 return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0; | 5017 return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0; |
5052 } | 5018 } |
5053 | 5019 |
(...skipping 21 matching lines...) Expand all Loading... |
5075 virtual void HandleSideEffectDominator(GVNFlag side_effect, | 5041 virtual void HandleSideEffectDominator(GVNFlag side_effect, |
5076 HValue* dominator); | 5042 HValue* dominator); |
5077 | 5043 |
5078 virtual void PrintDataTo(StringStream* stream); | 5044 virtual void PrintDataTo(StringStream* stream); |
5079 | 5045 |
5080 DECLARE_CONCRETE_INSTRUCTION(Allocate) | 5046 DECLARE_CONCRETE_INSTRUCTION(Allocate) |
5081 | 5047 |
5082 private: | 5048 private: |
5083 HType type_; | 5049 HType type_; |
5084 Flags flags_; | 5050 Flags flags_; |
| 5051 Handle<Map> known_initial_map_; |
5085 }; | 5052 }; |
5086 | 5053 |
5087 | 5054 |
5088 class HInnerAllocatedObject: public HTemplateInstruction<1> { | 5055 class HInnerAllocatedObject: public HTemplateInstruction<1> { |
5089 public: | 5056 public: |
5090 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) | 5057 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) |
5091 : offset_(offset), | 5058 : offset_(offset), |
5092 type_(type) { | 5059 type_(type) { |
5093 ASSERT(value->IsAllocate()); | 5060 ASSERT(value->IsAllocate()); |
5094 SetOperandAt(0, value); | 5061 SetOperandAt(0, value); |
(...skipping 30 matching lines...) Expand all Loading... |
5125 HValue* new_space_dominator) { | 5092 HValue* new_space_dominator) { |
5126 if (object->IsInnerAllocatedObject()) { | 5093 if (object->IsInnerAllocatedObject()) { |
5127 return ReceiverObjectNeedsWriteBarrier( | 5094 return ReceiverObjectNeedsWriteBarrier( |
5128 HInnerAllocatedObject::cast(object)->base_object(), | 5095 HInnerAllocatedObject::cast(object)->base_object(), |
5129 new_space_dominator); | 5096 new_space_dominator); |
5130 } | 5097 } |
5131 if (object->IsConstant() && HConstant::cast(object)->IsCell()) { | 5098 if (object->IsConstant() && HConstant::cast(object)->IsCell()) { |
5132 return false; | 5099 return false; |
5133 } | 5100 } |
5134 if (object != new_space_dominator) return true; | 5101 if (object != new_space_dominator) return true; |
5135 if (object->IsAllocateObject()) return false; | |
5136 if (object->IsAllocate()) { | 5102 if (object->IsAllocate()) { |
5137 return !HAllocate::cast(object)->GuaranteedInNewSpace(); | 5103 return !HAllocate::cast(object)->GuaranteedInNewSpace(); |
5138 } | 5104 } |
5139 return true; | 5105 return true; |
5140 } | 5106 } |
5141 | 5107 |
5142 | 5108 |
5143 class HStoreGlobalCell: public HUnaryOperation { | 5109 class HStoreGlobalCell: public HUnaryOperation { |
5144 public: | 5110 public: |
5145 HStoreGlobalCell(HValue* value, | 5111 HStoreGlobalCell(HValue* value, |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6672 virtual bool IsDeletable() const { return true; } | 6638 virtual bool IsDeletable() const { return true; } |
6673 }; | 6639 }; |
6674 | 6640 |
6675 | 6641 |
6676 #undef DECLARE_INSTRUCTION | 6642 #undef DECLARE_INSTRUCTION |
6677 #undef DECLARE_CONCRETE_INSTRUCTION | 6643 #undef DECLARE_CONCRETE_INSTRUCTION |
6678 | 6644 |
6679 } } // namespace v8::internal | 6645 } } // namespace v8::internal |
6680 | 6646 |
6681 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6647 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |