Skip to content
Permalink
Browse files

8235760: ZGC: Implement precise check for @require vm.gc.Z for Windows

Reviewed-by: eosterlund, pliden
  • Loading branch information
stefank committed Dec 11, 2019
1 parent 938a495 commit 47ee85a247e897a9a6c3f788d5ddb06f62cb1840
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#include "precompiled.hpp"
#include "gc/z/zArguments.hpp"

bool ZArguments::is_os_supported() const {
return true;
}
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#include "precompiled.hpp"
#include "gc/z/zArguments.hpp"
#include "gc/z/zSyscall_windows.hpp"

bool ZArguments::is_os_supported() const {
return ZSyscall::is_supported();
}
@@ -56,3 +56,14 @@ void ZSyscall::initialize() {
lookup_symbol(MapViewOfFile3, "KernelBase", "MapViewOfFile3");
lookup_symbol(UnmapViewOfFile2, "KernelBase", "UnmapViewOfFile2");
}

bool ZSyscall::is_supported() {
char ebuf[1024];
void* const handle = os::dll_load("KernelBase", ebuf, sizeof(ebuf));
if (handle == NULL) {
assert(false, "Failed to load library: KernelBase");
return false;
}

return os::dll_lookup(handle, "VirtualAlloc2") != NULL;
}
@@ -45,6 +45,8 @@ class ZSyscall {
static UnmapViewOfFile2Fn UnmapViewOfFile2;

static void initialize();

static bool is_supported();
};

#endif // OS_WINDOWS_GC_Z_ZSYSCALL_WINDOWS_HPP
@@ -117,3 +117,7 @@ size_t ZArguments::conservative_max_heap_alignment() {
CollectedHeap* ZArguments::create_heap() {
return new ZCollectedHeap();
}

bool ZArguments::is_supported() const {
return is_os_supported();
}
@@ -37,6 +37,10 @@ class ZArguments : public GCArguments {
virtual void initialize();
virtual size_t conservative_max_heap_alignment();
virtual CollectedHeap* create_heap();

virtual bool is_supported() const;

bool is_os_supported() const;
};

#endif // SHARE_GC_Z_ZARGUMENTS_HPP
@@ -48,28 +48,11 @@ private GC(int name) {
this.name = name;
}

private boolean supportsOSVersion() {
if (this != Z) {
return true;
}

String osName = System.getProperty("os.name");

if (!osName.startsWith("Windows")) {
return true;
}

// ZGC has specific Windows version requirements (>= 1803).
// The following check should be made more precise to
// also catch the corresponding Windows 10 version.
return osName.equals("Windows Server 2019");
}

/**
* @return true if this GC is supported by the VM, i.e., it is built into the VM.
*/
public boolean isSupported() {
return WB.isGCSupported(name) && supportsOSVersion();
return WB.isGCSupported(name);
}

/**

0 comments on commit 47ee85a

Please sign in to comment.
You can’t perform that action at this time.