test/hotspot/gtest/gc/z/test_zVirtualMemory.cpp
author pliden
Wed, 13 Mar 2019 11:31:00 +0100
changeset 54094 ed3c6f07faab
parent 50975 b833992fa8fa
child 54834 39ba09047e19
permissions -rw-r--r--
8219633: ZGC: Rename ZPageSizeMin to ZGranuleSize Reviewed-by: eosterlund, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     1
/*
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
50975
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
     4
 *
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
     7
 * published by the Free Software Foundation.
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
     8
 *
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    13
 * accompanied this code).
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    14
 *
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    18
 *
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b833992fa8fa 8206322: ZGC: Incorrect license header in gtests
pliden
parents: 50525
diff changeset
    21
 * questions.
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    22
 */
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    23
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    24
#include "precompiled.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    25
#include "gc/z/zVirtualMemory.inline.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    26
#include "utilities/debug.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    27
#include "unittest.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    28
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    29
TEST(ZVirtualMemory, split) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    30
  const size_t PageSize = 2 * M;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    31
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    32
  ZVirtualMemory mem(0, 10 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    33
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    34
  ZVirtualMemory mem_split0 = mem.split(0 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    35
  EXPECT_EQ(mem_split0.size(),  0 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    36
  EXPECT_EQ(       mem.size(), 10 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    37
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    38
  ZVirtualMemory mem_split1 = mem.split(5u * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    39
  EXPECT_EQ(mem_split1.size(),  5 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    40
  EXPECT_EQ(       mem.size(),  5 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    41
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    42
  ZVirtualMemory mem_split2 = mem.split(5u * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    43
  EXPECT_EQ(mem_split2.size(),  5 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    44
  EXPECT_EQ(       mem.size(),  0 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    45
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    46
  ZVirtualMemory mem_split3 = mem.split(0 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    47
  EXPECT_EQ(mem_split3.size(),  0 * PageSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    48
}