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 3210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3221 DECLARE_CONCRETE_INSTRUCTION(CapturedObject) | 3221 DECLARE_CONCRETE_INSTRUCTION(CapturedObject) |
3222 }; | 3222 }; |
3223 | 3223 |
3224 | 3224 |
3225 class HConstant: public HTemplateInstruction<0> { | 3225 class HConstant: public HTemplateInstruction<0> { |
3226 public: | 3226 public: |
3227 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t); | 3227 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t); |
3228 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation); | 3228 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation); |
3229 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double); | 3229 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double); |
3230 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>); | 3230 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>); |
| 3231 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, Handle<Map>, UniqueValueId); |
3231 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); | 3232 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); |
3232 | 3233 |
| 3234 static HConstant* CreateAndInsertAfter(Zone* zone, |
| 3235 HValue* context, |
| 3236 int32_t value, |
| 3237 HInstruction* instruction) { |
| 3238 HConstant* new_constant = HConstant::New(zone, context, value); |
| 3239 new_constant->InsertAfter(instruction); |
| 3240 return new_constant; |
| 3241 } |
| 3242 |
| 3243 static HConstant* CreateAndInsertBefore(Zone* zone, |
| 3244 HValue* context, |
| 3245 int32_t value, |
| 3246 HInstruction* instruction) { |
| 3247 HConstant* new_constant = HConstant::New(zone, context, value); |
| 3248 new_constant->InsertBefore(instruction); |
| 3249 return new_constant; |
| 3250 } |
| 3251 |
3233 Handle<Object> handle() { | 3252 Handle<Object> handle() { |
3234 if (handle_.is_null()) { | 3253 if (handle_.is_null()) { |
3235 Factory* factory = Isolate::Current()->factory(); | 3254 Factory* factory = Isolate::Current()->factory(); |
3236 // Default arguments to is_not_in_new_space depend on this heap number | 3255 // Default arguments to is_not_in_new_space depend on this heap number |
3237 // to be tenured so that it's guaranteed not be be located in new space. | 3256 // to be tenured so that it's guaranteed not be be located in new space. |
3238 handle_ = factory->NewNumber(double_value_, TENURED); | 3257 handle_ = factory->NewNumber(double_value_, TENURED); |
3239 } | 3258 } |
3240 AllowDeferredHandleDereference smi_check; | 3259 AllowDeferredHandleDereference smi_check; |
3241 ASSERT(has_int32_value_ || !handle_->IsSmi()); | 3260 ASSERT(has_int32_value_ || !handle_->IsSmi()); |
3242 return handle_; | 3261 return handle_; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3423 bool is_not_in_new_space = true, | 3442 bool is_not_in_new_space = true, |
3424 Handle<Object> optional_handle = Handle<Object>::null()); | 3443 Handle<Object> optional_handle = Handle<Object>::null()); |
3425 HConstant(Handle<Object> handle, | 3444 HConstant(Handle<Object> handle, |
3426 UniqueValueId unique_id, | 3445 UniqueValueId unique_id, |
3427 Representation r, | 3446 Representation r, |
3428 HType type, | 3447 HType type, |
3429 bool is_internalized_string, | 3448 bool is_internalized_string, |
3430 bool is_not_in_new_space, | 3449 bool is_not_in_new_space, |
3431 bool is_cell, | 3450 bool is_cell, |
3432 bool boolean_value); | 3451 bool boolean_value); |
| 3452 HConstant(Handle<Map> handle, |
| 3453 UniqueValueId unique_id); |
3433 explicit HConstant(ExternalReference reference); | 3454 explicit HConstant(ExternalReference reference); |
3434 | 3455 |
3435 void Initialize(Representation r); | 3456 void Initialize(Representation r); |
3436 | 3457 |
3437 virtual bool IsDeletable() const { return true; } | 3458 virtual bool IsDeletable() const { return true; } |
3438 | 3459 |
3439 // If this is a numerical constant, handle_ either points to to the | 3460 // If this is a numerical constant, handle_ either points to to the |
3440 // HeapObject the constant originated from or is null. If the | 3461 // HeapObject the constant originated from or is null. If the |
3441 // constant is non-numeric, handle_ always points to a valid | 3462 // constant is non-numeric, handle_ always points to a valid |
3442 // constant HeapObject. | 3463 // constant HeapObject. |
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5056 } | 5077 } |
5057 | 5078 |
5058 void MakePrefillWithFiller() { | 5079 void MakePrefillWithFiller() { |
5059 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER); | 5080 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER); |
5060 } | 5081 } |
5061 | 5082 |
5062 void MakeDoubleAligned() { | 5083 void MakeDoubleAligned() { |
5063 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); | 5084 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); |
5064 } | 5085 } |
5065 | 5086 |
5066 void UpdateSize(HValue* size) { | |
5067 SetOperandAt(1, size); | |
5068 } | |
5069 | |
5070 virtual void HandleSideEffectDominator(GVNFlag side_effect, | 5087 virtual void HandleSideEffectDominator(GVNFlag side_effect, |
5071 HValue* dominator); | 5088 HValue* dominator); |
5072 | 5089 |
5073 virtual void PrintDataTo(StringStream* stream); | 5090 virtual void PrintDataTo(StringStream* stream); |
5074 | 5091 |
5075 DECLARE_CONCRETE_INSTRUCTION(Allocate) | 5092 DECLARE_CONCRETE_INSTRUCTION(Allocate) |
5076 | 5093 |
5077 private: | 5094 private: |
5078 enum Flags { | 5095 enum Flags { |
5079 ALLOCATE_IN_NEW_SPACE = 1 << 0, | 5096 ALLOCATE_IN_NEW_SPACE = 1 << 0, |
5080 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, | 5097 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, |
5081 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, | 5098 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, |
5082 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, | 5099 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, |
5083 PREFILL_WITH_FILLER = 1 << 4 | 5100 PREFILL_WITH_FILLER = 1 << 4 |
5084 }; | 5101 }; |
5085 | 5102 |
5086 HAllocate(HValue* context, | 5103 HAllocate(HValue* context, |
5087 HValue* size, | 5104 HValue* size, |
5088 HType type, | 5105 HType type, |
5089 PretenureFlag pretenure_flag, | 5106 PretenureFlag pretenure_flag, |
5090 InstanceType instance_type) | 5107 InstanceType instance_type) |
5091 : HTemplateInstruction<2>(type) { | 5108 : HTemplateInstruction<2>(type), |
| 5109 dominating_allocate_(NULL), |
| 5110 filler_free_space_size_(NULL) { |
5092 SetOperandAt(0, context); | 5111 SetOperandAt(0, context); |
5093 SetOperandAt(1, size); | 5112 SetOperandAt(1, size); |
5094 set_representation(Representation::Tagged()); | 5113 set_representation(Representation::Tagged()); |
5095 SetFlag(kTrackSideEffectDominators); | 5114 SetFlag(kTrackSideEffectDominators); |
5096 SetGVNFlag(kChangesNewSpacePromotion); | 5115 SetGVNFlag(kChangesNewSpacePromotion); |
5097 SetGVNFlag(kDependsOnNewSpacePromotion); | 5116 SetGVNFlag(kDependsOnNewSpacePromotion); |
5098 flags_ = pretenure_flag == TENURED | 5117 flags_ = pretenure_flag == TENURED |
5099 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE | 5118 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE |
5100 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) | 5119 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) |
5101 : ALLOCATE_IN_NEW_SPACE; | 5120 : ALLOCATE_IN_NEW_SPACE; |
5102 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 5121 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
5103 flags_ = static_cast<HAllocate::Flags>(flags_ | | 5122 flags_ = static_cast<HAllocate::Flags>(flags_ | |
5104 ALLOCATE_DOUBLE_ALIGNED); | 5123 ALLOCATE_DOUBLE_ALIGNED); |
5105 } | 5124 } |
5106 } | 5125 } |
5107 | 5126 |
| 5127 void UpdateSize(HValue* size) { |
| 5128 SetOperandAt(1, size); |
| 5129 } |
| 5130 |
| 5131 HAllocate* GetFoldableDominator(HAllocate* dominator); |
| 5132 |
| 5133 void UpdateFreeSpaceFiller(int32_t filler_size); |
| 5134 |
| 5135 void CreateFreeSpaceFiller(int32_t filler_size); |
| 5136 |
| 5137 bool IsFoldable(HAllocate* allocate) { |
| 5138 return (IsNewSpaceAllocation() && allocate->IsNewSpaceAllocation()) || |
| 5139 (IsOldDataSpaceAllocation() && allocate->IsOldDataSpaceAllocation()) || |
| 5140 (IsOldPointerSpaceAllocation() && |
| 5141 allocate->IsOldPointerSpaceAllocation()); |
| 5142 } |
| 5143 |
5108 Flags flags_; | 5144 Flags flags_; |
5109 Handle<Map> known_initial_map_; | 5145 Handle<Map> known_initial_map_; |
| 5146 HAllocate* dominating_allocate_; |
| 5147 HConstant* filler_free_space_size_; |
5110 }; | 5148 }; |
5111 | 5149 |
5112 | 5150 |
5113 class HInnerAllocatedObject: public HTemplateInstruction<1> { | 5151 class HInnerAllocatedObject: public HTemplateInstruction<1> { |
5114 public: | 5152 public: |
5115 static HInnerAllocatedObject* New(Zone* zone, | 5153 static HInnerAllocatedObject* New(Zone* zone, |
5116 HValue* context, | 5154 HValue* context, |
5117 HValue* value, | 5155 HValue* value, |
5118 int offset, | 5156 int offset, |
5119 HType type = HType::Tagged()) { | 5157 HType type = HType::Tagged()) { |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6766 virtual bool IsDeletable() const { return true; } | 6804 virtual bool IsDeletable() const { return true; } |
6767 }; | 6805 }; |
6768 | 6806 |
6769 | 6807 |
6770 #undef DECLARE_INSTRUCTION | 6808 #undef DECLARE_INSTRUCTION |
6771 #undef DECLARE_CONCRETE_INSTRUCTION | 6809 #undef DECLARE_CONCRETE_INSTRUCTION |
6772 | 6810 |
6773 } } // namespace v8::internal | 6811 } } // namespace v8::internal |
6774 | 6812 |
6775 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6813 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |