OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ | 5 #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ |
6 #define V8_HYDROGEN_INSTRUCTIONS_H_ | 6 #define V8_HYDROGEN_INSTRUCTIONS_H_ |
7 | 7 |
8 #include "v8.h" | 8 #include "v8.h" |
9 | 9 |
10 #include "allocation.h" | 10 #include "allocation.h" |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 virtual HSourcePosition operand_position(int index) const V8_OVERRIDE { | 1152 virtual HSourcePosition operand_position(int index) const V8_OVERRIDE { |
1153 const HSourcePosition pos = position_.operand_position(index); | 1153 const HSourcePosition pos = position_.operand_position(index); |
1154 return pos.IsUnknown() ? position() : pos; | 1154 return pos.IsUnknown() ? position() : pos; |
1155 } | 1155 } |
1156 void set_operand_position(Zone* zone, int index, HSourcePosition pos) { | 1156 void set_operand_position(Zone* zone, int index, HSourcePosition pos) { |
1157 ASSERT(0 <= index && index < OperandCount()); | 1157 ASSERT(0 <= index && index < OperandCount()); |
1158 position_.ensure_storage_for_operand_positions(zone, OperandCount()); | 1158 position_.ensure_storage_for_operand_positions(zone, OperandCount()); |
1159 position_.set_operand_position(index, pos); | 1159 position_.set_operand_position(index, pos); |
1160 } | 1160 } |
1161 | 1161 |
| 1162 bool Dominates(HInstruction* other); |
1162 bool CanTruncateToSmi() const { return CheckFlag(kTruncatingToSmi); } | 1163 bool CanTruncateToSmi() const { return CheckFlag(kTruncatingToSmi); } |
1163 bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); } | 1164 bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); } |
1164 | 1165 |
1165 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; | 1166 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; |
1166 | 1167 |
1167 #ifdef DEBUG | 1168 #ifdef DEBUG |
1168 virtual void Verify() V8_OVERRIDE; | 1169 virtual void Verify() V8_OVERRIDE; |
1169 #endif | 1170 #endif |
1170 | 1171 |
1171 bool CanDeoptimize(); | 1172 bool CanDeoptimize(); |
(...skipping 4266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5438 return new(zone) HAllocate(context, size, type, pretenure_flag, | 5439 return new(zone) HAllocate(context, size, type, pretenure_flag, |
5439 instance_type, allocation_site); | 5440 instance_type, allocation_site); |
5440 } | 5441 } |
5441 | 5442 |
5442 // Maximum instance size for which allocations will be inlined. | 5443 // Maximum instance size for which allocations will be inlined. |
5443 static const int kMaxInlineSize = 64 * kPointerSize; | 5444 static const int kMaxInlineSize = 64 * kPointerSize; |
5444 | 5445 |
5445 HValue* context() { return OperandAt(0); } | 5446 HValue* context() { return OperandAt(0); } |
5446 HValue* size() { return OperandAt(1); } | 5447 HValue* size() { return OperandAt(1); } |
5447 | 5448 |
| 5449 bool has_size_upper_bound() { return size_upper_bound_ != NULL; } |
| 5450 HConstant* size_upper_bound() { return size_upper_bound_; } |
| 5451 void set_size_upper_bound(HConstant* value) { |
| 5452 ASSERT(size_upper_bound_ == NULL); |
| 5453 size_upper_bound_ = value; |
| 5454 } |
| 5455 |
5448 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 5456 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
5449 if (index == 0) { | 5457 if (index == 0) { |
5450 return Representation::Tagged(); | 5458 return Representation::Tagged(); |
5451 } else { | 5459 } else { |
5452 return Representation::Integer32(); | 5460 return Representation::Integer32(); |
5453 } | 5461 } |
5454 } | 5462 } |
5455 | 5463 |
5456 virtual Handle<Map> GetMonomorphicJSObjectMap() { | 5464 virtual Handle<Map> GetMonomorphicJSObjectMap() { |
5457 return known_initial_map_; | 5465 return known_initial_map_; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5513 HAllocate(HValue* context, | 5521 HAllocate(HValue* context, |
5514 HValue* size, | 5522 HValue* size, |
5515 HType type, | 5523 HType type, |
5516 PretenureFlag pretenure_flag, | 5524 PretenureFlag pretenure_flag, |
5517 InstanceType instance_type, | 5525 InstanceType instance_type, |
5518 Handle<AllocationSite> allocation_site = | 5526 Handle<AllocationSite> allocation_site = |
5519 Handle<AllocationSite>::null()) | 5527 Handle<AllocationSite>::null()) |
5520 : HTemplateInstruction<2>(type), | 5528 : HTemplateInstruction<2>(type), |
5521 flags_(ComputeFlags(pretenure_flag, instance_type)), | 5529 flags_(ComputeFlags(pretenure_flag, instance_type)), |
5522 dominating_allocate_(NULL), | 5530 dominating_allocate_(NULL), |
5523 filler_free_space_size_(NULL) { | 5531 filler_free_space_size_(NULL), |
| 5532 size_upper_bound_(NULL) { |
5524 SetOperandAt(0, context); | 5533 SetOperandAt(0, context); |
5525 SetOperandAt(1, size); | 5534 UpdateSize(size); |
5526 set_representation(Representation::Tagged()); | 5535 set_representation(Representation::Tagged()); |
5527 SetFlag(kTrackSideEffectDominators); | 5536 SetFlag(kTrackSideEffectDominators); |
5528 SetChangesFlag(kNewSpacePromotion); | 5537 SetChangesFlag(kNewSpacePromotion); |
5529 SetDependsOnFlag(kNewSpacePromotion); | 5538 SetDependsOnFlag(kNewSpacePromotion); |
5530 | 5539 |
5531 if (FLAG_trace_pretenuring) { | 5540 if (FLAG_trace_pretenuring) { |
5532 PrintF("HAllocate with AllocationSite %p %s\n", | 5541 PrintF("HAllocate with AllocationSite %p %s\n", |
5533 allocation_site.is_null() | 5542 allocation_site.is_null() |
5534 ? static_cast<void*>(NULL) | 5543 ? static_cast<void*>(NULL) |
5535 : static_cast<void*>(*allocation_site), | 5544 : static_cast<void*>(*allocation_site), |
(...skipping 26 matching lines...) Expand all Loading... |
5562 } | 5571 } |
5563 | 5572 |
5564 void UpdateClearNextMapWord(bool clear_next_map_word) { | 5573 void UpdateClearNextMapWord(bool clear_next_map_word) { |
5565 flags_ = static_cast<Flags>(clear_next_map_word | 5574 flags_ = static_cast<Flags>(clear_next_map_word |
5566 ? flags_ | CLEAR_NEXT_MAP_WORD | 5575 ? flags_ | CLEAR_NEXT_MAP_WORD |
5567 : flags_ & ~CLEAR_NEXT_MAP_WORD); | 5576 : flags_ & ~CLEAR_NEXT_MAP_WORD); |
5568 } | 5577 } |
5569 | 5578 |
5570 void UpdateSize(HValue* size) { | 5579 void UpdateSize(HValue* size) { |
5571 SetOperandAt(1, size); | 5580 SetOperandAt(1, size); |
| 5581 if (size->IsInteger32Constant()) { |
| 5582 size_upper_bound_ = HConstant::cast(size); |
| 5583 } else { |
| 5584 size_upper_bound_ = NULL; |
| 5585 } |
5572 } | 5586 } |
5573 | 5587 |
5574 HAllocate* GetFoldableDominator(HAllocate* dominator); | 5588 HAllocate* GetFoldableDominator(HAllocate* dominator); |
5575 | 5589 |
5576 void UpdateFreeSpaceFiller(int32_t filler_size); | 5590 void UpdateFreeSpaceFiller(int32_t filler_size); |
5577 | 5591 |
5578 void CreateFreeSpaceFiller(int32_t filler_size); | 5592 void CreateFreeSpaceFiller(int32_t filler_size); |
5579 | 5593 |
5580 bool IsFoldable(HAllocate* allocate) { | 5594 bool IsFoldable(HAllocate* allocate) { |
5581 return (IsNewSpaceAllocation() && allocate->IsNewSpaceAllocation()) || | 5595 return (IsNewSpaceAllocation() && allocate->IsNewSpaceAllocation()) || |
5582 (IsOldDataSpaceAllocation() && allocate->IsOldDataSpaceAllocation()) || | 5596 (IsOldDataSpaceAllocation() && allocate->IsOldDataSpaceAllocation()) || |
5583 (IsOldPointerSpaceAllocation() && | 5597 (IsOldPointerSpaceAllocation() && |
5584 allocate->IsOldPointerSpaceAllocation()); | 5598 allocate->IsOldPointerSpaceAllocation()); |
5585 } | 5599 } |
5586 | 5600 |
5587 void ClearNextMapWord(int offset); | 5601 void ClearNextMapWord(int offset); |
5588 | 5602 |
5589 Flags flags_; | 5603 Flags flags_; |
5590 Handle<Map> known_initial_map_; | 5604 Handle<Map> known_initial_map_; |
5591 HAllocate* dominating_allocate_; | 5605 HAllocate* dominating_allocate_; |
5592 HStoreNamedField* filler_free_space_size_; | 5606 HStoreNamedField* filler_free_space_size_; |
| 5607 HConstant* size_upper_bound_; |
5593 }; | 5608 }; |
5594 | 5609 |
5595 | 5610 |
5596 class HStoreCodeEntry V8_FINAL: public HTemplateInstruction<2> { | 5611 class HStoreCodeEntry V8_FINAL: public HTemplateInstruction<2> { |
5597 public: | 5612 public: |
5598 static HStoreCodeEntry* New(Zone* zone, | 5613 static HStoreCodeEntry* New(Zone* zone, |
5599 HValue* context, | 5614 HValue* context, |
5600 HValue* function, | 5615 HValue* function, |
5601 HValue* code) { | 5616 HValue* code) { |
5602 return new(zone) HStoreCodeEntry(function, code); | 5617 return new(zone) HStoreCodeEntry(function, code); |
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7714 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7729 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
7715 }; | 7730 }; |
7716 | 7731 |
7717 | 7732 |
7718 #undef DECLARE_INSTRUCTION | 7733 #undef DECLARE_INSTRUCTION |
7719 #undef DECLARE_CONCRETE_INSTRUCTION | 7734 #undef DECLARE_CONCRETE_INSTRUCTION |
7720 | 7735 |
7721 } } // namespace v8::internal | 7736 } } // namespace v8::internal |
7722 | 7737 |
7723 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7738 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |