Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: src/hydrogen-instructions.h

Issue 22378003: Added allocation folding support for old space allocations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen-instructions.cc » ('j') | src/hydrogen-instructions.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3186 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 ZoneList<HValue*> values_; 3197 ZoneList<HValue*> values_;
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<Object>, UniqueValueId);
3207 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); 3208 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference);
3208 3209
3210 static HConstant* CreateAndInsert(Zone* zone,
3211 HValue* context,
3212 int32_t value,
3213 HInstruction* instruction,
3214 bool before) {
3215 HConstant* new_constant = HConstant::New(zone, context, value);
3216 if (before) {
3217 new_constant->InsertBefore(instruction);
3218 } else {
3219 new_constant->InsertAfter(instruction);
3220 }
3221 return new_constant;
3222 }
3223
3209 Handle<Object> handle() { 3224 Handle<Object> handle() {
3210 if (handle_.is_null()) { 3225 if (handle_.is_null()) {
3211 Factory* factory = Isolate::Current()->factory(); 3226 Factory* factory = Isolate::Current()->factory();
3212 // Default arguments to is_not_in_new_space depend on this heap number 3227 // 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. 3228 // to be tenured so that it's guaranteed not be be located in new space.
3214 handle_ = factory->NewNumber(double_value_, TENURED); 3229 handle_ = factory->NewNumber(double_value_, TENURED);
3215 } 3230 }
3216 AllowDeferredHandleDereference smi_check; 3231 AllowDeferredHandleDereference smi_check;
3217 ASSERT(has_int32_value_ || !handle_->IsSmi()); 3232 ASSERT(has_int32_value_ || !handle_->IsSmi());
3218 return handle_; 3233 return handle_;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 HConstant(int32_t value, 3405 HConstant(int32_t value,
3391 Representation r = Representation::None(), 3406 Representation r = Representation::None(),
3392 bool is_not_in_new_space = true, 3407 bool is_not_in_new_space = true,
3393 Handle<Object> optional_handle = Handle<Object>::null()); 3408 Handle<Object> optional_handle = Handle<Object>::null());
3394 HConstant(double value, 3409 HConstant(double value,
3395 Representation r = Representation::None(), 3410 Representation r = Representation::None(),
3396 bool is_not_in_new_space = true, 3411 bool is_not_in_new_space = true,
3397 Handle<Object> optional_handle = Handle<Object>::null()); 3412 Handle<Object> optional_handle = Handle<Object>::null());
3398 HConstant(Handle<Object> handle, 3413 HConstant(Handle<Object> handle,
3399 UniqueValueId unique_id, 3414 UniqueValueId unique_id,
3400 Representation r, 3415 Representation r = Representation::Tagged(),
3401 HType type, 3416 HType type = HType::Tagged(),
3402 bool is_internalized_string, 3417 bool is_internalized_string = false,
3403 bool is_not_in_new_space, 3418 bool is_not_in_new_space = true,
3404 bool is_cell, 3419 bool is_cell = false,
3405 bool boolean_value); 3420 bool boolean_value = false);
3406 explicit HConstant(ExternalReference reference); 3421 explicit HConstant(ExternalReference reference);
3407 3422
3408 void Initialize(Representation r); 3423 void Initialize(Representation r);
3409 3424
3410 virtual bool IsDeletable() const { return true; } 3425 virtual bool IsDeletable() const { return true; }
3411 3426
3412 // If this is a numerical constant, handle_ either points to to the 3427 // If this is a numerical constant, handle_ either points to to the
3413 // HeapObject the constant originated from or is null. If the 3428 // HeapObject the constant originated from or is null. If the
3414 // constant is non-numeric, handle_ always points to a valid 3429 // constant is non-numeric, handle_ always points to a valid
3415 // constant HeapObject. 3430 // constant HeapObject.
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
5029 } 5044 }
5030 5045
5031 void MakePrefillWithFiller() { 5046 void MakePrefillWithFiller() {
5032 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER); 5047 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER);
5033 } 5048 }
5034 5049
5035 void MakeDoubleAligned() { 5050 void MakeDoubleAligned() {
5036 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); 5051 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED);
5037 } 5052 }
5038 5053
5039 void UpdateSize(HValue* size) {
5040 SetOperandAt(1, size);
5041 }
5042
5043 virtual void HandleSideEffectDominator(GVNFlag side_effect, 5054 virtual void HandleSideEffectDominator(GVNFlag side_effect,
5044 HValue* dominator); 5055 HValue* dominator);
5045 5056
5046 virtual void PrintDataTo(StringStream* stream); 5057 virtual void PrintDataTo(StringStream* stream);
5047 5058
5048 DECLARE_CONCRETE_INSTRUCTION(Allocate) 5059 DECLARE_CONCRETE_INSTRUCTION(Allocate)
5049 5060
5050 private: 5061 private:
5051 enum Flags { 5062 enum Flags {
5052 ALLOCATE_IN_NEW_SPACE = 1 << 0, 5063 ALLOCATE_IN_NEW_SPACE = 1 << 0,
5053 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, 5064 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1,
5054 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, 5065 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2,
5055 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, 5066 ALLOCATE_DOUBLE_ALIGNED = 1 << 3,
5056 PREFILL_WITH_FILLER = 1 << 4 5067 PREFILL_WITH_FILLER = 1 << 4
5057 }; 5068 };
5058 5069
5059 HAllocate(HValue* context, 5070 HAllocate(HValue* context,
5060 HValue* size, 5071 HValue* size,
5061 HType type, 5072 HType type,
5062 PretenureFlag pretenure_flag, 5073 PretenureFlag pretenure_flag,
5063 InstanceType instance_type) 5074 InstanceType instance_type)
5064 : HTemplateInstruction<2>(type) { 5075 : HTemplateInstruction<2>(type),
5076 dominating_allocate_(NULL),
5077 filler_free_space_size_(NULL) {
5065 SetOperandAt(0, context); 5078 SetOperandAt(0, context);
5066 SetOperandAt(1, size); 5079 SetOperandAt(1, size);
5067 set_representation(Representation::Tagged()); 5080 set_representation(Representation::Tagged());
5068 SetFlag(kTrackSideEffectDominators); 5081 SetFlag(kTrackSideEffectDominators);
5069 SetGVNFlag(kChangesNewSpacePromotion); 5082 SetGVNFlag(kChangesNewSpacePromotion);
5070 SetGVNFlag(kDependsOnNewSpacePromotion); 5083 SetGVNFlag(kDependsOnNewSpacePromotion);
5071 flags_ = pretenure_flag == TENURED 5084 flags_ = pretenure_flag == TENURED
5072 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE 5085 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE
5073 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) 5086 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE)
5074 : ALLOCATE_IN_NEW_SPACE; 5087 : ALLOCATE_IN_NEW_SPACE;
5075 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { 5088 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
5076 flags_ = static_cast<HAllocate::Flags>(flags_ | 5089 flags_ = static_cast<HAllocate::Flags>(flags_ |
5077 ALLOCATE_DOUBLE_ALIGNED); 5090 ALLOCATE_DOUBLE_ALIGNED);
5078 } 5091 }
5079 } 5092 }
5080 5093
5094 void UpdateSize(HValue* size) {
5095 SetOperandAt(1, size);
5096 }
5097
5098 HAllocate* GetFoldableDominator(HAllocate* dominator);
5099
5100 void UpdateFreeSpaceFiller(HConstant* old_filler_size, int32_t filler_size);
5101
5102 void CreateFreeSpaceFiller(HAllocate* dominator,
5103 int32_t dominator_size,
5104 int32_t filler_size);
5105
5106 bool IsFoldable(HAllocate* allocate) {
5107 return (IsNewSpaceAllocation() && allocate->IsNewSpaceAllocation()) ||
5108 (IsOldDataSpaceAllocation() && allocate->IsOldDataSpaceAllocation()) ||
5109 (IsOldPointerSpaceAllocation() &&
5110 allocate->IsOldPointerSpaceAllocation());
5111 }
5112
5113 HAllocate* dominating_allocate() const {
titzer 2013/08/07 11:53:44 Private getters and setters for the fields are alt
Hannes Payer (out of office) 2013/08/07 12:47:55 Done.
5114 return dominating_allocate_;
5115 }
5116
5117 void set_dominating_allocate(HAllocate* allocate) {
5118 dominating_allocate_ = allocate;
5119 }
5120
5121 HConstant* filler_free_space_size() const {
5122 return filler_free_space_size_;
5123 }
5124
5125 void set_filler_free_space_size(HConstant* filler_free_space_size) {
5126 filler_free_space_size_ = filler_free_space_size;
5127 }
5128
5129
5081 Flags flags_; 5130 Flags flags_;
5082 Handle<Map> known_initial_map_; 5131 Handle<Map> known_initial_map_;
5132 HAllocate* dominating_allocate_;
5133 HConstant* filler_free_space_size_;
5083 }; 5134 };
5084 5135
5085 5136
5086 class HInnerAllocatedObject: public HTemplateInstruction<1> { 5137 class HInnerAllocatedObject: public HTemplateInstruction<1> {
5087 public: 5138 public:
5088 static HInnerAllocatedObject* New(Zone* zone, 5139 static HInnerAllocatedObject* New(Zone* zone,
5089 HValue* context, 5140 HValue* context,
5090 HValue* value, 5141 HValue* value,
5091 int offset, 5142 int offset,
5092 HType type = HType::Tagged()) { 5143 HType type = HType::Tagged()) {
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
6778 virtual bool IsDeletable() const { return true; } 6829 virtual bool IsDeletable() const { return true; }
6779 }; 6830 };
6780 6831
6781 6832
6782 #undef DECLARE_INSTRUCTION 6833 #undef DECLARE_INSTRUCTION
6783 #undef DECLARE_CONCRETE_INSTRUCTION 6834 #undef DECLARE_CONCRETE_INSTRUCTION
6784 6835
6785 } } // namespace v8::internal 6836 } } // namespace v8::internal
6786 6837
6787 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6838 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.cc » ('j') | src/hydrogen-instructions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698