Files
sdk/runtime/vm/heap/pages_test.cc
T
Ryan Macnak e7dc37c516 [vm, gc] Don't start or finalize concurrent marking during a force growth scope.
Adjust tests to exit force growth scopes before forcing a GC.

Change-Id: I6d84c83e75ab8da4e0d623256d1997efd61341d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163140
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-09-18 21:32:56 +00:00

36 lines
1.1 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/heap/pages.h"
#include "platform/assert.h"
#include "vm/unit_test.h"
namespace dart {
TEST_CASE(Pages) {
PageSpace* space = new PageSpace(NULL, 4 * MBInWords);
space->InitGrowthControl();
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