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 5223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5234 | 5234 |
5235 private: | 5235 private: |
5236 Handle<Object> name_; | 5236 Handle<Object> name_; |
5237 bool for_typeof_; | 5237 bool for_typeof_; |
5238 }; | 5238 }; |
5239 | 5239 |
5240 | 5240 |
5241 class HAllocate: public HTemplateInstruction<2> { | 5241 class HAllocate: public HTemplateInstruction<2> { |
5242 public: | 5242 public: |
5243 enum Flags { | 5243 enum Flags { |
5244 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, | 5244 ALLOCATE_IN_NEW_SPACE = 1 << 0, |
5245 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, | 5245 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, |
5246 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, | 5246 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, |
5247 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, | 5247 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, |
5248 PREFILL_WITH_FILLER = 1 << 4 | 5248 PREFILL_WITH_FILLER = 1 << 4 |
5249 }; | 5249 }; |
5250 | 5250 |
5251 HAllocate(HValue* context, HValue* size, HType type, Flags flags) | 5251 HAllocate(HValue* context, HValue* size, HType type, Flags flags) |
5252 : flags_(flags) { | 5252 : flags_(flags) { |
5253 ASSERT(((flags & kAllocationFlagsMask) == ALLOCATE_IN_NEW_SPACE) || | |
5254 ((flags & kAllocationFlagsMask) == ALLOCATE_IN_OLD_DATA_SPACE) || | |
5255 ((flags & kAllocationFlagsMask) == ALLOCATE_IN_OLD_POINTER_SPACE)); | |
5253 SetOperandAt(0, context); | 5256 SetOperandAt(0, context); |
5254 SetOperandAt(1, size); | 5257 SetOperandAt(1, size); |
5255 set_type(type); | 5258 set_type(type); |
5256 set_representation(Representation::Tagged()); | 5259 set_representation(Representation::Tagged()); |
5257 SetFlag(kTrackSideEffectDominators); | 5260 SetFlag(kTrackSideEffectDominators); |
5258 SetGVNFlag(kChangesNewSpacePromotion); | 5261 SetGVNFlag(kChangesNewSpacePromotion); |
5259 SetGVNFlag(kDependsOnNewSpacePromotion); | 5262 SetGVNFlag(kDependsOnNewSpacePromotion); |
5260 } | 5263 } |
5261 | 5264 |
5262 // Maximum instance size for which allocations will be inlined. | 5265 // Maximum instance size for which allocations will be inlined. |
5263 static const int kMaxInlineSize = 64 * kPointerSize; | 5266 static const int kMaxInlineSize = 64 * kPointerSize; |
5264 | 5267 |
5265 static Flags DefaultFlags() { | 5268 static Flags DefaultFlags() { |
5266 return CAN_ALLOCATE_IN_NEW_SPACE; | 5269 return ALLOCATE_IN_NEW_SPACE; |
5267 } | 5270 } |
5268 | 5271 |
5269 static Flags DefaultFlags(ElementsKind kind) { | 5272 static Flags DefaultFlags(ElementsKind kind) { |
5270 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE; | 5273 Flags flags = ALLOCATE_IN_NEW_SPACE; |
5271 if (IsFastDoubleElementsKind(kind)) { | 5274 if (IsFastDoubleElementsKind(kind)) { |
5272 flags = static_cast<HAllocate::Flags>( | 5275 flags = static_cast<HAllocate::Flags>( |
5273 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); | 5276 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); |
5274 } | 5277 } |
5275 return flags; | 5278 return flags; |
5276 } | 5279 } |
5277 | 5280 |
5281 static Flags SetAllocationFlag(Flags flags, Flags allocation_flag) { | |
Michael Starzinger
2013/07/30 12:50:41
As discussed offline: I don't like this helper ver
Hannes Payer (out of office)
2013/07/30 15:23:05
I took that idea even further and made the HAlloca
| |
5282 ASSERT(allocation_flag == ALLOCATE_IN_NEW_SPACE || | |
5283 allocation_flag == ALLOCATE_IN_OLD_DATA_SPACE || | |
5284 allocation_flag == ALLOCATE_IN_OLD_POINTER_SPACE); | |
5285 flags = static_cast<HAllocate::Flags>(flags & ~kAllocationFlagsMask); | |
5286 return static_cast<HAllocate::Flags>(flags | allocation_flag); | |
5287 } | |
5288 | |
5278 HValue* context() { return OperandAt(0); } | 5289 HValue* context() { return OperandAt(0); } |
5279 HValue* size() { return OperandAt(1); } | 5290 HValue* size() { return OperandAt(1); } |
5280 | 5291 |
5281 virtual Representation RequiredInputRepresentation(int index) { | 5292 virtual Representation RequiredInputRepresentation(int index) { |
5282 if (index == 0) { | 5293 if (index == 0) { |
5283 return Representation::Tagged(); | 5294 return Representation::Tagged(); |
5284 } else { | 5295 } else { |
5285 return Representation::Integer32(); | 5296 return Representation::Integer32(); |
5286 } | 5297 } |
5287 } | 5298 } |
5288 | 5299 |
5289 virtual Handle<Map> GetMonomorphicJSObjectMap() { | 5300 virtual Handle<Map> GetMonomorphicJSObjectMap() { |
5290 return known_initial_map_; | 5301 return known_initial_map_; |
5291 } | 5302 } |
5292 | 5303 |
5293 void set_known_initial_map(Handle<Map> known_initial_map) { | 5304 void set_known_initial_map(Handle<Map> known_initial_map) { |
5294 known_initial_map_ = known_initial_map; | 5305 known_initial_map_ = known_initial_map; |
5295 } | 5306 } |
5296 | 5307 |
5297 bool CanAllocateInNewSpace() const { | 5308 bool AllocateInNewSpace() const { |
5298 return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; | 5309 return (flags_ & ALLOCATE_IN_NEW_SPACE) != 0; |
5299 } | 5310 } |
5300 | 5311 |
5301 bool CanAllocateInOldDataSpace() const { | 5312 bool AllocateInOldDataSpace() const { |
5302 return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0; | 5313 return (flags_ & ALLOCATE_IN_OLD_DATA_SPACE) != 0; |
5303 } | 5314 } |
5304 | 5315 |
5305 bool CanAllocateInOldPointerSpace() const { | 5316 bool AllocateInOldPointerSpace() const { |
5306 return (flags_ & CAN_ALLOCATE_IN_OLD_POINTER_SPACE) != 0; | 5317 return (flags_ & ALLOCATE_IN_OLD_POINTER_SPACE) != 0; |
5307 } | |
5308 | |
5309 bool CanAllocateInOldSpace() const { | |
5310 return CanAllocateInOldDataSpace() || | |
5311 CanAllocateInOldPointerSpace(); | |
5312 } | |
5313 | |
5314 bool GuaranteedInNewSpace() const { | |
5315 return CanAllocateInNewSpace() && !CanAllocateInOldSpace(); | |
5316 } | 5318 } |
5317 | 5319 |
5318 bool MustAllocateDoubleAligned() const { | 5320 bool MustAllocateDoubleAligned() const { |
5319 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0; | 5321 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0; |
5320 } | 5322 } |
5321 | 5323 |
5322 bool MustPrefillWithFiller() const { | 5324 bool MustPrefillWithFiller() const { |
5323 return (flags_ & PREFILL_WITH_FILLER) != 0; | 5325 return (flags_ & PREFILL_WITH_FILLER) != 0; |
5324 } | 5326 } |
5325 | 5327 |
5326 void SetFlags(Flags flags) { | 5328 void SetFlags(Flags flags) { |
5327 flags_ = static_cast<HAllocate::Flags>(flags_ | flags); | 5329 flags_ = static_cast<HAllocate::Flags>(flags_ | flags); |
5330 ASSERT(((flags_ & kAllocationFlagsMask) == ALLOCATE_IN_NEW_SPACE) || | |
5331 ((flags_ & kAllocationFlagsMask) == ALLOCATE_IN_OLD_DATA_SPACE) || | |
5332 ((flags_ & kAllocationFlagsMask) == ALLOCATE_IN_OLD_POINTER_SPACE)); | |
5328 } | 5333 } |
5329 | 5334 |
5330 void UpdateSize(HValue* size) { | 5335 void UpdateSize(HValue* size) { |
5331 SetOperandAt(1, size); | 5336 SetOperandAt(1, size); |
5332 } | 5337 } |
5333 | 5338 |
5334 virtual void HandleSideEffectDominator(GVNFlag side_effect, | 5339 virtual void HandleSideEffectDominator(GVNFlag side_effect, |
5335 HValue* dominator); | 5340 HValue* dominator); |
5336 | 5341 |
5337 virtual void PrintDataTo(StringStream* stream); | 5342 virtual void PrintDataTo(StringStream* stream); |
5338 | 5343 |
5339 DECLARE_CONCRETE_INSTRUCTION(Allocate) | 5344 DECLARE_CONCRETE_INSTRUCTION(Allocate) |
5340 | 5345 |
5341 private: | 5346 private: |
5347 static const int kAllocationFlagsMask = 0x7; | |
Michael Starzinger
2013/07/30 12:50:41
Better compute this using the above three enum val
Hannes Payer (out of office)
2013/07/30 15:23:05
Removed, not needed anymore
| |
5342 Flags flags_; | 5348 Flags flags_; |
5343 Handle<Map> known_initial_map_; | 5349 Handle<Map> known_initial_map_; |
5344 }; | 5350 }; |
5345 | 5351 |
5346 | 5352 |
5347 class HInnerAllocatedObject: public HTemplateInstruction<1> { | 5353 class HInnerAllocatedObject: public HTemplateInstruction<1> { |
5348 public: | 5354 public: |
5349 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) | 5355 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) |
5350 : offset_(offset) { | 5356 : offset_(offset) { |
5351 ASSERT(value->IsAllocate()); | 5357 ASSERT(value->IsAllocate()); |
(...skipping 30 matching lines...) Expand all Loading... | |
5382 if (object->IsInnerAllocatedObject()) { | 5388 if (object->IsInnerAllocatedObject()) { |
5383 return ReceiverObjectNeedsWriteBarrier( | 5389 return ReceiverObjectNeedsWriteBarrier( |
5384 HInnerAllocatedObject::cast(object)->base_object(), | 5390 HInnerAllocatedObject::cast(object)->base_object(), |
5385 new_space_dominator); | 5391 new_space_dominator); |
5386 } | 5392 } |
5387 if (object->IsConstant() && HConstant::cast(object)->IsCell()) { | 5393 if (object->IsConstant() && HConstant::cast(object)->IsCell()) { |
5388 return false; | 5394 return false; |
5389 } | 5395 } |
5390 if (object != new_space_dominator) return true; | 5396 if (object != new_space_dominator) return true; |
5391 if (object->IsAllocate()) { | 5397 if (object->IsAllocate()) { |
5392 return !HAllocate::cast(object)->GuaranteedInNewSpace(); | 5398 return !HAllocate::cast(object)->AllocateInNewSpace(); |
5393 } | 5399 } |
5394 return true; | 5400 return true; |
5395 } | 5401 } |
5396 | 5402 |
5397 | 5403 |
5398 class HStoreGlobalCell: public HUnaryOperation { | 5404 class HStoreGlobalCell: public HUnaryOperation { |
5399 public: | 5405 public: |
5400 HStoreGlobalCell(HValue* value, | 5406 HStoreGlobalCell(HValue* value, |
5401 Handle<PropertyCell> cell, | 5407 Handle<PropertyCell> cell, |
5402 PropertyDetails details) | 5408 PropertyDetails details) |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7006 virtual bool IsDeletable() const { return true; } | 7012 virtual bool IsDeletable() const { return true; } |
7007 }; | 7013 }; |
7008 | 7014 |
7009 | 7015 |
7010 #undef DECLARE_INSTRUCTION | 7016 #undef DECLARE_INSTRUCTION |
7011 #undef DECLARE_CONCRETE_INSTRUCTION | 7017 #undef DECLARE_CONCRETE_INSTRUCTION |
7012 | 7018 |
7013 } } // namespace v8::internal | 7019 } } // namespace v8::internal |
7014 | 7020 |
7015 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7021 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |