提交 e20abd58 编写于 作者: K kvn

8171008: Integrate AOT compiler into JDK

Reviewed-by: erikj, mchung, twisti, simonis
上级 2f0f2b13
......@@ -205,7 +205,7 @@ JDKOPT_SETUP_CODE_COVERAGE
# Need toolchain to setup dtrace
HOTSPOT_SETUP_DTRACE
HOTSPOT_SETUP_JVM_FEATURES
HOTSPOT_ENABLE_DISABLE_AOT
HOTSPOT_ENABLE_DISABLE_GTEST
###############################################################################
......@@ -220,6 +220,10 @@ BASIC_COMPILE_FIXPATH
LIB_DETERMINE_DEPENDENCIES
LIB_SETUP_LIBRARIES
# Hotspot setup depends on lib checks (AOT needs libelf).
HOTSPOT_SETUP_JVM_FEATURES
###############################################################################
#
# We need to do some final tweaking, when everything else is done.
......
......@@ -121,6 +121,8 @@ apt_help() {
PKGHANDLER_COMMAND="sudo apt-get install ccache" ;;
dtrace)
PKGHANDLER_COMMAND="sudo apt-get install systemtap-sdt-dev" ;;
elf)
PKGHANDLER_COMMAND="sudo apt-get install libelf-dev" ;;
esac
}
......@@ -140,6 +142,8 @@ yum_help() {
PKGHANDLER_COMMAND="sudo yum install libXtst-devel libXt-devel libXrender-devel libXi-devel" ;;
ccache)
PKGHANDLER_COMMAND="sudo yum install ccache" ;;
elf)
PKGHANDLER_COMMAND="sudo yum install elfutils-libelf-devel" ;;
esac
}
......
......@@ -25,7 +25,7 @@
# All valid JVM features, regardless of platform
VALID_JVM_FEATURES="compiler1 compiler2 zero shark minimal dtrace jvmti jvmci \
graal fprof vm-structs jni-check services management all-gcs nmt cds static-build"
graal fprof vm-structs jni-check services management all-gcs nmt cds static-build aot"
# All valid JVM variants
VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom"
......@@ -189,6 +189,55 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_DTRACE],
AC_SUBST(INCLUDE_DTRACE)
])
################################################################################
# Check if AOT should be enabled
#
AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_AOT],
[
AC_ARG_ENABLE([aot], [AS_HELP_STRING([--enable-aot@<:@=yes/no/auto@:>@],
[enable ahead of time compilation feature. Default is auto, where aot is enabled if all dependencies are present.])])
if test "x$enable_aot" = "x" || test "x$enable_aot" = "xauto"; then
ENABLE_AOT="true"
elif test "x$enable_aot" = "xyes"; then
ENABLE_AOT="true"
elif test "x$enable_aot" = "xno"; then
ENABLE_AOT="false"
AC_MSG_CHECKING([if aot should be enabled])
AC_MSG_RESULT([no, forced])
else
AC_MSG_ERROR([Invalid value for --enable-aot: $enable_aot])
fi
if test "x$ENABLE_AOT" = "xtrue"; then
# Only enable AOT on linux-X64.
if test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-x86_64"; then
if test -e "$HOTSPOT_TOPDIR/src/jdk.aot"; then
if test -e "$HOTSPOT_TOPDIR/src/jdk.vm.compiler"; then
ENABLE_AOT="true"
else
ENABLE_AOT="false"
if test "x$enable_aot" = "xyes"; then
AC_MSG_ERROR([Cannot build AOT without hotspot/src/jdk.vm.compiler sources. Remove --enable-aot.])
fi
fi
else
ENABLE_AOT="false"
if test "x$enable_aot" = "xyes"; then
AC_MSG_ERROR([Cannot build AOT without hotspot/src/jdk.aot sources. Remove --enable-aot.])
fi
fi
else
ENABLE_AOT="false"
if test "x$enable_aot" = "xyes"; then
AC_MSG_ERROR([AOT is currently only supported on Linux-x86_64. Remove --enable-aot.])
fi
fi
fi
AC_SUBST(ENABLE_AOT)
])
###############################################################################
# Set up all JVM features for each JVM variant.
#
......@@ -271,8 +320,8 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
fi
INCLUDE_GRAAL="true"
else
# By default enable graal build on linux-X64 and when JVMCI is available
if test "x$JVM_FEATURES_jvmci" = "xjvmci" && test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-x86_64"; then
# By default enable graal build where AOT is available
if test "x$ENABLE_AOT" = "xtrue"; then
AC_MSG_RESULT([yes])
JVM_FEATURES_graal="graal"
INCLUDE_GRAAL="true"
......@@ -285,11 +334,28 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
AC_SUBST(INCLUDE_GRAAL)
AC_MSG_CHECKING([if aot should be enabled])
if test "x$ENABLE_AOT" = "xtrue"; then
if test "x$enable_aot" = "xyes"; then
AC_MSG_RESULT([yes, forced])
else
AC_MSG_RESULT([yes])
fi
JVM_FEATURES_aot="aot"
else
if test "x$enable_aot" = "xno"; then
AC_MSG_RESULT([no, forced])
else
AC_MSG_RESULT([no])
fi
JVM_FEATURES_aot=""
fi
# All variants but minimal (and custom) get these features
NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt cds"
# Enable features depending on variant.
JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_graal"
JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_aot $JVM_FEATURES_graal"
JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci"
JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES"
JVM_FEATURES_minimal="compiler1 minimal $JVM_FEATURES"
......
#
# Copyright (c) 2015, 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. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# 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.
#
################################################################################
# Setup libelf (ELF library)
################################################################################
AC_DEFUN_ONCE([LIB_SETUP_LIBELF],
[
AC_ARG_WITH(libelf, [AS_HELP_STRING([--with-libelf],
[specify prefix directory for the libelf package
(expecting the libraries under PATH/lib and the headers under PATH/include)])])
AC_ARG_WITH(libelf-include, [AS_HELP_STRING([--with-libelf-include],
[specify directory for the libelf include files])])
AC_ARG_WITH(libelf-lib, [AS_HELP_STRING([--with-libelf-lib],
[specify directory for the libelf library])])
if test "x$ENABLE_AOT" = xfalse; then
if (test "x${with_libelf}" != x && test "x${with_libelf}" != xno) || \
(test "x${with_libelf_include}" != x && test "x${with_libelf_include}" != xno) || \
(test "x${with_libelf_lib}" != x && test "x${with_libelf_lib}" != xno); then
AC_MSG_WARN([[libelf is not used, so --with-libelf[-*] is ignored]])
fi
LIBELF_CFLAGS=
LIBELF_LIBS=
else
LIBELF_FOUND=no
if test "x${with_libelf}" = xno || test "x${with_libelf_include}" = xno || test "x${with_libelf_lib}" = xno; then
ENABLE_AOT="false"
if test "x${enable_aot}" = xyes; then
AC_MSG_ERROR([libelf is explicitly disabled, cannot build AOT. Enable libelf or remove --enable-aot to disable AOT.])
fi
else
if test "x${with_libelf}" != x; then
ELF_LIBS="-L${with_libelf}/lib -lelf"
ELF_CFLAGS="-I${with_libelf}/include"
LIBELF_FOUND=yes
fi
if test "x${with_libelf_include}" != x; then
ELF_CFLAGS="-I${with_libelf_include}"
LIBELF_FOUND=yes
fi
if test "x${with_libelf_lib}" != x; then
ELF_LIBS="-L${with_libelf_lib} -lelf"
LIBELF_FOUND=yes
fi
# Do not try pkg-config if we have a sysroot set.
if test "x$SYSROOT" = x; then
if test "x$LIBELF_FOUND" = xno; then
# Figure out ELF_CFLAGS and ELF_LIBS
PKG_CHECK_MODULES([ELF], [libelf], [LIBELF_FOUND=yes], [LIBELF_FOUND=no])
fi
fi
if test "x$LIBELF_FOUND" = xno; then
AC_CHECK_HEADERS([libelf.h],
[
LIBELF_FOUND=yes
ELF_CFLAGS=
ELF_LIBS=-lelf
],
[LIBELF_FOUND=no]
)
fi
if test "x$LIBELF_FOUND" = xno; then
ENABLE_AOT="false"
HELP_MSG_MISSING_DEPENDENCY([elf])
if test "x${enable_aot}" = xyes; then
AC_MSG_ERROR([libelf not found, cannot build AOT. Remove --enable-aot to disable AOT or: $HELP_MSG])
else
AC_MSG_WARN([libelf not found, cannot build AOT. $HELP_MSG])
fi
else
AC_MSG_CHECKING([if libelf works])
AC_LANG_PUSH(C)
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $ELF_CFLAGS"
OLD_LIBS="$LIBS"
LIBS="$LIBS $ELF_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libelf.h>],
[
elf_version(0);
return 0;
])],
[LIBELF_WORKS=yes],
[LIBELF_WORKS=no]
)
CFLAGS="$OLD_CFLAGS"
LIBS="$OLD_LIBS"
AC_LANG_POP(C)
AC_MSG_RESULT([$LIBELF_WORKS])
if test "x$LIBELF_WORKS" = xno; then
ENABLE_AOT="false"
HELP_MSG_MISSING_DEPENDENCY([elf])
if test "x$enable_aot" = "xyes"; then
AC_MSG_ERROR([Found libelf but could not link and compile with it. Remove --enable-aot to disable AOT or: $HELP_MSG])
else
AC_MSG_WARN([Found libelf but could not link and compile with it. $HELP_MSG])
fi
fi
fi
fi
fi
AC_SUBST(ELF_CFLAGS)
AC_SUBST(ELF_LIBS)
])
......@@ -31,6 +31,7 @@ m4_include([lib-ffi.m4])
m4_include([lib-freetype.m4])
m4_include([lib-std.m4])
m4_include([lib-x11.m4])
m4_include([lib-elf.m4])
################################################################################
# Determine which libraries are needed for this configuration
......@@ -90,6 +91,7 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
LIB_SETUP_BUNDLED_LIBS
LIB_SETUP_MISC_LIBS
LIB_SETUP_SOLARIS_STLPORT
LIB_SETUP_LIBELF
])
################################################################################
......
......@@ -683,6 +683,7 @@ TAR_INCLUDE_PARAM:=@TAR_INCLUDE_PARAM@
TAR_SUPPORTS_TRANSFORM:=@TAR_SUPPORTS_TRANSFORM@
# Build setup
ENABLE_AOT:=@ENABLE_AOT@
ENABLE_JFR=@ENABLE_JFR@
ENABLE_INTREE_EC=@ENABLE_INTREE_EC@
USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@
......@@ -757,6 +758,8 @@ USE_EXTERNAL_LIBPNG:=@USE_EXTERNAL_LIBPNG@
PNG_LIBS:=@PNG_LIBS@
PNG_CFLAGS:=@PNG_CFLAGS@
ELF_CFLAGS:=@ELF_CFLAGS@
ELF_LIBS:=@ELF_LIBS@
####################################################
#
......
......@@ -492,6 +492,10 @@ jdk.vm.compiler_EXCLUDES += \
################################################################################
jdk.aot_ADD_JAVAC_FLAGS := -parameters -XDstringConcat=inline
################################################################################
jdk.xml.bind_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
jdk.xml.bind_CLEAN := .properties
jdk.xml.bind_COPY := .xsd JAXBContextFactory.java ZeroOneBooleanAdapter.java
......@@ -559,6 +563,14 @@ ifeq ($(MODULE), jdk.vm.compiler)
MODULESOURCEPATH := $(call PathList, $(VM_COMPILER_MODULESOURCEPATH))
endif
ifeq ($(MODULE), jdk.aot)
## WORKAROUND jdk.aot source structure issue
AOT_MODULESOURCEPATH := $(MODULESOURCEPATH) \
$(subst /$(MODULE)/,/*/, $(filter-out %processor/src, \
$(wildcard $(HOTSPOT_TOPDIR)/src/$(MODULE)/share/classes/*/src)))
MODULESOURCEPATH := $(call PathList, $(AOT_MODULESOURCEPATH))
endif
$(eval $(call SetupJavaCompilation, $(MODULE), \
SETUP := $(if $($(MODULE)_SETUP), $($(MODULE)_SETUP), GENERATE_JDKBYTECODE), \
MODULE := $(MODULE), \
......
......@@ -145,12 +145,19 @@ ifeq ($(INCLUDE_SA), false)
endif
################################################################################
# Filter out specific modules
# Filter out Graal specific modules if Graal build is disabled
ifeq ($(INCLUDE_GRAAL), false)
MODULES_FILTER += jdk.vm.compiler
endif
################################################################################
# Filter out aot specific modules if aot is disabled
ifeq ($(ENABLE_AOT), false)
MODULES_FILTER += jdk.aot
endif
################################################################################
# Module list macros
......
......@@ -229,7 +229,7 @@ public class WhiteBox {
return isMethodCompiled0(method, isOsr);
}
public boolean isMethodCompilable(Executable method) {
return isMethodCompilable(method, -1 /*any*/);
return isMethodCompilable(method, -2 /*any*/);
}
public boolean isMethodCompilable(Executable method, int compLevel) {
return isMethodCompilable(method, compLevel, false /*not osr*/);
......@@ -277,7 +277,7 @@ public class WhiteBox {
return deoptimizeMethod0(method, isOsr);
}
public void makeMethodNotCompilable(Executable method) {
makeMethodNotCompilable(method, -1 /*any*/);
makeMethodNotCompilable(method, -2 /*any*/);
}
public void makeMethodNotCompilable(Executable method, int compLevel) {
makeMethodNotCompilable(method, compLevel, false /*not osr*/);
......@@ -301,7 +301,7 @@ public class WhiteBox {
return testSetDontInlineMethod0(method, value);
}
public int getCompileQueuesSize() {
return getCompileQueueSize(-1 /*any*/);
return getCompileQueueSize(-2 /*any*/);
}
public native int getCompileQueueSize(int compLevel);
private native boolean testSetForceInlineMethod0(Executable method, boolean value);
......
......@@ -49,8 +49,13 @@ public class CodeBlob {
assert obj.length == 4;
name = (String) obj[0];
size = (Integer) obj[1];
code_blob_type = BlobType.values()[(Integer) obj[2]];
assert code_blob_type.id == (Integer) obj[2];
int blob_type_index = (Integer) obj[2];
if (blob_type_index == -1) { // AOT
code_blob_type = null;
} else {
code_blob_type = BlobType.values()[blob_type_index];
assert code_blob_type.id == (Integer) obj[2];
}
address = (Long) obj[3];
}
public final String name;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册