Files
sdk/runtime/vm/pages_test.cc
T
Zach Anderson 0bec11a4f2 [vm] Control growth of external allocations
Previously, GC would only be triggered by external allocations on
reaching a limit indicated by a flag. This limit was too large
and not set thoughtfully by anyone.

This CL triggers GC when external allocations in old gen grow
larger than some limit based on results of previous GC, similar
to how Dart heap growth triggers GC. GC is triggered for new gen
when external allocations reach 4x the current new gen
capacity.

FL-61

Change-Id: I1d4da467bc2aab64058f25296aefdd73eebc38e6
Reviewed-on: https://dart-review.googlesource.com/58100
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-06-04 17:24:18 +00:00

35 lines
1.0 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/pages.h"
#include "platform/assert.h"
#include "vm/unit_test.h"
namespace dart {
TEST_CASE(Pages) {
PageSpace* space = new PageSpace(NULL, 4 * MBInWords);
EXPECT(!space->Contains(reinterpret_cast<uword>(&space)));
uword block = space->TryAllocate(8 * kWordSize);
EXPECT(block != 0);
uword total = 0;
while (total < 2 * MB) {
const intptr_t kBlockSize = 16 * kWordSize;
uword new_block = space->TryAllocate(kBlockSize);
EXPECT(block != 0);
EXPECT(block != new_block);
EXPECT(space->IsValidAddress(new_block));
block = new_block;
total += kBlockSize;
}
// Allocate a large block.
uword large_block = space->TryAllocate(1 * MB);
EXPECT(large_block != 0);
EXPECT(block != large_block);
EXPECT(space->IsValidAddress(large_block));
delete space;
}
} // namespace dart