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 5410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5421 SetAllSideEffects(); | 5421 SetAllSideEffects(); |
5422 } | 5422 } |
5423 | 5423 |
5424 Handle<Object> name_; | 5424 Handle<Object> name_; |
5425 bool for_typeof_; | 5425 bool for_typeof_; |
5426 }; | 5426 }; |
5427 | 5427 |
5428 | 5428 |
5429 class HAllocate V8_FINAL : public HTemplateInstruction<2> { | 5429 class HAllocate V8_FINAL : public HTemplateInstruction<2> { |
5430 public: | 5430 public: |
| 5431 enum Flags { |
| 5432 ALLOCATE_IN_NEW_SPACE = 1 << 0, |
| 5433 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, |
| 5434 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, |
| 5435 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, |
| 5436 PREFILL_WITH_FILLER = 1 << 4, |
| 5437 CLEAR_NEXT_MAP_WORD = 1 << 5 |
| 5438 }; |
| 5439 |
| 5440 static Flags ComputeFlags(PretenureFlag pretenure_flag, |
| 5441 InstanceType instance_type) { |
| 5442 Flags flags = pretenure_flag == TENURED |
| 5443 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE |
| 5444 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) |
| 5445 : ALLOCATE_IN_NEW_SPACE; |
| 5446 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
| 5447 flags = static_cast<Flags>(flags | ALLOCATE_DOUBLE_ALIGNED); |
| 5448 } |
| 5449 // We have to fill the allocated object with one word fillers if we do |
| 5450 // not use allocation folding since some allocations may depend on each |
| 5451 // other, i.e., have a pointer to each other. A GC in between these |
| 5452 // allocations may leave such objects behind in a not completely initialized |
| 5453 // state. |
| 5454 if (!FLAG_use_gvn || !FLAG_use_allocation_folding) { |
| 5455 flags = static_cast<Flags>(flags | PREFILL_WITH_FILLER); |
| 5456 } |
| 5457 if (pretenure_flag == NOT_TENURED && |
| 5458 AllocationSite::CanTrack(instance_type)) { |
| 5459 flags = static_cast<Flags>(flags | CLEAR_NEXT_MAP_WORD); |
| 5460 } |
| 5461 return flags; |
| 5462 } |
| 5463 |
5431 static HAllocate* New(Zone* zone, | 5464 static HAllocate* New(Zone* zone, |
5432 HValue* context, | 5465 HValue* context, |
5433 HValue* size, | 5466 HValue* size, |
| 5467 HType type, |
| 5468 Flags flags, |
| 5469 Handle<AllocationSite> allocation_site = |
| 5470 Handle<AllocationSite>::null()) { |
| 5471 return new(zone) HAllocate(context, size, type, flags, allocation_site); |
| 5472 } |
| 5473 |
| 5474 static HAllocate* New(Zone* zone, |
| 5475 HValue* context, |
| 5476 HValue* size, |
5434 HType type, | 5477 HType type, |
5435 PretenureFlag pretenure_flag, | 5478 PretenureFlag pretenure_flag, |
5436 InstanceType instance_type, | 5479 InstanceType instance_type, |
5437 Handle<AllocationSite> allocation_site = | 5480 Handle<AllocationSite> allocation_site = |
5438 Handle<AllocationSite>::null()) { | 5481 Handle<AllocationSite>::null()) { |
5439 return new(zone) HAllocate(context, size, type, pretenure_flag, | 5482 Flags flags = ComputeFlags(pretenure_flag, instance_type); |
5440 instance_type, allocation_site); | 5483 return New(zone, context, size, type, flags, allocation_site); |
5441 } | 5484 } |
5442 | 5485 |
5443 // Maximum instance size for which allocations will be inlined. | 5486 // Maximum instance size for which allocations will be inlined. |
5444 static const int kMaxInlineSize = 64 * kPointerSize; | 5487 static const int kMaxInlineSize = 64 * kPointerSize; |
5445 | 5488 |
5446 HValue* context() { return OperandAt(0); } | 5489 HValue* context() { return OperandAt(0); } |
5447 HValue* size() { return OperandAt(1); } | 5490 HValue* size() { return OperandAt(1); } |
5448 | 5491 |
5449 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 5492 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
5450 if (index == 0) { | 5493 if (index == 0) { |
(...skipping 28 matching lines...) Expand all Loading... |
5479 } | 5522 } |
5480 | 5523 |
5481 bool MustPrefillWithFiller() const { | 5524 bool MustPrefillWithFiller() const { |
5482 return (flags_ & PREFILL_WITH_FILLER) != 0; | 5525 return (flags_ & PREFILL_WITH_FILLER) != 0; |
5483 } | 5526 } |
5484 | 5527 |
5485 void MakePrefillWithFiller() { | 5528 void MakePrefillWithFiller() { |
5486 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER); | 5529 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER); |
5487 } | 5530 } |
5488 | 5531 |
| 5532 bool MustClearNextMapWord() const { |
| 5533 return (flags_ & CLEAR_NEXT_MAP_WORD) != 0; |
| 5534 } |
| 5535 |
5489 void MakeDoubleAligned() { | 5536 void MakeDoubleAligned() { |
5490 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); | 5537 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); |
5491 } | 5538 } |
5492 | 5539 |
5493 virtual void HandleSideEffectDominator(GVNFlag side_effect, | 5540 virtual void HandleSideEffectDominator(GVNFlag side_effect, |
5494 HValue* dominator) V8_OVERRIDE; | 5541 HValue* dominator) V8_OVERRIDE; |
5495 | 5542 |
5496 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 5543 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
5497 | 5544 |
5498 DECLARE_CONCRETE_INSTRUCTION(Allocate) | 5545 DECLARE_CONCRETE_INSTRUCTION(Allocate) |
5499 | 5546 |
5500 private: | 5547 private: |
5501 enum Flags { | |
5502 ALLOCATE_IN_NEW_SPACE = 1 << 0, | |
5503 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, | |
5504 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, | |
5505 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, | |
5506 PREFILL_WITH_FILLER = 1 << 4 | |
5507 }; | |
5508 | |
5509 HAllocate(HValue* context, | 5548 HAllocate(HValue* context, |
5510 HValue* size, | 5549 HValue* size, |
5511 HType type, | 5550 HType type, |
5512 PretenureFlag pretenure_flag, | 5551 Flags flags, |
5513 InstanceType instance_type, | 5552 Handle<AllocationSite> allocation_site) |
5514 Handle<AllocationSite> allocation_site = | |
5515 Handle<AllocationSite>::null()) | |
5516 : HTemplateInstruction<2>(type), | 5553 : HTemplateInstruction<2>(type), |
| 5554 flags_(flags), |
5517 dominating_allocate_(NULL), | 5555 dominating_allocate_(NULL), |
5518 filler_free_space_size_(NULL), | 5556 filler_free_space_size_(NULL) { |
5519 clear_next_map_word_(false) { | |
5520 SetOperandAt(0, context); | 5557 SetOperandAt(0, context); |
5521 SetOperandAt(1, size); | 5558 SetOperandAt(1, size); |
5522 set_representation(Representation::Tagged()); | 5559 set_representation(Representation::Tagged()); |
5523 SetFlag(kTrackSideEffectDominators); | 5560 SetFlag(kTrackSideEffectDominators); |
5524 SetGVNFlag(kChangesNewSpacePromotion); | 5561 SetGVNFlag(kChangesNewSpacePromotion); |
5525 SetGVNFlag(kDependsOnNewSpacePromotion); | 5562 SetGVNFlag(kDependsOnNewSpacePromotion); |
5526 flags_ = pretenure_flag == TENURED | |
5527 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE | |
5528 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) | |
5529 : ALLOCATE_IN_NEW_SPACE; | |
5530 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | |
5531 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); | |
5532 } | |
5533 // We have to fill the allocated object with one word fillers if we do | |
5534 // not use allocation folding since some allocations may depend on each | |
5535 // other, i.e., have a pointer to each other. A GC in between these | |
5536 // allocations may leave such objects behind in a not completely initialized | |
5537 // state. | |
5538 if (!FLAG_use_gvn || !FLAG_use_allocation_folding) { | |
5539 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER); | |
5540 } | |
5541 clear_next_map_word_ = pretenure_flag == NOT_TENURED && | |
5542 AllocationSite::CanTrack(instance_type); | |
5543 | 5563 |
5544 if (FLAG_trace_pretenuring) { | 5564 if (FLAG_trace_pretenuring) { |
5545 PrintF("HAllocate with AllocationSite %p %s\n", | 5565 PrintF("HAllocate with AllocationSite %p %s\n", |
5546 allocation_site.is_null() | 5566 allocation_site.is_null() |
5547 ? static_cast<void*>(NULL) | 5567 ? static_cast<void*>(NULL) |
5548 : static_cast<void*>(*allocation_site), | 5568 : static_cast<void*>(*allocation_site), |
5549 pretenure_flag == TENURED ? "tenured" : "not tenured"); | 5569 IsNewSpaceAllocation() ? "not tenured" : "tenured"); |
5550 } | 5570 } |
5551 } | 5571 } |
5552 | 5572 |
5553 void UpdateSize(HValue* size) { | 5573 void UpdateSize(HValue* size) { |
5554 SetOperandAt(1, size); | 5574 SetOperandAt(1, size); |
5555 } | 5575 } |
5556 | 5576 |
5557 HAllocate* GetFoldableDominator(HAllocate* dominator); | 5577 HAllocate* GetFoldableDominator(HAllocate* dominator); |
5558 | 5578 |
5559 void UpdateFreeSpaceFiller(int32_t filler_size); | 5579 void UpdateFreeSpaceFiller(int32_t filler_size); |
5560 | 5580 |
5561 void CreateFreeSpaceFiller(int32_t filler_size); | 5581 void CreateFreeSpaceFiller(int32_t filler_size); |
5562 | 5582 |
5563 bool IsFoldable(HAllocate* allocate) { | 5583 bool IsFoldable(HAllocate* allocate) { |
5564 return (IsNewSpaceAllocation() && allocate->IsNewSpaceAllocation()) || | 5584 return (IsNewSpaceAllocation() && allocate->IsNewSpaceAllocation()) || |
5565 (IsOldDataSpaceAllocation() && allocate->IsOldDataSpaceAllocation()) || | 5585 (IsOldDataSpaceAllocation() && allocate->IsOldDataSpaceAllocation()) || |
5566 (IsOldPointerSpaceAllocation() && | 5586 (IsOldPointerSpaceAllocation() && |
5567 allocate->IsOldPointerSpaceAllocation()); | 5587 allocate->IsOldPointerSpaceAllocation()); |
5568 } | 5588 } |
5569 | 5589 |
5570 void ClearNextMapWord(int offset); | 5590 void ClearNextMapWord(int offset); |
5571 | 5591 |
5572 Flags flags_; | 5592 Flags flags_; |
5573 Handle<Map> known_initial_map_; | 5593 Handle<Map> known_initial_map_; |
5574 HAllocate* dominating_allocate_; | 5594 HAllocate* dominating_allocate_; |
5575 HStoreNamedField* filler_free_space_size_; | 5595 HStoreNamedField* filler_free_space_size_; |
5576 bool clear_next_map_word_; | |
5577 }; | 5596 }; |
5578 | 5597 |
5579 | 5598 |
5580 class HStoreCodeEntry V8_FINAL: public HTemplateInstruction<2> { | 5599 class HStoreCodeEntry V8_FINAL: public HTemplateInstruction<2> { |
5581 public: | 5600 public: |
5582 static HStoreCodeEntry* New(Zone* zone, | 5601 static HStoreCodeEntry* New(Zone* zone, |
5583 HValue* context, | 5602 HValue* context, |
5584 HValue* function, | 5603 HValue* function, |
5585 HValue* code) { | 5604 HValue* code) { |
5586 return new(zone) HStoreCodeEntry(function, code); | 5605 return new(zone) HStoreCodeEntry(function, code); |
(...skipping 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7493 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7512 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
7494 }; | 7513 }; |
7495 | 7514 |
7496 | 7515 |
7497 #undef DECLARE_INSTRUCTION | 7516 #undef DECLARE_INSTRUCTION |
7498 #undef DECLARE_CONCRETE_INSTRUCTION | 7517 #undef DECLARE_CONCRETE_INSTRUCTION |
7499 | 7518 |
7500 } } // namespace v8::internal | 7519 } } // namespace v8::internal |
7501 | 7520 |
7502 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7521 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |