[wasm] Rename Release to Merge in the DisjointAllocationPool

Merge better captures the upcoming usecase in the wasm native heap,
where allocating/freeing is moving the accounting of memory from
a free list to an allocated list and vice-versa - making 'Release'
an odd API when allocating.

Bug: 
Change-Id: I9010959c91a1e8585eb06303ab06078132a03f60
Reviewed-on: https://chromium-review.googlesource.com/688004
Reviewed-by: Eric Holk <eholk@chromium.org>
Commit-Queue: Mircea Trofin <mtrofin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48211}
This commit is contained in:
Mircea Trofin 2017-09-27 19:53:20 -07:00 committed by Commit Bot
parent 324e0a7adb
commit 1cb0b9bf6a
3 changed files with 17 additions and 17 deletions

View File

@ -12,7 +12,7 @@ DisjointAllocationPool::DisjointAllocationPool(Address start, Address end) {
ranges_.push_back({start, end});
}
void DisjointAllocationPool::Release(DisjointAllocationPool&& other) {
void DisjointAllocationPool::Merge(DisjointAllocationPool&& other) {
auto dest_it = ranges_.begin();
auto dest_end = ranges_.end();
@ -90,7 +90,7 @@ DisjointAllocationPool DisjointAllocationPool::Extract(size_t size,
}
}
if (size > 0) {
Release(std::move(ret));
Merge(std::move(ret));
return {};
}
return ret;

View File

@ -32,7 +32,7 @@ class V8_EXPORT_PRIVATE DisjointAllocationPool final {
// preserved. The assumption is that the passed parameter is
// not intersecting this object - for example, it was obtained
// from a previous Allocate{Pool}.
void Release(DisjointAllocationPool&&);
void Merge(DisjointAllocationPool&&);
// Allocate a contiguous range of size {size}. Return an empty pool on
// failure.

View File

@ -35,7 +35,7 @@ DisjointAllocationPool DisjointAllocationPoolTest::Make(
std::vector<std::pair<size_t, size_t>> model) {
DisjointAllocationPool ret;
for (auto& pair : model) {
ret.Release(DisjointAllocationPool(A(pair.first), A(pair.second)));
ret.Merge(DisjointAllocationPool(A(pair.first), A(pair.second)));
}
return ret;
}
@ -47,13 +47,13 @@ TEST_F(DisjointAllocationPoolTest, Construct) {
DisjointAllocationPool b = Make({{1, 5}});
CHECK(!b.IsEmpty());
CHECK_EQ(b.ranges().size(), 1);
a.Release(std::move(b));
a.Merge(std::move(b));
CheckLooksLike(a, {{1, 5}});
DisjointAllocationPool c;
a.Release(std::move(c));
a.Merge(std::move(c));
CheckLooksLike(a, {{1, 5}});
DisjointAllocationPool e, f;
e.Release(std::move(f));
e.Merge(std::move(f));
CHECK(e.IsEmpty());
}
@ -62,7 +62,7 @@ TEST_F(DisjointAllocationPoolTest, SimpleExtract) {
DisjointAllocationPool b = a.AllocatePool(2);
CheckLooksLike(a, {{3, 5}});
CheckLooksLike(b, {{1, 3}});
a.Release(std::move(b));
a.Merge(std::move(b));
CheckLooksLike(a, {{1, 5}});
CHECK_EQ(a.ranges().size(), 1);
CHECK_EQ(a.ranges().front().first, A(1));
@ -74,7 +74,7 @@ TEST_F(DisjointAllocationPoolTest, ExtractAll) {
DisjointAllocationPool b = a.AllocatePool(4);
CheckLooksLike(b, {{1, 5}});
CHECK(a.IsEmpty());
a.Release(std::move(b));
a.Merge(std::move(b));
CheckLooksLike(a, {{1, 5}});
}
@ -83,19 +83,19 @@ TEST_F(DisjointAllocationPoolTest, ExtractAccross) {
DisjointAllocationPool b = a.AllocatePool(5);
CheckLooksLike(a, {{11, 20}});
CheckLooksLike(b, {{1, 5}, {10, 11}});
a.Release(std::move(b));
a.Merge(std::move(b));
CheckLooksLike(a, {{1, 5}, {10, 20}});
}
TEST_F(DisjointAllocationPoolTest, ReassembleOutOfOrder) {
DisjointAllocationPool a = Make({{1, 5}, {10, 15}});
DisjointAllocationPool b = Make({{7, 8}, {20, 22}});
a.Release(std::move(b));
a.Merge(std::move(b));
CheckLooksLike(a, {{1, 5}, {7, 8}, {10, 15}, {20, 22}});
DisjointAllocationPool c = Make({{1, 5}, {10, 15}});
DisjointAllocationPool d = Make({{7, 8}, {20, 22}});
d.Release(std::move(c));
d.Merge(std::move(c));
CheckLooksLike(d, {{1, 5}, {7, 8}, {10, 15}, {20, 22}});
}
@ -122,31 +122,31 @@ TEST_F(DisjointAllocationPoolTest, ExtractExact) {
TEST_F(DisjointAllocationPoolTest, Merging) {
DisjointAllocationPool a = Make({{10, 15}, {20, 25}});
a.Release(Make({{15, 20}}));
a.Merge(Make({{15, 20}}));
CheckLooksLike(a, {{10, 25}});
}
TEST_F(DisjointAllocationPoolTest, MergingMore) {
DisjointAllocationPool a = Make({{10, 15}, {20, 25}, {30, 35}});
a.Release(Make({{15, 20}, {25, 30}}));
a.Merge(Make({{15, 20}, {25, 30}}));
CheckLooksLike(a, {{10, 35}});
}
TEST_F(DisjointAllocationPoolTest, MergingSkip) {
DisjointAllocationPool a = Make({{10, 15}, {20, 25}, {30, 35}});
a.Release(Make({{25, 30}}));
a.Merge(Make({{25, 30}}));
CheckLooksLike(a, {{10, 15}, {20, 35}});
}
TEST_F(DisjointAllocationPoolTest, MergingSkipLargerSrc) {
DisjointAllocationPool a = Make({{10, 15}, {20, 25}, {30, 35}});
a.Release(Make({{25, 30}, {35, 40}}));
a.Merge(Make({{25, 30}, {35, 40}}));
CheckLooksLike(a, {{10, 15}, {20, 40}});
}
TEST_F(DisjointAllocationPoolTest, MergingSkipLargerSrcWithGap) {
DisjointAllocationPool a = Make({{10, 15}, {20, 25}, {30, 35}});
a.Release(Make({{25, 30}, {36, 40}}));
a.Merge(Make({{25, 30}, {36, 40}}));
CheckLooksLike(a, {{10, 15}, {20, 35}, {36, 40}});
}