| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 namespace v8 { | 43 namespace v8 { |
| 44 namespace internal { | 44 namespace internal { |
| 45 | 45 |
| 46 // Forward declarations. | 46 // Forward declarations. |
| 47 class HBasicBlock; | 47 class HBasicBlock; |
| 48 class HEnvironment; | 48 class HEnvironment; |
| 49 class HInferRepresentationPhase; | 49 class HInferRepresentationPhase; |
| 50 class HInstruction; | 50 class HInstruction; |
| 51 class HLoopInformation; | 51 class HLoopInformation; |
| 52 class HStoreNamedField; | |
| 53 class HValue; | 52 class HValue; |
| 54 class LInstruction; | 53 class LInstruction; |
| 55 class LChunkBuilder; | 54 class LChunkBuilder; |
| 56 | 55 |
| 56 |
| 57 #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ | 57 #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ |
| 58 V(ArithmeticBinaryOperation) \ | 58 V(ArithmeticBinaryOperation) \ |
| 59 V(BinaryOperation) \ | 59 V(BinaryOperation) \ |
| 60 V(BitwiseBinaryOperation) \ | 60 V(BitwiseBinaryOperation) \ |
| 61 V(ControlInstruction) \ | 61 V(ControlInstruction) \ |
| 62 V(Instruction) \ | 62 V(Instruction) \ |
| 63 | 63 |
| 64 | 64 |
| 65 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ | 65 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ |
| 66 V(AccessArgumentsAt) \ | 66 V(AccessArgumentsAt) \ |
| (...skipping 3130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 DECLARE_CONCRETE_INSTRUCTION(CapturedObject) | 3197 DECLARE_CONCRETE_INSTRUCTION(CapturedObject) |
| 3198 }; | 3198 }; |
| 3199 | 3199 |
| 3200 | 3200 |
| 3201 class HConstant: public HTemplateInstruction<0> { | 3201 class HConstant: public HTemplateInstruction<0> { |
| 3202 public: | 3202 public: |
| 3203 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t); | 3203 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t); |
| 3204 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation); | 3204 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation); |
| 3205 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double); | 3205 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double); |
| 3206 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>); | 3206 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>); |
| 3207 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, Handle<Map>, UniqueValueId); | |
| 3208 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); | 3207 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); |
| 3209 | 3208 |
| 3210 static HConstant* CreateAndInsertAfter(Zone* zone, | |
| 3211 HValue* context, | |
| 3212 int32_t value, | |
| 3213 HInstruction* instruction) { | |
| 3214 HConstant* new_constant = HConstant::New(zone, context, value); | |
| 3215 new_constant->InsertAfter(instruction); | |
| 3216 return new_constant; | |
| 3217 } | |
| 3218 | |
| 3219 static HConstant* CreateAndInsertBefore(Zone* zone, | |
| 3220 HValue* context, | |
| 3221 int32_t value, | |
| 3222 HInstruction* instruction) { | |
| 3223 HConstant* new_constant = HConstant::New(zone, context, value); | |
| 3224 new_constant->InsertBefore(instruction); | |
| 3225 return new_constant; | |
| 3226 } | |
| 3227 | |
| 3228 Handle<Object> handle() { | 3209 Handle<Object> handle() { |
| 3229 if (handle_.is_null()) { | 3210 if (handle_.is_null()) { |
| 3230 Factory* factory = Isolate::Current()->factory(); | 3211 Factory* factory = Isolate::Current()->factory(); |
| 3231 // Default arguments to is_not_in_new_space depend on this heap number | 3212 // Default arguments to is_not_in_new_space depend on this heap number |
| 3232 // to be tenured so that it's guaranteed not be be located in new space. | 3213 // to be tenured so that it's guaranteed not be be located in new space. |
| 3233 handle_ = factory->NewNumber(double_value_, TENURED); | 3214 handle_ = factory->NewNumber(double_value_, TENURED); |
| 3234 } | 3215 } |
| 3235 AllowDeferredHandleDereference smi_check; | 3216 AllowDeferredHandleDereference smi_check; |
| 3236 ASSERT(has_int32_value_ || !handle_->IsSmi()); | 3217 ASSERT(has_int32_value_ || !handle_->IsSmi()); |
| 3237 return handle_; | 3218 return handle_; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3420 bool is_not_in_new_space = true, | 3401 bool is_not_in_new_space = true, |
| 3421 Handle<Object> optional_handle = Handle<Object>::null()); | 3402 Handle<Object> optional_handle = Handle<Object>::null()); |
| 3422 HConstant(Handle<Object> handle, | 3403 HConstant(Handle<Object> handle, |
| 3423 UniqueValueId unique_id, | 3404 UniqueValueId unique_id, |
| 3424 Representation r, | 3405 Representation r, |
| 3425 HType type, | 3406 HType type, |
| 3426 bool is_internalized_string, | 3407 bool is_internalized_string, |
| 3427 bool is_not_in_new_space, | 3408 bool is_not_in_new_space, |
| 3428 bool is_cell, | 3409 bool is_cell, |
| 3429 bool boolean_value); | 3410 bool boolean_value); |
| 3430 HConstant(Handle<Map> handle, | |
| 3431 UniqueValueId unique_id); | |
| 3432 explicit HConstant(ExternalReference reference); | 3411 explicit HConstant(ExternalReference reference); |
| 3433 | 3412 |
| 3434 void Initialize(Representation r); | 3413 void Initialize(Representation r); |
| 3435 | 3414 |
| 3436 virtual bool IsDeletable() const { return true; } | 3415 virtual bool IsDeletable() const { return true; } |
| 3437 | 3416 |
| 3438 // If this is a numerical constant, handle_ either points to to the | 3417 // If this is a numerical constant, handle_ either points to to the |
| 3439 // HeapObject the constant originated from or is null. If the | 3418 // HeapObject the constant originated from or is null. If the |
| 3440 // constant is non-numeric, handle_ always points to a valid | 3419 // constant is non-numeric, handle_ always points to a valid |
| 3441 // constant HeapObject. | 3420 // constant HeapObject. |
| (...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5112 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, | 5091 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, |
| 5113 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, | 5092 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, |
| 5114 PREFILL_WITH_FILLER = 1 << 4 | 5093 PREFILL_WITH_FILLER = 1 << 4 |
| 5115 }; | 5094 }; |
| 5116 | 5095 |
| 5117 HAllocate(HValue* context, | 5096 HAllocate(HValue* context, |
| 5118 HValue* size, | 5097 HValue* size, |
| 5119 HType type, | 5098 HType type, |
| 5120 PretenureFlag pretenure_flag, | 5099 PretenureFlag pretenure_flag, |
| 5121 InstanceType instance_type) | 5100 InstanceType instance_type) |
| 5122 : HTemplateInstruction<2>(type), | 5101 : HTemplateInstruction<2>(type) { |
| 5123 dominating_allocate_(NULL), | |
| 5124 filler_free_space_size_(NULL), | |
| 5125 clear_next_map_word_(false) { | |
| 5126 SetOperandAt(0, context); | 5102 SetOperandAt(0, context); |
| 5127 SetOperandAt(1, size); | 5103 SetOperandAt(1, size); |
| 5128 set_representation(Representation::Tagged()); | 5104 set_representation(Representation::Tagged()); |
| 5129 SetFlag(kTrackSideEffectDominators); | 5105 SetFlag(kTrackSideEffectDominators); |
| 5130 SetGVNFlag(kChangesNewSpacePromotion); | 5106 SetGVNFlag(kChangesNewSpacePromotion); |
| 5131 SetGVNFlag(kDependsOnNewSpacePromotion); | 5107 SetGVNFlag(kDependsOnNewSpacePromotion); |
| 5132 flags_ = pretenure_flag == TENURED | 5108 flags_ = pretenure_flag == TENURED |
| 5133 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE | 5109 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE |
| 5134 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) | 5110 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) |
| 5135 : ALLOCATE_IN_NEW_SPACE; | 5111 : ALLOCATE_IN_NEW_SPACE; |
| 5136 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 5112 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
| 5137 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); | 5113 flags_ = static_cast<HAllocate::Flags>(flags_ | |
| 5114 ALLOCATE_DOUBLE_ALIGNED); |
| 5138 } | 5115 } |
| 5139 // We have to fill the allocated object with one word fillers if we do | |
| 5140 // not use allocation folding since some allocations may depend on each | |
| 5141 // other, i.e., have a pointer to each other. A GC in between these | |
| 5142 // allocations may leave such objects behind in a not completely initialized | |
| 5143 // state. | |
| 5144 if (!FLAG_use_gvn || !FLAG_use_allocation_folding) { | |
| 5145 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER); | |
| 5146 } | |
| 5147 clear_next_map_word_ = pretenure_flag == NOT_TENURED && | |
| 5148 AllocationSite::CanTrack(instance_type); | |
| 5149 } | 5116 } |
| 5150 | 5117 |
| 5151 HAllocate* GetFoldableDominator(HAllocate* dominator); | |
| 5152 | |
| 5153 void UpdateFreeSpaceFiller(int32_t filler_size); | |
| 5154 | |
| 5155 void CreateFreeSpaceFiller(int32_t filler_size); | |
| 5156 | |
| 5157 bool IsFoldable(HAllocate* allocate) { | |
| 5158 return (IsNewSpaceAllocation() && allocate->IsNewSpaceAllocation()) || | |
| 5159 (IsOldDataSpaceAllocation() && allocate->IsOldDataSpaceAllocation()) || | |
| 5160 (IsOldPointerSpaceAllocation() && | |
| 5161 allocate->IsOldPointerSpaceAllocation()); | |
| 5162 } | |
| 5163 | |
| 5164 void ClearNextMapWord(int offset); | |
| 5165 | |
| 5166 Flags flags_; | 5118 Flags flags_; |
| 5167 Handle<Map> known_initial_map_; | 5119 Handle<Map> known_initial_map_; |
| 5168 HAllocate* dominating_allocate_; | |
| 5169 HStoreNamedField* filler_free_space_size_; | |
| 5170 bool clear_next_map_word_; | |
| 5171 }; | 5120 }; |
| 5172 | 5121 |
| 5173 | 5122 |
| 5174 class HInnerAllocatedObject: public HTemplateInstruction<1> { | 5123 class HInnerAllocatedObject: public HTemplateInstruction<1> { |
| 5175 public: | 5124 public: |
| 5176 static HInnerAllocatedObject* New(Zone* zone, | 5125 static HInnerAllocatedObject* New(Zone* zone, |
| 5177 HValue* context, | 5126 HValue* context, |
| 5178 HValue* value, | 5127 HValue* value, |
| 5179 int offset, | 5128 int offset, |
| 5180 HType type = HType::Tagged()) { | 5129 HType type = HType::Tagged()) { |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6017 | 5966 |
| 6018 bool NeedsWriteBarrierForMap() { | 5967 bool NeedsWriteBarrierForMap() { |
| 6019 if (IsSkipWriteBarrier()) return false; | 5968 if (IsSkipWriteBarrier()) return false; |
| 6020 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); | 5969 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
| 6021 } | 5970 } |
| 6022 | 5971 |
| 6023 Representation field_representation() const { | 5972 Representation field_representation() const { |
| 6024 return access_.representation(); | 5973 return access_.representation(); |
| 6025 } | 5974 } |
| 6026 | 5975 |
| 6027 void UpdateValue(HValue* value) { | |
| 6028 SetOperandAt(1, value); | |
| 6029 } | |
| 6030 | |
| 6031 private: | 5976 private: |
| 6032 HStoreNamedField(HValue* obj, | 5977 HStoreNamedField(HValue* obj, |
| 6033 HObjectAccess access, | 5978 HObjectAccess access, |
| 6034 HValue* val) | 5979 HValue* val) |
| 6035 : access_(access), | 5980 : access_(access), |
| 6036 new_space_dominator_(NULL), | 5981 new_space_dominator_(NULL), |
| 6037 write_barrier_mode_(UPDATE_WRITE_BARRIER), | 5982 write_barrier_mode_(UPDATE_WRITE_BARRIER), |
| 6038 has_transition_(false) { | 5983 has_transition_(false) { |
| 6039 SetOperandAt(0, obj); | 5984 SetOperandAt(0, obj); |
| 6040 SetOperandAt(1, val); | 5985 SetOperandAt(1, val); |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6833 virtual bool IsDeletable() const { return true; } | 6778 virtual bool IsDeletable() const { return true; } |
| 6834 }; | 6779 }; |
| 6835 | 6780 |
| 6836 | 6781 |
| 6837 #undef DECLARE_INSTRUCTION | 6782 #undef DECLARE_INSTRUCTION |
| 6838 #undef DECLARE_CONCRETE_INSTRUCTION | 6783 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6839 | 6784 |
| 6840 } } // namespace v8::internal | 6785 } } // namespace v8::internal |
| 6841 | 6786 |
| 6842 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6787 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |