Skip to content
Snippets Groups Projects
Commit 5b6b9c15 authored by whh8b's avatar whh8b
Browse files

Return a range of instructions

When the memory space is asked for nearby ranges,
it should return a range.
parent 99e4be90
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,8 @@ class ZiprMemorySpace_t : public MemorySpace_t ...@@ -46,7 +46,8 @@ class ZiprMemorySpace_t : public MemorySpace_t
void MergeFreeRange(RangeAddress_t addr); void MergeFreeRange(RangeAddress_t addr);
RangeSet_t::iterator FindFreeRange(RangeAddress_t addr); RangeSet_t::iterator FindFreeRange(RangeAddress_t addr);
Range_t GetFreeRange(int size); Range_t GetFreeRange(int size);
Range_t GetNearbyFreeRange(const RangeAddress_t hint); std::pair<RangeSet_t::const_iterator,RangeSet_t::const_iterator>
GetNearbyFreeRanges(const RangeAddress_t hint, size_t count = 0);
void AddFreeRange(Range_t newRange); void AddFreeRange(Range_t newRange);
void RemoveFreeRange(Range_t newRange); void RemoveFreeRange(Range_t newRange);
......
...@@ -161,18 +161,16 @@ bool ZiprMemorySpace_t::IsValidRange(RangeSet_t::iterator it) ...@@ -161,18 +161,16 @@ bool ZiprMemorySpace_t::IsValidRange(RangeSet_t::iterator it)
return it!=free_ranges.end(); return it!=free_ranges.end();
} }
Range_t ZiprMemorySpace_t::GetNearbyFreeRange(const RangeAddress_t hint) std::pair<RangeSet_t::const_iterator,RangeSet_t::const_iterator>
ZiprMemorySpace_t::GetNearbyFreeRanges(const RangeAddress_t hint,size_t count)
{ {
RangeSet_t::iterator result;
Range_t search(hint, hint+1); Range_t search(hint, hint+1);
RangeSet_t::const_iterator result = free_ranges.upper_bound(search);
/* /*
* TODO: Not quite sure what to make of this. * TODO: Not quite sure what to make of this.
*/ */
if (free_ranges.end() == (result = free_ranges.upper_bound(search))) { return std::pair<RangeSet_t::const_iterator,RangeSet_t::const_iterator>(
cout << "Oops: GetNearbyFreeRange() is BAD" << endl; result, free_ranges.end());
return Range_t(0,0);
}
return *result;
} }
Range_t ZiprMemorySpace_t::GetFreeRange(int size) Range_t ZiprMemorySpace_t::GetFreeRange(int size)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment