| 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; |
| 52 class HValue; | 53 class HValue; |
| 53 class LInstruction; | 54 class LInstruction; |
| 54 class LChunkBuilder; | 55 class LChunkBuilder; |
| 55 | 56 |
| 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); |
| 3207 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); | 3208 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); |
| 3208 | 3209 |
| 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 |
| 3209 Handle<Object> handle() { | 3228 Handle<Object> handle() { |
| 3210 if (handle_.is_null()) { | 3229 if (handle_.is_null()) { |
| 3211 Factory* factory = Isolate::Current()->factory(); | 3230 Factory* factory = Isolate::Current()->factory(); |
| 3212 // Default arguments to is_not_in_new_space depend on this heap number | 3231 // Default arguments to is_not_in_new_space depend on this heap number |
| 3213 // to be tenured so that it's guaranteed not be be located in new space. | 3232 // to be tenured so that it's guaranteed not be be located in new space. |
| 3214 handle_ = factory->NewNumber(double_value_, TENURED); | 3233 handle_ = factory->NewNumber(double_value_, TENURED); |
| 3215 } | 3234 } |
| 3216 AllowDeferredHandleDereference smi_check; | 3235 AllowDeferredHandleDereference smi_check; |
| 3217 ASSERT(has_int32_value_ || !handle_->IsSmi()); | 3236 ASSERT(has_int32_value_ || !handle_->IsSmi()); |
| 3218 return handle_; | 3237 return handle_; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3401 bool is_not_in_new_space = true, | 3420 bool is_not_in_new_space = true, |
| 3402 Handle<Object> optional_handle = Handle<Object>::null()); | 3421 Handle<Object> optional_handle = Handle<Object>::null()); |
| 3403 HConstant(Handle<Object> handle, | 3422 HConstant(Handle<Object> handle, |
| 3404 UniqueValueId unique_id, | 3423 UniqueValueId unique_id, |
| 3405 Representation r, | 3424 Representation r, |
| 3406 HType type, | 3425 HType type, |
| 3407 bool is_internalized_string, | 3426 bool is_internalized_string, |
| 3408 bool is_not_in_new_space, | 3427 bool is_not_in_new_space, |
| 3409 bool is_cell, | 3428 bool is_cell, |
| 3410 bool boolean_value); | 3429 bool boolean_value); |
| 3430 HConstant(Handle<Map> handle, |
| 3431 UniqueValueId unique_id); |
| 3411 explicit HConstant(ExternalReference reference); | 3432 explicit HConstant(ExternalReference reference); |
| 3412 | 3433 |
| 3413 void Initialize(Representation r); | 3434 void Initialize(Representation r); |
| 3414 | 3435 |
| 3415 virtual bool IsDeletable() const { return true; } | 3436 virtual bool IsDeletable() const { return true; } |
| 3416 | 3437 |
| 3417 // If this is a numerical constant, handle_ either points to to the | 3438 // If this is a numerical constant, handle_ either points to to the |
| 3418 // HeapObject the constant originated from or is null. If the | 3439 // HeapObject the constant originated from or is null. If the |
| 3419 // constant is non-numeric, handle_ always points to a valid | 3440 // constant is non-numeric, handle_ always points to a valid |
| 3420 // constant HeapObject. | 3441 // constant HeapObject. |
| (...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5091 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, | 5112 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, |
| 5092 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, | 5113 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, |
| 5093 PREFILL_WITH_FILLER = 1 << 4 | 5114 PREFILL_WITH_FILLER = 1 << 4 |
| 5094 }; | 5115 }; |
| 5095 | 5116 |
| 5096 HAllocate(HValue* context, | 5117 HAllocate(HValue* context, |
| 5097 HValue* size, | 5118 HValue* size, |
| 5098 HType type, | 5119 HType type, |
| 5099 PretenureFlag pretenure_flag, | 5120 PretenureFlag pretenure_flag, |
| 5100 InstanceType instance_type) | 5121 InstanceType instance_type) |
| 5101 : HTemplateInstruction<2>(type) { | 5122 : HTemplateInstruction<2>(type), |
| 5123 dominating_allocate_(NULL), |
| 5124 filler_free_space_size_(NULL), |
| 5125 clear_next_map_word_(false) { |
| 5102 SetOperandAt(0, context); | 5126 SetOperandAt(0, context); |
| 5103 SetOperandAt(1, size); | 5127 SetOperandAt(1, size); |
| 5104 set_representation(Representation::Tagged()); | 5128 set_representation(Representation::Tagged()); |
| 5105 SetFlag(kTrackSideEffectDominators); | 5129 SetFlag(kTrackSideEffectDominators); |
| 5106 SetGVNFlag(kChangesNewSpacePromotion); | 5130 SetGVNFlag(kChangesNewSpacePromotion); |
| 5107 SetGVNFlag(kDependsOnNewSpacePromotion); | 5131 SetGVNFlag(kDependsOnNewSpacePromotion); |
| 5108 flags_ = pretenure_flag == TENURED | 5132 flags_ = pretenure_flag == TENURED |
| 5109 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE | 5133 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE |
| 5110 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) | 5134 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) |
| 5111 : ALLOCATE_IN_NEW_SPACE; | 5135 : ALLOCATE_IN_NEW_SPACE; |
| 5112 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 5136 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
| 5113 flags_ = static_cast<HAllocate::Flags>(flags_ | | 5137 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); |
| 5114 ALLOCATE_DOUBLE_ALIGNED); | |
| 5115 } | 5138 } |
| 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); |
| 5116 } | 5149 } |
| 5117 | 5150 |
| 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 |
| 5118 Flags flags_; | 5166 Flags flags_; |
| 5119 Handle<Map> known_initial_map_; | 5167 Handle<Map> known_initial_map_; |
| 5168 HAllocate* dominating_allocate_; |
| 5169 HStoreNamedField* filler_free_space_size_; |
| 5170 bool clear_next_map_word_; |
| 5120 }; | 5171 }; |
| 5121 | 5172 |
| 5122 | 5173 |
| 5123 class HInnerAllocatedObject: public HTemplateInstruction<1> { | 5174 class HInnerAllocatedObject: public HTemplateInstruction<1> { |
| 5124 public: | 5175 public: |
| 5125 static HInnerAllocatedObject* New(Zone* zone, | 5176 static HInnerAllocatedObject* New(Zone* zone, |
| 5126 HValue* context, | 5177 HValue* context, |
| 5127 HValue* value, | 5178 HValue* value, |
| 5128 int offset, | 5179 int offset, |
| 5129 HType type = HType::Tagged()) { | 5180 HType type = HType::Tagged()) { |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5966 | 6017 |
| 5967 bool NeedsWriteBarrierForMap() { | 6018 bool NeedsWriteBarrierForMap() { |
| 5968 if (IsSkipWriteBarrier()) return false; | 6019 if (IsSkipWriteBarrier()) return false; |
| 5969 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); | 6020 return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
| 5970 } | 6021 } |
| 5971 | 6022 |
| 5972 Representation field_representation() const { | 6023 Representation field_representation() const { |
| 5973 return access_.representation(); | 6024 return access_.representation(); |
| 5974 } | 6025 } |
| 5975 | 6026 |
| 6027 void UpdateValue(HValue* value) { |
| 6028 SetOperandAt(1, value); |
| 6029 } |
| 6030 |
| 5976 private: | 6031 private: |
| 5977 HStoreNamedField(HValue* obj, | 6032 HStoreNamedField(HValue* obj, |
| 5978 HObjectAccess access, | 6033 HObjectAccess access, |
| 5979 HValue* val) | 6034 HValue* val) |
| 5980 : access_(access), | 6035 : access_(access), |
| 5981 new_space_dominator_(NULL), | 6036 new_space_dominator_(NULL), |
| 5982 write_barrier_mode_(UPDATE_WRITE_BARRIER), | 6037 write_barrier_mode_(UPDATE_WRITE_BARRIER), |
| 5983 has_transition_(false) { | 6038 has_transition_(false) { |
| 5984 SetOperandAt(0, obj); | 6039 SetOperandAt(0, obj); |
| 5985 SetOperandAt(1, val); | 6040 SetOperandAt(1, val); |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6778 virtual bool IsDeletable() const { return true; } | 6833 virtual bool IsDeletable() const { return true; } |
| 6779 }; | 6834 }; |
| 6780 | 6835 |
| 6781 | 6836 |
| 6782 #undef DECLARE_INSTRUCTION | 6837 #undef DECLARE_INSTRUCTION |
| 6783 #undef DECLARE_CONCRETE_INSTRUCTION | 6838 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6784 | 6839 |
| 6785 } } // namespace v8::internal | 6840 } } // namespace v8::internal |
| 6786 | 6841 |
| 6787 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6842 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |