Merge
This commit is contained in:
commit
2c25f6b054
.hgtags.hgtags-top-repoMakefileREADME-builds.html
common
autoconf
basics.m4bootcycle-spec.gmk.inbuild-performance.m4configureconfigure.acflags.m4generated-configure.shhelp.m4hotspot-spec.gmk.inlibraries.m4spec.gmk.intoolchain.m4toolchain_windows.m4
bin
corba
hotspot
.hgtags
agent/src
os/linux
share/classes/sun/jvm/hotspot
make
src
cpu
ppc/vm
assembler_ppc.hppassembler_ppc.inline.hppinterp_masm_ppc_64.cppmacroAssembler_ppc.hppmacroAssembler_ppc.inline.hppmethodHandles_ppc.cppppc.adstubGenerator_ppc.cpptemplateInterpreter_ppc.cpptemplateTable_ppc_64.cpp
sparc/vm
c1_CodeStubs_sparc.cppc1_LIRAssembler_sparc.cppinterp_masm_sparc.cppinterp_masm_sparc.hppmacroAssembler_sparc.inline.hppnativeInst_sparc.cppnativeInst_sparc.hppsharedRuntime_sparc.cppsparc.adtemplateInterpreter_sparc.cpptemplateTable_sparc.cpp
x86/vm
c1_CodeStubs_x86.cppc1_LIRAssembler_x86.cppframe_x86.cppglobals_x86.hppinterp_masm_x86_32.cppinterp_masm_x86_32.hppinterp_masm_x86_64.cppinterp_masm_x86_64.hppmacroAssembler_x86.cppnativeInst_x86.cppnativeInst_x86.hppsharedRuntime_x86_32.cppsharedRuntime_x86_64.cpptemplateInterpreter_x86_32.cpptemplateInterpreter_x86_64.cpptemplateTable_x86_32.cpptemplateTable_x86_64.cppvm_version_x86.cppx86_32.adx86_64.ad
os
5
.hgtags
5
.hgtags
@ -289,3 +289,8 @@ b409bc51bc23cfd51f2bd04ea919ec83535af9d0 jdk9-b37
|
||||
abbfccd659b91a7bb815d5e36fed635dcdd40f31 jdk9-b44
|
||||
bfc24ae2b900187585079bb11e66e459d1e525fe jdk9-b45
|
||||
722378bc599e38d9a1dd484de30f10dfd7b21438 jdk9-b46
|
||||
8327024a99559982b848e9c2191da9c0bf8838fd jdk9-b47
|
||||
b2f9702efbe95527ea3a991474fda23987ff1c5c jdk9-b48
|
||||
5b8db585a33c3cc48e70e688ceee57dd9271dc5d jdk9-b49
|
||||
1550b2f6b63d1411fa84dc7bbc6f04809aedb43f jdk9-b50
|
||||
6efe265424e3f1ea596408a1f71baf2de316c772 jdk9-b51
|
||||
|
@ -289,3 +289,8 @@ f7c11da0b0481d49cc7a65a453336c108191e821 jdk9-b42
|
||||
8994f5d87b3bb5e8d317d4e8ccb326da1a73684a jdk9-b44
|
||||
3dd628fde2086218d548841022ee8436b6b88185 jdk9-b45
|
||||
12f1e276447bcc81516e85367d53e4f08897049d jdk9-b46
|
||||
b6cca3e6175a69f39e5799b7349ddb0176630291 jdk9-b47
|
||||
0064e246d83f6f9fc245c19b6d05041ecaf4b6d4 jdk9-b48
|
||||
d91ed1951b948210590ce1394bea5515357246ba jdk9-b49
|
||||
d1f37d39ff2421f956a6ddf316cf763807bc3363 jdk9-b50
|
||||
6207b4b8731ca75c51b031c47daa813ab92ef558 jdk9-b51
|
||||
|
103
Makefile
103
Makefile
@ -48,6 +48,17 @@ else
|
||||
endif
|
||||
root_dir:=$(patsubst %/,%,$(dir $(makefile_path)))
|
||||
|
||||
ifeq ($(MAIN_TARGETS), )
|
||||
COMMAND_LINE_VARIABLES:=$(subst =command,,$(filter %=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var))))))
|
||||
MAKE_CONTROL_VARIABLES:=LOG CONF SPEC JOBS TEST IGNORE_OLD_CONFIG
|
||||
UNKNOWN_COMMAND_LINE_VARIABLES:=$(strip $(filter-out $(MAKE_CONTROL_VARIABLES), $(COMMAND_LINE_VARIABLES)))
|
||||
ifneq ($(UNKNOWN_COMMAND_LINE_VARIABLES), )
|
||||
$(info Note: Command line contains non-control variables: $(UNKNOWN_COMMAND_LINE_VARIABLES).)
|
||||
$(info Make sure it is not mistyped, and that you intend to override this variable.)
|
||||
$(info 'make help' will list known control variables)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(findstring qp,$(MAKEFLAGS)),)
|
||||
# When called with -qp, assume an external part (e.g. bash completion) is trying
|
||||
# to understand our targets.
|
||||
@ -148,62 +159,64 @@ endif
|
||||
# Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
|
||||
# If you add more global targets, please update the variable global_targets in MakeHelpers.
|
||||
|
||||
# Helper macro to allow $(info) to properly print strings beginning with spaces.
|
||||
_:=
|
||||
|
||||
help:
|
||||
$(info )
|
||||
$(info OpenJDK Makefile help)
|
||||
$(info =====================)
|
||||
$(info )
|
||||
$(info Common make targets)
|
||||
$(info . make [default] # Compile all modules in langtools, hotspot, jaxp, jaxws,)
|
||||
$(info . # corba and jdk and create a runnable "exploded" image)
|
||||
$(info . make all # Compile everything, all repos, docs and images)
|
||||
$(info . make images # Create complete jdk and jre images)
|
||||
$(info . make <phase> # Compile the specified phase and everything it depends on)
|
||||
$(info . # (gensrc, java, copy, libs, launchers, gendata, rmic))
|
||||
$(info . make *-only # Applies to most targets and disables compling the)
|
||||
$(info . # dependencies for the target. This is faster but may)
|
||||
$(info . # result in incorrect build results!)
|
||||
$(info . make docs # Create all docs)
|
||||
$(info . make docs-javadoc # Create just javadocs, depends on less than full docs)
|
||||
$(info . make profiles # Create complete jre compact profile images)
|
||||
$(info . make bootcycle-images # Build images twice, second time with newly built JDK)
|
||||
$(info . make install # Install the generated images locally)
|
||||
$(info . make reconfigure # Rerun configure with the same arguments as last time)
|
||||
$(info . make help # Give some help on using make)
|
||||
$(info . make test # Run tests, default is all tests (see TEST below))
|
||||
$(info $(_) make [default] # Compile all modules in langtools, hotspot, jdk, jaxws,)
|
||||
$(info $(_) # jaxp and corba, and create a runnable "exploded" image)
|
||||
$(info $(_) make all # Compile everything, all repos, docs and images)
|
||||
$(info $(_) make images # Create complete j2sdk and j2re images)
|
||||
$(info $(_) make <phase> # Build the specified phase and everything it depends on)
|
||||
$(info $(_) # (gensrc, java, copy, libs, launchers, gendata, rmic))
|
||||
$(info $(_) make *-only # Applies to most targets and disables compling the)
|
||||
$(info $(_) # dependencies for the target. This is faster but may)
|
||||
$(info $(_) # result in incorrect build results!)
|
||||
$(info $(_) make docs # Create all docs)
|
||||
$(info $(_) make docs-javadoc # Create just javadocs, depends on less than full docs)
|
||||
$(info $(_) make profiles # Create complete j2re compact profile images)
|
||||
$(info $(_) make bootcycle-images # Build images twice, second time with newly built JDK)
|
||||
$(info $(_) make install # Install the generated images locally)
|
||||
$(info $(_) make reconfigure # Rerun configure with the same arguments as last time)
|
||||
$(info $(_) make help # Give some help on using make)
|
||||
$(info $(_) make test # Run tests, default is all tests (see TEST below))
|
||||
$(info )
|
||||
$(info Targets for cleaning)
|
||||
$(info . make clean # Remove all files generated by make, but not those)
|
||||
$(info . # generated by configure)
|
||||
$(info . make dist-clean # Remove all files, including configuration)
|
||||
$(info . make clean-<outputdir> # Remove the subdir in the output dir with the name)
|
||||
$(info . make clean-<phase> # Remove all build results related to a certain build)
|
||||
$(info . # phase (gensrc, java, libs, launchers))
|
||||
$(info . make clean-<module> # Remove all build results related to a certain module)
|
||||
$(info . make clean-<module>-<phase> # Remove all build results related to a certain)
|
||||
$(info . # module and phase)
|
||||
$(info $(_) make clean # Remove all files generated by make, but not those)
|
||||
$(info $(_) # generated by configure)
|
||||
$(info $(_) make dist-clean # Remove all files, including configuration)
|
||||
$(info $(_) make clean-<outputdir> # Remove the subdir in the output dir with the name)
|
||||
$(info $(_) make clean-<phase> # Remove all build results related to a certain build)
|
||||
$(info $(_) # phase (gensrc, java, libs, launchers))
|
||||
$(info $(_) make clean-<module> # Remove all build results related to a certain module)
|
||||
$(info $(_) make clean-<module>-<phase> # Remove all build results related to a certain)
|
||||
$(info $(_) # module and phase)
|
||||
$(info )
|
||||
$(info Targets for specific modules)
|
||||
$(info . make <module> # Build <module> and everything it depends on. )
|
||||
$(info . make <module>-<phase> # Compile the specified phase for the specified module)
|
||||
$(info . # and everything it depends on)
|
||||
$(info . # (gensrc, java, copy, libs, launchers, gendata, rmic))
|
||||
$(info $(_) make <module> # Build <module> and everything it depends on.)
|
||||
$(info $(_) make <module>-<phase> # Compile the specified phase for the specified module)
|
||||
$(info $(_) # and everything it depends on)
|
||||
$(info $(_) # (gensrc, java, copy, libs, launchers, gendata, rmic))
|
||||
$(info )
|
||||
$(info Useful make variables)
|
||||
$(info . make CONF= # Build all configurations (note, assignment is empty))
|
||||
$(info . make CONF=<substring> # Build the configuration(s) with a name matching)
|
||||
$(info . # <substring>)
|
||||
$(info )
|
||||
$(info . make LOG=<loglevel> # Change the log level from warn to <loglevel>)
|
||||
$(info . # Available log levels are:)
|
||||
$(info . # 'warn' (default), 'info', 'debug' and 'trace')
|
||||
$(info . # To see executed command lines, use LOG=debug)
|
||||
$(info )
|
||||
$(info . make JOBS=<n> # Run <n> parallel make jobs)
|
||||
$(info . # Note that -jN does not work as expected!)
|
||||
$(info )
|
||||
$(info . make test TEST=<test> # Only run the given test or tests, e.g.)
|
||||
$(info . # make test TEST="jdk_lang jdk_net")
|
||||
$(info Make control variables)
|
||||
$(info $(_) CONF= # Build all configurations (note, assignment is empty))
|
||||
$(info $(_) CONF=<substring> # Build the configuration(s) with a name matching)
|
||||
$(info $(_) # <substring>)
|
||||
$(info $(_) SPEC=<spec file> # Build the configuration given by the spec file)
|
||||
$(info $(_) LOG=<loglevel> # Change the log level from warn to <loglevel>)
|
||||
$(info $(_) # Available log levels are:)
|
||||
$(info $(_) # 'warn' (default), 'info', 'debug' and 'trace')
|
||||
$(info $(_) # To see executed command lines, use LOG=debug)
|
||||
$(info $(_) JOBS=<n> # Run <n> parallel make jobs)
|
||||
$(info $(_) # Note that -jN does not work as expected!)
|
||||
$(info $(_) IGNORE_OLD_CONFIG=true # Skip tests if spec file is up to date)
|
||||
$(info $(_) make test TEST=<test> # Only run the given test or tests, e.g.)
|
||||
$(info $(_) # make test TEST="jdk_lang jdk_net")
|
||||
$(info )
|
||||
|
||||
.PHONY: help
|
||||
|
@ -1463,14 +1463,13 @@
|
||||
|
||||
<h4>Building with ccache</h4>
|
||||
|
||||
<p>A simple way to radically speed up compilation of native code
|
||||
(typically hotspot and native libraries in JDK) is to install
|
||||
ccache. This will cache and reuse prior compilation results, if the
|
||||
source code is unchanged. However, ccache versions prior to 3.1.4
|
||||
does not work correctly with the precompiled headers used in
|
||||
OpenJDK. So if your platform supports ccache at 3.1.4 or later, we
|
||||
highly recommend installing it. This is currently only supported on
|
||||
linux.</p>
|
||||
<p>The OpenJDK build supports building with ccache
|
||||
when using gcc or clang. Using ccache can
|
||||
radically speed up compilation of native code if
|
||||
you often rebuild the same sources. Your milage
|
||||
may vary however so we recommend evaluating it for
|
||||
yourself. To enable it, make sure it's on the path
|
||||
and configure with <code>--enable-ccache</code>.</p>
|
||||
|
||||
<h4>Building on local disk</h4>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
@ -77,26 +77,30 @@ AC_DEFUN([BASIC_PREPEND_TO_PATH],
|
||||
# $1: The name of the variable to fix
|
||||
AC_DEFUN([BASIC_FIXUP_PATH],
|
||||
[
|
||||
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
|
||||
BASIC_FIXUP_PATH_CYGWIN($1)
|
||||
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
|
||||
BASIC_FIXUP_PATH_MSYS($1)
|
||||
else
|
||||
# We're on a unix platform. Hooray! :)
|
||||
path="[$]$1"
|
||||
has_space=`$ECHO "$path" | $GREP " "`
|
||||
if test "x$has_space" != x; then
|
||||
AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
|
||||
AC_MSG_ERROR([Spaces are not allowed in this path.])
|
||||
fi
|
||||
# Only process if variable expands to non-empty
|
||||
|
||||
if test "x[$]$1" != x; then
|
||||
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
|
||||
BASIC_FIXUP_PATH_CYGWIN($1)
|
||||
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
|
||||
BASIC_FIXUP_PATH_MSYS($1)
|
||||
else
|
||||
# We're on a unix platform. Hooray! :)
|
||||
path="[$]$1"
|
||||
has_space=`$ECHO "$path" | $GREP " "`
|
||||
if test "x$has_space" != x; then
|
||||
AC_MSG_NOTICE([The path of $1, which resolves as "$path", is invalid.])
|
||||
AC_MSG_ERROR([Spaces are not allowed in this path.])
|
||||
fi
|
||||
|
||||
# Use eval to expand a potential ~
|
||||
eval path="$path"
|
||||
if test ! -f "$path" && test ! -d "$path"; then
|
||||
AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
|
||||
fi
|
||||
# Use eval to expand a potential ~
|
||||
eval path="$path"
|
||||
if test ! -f "$path" && test ! -d "$path"; then
|
||||
AC_MSG_ERROR([The path of $1, which resolves as "$path", is not found.])
|
||||
fi
|
||||
|
||||
$1="`cd "$path"; $THEPWDCMD -L`"
|
||||
$1="`cd "$path"; $THEPWDCMD -L`"
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
@ -113,57 +117,61 @@ AC_DEFUN([BASIC_FIXUP_PATH],
|
||||
# $1: The name of the variable to fix
|
||||
AC_DEFUN([BASIC_FIXUP_EXECUTABLE],
|
||||
[
|
||||
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
|
||||
BASIC_FIXUP_EXECUTABLE_CYGWIN($1)
|
||||
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
|
||||
BASIC_FIXUP_EXECUTABLE_MSYS($1)
|
||||
else
|
||||
# We're on a unix platform. Hooray! :)
|
||||
# First separate the path from the arguments. This will split at the first
|
||||
# space.
|
||||
complete="[$]$1"
|
||||
path="${complete%% *}"
|
||||
tmp="$complete EOL"
|
||||
arguments="${tmp#* }"
|
||||
|
||||
# Cannot rely on the command "which" here since it doesn't always work.
|
||||
is_absolute_path=`$ECHO "$path" | $GREP ^/`
|
||||
if test -z "$is_absolute_path"; then
|
||||
# Path to executable is not absolute. Find it.
|
||||
IFS_save="$IFS"
|
||||
IFS=:
|
||||
for p in $PATH; do
|
||||
if test -f "$p/$path" && test -x "$p/$path"; then
|
||||
new_path="$p/$path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$IFS_save"
|
||||
# Only process if variable expands to non-empty
|
||||
|
||||
if test "x[$]$1" != x; then
|
||||
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
|
||||
BASIC_FIXUP_EXECUTABLE_CYGWIN($1)
|
||||
elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
|
||||
BASIC_FIXUP_EXECUTABLE_MSYS($1)
|
||||
else
|
||||
# This is an absolute path, we can use it without further modifications.
|
||||
new_path="$path"
|
||||
fi
|
||||
# We're on a unix platform. Hooray! :)
|
||||
# First separate the path from the arguments. This will split at the first
|
||||
# space.
|
||||
complete="[$]$1"
|
||||
path="${complete%% *}"
|
||||
tmp="$complete EOL"
|
||||
arguments="${tmp#* }"
|
||||
|
||||
if test "x$new_path" = x; then
|
||||
AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
|
||||
has_space=`$ECHO "$complete" | $GREP " "`
|
||||
if test "x$has_space" != x; then
|
||||
AC_MSG_NOTICE([This might be caused by spaces in the path, which is not allowed.])
|
||||
# Cannot rely on the command "which" here since it doesn't always work.
|
||||
is_absolute_path=`$ECHO "$path" | $GREP ^/`
|
||||
if test -z "$is_absolute_path"; then
|
||||
# Path to executable is not absolute. Find it.
|
||||
IFS_save="$IFS"
|
||||
IFS=:
|
||||
for p in $PATH; do
|
||||
if test -f "$p/$path" && test -x "$p/$path"; then
|
||||
new_path="$p/$path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$IFS_save"
|
||||
else
|
||||
# This is an absolute path, we can use it without further modifications.
|
||||
new_path="$path"
|
||||
fi
|
||||
|
||||
if test "x$new_path" = x; then
|
||||
AC_MSG_NOTICE([The path of $1, which resolves as "$complete", is not found.])
|
||||
has_space=`$ECHO "$complete" | $GREP " "`
|
||||
if test "x$has_space" != x; then
|
||||
AC_MSG_NOTICE([This might be caused by spaces in the path, which is not allowed.])
|
||||
fi
|
||||
AC_MSG_ERROR([Cannot locate the the path of $1])
|
||||
fi
|
||||
AC_MSG_ERROR([Cannot locate the the path of $1])
|
||||
fi
|
||||
fi
|
||||
|
||||
# Now join together the path and the arguments once again
|
||||
if test "x$arguments" != xEOL; then
|
||||
new_complete="$new_path ${arguments% *}"
|
||||
else
|
||||
new_complete="$new_path"
|
||||
fi
|
||||
# Now join together the path and the arguments once again
|
||||
if test "x$arguments" != xEOL; then
|
||||
new_complete="$new_path ${arguments% *}"
|
||||
else
|
||||
new_complete="$new_path"
|
||||
fi
|
||||
|
||||
if test "x$complete" != "x$new_complete"; then
|
||||
$1="$new_complete"
|
||||
AC_MSG_NOTICE([Rewriting $1 to "$new_complete"])
|
||||
if test "x$complete" != "x$new_complete"; then
|
||||
$1="$new_complete"
|
||||
AC_MSG_NOTICE([Rewriting $1 to "$new_complete"])
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
@ -242,6 +250,9 @@ AC_DEFUN_ONCE([BASIC_INIT],
|
||||
[
|
||||
# Save the original command line. This is passed to us by the wrapper configure script.
|
||||
AC_SUBST(CONFIGURE_COMMAND_LINE)
|
||||
# Save the path variable before it gets changed
|
||||
ORIGINAL_PATH="$PATH"
|
||||
AC_SUBST(ORIGINAL_PATH)
|
||||
DATE_WHEN_CONFIGURED=`LANG=C date`
|
||||
AC_SUBST(DATE_WHEN_CONFIGURED)
|
||||
AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.])
|
||||
@ -896,10 +907,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
|
||||
fi
|
||||
AC_SUBST(IS_GNU_TIME)
|
||||
|
||||
if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
|
||||
BASIC_REQUIRE_PROGS(COMM, comm)
|
||||
fi
|
||||
|
||||
if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
|
||||
BASIC_REQUIRE_PROGS(DSYMUTIL, dsymutil)
|
||||
BASIC_REQUIRE_PROGS(XATTR, xattr)
|
||||
@ -987,3 +994,26 @@ AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],
|
||||
IS_RECONFIGURE=no
|
||||
fi
|
||||
])
|
||||
|
||||
# Check for support for specific options in bash
|
||||
AC_DEFUN_ONCE([BASIC_CHECK_BASH_OPTIONS],
|
||||
[
|
||||
# Test if bash supports pipefail.
|
||||
AC_MSG_CHECKING([if bash supports pipefail])
|
||||
if ${BASH} -c 'set -o pipefail'; then
|
||||
BASH_ARGS="$BASH_ARGS -o pipefail"
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if bash supports errexit (-e)])
|
||||
if ${BASH} -e -c 'true'; then
|
||||
BASH_ARGS="$BASH_ARGS -e"
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
AC_SUBST(BASH_ARGS)
|
||||
])
|
||||
|
@ -46,8 +46,12 @@ endif
|
||||
BOOT_JDK := $(JDK_IMAGE_DIR)
|
||||
|
||||
# The bootcycle build has a different output directory
|
||||
BUILD_OUTPUT:=@BUILD_OUTPUT@/bootcycle-build
|
||||
SJAVAC_SERVER_DIR:=$(subst @BUILD_OUTPUT@,$(BUILD_OUTPUT),$(SJAVAC_SERVER_DIR))
|
||||
OLD_BUILD_OUTPUT:=@BUILD_OUTPUT@
|
||||
BUILD_OUTPUT:=$(OLD_BUILD_OUTPUT)/bootcycle-build
|
||||
# The HOTSPOT_DIST dir is not defined relative to BUILD_OUTPUT in spec.gmk. Must not
|
||||
# use space in this patsubst to avoid leading space in HOTSPOT_DIST.
|
||||
HOTSPOT_DIST:=$(patsubst $(OLD_BUILD_OUTPUT)%,$(BUILD_OUTPUT)%,$(HOTSPOT_DIST))
|
||||
SJAVAC_SERVER_DIR:=$(patsubst $(OLD_BUILD_OUTPUT)%, $(BUILD_OUTPUT)%, $(SJAVAC_SERVER_DIR))
|
||||
|
||||
JAVA_CMD:=$(BOOT_JDK)/bin/java
|
||||
JAVAC_CMD:=$(BOOT_JDK)/bin/javac
|
||||
|
@ -164,19 +164,26 @@ AC_DEFUN([BPERF_SETUP_CCACHE],
|
||||
[enable using ccache to speed up recompilations @<:@disabled@:>@])])
|
||||
|
||||
CCACHE=
|
||||
CCACHE_STATUS=
|
||||
AC_MSG_CHECKING([is ccache enabled])
|
||||
ENABLE_CCACHE=$enable_ccache
|
||||
if test "x$enable_ccache" = xyes; then
|
||||
AC_MSG_RESULT([yes])
|
||||
OLD_PATH="$PATH"
|
||||
if test "x$TOOLCHAIN_PATH" != x; then
|
||||
PATH=$TOOLCHAIN_PATH:$PATH
|
||||
if test "x$TOOLCHAIN_TYPE" = "xgcc" -o "x$TOOLCHAIN_TYPE" = "xclang"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
OLD_PATH="$PATH"
|
||||
if test "x$TOOLCHAIN_PATH" != x; then
|
||||
PATH=$TOOLCHAIN_PATH:$PATH
|
||||
fi
|
||||
BASIC_REQUIRE_PROGS(CCACHE, ccache)
|
||||
PATH="$OLD_PATH"
|
||||
CCACHE_VERSION=[`$CCACHE --version | head -n1 | $SED 's/[A-Za-z ]*//'`]
|
||||
CCACHE_STATUS="Active ($CCACHE_VERSION)"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_WARN([ccache is not supported with toolchain type $TOOLCHAIN_TYPE])
|
||||
fi
|
||||
BASIC_REQUIRE_PROGS(CCACHE, ccache)
|
||||
CCACHE_STATUS="enabled"
|
||||
PATH="$OLD_PATH"
|
||||
elif test "x$enable_ccache" = xno; then
|
||||
AC_MSG_RESULT([no, explicitly disabled])
|
||||
CCACHE_STATUS="Disabled"
|
||||
elif test "x$enable_ccache" = x; then
|
||||
AC_MSG_RESULT([no])
|
||||
else
|
||||
@ -206,35 +213,31 @@ AC_DEFUN([BPERF_SETUP_CCACHE],
|
||||
AC_DEFUN([BPERF_SETUP_CCACHE_USAGE],
|
||||
[
|
||||
if test "x$CCACHE" != x; then
|
||||
# Only use ccache if it is 3.1.4 or later, which supports
|
||||
# precompiled headers.
|
||||
AC_MSG_CHECKING([if ccache supports precompiled headers])
|
||||
HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null`
|
||||
if test "x$HAS_GOOD_CCACHE" = x; then
|
||||
AC_MSG_RESULT([no, disabling ccache])
|
||||
CCACHE=
|
||||
CCACHE_STATUS="disabled"
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
if test "x$USE_PRECOMPILED_HEADER" = "x1"; then
|
||||
HAS_BAD_CCACHE=[`$ECHO $CCACHE_VERSION | \
|
||||
$GREP -e '^1.*' -e '^2.*' -e '^3\.0.*' -e '^3\.1\.[0123]'`]
|
||||
if test "x$HAS_BAD_CCACHE" != "x"; then
|
||||
AC_MSG_ERROR([Precompiled headers requires ccache 3.1.4 or later, found $CCACHE_VERSION])
|
||||
fi
|
||||
AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers])
|
||||
CCACHE_PRECOMP_FLAG="-fpch-preprocess"
|
||||
PUSHED_FLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="-fpch-preprocess $CXXFLAGS"
|
||||
CXXFLAGS="$CCACHE_PRECOMP_FLAG $CXXFLAGS"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no])
|
||||
CXXFLAGS="$PUSHED_FLAGS"
|
||||
if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS_CCACHE="$CCACHE_PRECOMP_FLAG"
|
||||
AC_SUBST(CFLAGS_CCACHE)
|
||||
CCACHE_SLOPPINESS=pch_defines,time_macros
|
||||
else
|
||||
AC_MSG_RESULT([no, disabling ccaching of precompiled headers])
|
||||
CCACHE=
|
||||
CCACHE_STATUS="disabled"
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([Cannot use ccache with precompiled headers without compiler support for $CCACHE_PRECOMP_FLAG])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$CCACHE" != x; then
|
||||
CCACHE_SLOPPINESS=time_macros
|
||||
CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE"
|
||||
CCACHE_FLAGS=-fpch-preprocess
|
||||
CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR \
|
||||
CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS CCACHE_BASEDIR=$TOPDIR $CCACHE"
|
||||
|
||||
if test "x$SET_CCACHE_DIR" != x; then
|
||||
mkdir -p $CCACHE_DIR > /dev/null 2>&1
|
||||
|
3
common/autoconf/configure
vendored
3
common/autoconf/configure
vendored
@ -40,8 +40,9 @@ if test "x$BASH" = x; then
|
||||
echo "Error: This script must be run using bash." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
# Force autoconf to use bash
|
||||
# Force autoconf to use bash. This also means we must disable autoconf re-exec.
|
||||
export CONFIG_SHELL=$BASH
|
||||
export _as_can_reexec=no
|
||||
|
||||
conf_script_dir="$TOPDIR/common/autoconf"
|
||||
|
||||
|
@ -113,6 +113,7 @@ HELP_SETUP_DEPENDENCY_HELP
|
||||
|
||||
# Setup tools that requires more complex handling, or that is not needed by the configure script.
|
||||
BASIC_SETUP_COMPLEX_TOOLS
|
||||
BASIC_CHECK_BASH_OPTIONS
|
||||
|
||||
# Check if pkg-config is available.
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
@ -558,15 +558,23 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
|
||||
CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
|
||||
CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
|
||||
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
|
||||
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
|
||||
-D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
|
||||
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
|
||||
-DWIN32 -DIAL"
|
||||
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK \
|
||||
-Zi -MD -Zc:wchar_t- -W3 -wd4800 \
|
||||
-DWIN32_LEAN_AND_MEAN \
|
||||
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
|
||||
-DWIN32 -DIAL"
|
||||
if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
|
||||
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
|
||||
else
|
||||
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
|
||||
fi
|
||||
# If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
|
||||
# avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
|
||||
# studio.
|
||||
if test "x$TOOLCHAIN_VERSION" = "x2010"; then
|
||||
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
|
||||
-D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
|
||||
fi
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -209,7 +209,10 @@ AC_DEFUN_ONCE([HELP_PRINT_SUMMARY_AND_WARNINGS],
|
||||
printf "* Environment: $WINDOWS_ENV_VENDOR version $WINDOWS_ENV_VERSION (root at $WINDOWS_ENV_ROOT_PATH)\n"
|
||||
fi
|
||||
printf "* Boot JDK: $BOOT_JDK_VERSION (at $BOOT_JDK)\n"
|
||||
printf "* Toolchain: $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)\n"
|
||||
if test "x$TOOLCHAIN_VERSION" != "x"; then
|
||||
print_version=" $TOOLCHAIN_VERSION"
|
||||
fi
|
||||
printf "* Toolchain: $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION$print_version)\n"
|
||||
printf "* C Compiler: Version $CC_VERSION_NUMBER (at $CC)\n"
|
||||
printf "* C++ Compiler: Version $CXX_VERSION_NUMBER (at $CXX)\n"
|
||||
|
||||
|
@ -109,8 +109,8 @@ LD:=@HOTSPOT_LD@
|
||||
MT:=@HOTSPOT_MT@
|
||||
RC:=@HOTSPOT_RC@
|
||||
|
||||
EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@
|
||||
EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@
|
||||
EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ $(CFLAGS_CCACHE)
|
||||
EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@ $(CFLAGS_CCACHE)
|
||||
EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@
|
||||
|
||||
USE_PRECOMPILED_HEADER=@USE_PRECOMPILED_HEADER@
|
||||
@ -132,6 +132,13 @@ else
|
||||
ZIP_DEBUGINFO_FILES:=0
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
# On Windows, the Visual Studio toolchain needs the LIB and INCLUDE
|
||||
# environment variables (in Windows path style).
|
||||
export INCLUDE:=@VS_INCLUDE@
|
||||
export LIB:=@VS_LIB@
|
||||
endif
|
||||
|
||||
# Sneak this in via the spec.gmk file, since we don't want to mess around too much with the Hotspot make files.
|
||||
# This is needed to get the LOG setting to work properly.
|
||||
include $(SRC_ROOT)/make/common/MakeBase.gmk
|
||||
|
@ -1124,10 +1124,9 @@ AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
|
||||
AC_DEFUN_ONCE([LIB_SETUP_ON_WINDOWS],
|
||||
[
|
||||
if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
|
||||
TOOLCHAIN_SETUP_MSVCR_DLL
|
||||
TOOLCHAIN_SETUP_VS_RUNTIME_DLLS
|
||||
BASIC_DEPRECATED_ARG_WITH([dxsdk])
|
||||
BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
|
||||
BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
|
||||
fi
|
||||
AC_SUBST(MSVCR_DLL)
|
||||
])
|
||||
|
@ -78,6 +78,11 @@ endif
|
||||
OUTPUT_SYNC_SUPPORTED:=@OUTPUT_SYNC_SUPPORTED@
|
||||
OUTPUT_SYNC:=@OUTPUT_SYNC@
|
||||
|
||||
# Override the shell with bash
|
||||
BASH:=@BASH@
|
||||
BASH_ARGS:=@BASH_ARGS@
|
||||
SHELL:=$(BASH) $(BASH_ARGS)
|
||||
|
||||
# The "human readable" name of this configuration
|
||||
CONF_NAME:=@CONF_NAME@
|
||||
|
||||
@ -124,14 +129,12 @@ LIBDL:=@LIBDL@
|
||||
# colon or semicolon
|
||||
PATH_SEP:=@PATH_SEP@
|
||||
|
||||
# Save the original path before replacing it with the Visual Studio tools
|
||||
ORIGINAL_PATH:=@ORIGINAL_PATH@
|
||||
ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
# On Windows, the Visual Studio toolchain needs the LIB and INCLUDE
|
||||
# environment variables (in Windows path style), and the PATH needs to
|
||||
# be adjusted to include Visual Studio tools (but this needs to be in
|
||||
# cygwin/msys style).
|
||||
# On Windows, the Visual Studio toolchain needs the PATH to be adjusted
|
||||
# to include Visual Studio tools (this needs to be in cygwin/msys style).
|
||||
export PATH:=@VS_PATH@
|
||||
export INCLUDE:=@VS_INCLUDE@
|
||||
export LIB:=@VS_LIB@
|
||||
endif
|
||||
|
||||
SYSROOT_CFLAGS := @SYSROOT_CFLAGS@
|
||||
@ -243,7 +246,7 @@ MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/makesupport
|
||||
HOTSPOT_OUTPUTDIR=$(BUILD_OUTPUT)/hotspot
|
||||
JDK_OUTPUTDIR=$(BUILD_OUTPUT)/jdk
|
||||
IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images
|
||||
TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/testmake
|
||||
TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/test-make
|
||||
MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support
|
||||
|
||||
HOTSPOT_DIST=@HOTSPOT_DIST@
|
||||
@ -323,6 +326,8 @@ CXX_FLAG_DEPS:=@CXX_FLAG_DEPS@
|
||||
|
||||
CFLAGS_WARNINGS_ARE_ERRORS:=@CFLAGS_WARNINGS_ARE_ERRORS@
|
||||
|
||||
CFLAGS_CCACHE:=@CFLAGS_CCACHE@
|
||||
|
||||
# Tools that potentially need to be cross compilation aware.
|
||||
CC:=@FIXPATH@ @CCACHE@ @CC@
|
||||
|
||||
@ -495,7 +500,6 @@ endif
|
||||
# Tools adhering to a minimal and common standard of posix compliance.
|
||||
AWK:=@AWK@
|
||||
BASENAME:=@BASENAME@
|
||||
BASH:=@BASH@
|
||||
CAT:=@CAT@
|
||||
CCACHE:=@CCACHE@
|
||||
# CD is going away, but remains to cater for legacy makefiles.
|
||||
@ -579,6 +583,7 @@ USE_EXTERNAL_LIBGIF:=@USE_EXTERNAL_LIBGIF@
|
||||
USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@
|
||||
LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@
|
||||
MSVCR_DLL:=@MSVCR_DLL@
|
||||
MSVCP_DLL:=@MSVCP_DLL@
|
||||
|
||||
|
||||
# ADD_SRCS takes a single argument with source roots
|
||||
|
@ -691,8 +691,8 @@ AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
|
||||
CC_VERSION_OUTPUT=`$CC 2>&1 | $HEAD -n 1 | $TR -d '\r'`
|
||||
COMPILER_CPU_TEST=`$ECHO $CC_VERSION_OUTPUT | $SED -n "s/^.* \(.*\)$/\1/p"`
|
||||
if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
|
||||
if test "x$COMPILER_CPU_TEST" != "x80x86"; then
|
||||
AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86".])
|
||||
if test "x$COMPILER_CPU_TEST" != "x80x86" -a "x$COMPILER_CPU_TEST" != "xx86"; then
|
||||
AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86" or "x86".])
|
||||
fi
|
||||
elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
|
||||
if test "x$COMPILER_CPU_TEST" != "xx64"; then
|
||||
|
@ -23,43 +23,90 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
|
||||
VALID_VS_VERSIONS="2010 2012 2013"
|
||||
|
||||
VS_DESCRIPTION_2010="Microsoft Visual Studio 2010"
|
||||
VS_VERSION_INTERNAL_2010=100
|
||||
VS_MSVCR_2010=msvcr100.dll
|
||||
# We don't use msvcp on Visual Studio 2010
|
||||
#VS_MSVCP_2010=msvcp100.dll
|
||||
VS_ENVVAR_2010="VS100COMNTOOLS"
|
||||
VS_VS_INSTALLDIR_2010="Microsoft Visual Studio 10.0"
|
||||
VS_SDK_INSTALLDIR_2010="Microsoft SDKs/Windows/v7.1"
|
||||
VS_VS_PLATFORM_NAME_2010="v100"
|
||||
VS_SDK_PLATFORM_NAME_2010="Windows7.1SDK"
|
||||
|
||||
VS_DESCRIPTION_2012="Microsoft Visual Studio 2012"
|
||||
VS_VERSION_INTERNAL_2012=110
|
||||
VS_MSVCR_2012=msvcr110.dll
|
||||
VS_MSVCP_2012=msvcp110.dll
|
||||
VS_ENVVAR_2012="VS110COMNTOOLS"
|
||||
VS_VS_INSTALLDIR_2012="Microsoft Visual Studio 11.0"
|
||||
VS_SDK_INSTALLDIR_2012=
|
||||
VS_VS_PLATFORM_NAME_2012="v110"
|
||||
VS_SDK_PLATFORM_NAME_2012=
|
||||
|
||||
VS_DESCRIPTION_2013="Microsoft Visual Studio 2013"
|
||||
VS_VERSION_INTERNAL_2013=120
|
||||
VS_MSVCR_2013=msvcr120.dll
|
||||
VS_MSVCP_2013=msvcp120.dll
|
||||
VS_ENVVAR_2013="VS120COMNTOOLS"
|
||||
VS_VS_INSTALLDIR_2013="Microsoft Visual Studio 12.0"
|
||||
VS_SDK_INSTALLDIR_2013=
|
||||
VS_VS_PLATFORM_NAME_2013="v120"
|
||||
VS_SDK_PLATFORM_NAME_2013=
|
||||
|
||||
################################################################################
|
||||
|
||||
AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT],
|
||||
[
|
||||
if test "x$VS_ENV_CMD" = x; then
|
||||
VS100BASE="$1"
|
||||
METHOD="$2"
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS100BASE)
|
||||
if test -d "$VS100BASE"; then
|
||||
if test -f "$VS100BASE/$VCVARSFILE"; then
|
||||
AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
|
||||
VS_ENV_CMD="$VS100BASE/$VCVARSFILE"
|
||||
VS_VERSION="$1"
|
||||
VS_BASE="$2"
|
||||
METHOD="$3"
|
||||
|
||||
if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
|
||||
VCVARSFILE="vc/bin/vcvars32.bat"
|
||||
else
|
||||
VCVARSFILE="vc/bin/amd64/vcvars64.bat"
|
||||
fi
|
||||
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS_BASE)
|
||||
if test -d "$VS_BASE"; then
|
||||
if test -f "$VS_BASE/$VCVARSFILE"; then
|
||||
AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
|
||||
VS_ENV_CMD="$VS_BASE/$VCVARSFILE"
|
||||
# PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
|
||||
# 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013
|
||||
# TODO: improve detection for other versions of VS
|
||||
PLATFORM_TOOLSET="v100"
|
||||
eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}"
|
||||
else
|
||||
AC_MSG_NOTICE([Found Visual Studio installation at $VS100BASE using $METHOD])
|
||||
AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD])
|
||||
AC_MSG_NOTICE([Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
################################################################################
|
||||
|
||||
AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
|
||||
[
|
||||
if test "x$VS_ENV_CMD" = x; then
|
||||
WIN_SDK_BASE="$1"
|
||||
METHOD="$2"
|
||||
VS_VERSION="$1"
|
||||
WIN_SDK_BASE="$2"
|
||||
METHOD="$3"
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(WIN_SDK_BASE)
|
||||
if test -d "$WIN_SDK_BASE"; then
|
||||
# There have been cases of partial or broken SDK installations. A missing
|
||||
# lib dir is not going to work.
|
||||
if test ! -d "$WIN_SDK_BASE/../lib"; then
|
||||
if test ! -d "$WIN_SDK_BASE/lib"; then
|
||||
AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
|
||||
AC_MSG_NOTICE([Warning: Installation is broken, lib dir is missing. Ignoring])
|
||||
elif test -f "$WIN_SDK_BASE/SetEnv.Cmd"; then
|
||||
elif test -f "$WIN_SDK_BASE/Bin/SetEnv.Cmd"; then
|
||||
AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
|
||||
VS_ENV_CMD="$WIN_SDK_BASE/SetEnv.Cmd"
|
||||
VS_ENV_CMD="$WIN_SDK_BASE/Bin/SetEnv.Cmd"
|
||||
if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
|
||||
VS_ENV_ARGS="/x86"
|
||||
else
|
||||
@ -68,7 +115,7 @@ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
|
||||
# PLATFORM_TOOLSET is used during the compilation of the freetype sources (see
|
||||
# 'LIB_BUILD_FREETYPE' in libraries.m4) and must be 'Windows7.1SDK' for Windows7.1SDK
|
||||
# TODO: improve detection for other versions of SDK
|
||||
PLATFORM_TOOLSET="Windows7.1SDK"
|
||||
eval PLATFORM_TOOLSET="\${VS_SDK_PLATFORM_NAME_${VS_VERSION}}"
|
||||
else
|
||||
AC_MSG_NOTICE([Found Windows SDK installation at $WIN_SDK_BASE using $METHOD])
|
||||
AC_MSG_NOTICE([Warning: Installation is broken, SetEnv.Cmd is missing. Ignoring])
|
||||
@ -77,50 +124,121 @@ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT],
|
||||
fi
|
||||
])
|
||||
|
||||
################################################################################
|
||||
# Finds the bat or cmd file in Visual Studio or the SDK that sets up a proper
|
||||
# build environment and assigns it to VS_ENV_CMD
|
||||
AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE],
|
||||
[
|
||||
if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
|
||||
VCVARSFILE="vc/bin/vcvars32.bat"
|
||||
else
|
||||
VCVARSFILE="vc/bin/amd64/vcvars64.bat"
|
||||
VS_VERSION="$1"
|
||||
eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}"
|
||||
eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}"
|
||||
eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}"
|
||||
eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}"
|
||||
|
||||
# When using --with-tools-dir, assume it points to the correct and default
|
||||
# version of Visual Studio or that --with-toolchain-version was also set.
|
||||
if test "x$with_tools_dir" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
|
||||
[$with_tools_dir/../..], [--with-tools-dir])
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
|
||||
[$with_tools_dir/../../..], [--with-tools-dir])
|
||||
if test "x$VS_ENV_CMD" = x; then
|
||||
# Having specified an argument which is incorrect will produce an instant failure;
|
||||
# we should not go on looking
|
||||
AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid])
|
||||
AC_MSG_NOTICE([Visual Studio installation. Please point to the VC/bin or VC/bin/amd64])
|
||||
AC_MSG_NOTICE([directory within the Visual Studio installation])
|
||||
AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
|
||||
fi
|
||||
fi
|
||||
|
||||
VS_ENV_CMD=""
|
||||
VS_ENV_ARGS=""
|
||||
if test "x$with_toolsdir" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$with_toolsdir/../..], [--with-tools-dir])
|
||||
fi
|
||||
|
||||
if test "x$with_toolsdir" != x && test "x$VS_ENV_CMD" = x; then
|
||||
# Having specified an argument which is incorrect will produce an instant failure;
|
||||
# we should not go on looking
|
||||
AC_MSG_NOTICE([The path given by --with-tools-dir does not contain a valid Visual Studio installation])
|
||||
AC_MSG_NOTICE([Please point to the VC/bin directory within the Visual Studio installation])
|
||||
AC_MSG_ERROR([Cannot locate a valid Visual Studio installation])
|
||||
fi
|
||||
|
||||
if test "x$VS100COMNTOOLS" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$VS100COMNTOOLS/../..], [VS100COMNTOOLS variable])
|
||||
if test "x$VS_COMNTOOLS" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
|
||||
[$VS_COMNTOOLS/../..], [$VS_COMNTOOLS_VAR variable])
|
||||
fi
|
||||
if test "x$PROGRAMFILES" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([$PROGRAMFILES/Microsoft Visual Studio 10.0], [well-known name])
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
|
||||
[$PROGRAMFILES/$VS_INSTALL_DIR], [well-known name])
|
||||
fi
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files/Microsoft Visual Studio 10.0], [well-known name])
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([C:/Program Files (x86)/Microsoft Visual Studio 10.0], [well-known name])
|
||||
# Work around the insanely named ProgramFiles(x86) env variable
|
||||
PROGRAMFILES_X86="`env | $SED -n 's/^ProgramFiles(x86)=//p'`"
|
||||
if test "x$PROGRAMFILES_X86" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
|
||||
[$PROGRAMFILES_X86/$VS_INSTALL_DIR], [well-known name])
|
||||
fi
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
|
||||
[C:/Program Files/$VS_INSTALL_DIR], [well-known name])
|
||||
TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}],
|
||||
[C:/Program Files (x86)/$VS_INSTALL_DIR], [well-known name])
|
||||
|
||||
if test "x$ProgramW6432" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$ProgramW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
|
||||
if test "x$SDK_INSTALL_DIR" != x; then
|
||||
if test "x$ProgramW6432" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
|
||||
[$ProgramW6432/$SDK_INSTALL_DIR], [well-known name])
|
||||
fi
|
||||
if test "x$PROGRAMW6432" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
|
||||
[$PROGRAMW6432/$SDK_INSTALL_DIR], [well-known name])
|
||||
fi
|
||||
if test "x$PROGRAMFILES" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
|
||||
[$PROGRAMFILES/$SDK_INSTALL_DIR], [well-known name])
|
||||
fi
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
|
||||
[C:/Program Files/$SDK_INSTALL_DIR], [well-known name])
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([${VS_VERSION}],
|
||||
[C:/Program Files (x86)/$SDK_INSTALL_DIR], [well-known name])
|
||||
fi
|
||||
if test "x$PROGRAMW6432" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMW6432/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
|
||||
fi
|
||||
if test "x$PROGRAMFILES" != x; then
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([$PROGRAMFILES/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
|
||||
fi
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
|
||||
TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT([C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1/Bin], [well-known name])
|
||||
])
|
||||
|
||||
################################################################################
|
||||
|
||||
AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO],
|
||||
[
|
||||
AC_ARG_WITH(toolchain-version, [AS_HELP_STRING([--with-toolchain-version],
|
||||
[the version of the toolchain to look for, use '--help' to show possible values @<:@platform dependent@:>@])])
|
||||
|
||||
if test "x$with_toolchain_version" = xlist; then
|
||||
# List all toolchains
|
||||
AC_MSG_NOTICE([The following toolchain versions are valid on this platform:])
|
||||
for version in $VALID_VS_VERSIONS; do
|
||||
eval VS_DESCRIPTION=\${VS_DESCRIPTION_$version}
|
||||
$PRINTF " %-10s %s\n" $version "$VS_DESCRIPTION"
|
||||
done
|
||||
|
||||
exit 0
|
||||
elif test "x$with_toolchain_version" != x; then
|
||||
# User override; check that it is valid
|
||||
if test "x${VALID_VS_VERSIONS/$with_toolchain_version/}" = "x${VALID_VS_VERSIONS}"; then
|
||||
AC_MSG_NOTICE([Visual Studio version $with_toolchain_version is not valid.])
|
||||
AC_MSG_NOTICE([Valid Visual Studio versions: $VALID_VS_VERSIONS.])
|
||||
AC_MSG_ERROR([Cannot continue.])
|
||||
fi
|
||||
VS_VERSIONS_PROBE_LIST="$with_toolchain_version"
|
||||
else
|
||||
# No flag given, use default
|
||||
VS_VERSIONS_PROBE_LIST="$VALID_VS_VERSIONS"
|
||||
fi
|
||||
|
||||
for VS_VERSION in $VS_VERSIONS_PROBE_LIST; do
|
||||
TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE([$VS_VERSION])
|
||||
if test "x$VS_ENV_CMD" != x; then
|
||||
TOOLCHAIN_VERSION=$VS_VERSION
|
||||
eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}"
|
||||
eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}"
|
||||
eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}"
|
||||
eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}"
|
||||
# The rest of the variables are already evaled while probing
|
||||
AC_MSG_NOTICE([Found $VS_DESCRIPTION])
|
||||
break
|
||||
fi
|
||||
done
|
||||
])
|
||||
|
||||
################################################################################
|
||||
# Check if the VS env variables were setup prior to running configure.
|
||||
# If not, then find vcvarsall.bat and run it automatically, and integrate
|
||||
# the set env variables into the spec file.
|
||||
@ -142,7 +260,8 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
|
||||
fi
|
||||
|
||||
# First-hand choice is to locate and run the vsvars bat file.
|
||||
TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE
|
||||
TOOLCHAIN_FIND_VISUAL_STUDIO
|
||||
|
||||
if test "x$VS_ENV_CMD" != x; then
|
||||
# We have found a Visual Studio environment on disk, let's extract variables from the vsvars bat file.
|
||||
BASIC_FIXUP_EXECUTABLE(VS_ENV_CMD)
|
||||
@ -213,9 +332,9 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
|
||||
AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
|
||||
else
|
||||
AC_MSG_RESULT([ok])
|
||||
# Remove any trailing "\" and " " from the variables.
|
||||
VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED 's/\\\\* *$//'`
|
||||
VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\* *$//'`
|
||||
# Remove any trailing "\" ";" and " " from the variables.
|
||||
VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED -e 's/\\\\*;* *$//'`
|
||||
VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\*;* *$//'`
|
||||
VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
|
||||
WindowsSDKDir=`$ECHO "$WindowsSDKDir" | $SED 's/\\\\* *$//'`
|
||||
WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
|
||||
@ -226,6 +345,42 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
|
||||
AC_SUBST(VS_PATH)
|
||||
AC_SUBST(VS_INCLUDE)
|
||||
AC_SUBST(VS_LIB)
|
||||
|
||||
# Convert VS_INCLUDE into SYSROOT_CFLAGS
|
||||
OLDIFS="$IFS"
|
||||
IFS=";"
|
||||
for i in $VS_INCLUDE; do
|
||||
ipath=$i
|
||||
# Only process non-empty elements
|
||||
if test "x$ipath" != x; then
|
||||
IFS="$OLDIFS"
|
||||
# Check that directory exists before calling fixup_path
|
||||
testpath=$ipath
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([testpath])
|
||||
if test -d "$testpath"; then
|
||||
BASIC_FIXUP_PATH([ipath])
|
||||
SYSROOT_CFLAGS="$SYSROOT_CFLAGS -I$ipath"
|
||||
fi
|
||||
IFS=";"
|
||||
fi
|
||||
done
|
||||
# Convert VS_LIB into SYSROOT_LDFLAGS
|
||||
for i in $VS_LIB; do
|
||||
libpath=$i
|
||||
# Only process non-empty elements
|
||||
if test "x$libpath" != x; then
|
||||
IFS="$OLDIFS"
|
||||
# Check that directory exists before calling fixup_path
|
||||
testpath=$libpath
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH([testpath])
|
||||
if test -d "$testpath"; then
|
||||
BASIC_FIXUP_PATH([libpath])
|
||||
SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -libpath:$libpath"
|
||||
fi
|
||||
IFS=";"
|
||||
fi
|
||||
done
|
||||
IFS="$OLDIFS"
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([not found])
|
||||
@ -242,16 +397,17 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL],
|
||||
AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL],
|
||||
[
|
||||
POSSIBLE_MSVCR_DLL="$1"
|
||||
METHOD="$2"
|
||||
if test -e "$POSSIBLE_MSVCR_DLL"; then
|
||||
AC_MSG_NOTICE([Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD])
|
||||
|
||||
DLL_NAME="$1"
|
||||
POSSIBLE_MSVC_DLL="$2"
|
||||
METHOD="$3"
|
||||
if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then
|
||||
AC_MSG_NOTICE([Found $1 at $POSSIBLE_MSVC_DLL using $METHOD])
|
||||
|
||||
# Need to check if the found msvcr is correct architecture
|
||||
AC_MSG_CHECKING([found msvcr100.dll architecture])
|
||||
MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"`
|
||||
AC_MSG_CHECKING([found $1 architecture])
|
||||
MSVC_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVC_DLL"`
|
||||
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
|
||||
# The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit"
|
||||
# on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems.
|
||||
@ -267,96 +423,135 @@ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL],
|
||||
CORRECT_MSVCR_ARCH=x86-64
|
||||
fi
|
||||
fi
|
||||
if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
|
||||
if $ECHO "$MSVC_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then
|
||||
AC_MSG_RESULT([ok])
|
||||
MSVCR_DLL="$POSSIBLE_MSVCR_DLL"
|
||||
AC_MSG_CHECKING([for msvcr100.dll])
|
||||
AC_MSG_RESULT([$MSVCR_DLL])
|
||||
MSVC_DLL="$POSSIBLE_MSVC_DLL"
|
||||
AC_MSG_CHECKING([for $1])
|
||||
AC_MSG_RESULT([$MSVC_DLL])
|
||||
else
|
||||
AC_MSG_RESULT([incorrect, ignoring])
|
||||
AC_MSG_NOTICE([The file type of the located msvcr100.dll is $MSVCR_DLL_FILETYPE])
|
||||
AC_MSG_NOTICE([The file type of the located $1 is $MSVC_DLL_FILETYPE])
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([TOOLCHAIN_SETUP_MSVCR_DLL],
|
||||
AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL],
|
||||
[
|
||||
AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
|
||||
[copy this msvcr100.dll into the built JDK (Windows only) @<:@probed@:>@])])
|
||||
VAR_NAME="$1"
|
||||
DLL_NAME="$2"
|
||||
MSVC_DLL=
|
||||
|
||||
if test "x$with_msvcr_dll" != x; then
|
||||
# If given explicitely by user, do not probe. If not present, fail directly.
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$with_msvcr_dll], [--with-msvcr-dll])
|
||||
if test "x$MSVCR_DLL" = x; then
|
||||
AC_MSG_ERROR([Could not find a proper msvcr100.dll as specified by --with-msvcr-dll])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$MSVCR_DLL" = x; then
|
||||
if test "x$MSVC_DLL" = x; then
|
||||
# Probe: Using well-known location from Visual Studio 10.0
|
||||
if test "x$VCINSTALLDIR" != x; then
|
||||
CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR"
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VC_INSTALL_DIR)
|
||||
if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
|
||||
POSSIBLE_MSVCR_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC100.CRT/msvcr100.dll"
|
||||
POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
|
||||
else
|
||||
POSSIBLE_MSVCR_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC100.CRT/msvcr100.dll"
|
||||
POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME"
|
||||
fi
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [well-known location in VCINSTALLDIR])
|
||||
$ECHO "POSSIBLE_MSVC_DLL $POSSIBLEMSVC_DLL"
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
|
||||
[well-known location in VCINSTALLDIR])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$MSVCR_DLL" = x; then
|
||||
if test "x$MSVC_DLL" = x; then
|
||||
# Probe: Check in the Boot JDK directory.
|
||||
POSSIBLE_MSVCR_DLL="$BOOT_JDK/bin/msvcr100.dll"
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [well-known location in Boot JDK])
|
||||
POSSIBLE_MSVC_DLL="$BOOT_JDK/bin/$DLL_NAME"
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
|
||||
[well-known location in Boot JDK])
|
||||
fi
|
||||
|
||||
if test "x$MSVCR_DLL" = x; then
|
||||
# Probe: Look in the Windows system32 directory
|
||||
|
||||
if test "x$MSVC_DLL" = x; then
|
||||
# Probe: Look in the Windows system32 directory
|
||||
CYGWIN_SYSTEMROOT="$SYSTEMROOT"
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_SYSTEMROOT)
|
||||
POSSIBLE_MSVCR_DLL="$CYGWIN_SYSTEMROOT/system32/msvcr100.dll"
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [well-known location in SYSTEMROOT])
|
||||
POSSIBLE_MSVC_DLL="$CYGWIN_SYSTEMROOT/system32/$DLL_NAME"
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
|
||||
[well-known location in SYSTEMROOT])
|
||||
fi
|
||||
|
||||
if test "x$MSVCR_DLL" = x; then
|
||||
if test "x$MSVC_DLL" = x; then
|
||||
# Probe: If Visual Studio Express is installed, there is usually one with the debugger
|
||||
if test "x$VS100COMNTOOLS" != x; then
|
||||
CYGWIN_VS_TOOLS_DIR="$VS100COMNTOOLS/.."
|
||||
BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VS_TOOLS_DIR)
|
||||
if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
|
||||
POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name msvcr100.dll | $GREP -i /x64/ | $HEAD --lines 1`
|
||||
POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
|
||||
| $GREP -i /x64/ | $HEAD --lines 1`
|
||||
else
|
||||
POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name msvcr100.dll | $GREP -i /x86/ | $HEAD --lines 1`
|
||||
POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VS_TOOLS_DIR" -name $DLL_NAME \
|
||||
| $GREP -i /x86/ | $HEAD --lines 1`
|
||||
fi
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [search of VS100COMNTOOLS])
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
|
||||
[search of VS100COMNTOOLS])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$MSVCR_DLL" = x; then
|
||||
|
||||
if test "x$MSVC_DLL" = x; then
|
||||
# Probe: Search wildly in the VCINSTALLDIR. We've probably lost by now.
|
||||
# (This was the original behaviour; kept since it might turn up something)
|
||||
# (This was the original behaviour; kept since it might turn something up)
|
||||
if test "x$CYGWIN_VC_INSTALL_DIR" != x; then
|
||||
if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
|
||||
POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $GREP x64 | $HEAD --lines 1`
|
||||
POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
|
||||
| $GREP x64 | $HEAD --lines 1`
|
||||
else
|
||||
POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
|
||||
if test "x$POSSIBLE_MSVCR_DLL" = x; then
|
||||
POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
|
||||
| $GREP x86 | $GREP -v ia64 | $GREP -v x64 | $HEAD --lines 1`
|
||||
if test "x$POSSIBLE_MSVC_DLL" = x; then
|
||||
# We're grasping at straws now...
|
||||
POSSIBLE_MSVCR_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name msvcr100.dll | $HEAD --lines 1`
|
||||
POSSIBLE_MSVC_DLL=`$FIND "$CYGWIN_VC_INSTALL_DIR" -name $DLL_NAME \
|
||||
| $HEAD --lines 1`
|
||||
fi
|
||||
fi
|
||||
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL([$POSSIBLE_MSVCR_DLL], [search of VCINSTALLDIR])
|
||||
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL],
|
||||
[search of VCINSTALLDIR])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$MSVCR_DLL" = x; then
|
||||
AC_MSG_CHECKING([for msvcr100.dll])
|
||||
|
||||
if test "x$MSVC_DLL" = x; then
|
||||
AC_MSG_CHECKING([for $DLL_NAME])
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([Could not find msvcr100.dll. Please specify using --with-msvcr-dll.])
|
||||
AC_MSG_ERROR([Could not find $DLL_NAME. Please specify using --with-msvcr-dll.])
|
||||
fi
|
||||
|
||||
BASIC_FIXUP_PATH(MSVCR_DLL)
|
||||
$1=$MSVC_DLL
|
||||
BASIC_FIXUP_PATH($1)
|
||||
AC_SUBST($1, [$]$1)
|
||||
])
|
||||
|
||||
AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS],
|
||||
[
|
||||
AC_ARG_WITH(msvcr-dll, [AS_HELP_STRING([--with-msvcr-dll],
|
||||
[path to microsoft C runtime dll (msvcr*.dll) (Windows only) @<:@probed@:>@])])
|
||||
|
||||
if test "x$with_msvcr_dll" != x; then
|
||||
# If given explicitely by user, do not probe. If not present, fail directly.
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$with_msvcr_dll],
|
||||
[--with-msvcr-dll])
|
||||
if test "x$MSVC_DLL" = x; then
|
||||
AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll])
|
||||
fi
|
||||
else
|
||||
TOOLCHAIN_SETUP_MSVC_DLL([MSVCR_DLL], [${MSVCR_NAME}])
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(msvcp-dll, [AS_HELP_STRING([--with-msvcp-dll],
|
||||
[path to microsoft C++ runtime dll (msvcp*.dll) (Windows only) @<:@probed@:>@])])
|
||||
|
||||
if test "x$MSVCP_NAME" != "x"; then
|
||||
if test "x$with_msvcp_dll" != x; then
|
||||
# If given explicitely by user, do not probe. If not present, fail directly.
|
||||
TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$with_msvcp_dll],
|
||||
[--with-msvcp-dll])
|
||||
if test "x$MSVC_DLL" = x; then
|
||||
AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll])
|
||||
fi
|
||||
else
|
||||
TOOLCHAIN_SETUP_MSVC_DLL([MSVCP_DLL], [${MSVCP_NAME}])
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
@ -123,6 +123,7 @@ jdk/src/java.base/share/classes/java/lang/reflect : jdk/src/share/classes/java/l
|
||||
jdk/src/java.base/share/classes/java/math : jdk/src/share/classes/java/math
|
||||
jdk/src/java.base/share/classes/java/net : jdk/src/share/classes/java/net
|
||||
jdk/src/java.base/share/classes/java/nio : jdk/src/share/classes/java/nio
|
||||
jdk/src/java.base/share/classes/java/security/acl : jdk/src/share/classes/java/security/acl
|
||||
jdk/src/java.base/share/classes/java/security/cert : jdk/src/share/classes/java/security/cert
|
||||
jdk/src/java.base/share/classes/java/security/interfaces : jdk/src/share/classes/java/security/interfaces
|
||||
jdk/src/java.base/share/classes/java/security : jdk/src/share/classes/java/security
|
||||
@ -1211,8 +1212,6 @@ jdk/src/java.rmi/share/doc/stub/java/rmi/activation : jdk/src/share/doc/stub/jav
|
||||
jdk/src/java.rmi/unix/bin/java-rmi.cgi.sh : jdk/src/solaris/bin/java-rmi.cgi.sh
|
||||
jdk/src/java.scripting/share/classes/javax/script : jdk/src/share/classes/javax/script
|
||||
jdk/src/java.scripting/share/classes/com/sun/tools/script/shell : jdk/src/share/classes/com/sun/tools/script/shell
|
||||
jdk/src/java.security.acl/share/classes/java/security/acl : jdk/src/share/classes/java/security/acl
|
||||
jdk/src/java.security.acl/share/classes/sun/security/acl : jdk/src/share/classes/sun/security/acl
|
||||
jdk/src/java.security.jgss/macosx/native/libosxkrb5/nativeccache.c : jdk/src/share/native/sun/security/krb5/nativeccache.c
|
||||
jdk/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m : jdk/src/macosx/native/sun/security/krb5/SCDynamicStoreConfig.m
|
||||
jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos : jdk/src/share/classes/javax/security/auth/kerberos
|
||||
@ -1303,6 +1302,7 @@ jdk/src/jdk.deploy.osx/macosx/native/libosx/KeystoreImpl.m : jdk/src/macosx/nati
|
||||
jdk/src/jdk.dev/share/classes/com/sun/jarsigner : jdk/src/share/classes/com/sun/jarsigner
|
||||
jdk/src/jdk.dev/share/classes/com/sun/tools/hat : jdk/src/share/classes/com/sun/tools/hat
|
||||
jdk/src/jdk.dev/share/classes/sun/security/tools/jarsigner : jdk/src/share/classes/sun/security/tools/jarsigner
|
||||
jdk/src/jdk.dev/share/classes/sun/security/tools/policytool : jdk/src/share/classes/sun/security/tools/policytool
|
||||
jdk/src/jdk.dev/share/classes/sun/tools/jar : jdk/src/share/classes/sun/tools/jar
|
||||
jdk/src/jdk.dev/share/classes/sun/tools/native2ascii : jdk/src/share/classes/sun/tools/native2ascii
|
||||
jdk/src/jdk.hprof.agent/share/classes/com/sun/demo/jvmti/hprof : jdk/src/share/classes/com/sun/demo/jvmti/hprof
|
||||
@ -1443,7 +1443,6 @@ jdk/src/jdk.rmic/share/classes/sun/tools/java : jdk/src/share/classes/sun/tools/
|
||||
jdk/src/jdk.rmic/share/classes/sun/tools/tree : jdk/src/share/classes/sun/tools/tree
|
||||
jdk/src/jdk.rmic/share/classes/sun/tools/util : jdk/src/share/classes/sun/tools/util
|
||||
jdk/src/jdk.runtime/share/classes/com/sun/tracing : jdk/src/share/classes/com/sun/tracing
|
||||
jdk/src/jdk.runtime/share/classes/sun/security/tools/policytool : jdk/src/share/classes/sun/security/tools/policytool
|
||||
jdk/src/jdk.runtime/share/classes/sun/tracing : jdk/src/share/classes/sun/tracing
|
||||
jdk/src/jdk.runtime/share/native/common-unpack/bands.cpp : jdk/src/share/native/com/sun/java/util/jar/pack/bands.cpp
|
||||
jdk/src/jdk.runtime/share/native/common-unpack/bands.h : jdk/src/share/native/com/sun/java/util/jar/pack/bands.h
|
||||
|
@ -289,3 +289,8 @@ e27c725d6c9d155667b35255f442d4ceb8c3c084 jdk9-b40
|
||||
1f57bd728c9e6865ccb9d43ccd80a1c11230a32f jdk9-b44
|
||||
9e3f2bed80c0e5a84a256ce41f1d10c5ade48466 jdk9-b45
|
||||
326f2068b4a4c05e2fa27d6acf93eba7b54b090d jdk9-b46
|
||||
ee8447ca632e1d39180b4767c749db101bff7314 jdk9-b47
|
||||
a13c49c5f2899b702652a460ed7aa73123e671e6 jdk9-b48
|
||||
9285d14eb7b6b0815679bae98dd936dbc136218d jdk9-b49
|
||||
224f593393e5b01b3c8f1e591b7f4b1790a3737a jdk9-b50
|
||||
2309c02386d1fa4ced5051873ffb9e04874f7a44 jdk9-b51
|
||||
|
@ -176,42 +176,9 @@ public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
|
||||
staticWrapper = ORBUtilSystemException.get(
|
||||
CORBALogDomains.RPC_PRESENTATION ) ;
|
||||
|
||||
boolean useDynamicStub =
|
||||
((Boolean)AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public java.lang.Object run() {
|
||||
return Boolean.valueOf( Boolean.getBoolean (
|
||||
ORBConstants.USE_DYNAMIC_STUB_PROPERTY ) ) ;
|
||||
}
|
||||
}
|
||||
)).booleanValue() ;
|
||||
boolean useDynamicStub = false;
|
||||
|
||||
PresentationManager.StubFactoryFactory dynamicStubFactoryFactory =
|
||||
(PresentationManager.StubFactoryFactory)AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public java.lang.Object run() {
|
||||
PresentationManager.StubFactoryFactory sff =
|
||||
PresentationDefaults.getProxyStubFactoryFactory() ;
|
||||
|
||||
String className = System.getProperty(
|
||||
ORBConstants.DYNAMIC_STUB_FACTORY_FACTORY_CLASS,
|
||||
"com.sun.corba.se.impl.presentation.rmi.bcel.StubFactoryFactoryBCELImpl" ) ;
|
||||
|
||||
try {
|
||||
// First try the configured class name, if any
|
||||
Class<?> cls =
|
||||
sun.corba.SharedSecrets.getJavaCorbaAccess().loadClass(className);
|
||||
sff = (PresentationManager.StubFactoryFactory)cls.newInstance();
|
||||
} catch (Exception exc) {
|
||||
// Use the default. Log the error as a warning.
|
||||
staticWrapper.errorInSettingDynamicStubFactoryFactory(
|
||||
exc, className ) ;
|
||||
}
|
||||
|
||||
return sff ;
|
||||
}
|
||||
}
|
||||
) ;
|
||||
PresentationManager.StubFactoryFactory dynamicStubFactoryFactory = null;
|
||||
|
||||
PresentationManager pm = new PresentationManagerImpl( useDynamicStub ) ;
|
||||
pm.setStubFactoryFactory( false,
|
||||
|
@ -28,7 +28,9 @@ package sun.corba;
|
||||
import com.sun.corba.se.impl.io.ValueUtility;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/** A repository of "shared secrets", which are a mechanism for
|
||||
calling implementation-private methods in another package without
|
||||
@ -41,9 +43,23 @@ import java.security.AccessController;
|
||||
|
||||
// SharedSecrets cloned in corba repo to avoid build issues
|
||||
public class SharedSecrets {
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static final Unsafe unsafe = getUnsafe();
|
||||
private static JavaCorbaAccess javaCorbaAccess;
|
||||
|
||||
private static Unsafe getUnsafe() {
|
||||
PrivilegedAction<Unsafe> pa = () -> {
|
||||
Class<?> unsafeClass = sun.misc.Unsafe.class ;
|
||||
try {
|
||||
Field f = unsafeClass.getDeclaredField("theUnsafe");
|
||||
f.setAccessible(true);
|
||||
return (Unsafe) f.get(null);
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
};
|
||||
return AccessController.doPrivileged(pa);
|
||||
}
|
||||
|
||||
public static JavaCorbaAccess getJavaCorbaAccess() {
|
||||
if (javaCorbaAccess == null) {
|
||||
// Ensure ValueUtility is initialized; we know that that class
|
||||
|
@ -449,3 +449,8 @@ c363a8b87e477ee45d6d3cb2a36cb365141bc596 jdk9-b38
|
||||
43a44b56dca61a4d766a20f0528fdd8b5ceff873 jdk9-b44
|
||||
5dc8184af1e2bb30b0103113d1f1a58a21a80c37 jdk9-b45
|
||||
a184ee1d717297bd35b7c3e35393e137921a3ed2 jdk9-b46
|
||||
3b241fb72b8925b75941d612db762a6d5da66d02 jdk9-b47
|
||||
cc775a4a24c7f5d9e624b4205e9fbd48a17331f6 jdk9-b48
|
||||
360cd1fc42f10941a9fd17cc32d5b85a22d12a0b jdk9-b49
|
||||
e0947f58c9c1426aa0d98b98ebb78357b27a7b99 jdk9-b50
|
||||
403b9cbadb04d3d1201823591cf931dc93b38e3a jdk9-b51
|
||||
|
@ -27,9 +27,11 @@
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <elf.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/uio.h>
|
||||
#include "libproc_impl.h"
|
||||
|
||||
#if defined(x86_64) && !defined(amd64)
|
||||
@ -138,6 +140,15 @@ static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct use
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#elif defined(PTRACE_GETREGSET)
|
||||
struct iovec iov;
|
||||
iov.iov_base = user;
|
||||
iov.iov_len = sizeof(*user);
|
||||
if (ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, (void*) &iov) < 0) {
|
||||
print_debug("ptrace(PTRACE_GETREGSET, ...) failed for lwp %d\n", pid);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
print_debug("ptrace(PTRACE_GETREGS, ...) not supported\n");
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 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
|
||||
@ -44,15 +44,22 @@ public class SymbolTable extends sun.jvm.hotspot.utilities.Hashtable {
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("SymbolTable");
|
||||
theTableField = type.getAddressField("_the_table");
|
||||
sharedTableField = type.getAddressField("_shared_table");
|
||||
}
|
||||
|
||||
// Fields
|
||||
private static AddressField theTableField;
|
||||
private static AddressField sharedTableField;
|
||||
|
||||
private CompactHashTable sharedTable;
|
||||
|
||||
// Accessors
|
||||
public static SymbolTable getTheTable() {
|
||||
Address tmp = theTableField.getValue();
|
||||
return (SymbolTable) VMObjectFactory.newObject(SymbolTable.class, tmp);
|
||||
SymbolTable table = (SymbolTable) VMObjectFactory.newObject(SymbolTable.class, tmp);
|
||||
Address shared = sharedTableField.getStaticFieldAddress();
|
||||
table.sharedTable = (CompactHashTable)VMObjectFactory.newObject(CompactHashTable.class, shared);
|
||||
return table;
|
||||
}
|
||||
|
||||
public SymbolTable(Address addr) {
|
||||
@ -73,8 +80,9 @@ public class SymbolTable extends sun.jvm.hotspot.utilities.Hashtable {
|
||||
|
||||
/** Clone of VM's "temporary" probe routine, as the SA currently
|
||||
does not support mutation so lookup() would have no effect
|
||||
anyway. Returns null if the given string is not in the symbol
|
||||
table. */
|
||||
anyway. Searches the regular symbol table and the shared symbol
|
||||
table. Null is returned if the given name is not found in both
|
||||
tables. */
|
||||
public Symbol probe(byte[] name) {
|
||||
long hashValue = hashSymbol(name);
|
||||
for (HashtableEntry e = (HashtableEntry) bucket(hashToIndex(hashValue)); e != null; e = (HashtableEntry) e.next()) {
|
||||
@ -85,7 +93,8 @@ public class SymbolTable extends sun.jvm.hotspot.utilities.Hashtable {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return sharedTable.probe(name, hashValue);
|
||||
}
|
||||
|
||||
public interface SymbolVisitor {
|
||||
|
@ -423,12 +423,22 @@ public class ClassWriter implements /* imports */ ClassConstants
|
||||
|
||||
protected void writeMethods() throws IOException {
|
||||
MethodArray methods = klass.getMethods();
|
||||
final int len = methods.length();
|
||||
ArrayList<Method> valid_methods = new ArrayList<Method>();
|
||||
for (int i = 0; i < methods.length(); i++) {
|
||||
Method m = methods.at(i);
|
||||
long accessFlags = m.getAccessFlags();
|
||||
// overpass method
|
||||
if (accessFlags == (JVM_ACC_PUBLIC | JVM_ACC_SYNTHETIC | JVM_ACC_BRIDGE)) {
|
||||
continue;
|
||||
}
|
||||
valid_methods.add(m);
|
||||
}
|
||||
final int len = valid_methods.size();
|
||||
// write number of methods
|
||||
dos.writeShort((short) len);
|
||||
if (DEBUG) debugMessage("number of methods = " + len);
|
||||
for (int m = 0; m < len; m++) {
|
||||
writeMethod(methods.at(m));
|
||||
writeMethod(valid_methods.get(m));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.utilities;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.oops.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
|
||||
public class CompactHashTable extends VMObject {
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
|
||||
Type type = db.lookupType("SymbolCompactHashTable");
|
||||
baseAddressField = type.getAddressField("_base_address");
|
||||
bucketCountField = type.getCIntegerField("_bucket_count");
|
||||
tableEndOffsetField = type.getCIntegerField("_table_end_offset");
|
||||
bucketsField = type.getAddressField("_buckets");
|
||||
uintSize = db.lookupType("juint").getSize();
|
||||
}
|
||||
|
||||
// Fields
|
||||
private static CIntegerField bucketCountField;
|
||||
private static CIntegerField tableEndOffsetField;
|
||||
private static AddressField baseAddressField;
|
||||
private static AddressField bucketsField;
|
||||
private static long uintSize;
|
||||
|
||||
private static int BUCKET_OFFSET_MASK = 0x3FFFFFFF;
|
||||
private static int BUCKET_TYPE_SHIFT = 30;
|
||||
private static int COMPACT_BUCKET_TYPE = 1;
|
||||
|
||||
public CompactHashTable(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
|
||||
private int bucketCount() {
|
||||
return (int)bucketCountField.getValue(addr);
|
||||
}
|
||||
|
||||
private int tableEndOffset() {
|
||||
return (int)tableEndOffsetField.getValue(addr);
|
||||
}
|
||||
|
||||
private boolean isCompactBucket(int bucket_info) {
|
||||
return (bucket_info >> BUCKET_TYPE_SHIFT) == COMPACT_BUCKET_TYPE;
|
||||
}
|
||||
|
||||
private int bucketOffset(int bucket_info) {
|
||||
return bucket_info & BUCKET_OFFSET_MASK;
|
||||
}
|
||||
|
||||
public Symbol probe(byte[] name, long hash) {
|
||||
long symOffset;
|
||||
Symbol sym;
|
||||
Address baseAddress = baseAddressField.getValue(addr);
|
||||
Address bucket = bucketsField.getValue(addr);
|
||||
Address bucketEnd = bucket;
|
||||
long index = hash % bucketCount();
|
||||
int bucketInfo = (int)bucket.getCIntegerAt(index * uintSize, uintSize, true);
|
||||
int bucketOffset = bucketOffset(bucketInfo);
|
||||
int nextBucketInfo = (int)bucket.getCIntegerAt((index+1) * uintSize, uintSize, true);
|
||||
int nextBucketOffset = bucketOffset(nextBucketInfo);
|
||||
|
||||
bucket = bucket.addOffsetTo(bucketOffset * uintSize);
|
||||
|
||||
if (isCompactBucket(bucketInfo)) {
|
||||
symOffset = bucket.getCIntegerAt(0, uintSize, true);
|
||||
sym = Symbol.create(baseAddress.addOffsetTo(symOffset));
|
||||
if (sym.equals(name)) {
|
||||
return sym;
|
||||
}
|
||||
} else {
|
||||
bucketEnd = bucket.addOffsetTo(nextBucketOffset * uintSize);
|
||||
while (bucket.lessThan(bucketEnd)) {
|
||||
long symHash = bucket.getCIntegerAt(0, uintSize, true);
|
||||
if (symHash == hash) {
|
||||
symOffset = bucket.getCIntegerAt(uintSize, uintSize, true);
|
||||
Address symAddr = baseAddress.addOffsetTo(symOffset);
|
||||
sym = Symbol.create(symAddr);
|
||||
if (sym.equals(name)) {
|
||||
return sym;
|
||||
}
|
||||
}
|
||||
bucket = bucket.addOffsetTo(2 * uintSize);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -246,8 +246,7 @@ endif
|
||||
XSLT_CHECK = $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory
|
||||
# If not found then fail fast.
|
||||
check_j2se_version:
|
||||
$(QUIETLY) $(XSLT_CHECK) > /dev/null 2>&1; \
|
||||
if [ $$? -ne 0 ]; then \
|
||||
$(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \
|
||||
$(REMOTE) $(RUN.JAVA) -version; \
|
||||
echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
|
||||
"to bootstrap this build" 1>&2; \
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 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
|
||||
@ -62,11 +62,6 @@ SUNWprivate_1.1 {
|
||||
JVM_DefineClassWithSourceCond;
|
||||
JVM_DesiredAssertionStatus;
|
||||
JVM_DoPrivileged;
|
||||
JVM_DTraceGetVersion;
|
||||
JVM_DTraceActivate;
|
||||
JVM_DTraceIsProbeEnabled;
|
||||
JVM_DTraceIsSupported;
|
||||
JVM_DTraceDispose;
|
||||
JVM_DumpAllStacks;
|
||||
JVM_DumpThreads;
|
||||
JVM_FillInStackTrace;
|
||||
@ -132,6 +127,7 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 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
|
||||
@ -62,11 +62,6 @@ SUNWprivate_1.1 {
|
||||
JVM_DefineClassWithSourceCond;
|
||||
JVM_DesiredAssertionStatus;
|
||||
JVM_DoPrivileged;
|
||||
JVM_DTraceGetVersion;
|
||||
JVM_DTraceActivate;
|
||||
JVM_DTraceIsProbeEnabled;
|
||||
JVM_DTraceIsSupported;
|
||||
JVM_DTraceDispose;
|
||||
JVM_DumpAllStacks;
|
||||
JVM_DumpThreads;
|
||||
JVM_FillInStackTrace;
|
||||
@ -130,6 +125,7 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxNameUTF;
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -74,6 +74,12 @@ CFLAGS += -D_REENTRANT
|
||||
# no xlc counterpart for -fcheck-new
|
||||
# CFLAGS += -fcheck-new
|
||||
|
||||
# We need to define this on the command line if we want to use the the
|
||||
# predefined format specifiers from "inttypes.h". Otherwise system headrs
|
||||
# can indirectly include inttypes.h before we define __STDC_FORMAT_MACROS
|
||||
# in globalDefinitions.hpp
|
||||
CFLAGS += -D__STDC_FORMAT_MACROS
|
||||
|
||||
ARCHFLAG = -q64
|
||||
|
||||
CFLAGS += $(ARCHFLAG)
|
||||
|
@ -240,8 +240,7 @@ endif
|
||||
XSLT_CHECK = $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory
|
||||
# If not found then fail fast.
|
||||
check_j2se_version:
|
||||
$(QUIETLY) $(XSLT_CHECK) > /dev/null 2>&1; \
|
||||
if [ $$? -ne 0 ]; then \
|
||||
$(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \
|
||||
$(REMOTE) $(RUN.JAVA) -version; \
|
||||
echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
|
||||
"to bootstrap this build" 1>&2; \
|
||||
|
@ -179,23 +179,23 @@ $(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).dylib
|
||||
# $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs.
|
||||
$(JVMOFFS).h: $(GENOFFS)
|
||||
$(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -header > $@.tmp; touch $@; \
|
||||
if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
|
||||
then rm -f $@; mv $@.tmp $@; \
|
||||
else rm -f $@.tmp; \
|
||||
if diff $@.tmp $@ > /dev/null 2>&1 ; \
|
||||
then rm -f $@.tmp; \
|
||||
else rm -f $@; mv $@.tmp $@; \
|
||||
fi
|
||||
|
||||
$(JVMOFFS)Index.h: $(GENOFFS)
|
||||
$(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -index > $@.tmp; touch $@; \
|
||||
if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
|
||||
then rm -f $@; mv $@.tmp $@; \
|
||||
else rm -f $@.tmp; \
|
||||
if diff $@.tmp $@ > /dev/null 2>&1 ; \
|
||||
then rm -f $@.tmp; \
|
||||
else rm -f $@; mv $@.tmp $@; \
|
||||
fi
|
||||
|
||||
$(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h
|
||||
$(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -table > $@.tmp; touch $@; \
|
||||
if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
|
||||
then rm -f $@; mv $@.tmp $@; \
|
||||
else rm -f $@.tmp; \
|
||||
if diff $@.tmp $@ > /dev/null 2>&1; \
|
||||
then rm -f $@.tmp; \
|
||||
else rm -f $@; mv $@.tmp $@; \
|
||||
fi
|
||||
|
||||
$(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 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
|
||||
@ -60,11 +60,6 @@
|
||||
_JVM_DefineClassWithSourceCond
|
||||
_JVM_DesiredAssertionStatus
|
||||
_JVM_DoPrivileged
|
||||
_JVM_DTraceGetVersion
|
||||
_JVM_DTraceActivate
|
||||
_JVM_DTraceIsProbeEnabled
|
||||
_JVM_DTraceIsSupported
|
||||
_JVM_DTraceDispose
|
||||
_JVM_DumpAllStacks
|
||||
_JVM_DumpThreads
|
||||
_JVM_FillInStackTrace
|
||||
@ -130,6 +125,7 @@
|
||||
_JVM_GetMethodIxSignatureUTF
|
||||
_JVM_GetMethodParameters
|
||||
_JVM_GetMethodTypeAnnotations
|
||||
_JVM_GetNanoTimeAdjustment
|
||||
_JVM_GetPrimitiveArrayElement
|
||||
_JVM_GetProtectionDomain
|
||||
_JVM_GetStackAccessControlContext
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 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
|
||||
@ -60,11 +60,6 @@
|
||||
_JVM_DefineClassWithSourceCond
|
||||
_JVM_DesiredAssertionStatus
|
||||
_JVM_DoPrivileged
|
||||
_JVM_DTraceGetVersion
|
||||
_JVM_DTraceActivate
|
||||
_JVM_DTraceIsProbeEnabled
|
||||
_JVM_DTraceIsSupported
|
||||
_JVM_DTraceDispose
|
||||
_JVM_DumpAllStacks
|
||||
_JVM_DumpThreads
|
||||
_JVM_FillInStackTrace
|
||||
@ -130,6 +125,7 @@
|
||||
_JVM_GetMethodIxSignatureUTF
|
||||
_JVM_GetMethodParameters
|
||||
_JVM_GetMethodTypeAnnotations
|
||||
_JVM_GetNanoTimeAdjustment
|
||||
_JVM_GetPrimitiveArrayElement
|
||||
_JVM_GetProtectionDomain
|
||||
_JVM_GetStackAccessControlContext
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 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
|
||||
@ -62,11 +62,6 @@ SUNWprivate_1.1 {
|
||||
JVM_DefineClassWithSourceCond;
|
||||
JVM_DesiredAssertionStatus;
|
||||
JVM_DoPrivileged;
|
||||
JVM_DTraceGetVersion;
|
||||
JVM_DTraceActivate;
|
||||
JVM_DTraceIsProbeEnabled;
|
||||
JVM_DTraceIsSupported;
|
||||
JVM_DTraceDispose;
|
||||
JVM_DumpAllStacks;
|
||||
JVM_DumpThreads;
|
||||
JVM_FillInStackTrace;
|
||||
@ -132,6 +127,7 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 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
|
||||
@ -62,11 +62,6 @@ SUNWprivate_1.1 {
|
||||
JVM_DefineClassWithSourceCond;
|
||||
JVM_DesiredAssertionStatus;
|
||||
JVM_DoPrivileged;
|
||||
JVM_DTraceGetVersion;
|
||||
JVM_DTraceActivate;
|
||||
JVM_DTraceIsProbeEnabled;
|
||||
JVM_DTraceIsSupported;
|
||||
JVM_DTraceDispose;
|
||||
JVM_DumpAllStacks;
|
||||
JVM_DumpThreads;
|
||||
JVM_FillInStackTrace;
|
||||
@ -132,6 +127,7 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -59,7 +59,7 @@ universalize: $(UNIVERSAL_LIPO_LIST) $(UNIVERSAL_COPY_LIST)
|
||||
|
||||
# Package built libraries in a universal binary
|
||||
$(UNIVERSAL_LIPO_LIST):
|
||||
BUILT_LIPO_FILES="`find $(EXPORT_JRE_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) 2>/dev/null`"; \
|
||||
BUILT_LIPO_FILES="`find $(EXPORT_JRE_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) 2>/dev/null`" || test $$? = "1"; \
|
||||
if [ -n "$${BUILT_LIPO_FILES}" ]; then \
|
||||
$(MKDIR) -p $(shell dirname $@); \
|
||||
lipo -create -output $@ $${BUILT_LIPO_FILES}; \
|
||||
@ -70,7 +70,7 @@ $(UNIVERSAL_LIPO_LIST):
|
||||
# - copies directories; including empty dirs
|
||||
# - copies files, symlinks, other non-directory files
|
||||
$(UNIVERSAL_COPY_LIST):
|
||||
BUILT_COPY_FILES="`find $(EXPORT_JRE_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) -prune 2>/dev/null`"; \
|
||||
BUILT_COPY_FILES="`find $(EXPORT_JRE_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) -prune 2>/dev/null`" || test $$? = "1"; \
|
||||
if [ -n "$${BUILT_COPY_FILES}" ]; then \
|
||||
for i in $${BUILT_COPY_FILES}; do \
|
||||
$(MKDIR) -p $(shell dirname $@); \
|
||||
|
@ -246,8 +246,7 @@ endif
|
||||
XSLT_CHECK = $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory
|
||||
# If not found then fail fast.
|
||||
check_j2se_version:
|
||||
$(QUIETLY) $(XSLT_CHECK) > /dev/null 2>&1; \
|
||||
if [ $$? -ne 0 ]; then \
|
||||
$(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \
|
||||
$(REMOTE) $(RUN.JAVA) -version; \
|
||||
echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
|
||||
"to bootstrap this build" 1>&2; \
|
||||
|
@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# If we're cross compiling use that path for nm
|
||||
if [ "$CROSS_COMPILE_ARCH" != "" ]; then
|
||||
NM=$ALT_COMPILER_PATH/nm
|
||||
else
|
||||
NM=nm
|
||||
fi
|
||||
|
||||
$NM --defined-only $* \
|
||||
| awk '{
|
||||
if ($3 ~ /^_ZTV/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";"
|
||||
if ($3 ~ /^UseSharedSpaces$/) print "\t" $3 ";"
|
||||
if ($3 ~ /^_ZN9Arguments17SharedArchivePathE$/) print "\t" $3 ";"
|
||||
}' \
|
||||
| sort -u
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 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
|
||||
@ -62,11 +62,6 @@ SUNWprivate_1.1 {
|
||||
JVM_DefineClassWithSourceCond;
|
||||
JVM_DesiredAssertionStatus;
|
||||
JVM_DoPrivileged;
|
||||
JVM_DTraceGetVersion;
|
||||
JVM_DTraceActivate;
|
||||
JVM_DTraceIsProbeEnabled;
|
||||
JVM_DTraceIsSupported;
|
||||
JVM_DTraceDispose;
|
||||
JVM_DumpAllStacks;
|
||||
JVM_DumpThreads;
|
||||
JVM_FillInStackTrace;
|
||||
@ -132,6 +127,7 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 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
|
||||
@ -62,11 +62,6 @@ SUNWprivate_1.1 {
|
||||
JVM_DefineClassWithSourceCond;
|
||||
JVM_DesiredAssertionStatus;
|
||||
JVM_DoPrivileged;
|
||||
JVM_DTraceGetVersion;
|
||||
JVM_DTraceActivate;
|
||||
JVM_DTraceIsProbeEnabled;
|
||||
JVM_DTraceIsSupported;
|
||||
JVM_DTraceDispose;
|
||||
JVM_DumpAllStacks;
|
||||
JVM_DumpThreads;
|
||||
JVM_FillInStackTrace;
|
||||
@ -132,6 +127,7 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 1999, 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
|
||||
@ -239,8 +239,14 @@ mapfile_reorder : mapfile $(REORDERFILE)
|
||||
rm -f $@
|
||||
cat $^ > $@
|
||||
|
||||
VMDEF_PAT = ^_ZTV
|
||||
VMDEF_PAT := ^gHotSpotVM|$(VMDEF_PAT)
|
||||
VMDEF_PAT := ^UseSharedSpaces$$|$(VMDEF_PAT)
|
||||
VMDEF_PAT := ^_ZN9Arguments17SharedArchivePathE$$|$(VMDEF_PAT)
|
||||
|
||||
vm.def: $(Res_Files) $(Obj_Files)
|
||||
sh $(GAMMADIR)/make/linux/makefiles/build_vm_def.sh *.o > $@
|
||||
$(QUIETLY) $(NM) --defined-only $(Obj_Files) | sort -k3 -u | \
|
||||
awk '$$3 ~ /$(VMDEF_PAT)/ { print "\t" $$3 ";" }' > $@
|
||||
|
||||
mapfile_ext:
|
||||
rm -f $@
|
||||
@ -334,10 +340,8 @@ $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
|
||||
rm -f $@.1; ln -s $@ $@.1; \
|
||||
if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then \
|
||||
if [ -x /usr/sbin/selinuxenabled ] ; then \
|
||||
/usr/sbin/selinuxenabled; \
|
||||
if [ $$? = 0 ] ; then \
|
||||
/usr/bin/chcon -t textrel_shlib_t $@; \
|
||||
if [ $$? != 0 ]; then \
|
||||
if /usr/sbin/selinuxenabled; then \
|
||||
if ! /usr/bin/chcon -t textrel_shlib_t $@; then \
|
||||
echo "ERROR: Cannot chcon $@"; \
|
||||
fi \
|
||||
fi \
|
||||
|
@ -39,6 +39,7 @@ $(AGENT_SRC_DIR)/sun/jvm/hotspot/asm/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/asm/sparc/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/c1/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/ci/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/classfile/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/code/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/compiler/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/*.java \
|
||||
@ -49,8 +50,10 @@ $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/x86/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/dummy/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/ia64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/amd64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/ia64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/ppc64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/x86/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/sparc/*.java \
|
||||
@ -71,6 +74,7 @@ $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/sparc/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/win32/coff/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/amd64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/ia64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/x86/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windows/x86/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windows/amd64/*.java \
|
||||
@ -101,6 +105,8 @@ $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/solaris_sparc/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/solaris_x86/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/sparc/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/x86/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/win32_amd64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/win32_x86/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/ppc64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/tools/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/tools/jcore/*.java \
|
||||
|
@ -190,8 +190,7 @@ endif
|
||||
XSLT_CHECK = $(RUN.JAVAP) javax.xml.transform.TransformerFactory
|
||||
# If not found then fail fast.
|
||||
check_j2se_version:
|
||||
$(QUIETLY) $(XSLT_CHECK) > /dev/null 2>&1; \
|
||||
if [ $$? -ne 0 ]; then \
|
||||
$(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \
|
||||
$(RUN.JAVA) -version; \
|
||||
echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
|
||||
"to bootstrap this build" 1>&2; \
|
||||
|
@ -171,11 +171,11 @@ $(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).so
|
||||
./lib$(GENOFFS).so
|
||||
|
||||
CONDITIONALLY_UPDATE_JVMOFFS_TARGET = \
|
||||
cmp -s $@ $@.tmp; \
|
||||
case $$? in \
|
||||
0) rm -f $@.tmp;; \
|
||||
*) rm -f $@ && mv $@.tmp $@ && echo Updated $@;; \
|
||||
esac
|
||||
if cmp -s $@ $@.tmp; then \
|
||||
rm -f $@.tmp; \
|
||||
else \
|
||||
rm -f $@ && mv $@.tmp $@ && echo Updated $@; \
|
||||
fi
|
||||
|
||||
# $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs.
|
||||
$(JVMOFFS).h: $(GENOFFS)
|
||||
@ -336,16 +336,10 @@ $(DTRACE_JHELPER.o) : $(DTRACE_JHELPER).d $(JVMOFFS).h $(JVMOFFS)Index.h
|
||||
|
||||
.PHONY: dtraceCheck
|
||||
|
||||
SYSTEM_DTRACE_H = /usr/include/dtrace.h
|
||||
SYSTEM_DTRACE_PROG = /usr/sbin/dtrace
|
||||
PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace
|
||||
systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG})
|
||||
patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG})
|
||||
systemDtraceHdrFound := $(wildcard $(SYSTEM_DTRACE_H))
|
||||
|
||||
ifneq ("$(systemDtraceHdrFound)", "")
|
||||
CFLAGS += -DHAVE_DTRACE_H
|
||||
endif
|
||||
|
||||
ifneq ("$(patchDtraceFound)", "")
|
||||
DTRACE_PROG=$(PATCH_DTRACE_PROG)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2000, 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
|
||||
@ -62,11 +62,6 @@ SUNWprivate_1.1 {
|
||||
JVM_DefineClassWithSourceCond;
|
||||
JVM_DesiredAssertionStatus;
|
||||
JVM_DoPrivileged;
|
||||
JVM_DTraceGetVersion;
|
||||
JVM_DTraceActivate;
|
||||
JVM_DTraceIsProbeEnabled;
|
||||
JVM_DTraceIsSupported;
|
||||
JVM_DTraceDispose;
|
||||
JVM_DumpAllStacks;
|
||||
JVM_DumpThreads;
|
||||
JVM_FillInStackTrace;
|
||||
@ -132,6 +127,7 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2012, 2013 SAP AG. All rights reserved.
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2012, 2015 SAP AG. 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
|
||||
@ -284,19 +284,20 @@ class Assembler : public AbstractAssembler {
|
||||
MTCTR_OPCODE = (MTSPR_OPCODE | 9 << SPR_0_4_SHIFT),
|
||||
MFCTR_OPCODE = (MFSPR_OPCODE | 9 << SPR_0_4_SHIFT),
|
||||
|
||||
MTTFHAR_OPCODE = (MTSPR_OPCODE | 128 << SPR_0_4_SHIFT),
|
||||
MFTFHAR_OPCODE = (MFSPR_OPCODE | 128 << SPR_0_4_SHIFT),
|
||||
MTTFIAR_OPCODE = (MTSPR_OPCODE | 129 << SPR_0_4_SHIFT),
|
||||
MFTFIAR_OPCODE = (MFSPR_OPCODE | 129 << SPR_0_4_SHIFT),
|
||||
MTTEXASR_OPCODE = (MTSPR_OPCODE | 130 << SPR_0_4_SHIFT),
|
||||
MFTEXASR_OPCODE = (MFSPR_OPCODE | 130 << SPR_0_4_SHIFT),
|
||||
MTTEXASRU_OPCODE = (MTSPR_OPCODE | 131 << SPR_0_4_SHIFT),
|
||||
MFTEXASRU_OPCODE = (MFSPR_OPCODE | 131 << SPR_0_4_SHIFT),
|
||||
// Attention: Higher and lower half are inserted in reversed order.
|
||||
MTTFHAR_OPCODE = (MTSPR_OPCODE | 4 << SPR_5_9_SHIFT | 0 << SPR_0_4_SHIFT),
|
||||
MFTFHAR_OPCODE = (MFSPR_OPCODE | 4 << SPR_5_9_SHIFT | 0 << SPR_0_4_SHIFT),
|
||||
MTTFIAR_OPCODE = (MTSPR_OPCODE | 4 << SPR_5_9_SHIFT | 1 << SPR_0_4_SHIFT),
|
||||
MFTFIAR_OPCODE = (MFSPR_OPCODE | 4 << SPR_5_9_SHIFT | 1 << SPR_0_4_SHIFT),
|
||||
MTTEXASR_OPCODE = (MTSPR_OPCODE | 4 << SPR_5_9_SHIFT | 2 << SPR_0_4_SHIFT),
|
||||
MFTEXASR_OPCODE = (MFSPR_OPCODE | 4 << SPR_5_9_SHIFT | 2 << SPR_0_4_SHIFT),
|
||||
MTTEXASRU_OPCODE = (MTSPR_OPCODE | 4 << SPR_5_9_SHIFT | 3 << SPR_0_4_SHIFT),
|
||||
MFTEXASRU_OPCODE = (MFSPR_OPCODE | 4 << SPR_5_9_SHIFT | 3 << SPR_0_4_SHIFT),
|
||||
|
||||
MTVRSAVE_OPCODE = (MTSPR_OPCODE | 256 << SPR_0_4_SHIFT),
|
||||
MFVRSAVE_OPCODE = (MFSPR_OPCODE | 256 << SPR_0_4_SHIFT),
|
||||
MTVRSAVE_OPCODE = (MTSPR_OPCODE | 8 << SPR_5_9_SHIFT | 0 << SPR_0_4_SHIFT),
|
||||
MFVRSAVE_OPCODE = (MFSPR_OPCODE | 8 << SPR_5_9_SHIFT | 0 << SPR_0_4_SHIFT),
|
||||
|
||||
MFTB_OPCODE = (MFSPR_OPCODE | 268 << SPR_0_4_SHIFT),
|
||||
MFTB_OPCODE = (MFSPR_OPCODE | 8 << SPR_5_9_SHIFT | 12 << SPR_0_4_SHIFT),
|
||||
|
||||
MTCRF_OPCODE = (31u << OPCODE_SHIFT | 144u << 1),
|
||||
MFCR_OPCODE = (31u << OPCODE_SHIFT | 19u << 1),
|
||||
@ -1494,6 +1495,26 @@ class Assembler : public AbstractAssembler {
|
||||
inline void mftexasr(Register d);
|
||||
inline void mftexasru(Register d);
|
||||
|
||||
// TEXASR bit description
|
||||
enum transaction_failure_reason {
|
||||
// Upper half (TEXASRU):
|
||||
tm_failure_persistent = 7, // The failure is likely to recur on each execution.
|
||||
tm_disallowed = 8, // The instruction is not permitted.
|
||||
tm_nesting_of = 9, // The maximum transaction level was exceeded.
|
||||
tm_footprint_of = 10, // The tracking limit for transactional storage accesses was exceeded.
|
||||
tm_self_induced_cf = 11, // A self-induced conflict occurred in Suspended state.
|
||||
tm_non_trans_cf = 12, // A conflict occurred with a non-transactional access by another processor.
|
||||
tm_trans_cf = 13, // A conflict occurred with another transaction.
|
||||
tm_translation_cf = 14, // A conflict occurred with a TLB invalidation.
|
||||
tm_inst_fetch_cf = 16, // An instruction fetch was performed from a block that was previously written transactionally.
|
||||
tm_tabort = 31, // Termination was caused by the execution of an abort instruction.
|
||||
// Lower half:
|
||||
tm_suspended = 32, // Failure was recorded in Suspended state.
|
||||
tm_failure_summary = 36, // Failure has been detected and recorded.
|
||||
tm_tfiar_exact = 37, // Value in the TFIAR is exact.
|
||||
tm_rot = 38, // Rollback-only transaction.
|
||||
};
|
||||
|
||||
// PPC 1, section 2.4.1 Branch Instructions
|
||||
inline void b( address a, relocInfo::relocType rt = relocInfo::none);
|
||||
inline void b( Label& L);
|
||||
@ -1581,6 +1602,7 @@ class Assembler : public AbstractAssembler {
|
||||
inline void bnectrl(ConditionRegister crx, relocInfo::relocType rt = relocInfo::none);
|
||||
|
||||
// condition register logic instructions
|
||||
// NOTE: There's a preferred form: d and s2 should point into the same condition register.
|
||||
inline void crand( int d, int s1, int s2);
|
||||
inline void crnand(int d, int s1, int s2);
|
||||
inline void cror( int d, int s1, int s2);
|
||||
@ -1590,6 +1612,19 @@ class Assembler : public AbstractAssembler {
|
||||
inline void crandc(int d, int s1, int s2);
|
||||
inline void crorc( int d, int s1, int s2);
|
||||
|
||||
// More convenient version.
|
||||
int condition_register_bit(ConditionRegister cr, Condition c) {
|
||||
return 4 * (int)(intptr_t)cr + c;
|
||||
}
|
||||
void crand( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
|
||||
void crnand(ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
|
||||
void cror( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
|
||||
void crxor( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
|
||||
void crnor( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
|
||||
void creqv( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
|
||||
void crandc(ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
|
||||
void crorc( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc);
|
||||
|
||||
// icache and dcache related instructions
|
||||
inline void icbi( Register s1, Register s2);
|
||||
//inline void dcba(Register s1, Register s2); // Instruction for embedded processor only.
|
||||
@ -1673,6 +1708,10 @@ class Assembler : public AbstractAssembler {
|
||||
inline void smt_prio_low();
|
||||
inline void smt_prio_medium_low();
|
||||
inline void smt_prio_medium();
|
||||
// >= Power7
|
||||
inline void smt_yield();
|
||||
inline void smt_mdoio();
|
||||
inline void smt_mdoom();
|
||||
|
||||
// trap instructions
|
||||
inline void twi_0(Register a); // for load with acquire semantics use load+twi_0+isync (trap can't occur)
|
||||
@ -1958,6 +1997,7 @@ class Assembler : public AbstractAssembler {
|
||||
inline void tbeginrot_(); // R=1 Rollback-Only Transaction
|
||||
inline void tend_(); // A=0
|
||||
inline void tendall_(); // A=1
|
||||
inline void tabort_();
|
||||
inline void tabort_(Register a);
|
||||
inline void tabortwc_(int t, Register a, Register b);
|
||||
inline void tabortwci_(int t, Register a, int si);
|
||||
@ -1967,6 +2007,10 @@ class Assembler : public AbstractAssembler {
|
||||
inline void tresume_(); // tsr with L=1
|
||||
inline void tcheck(int f);
|
||||
|
||||
static bool is_tbegin(int x) {
|
||||
return TBEGIN_OPCODE == (x & (0x3f << OPCODE_SHIFT | 0x3ff << 1));
|
||||
}
|
||||
|
||||
// The following encoders use r0 as second operand. These instructions
|
||||
// read r0 as '0'.
|
||||
inline void lwzx( Register d, Register s2);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2012, 2014 SAP AG. All rights reserved.
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2012, 2015 SAP AG. 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
|
||||
@ -453,6 +453,48 @@ inline void Assembler::creqv( int d, int s1, int s2) { emit_int32(CREQV_OPCODE
|
||||
inline void Assembler::crandc(int d, int s1, int s2) { emit_int32(CRANDC_OPCODE | bt(d) | ba(s1) | bb(s2)); }
|
||||
inline void Assembler::crorc( int d, int s1, int s2) { emit_int32(CRORC_OPCODE | bt(d) | ba(s1) | bb(s2)); }
|
||||
|
||||
// More convenient version.
|
||||
inline void Assembler::crand( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
|
||||
int dst_bit = condition_register_bit(crdst, cdst),
|
||||
src_bit = condition_register_bit(crsrc, csrc);
|
||||
crand(dst_bit, src_bit, dst_bit);
|
||||
}
|
||||
inline void Assembler::crnand(ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
|
||||
int dst_bit = condition_register_bit(crdst, cdst),
|
||||
src_bit = condition_register_bit(crsrc, csrc);
|
||||
crnand(dst_bit, src_bit, dst_bit);
|
||||
}
|
||||
inline void Assembler::cror( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
|
||||
int dst_bit = condition_register_bit(crdst, cdst),
|
||||
src_bit = condition_register_bit(crsrc, csrc);
|
||||
cror(dst_bit, src_bit, dst_bit);
|
||||
}
|
||||
inline void Assembler::crxor( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
|
||||
int dst_bit = condition_register_bit(crdst, cdst),
|
||||
src_bit = condition_register_bit(crsrc, csrc);
|
||||
crxor(dst_bit, src_bit, dst_bit);
|
||||
}
|
||||
inline void Assembler::crnor( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
|
||||
int dst_bit = condition_register_bit(crdst, cdst),
|
||||
src_bit = condition_register_bit(crsrc, csrc);
|
||||
crnor(dst_bit, src_bit, dst_bit);
|
||||
}
|
||||
inline void Assembler::creqv( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
|
||||
int dst_bit = condition_register_bit(crdst, cdst),
|
||||
src_bit = condition_register_bit(crsrc, csrc);
|
||||
creqv(dst_bit, src_bit, dst_bit);
|
||||
}
|
||||
inline void Assembler::crandc(ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
|
||||
int dst_bit = condition_register_bit(crdst, cdst),
|
||||
src_bit = condition_register_bit(crsrc, csrc);
|
||||
crandc(dst_bit, src_bit, dst_bit);
|
||||
}
|
||||
inline void Assembler::crorc( ConditionRegister crdst, Condition cdst, ConditionRegister crsrc, Condition csrc) {
|
||||
int dst_bit = condition_register_bit(crdst, cdst),
|
||||
src_bit = condition_register_bit(crsrc, csrc);
|
||||
crorc(dst_bit, src_bit, dst_bit);
|
||||
}
|
||||
|
||||
// Conditional move (>= Power7)
|
||||
inline void Assembler::isel(Register d, ConditionRegister cr, Condition cc, bool inv, Register a, Register b) {
|
||||
if (b == noreg) {
|
||||
@ -516,6 +558,10 @@ inline void Assembler::smt_prio_medium_low() { Assembler::or_unchecked(R6, R6,
|
||||
inline void Assembler::smt_prio_medium() { Assembler::or_unchecked(R2, R2, R2); }
|
||||
inline void Assembler::smt_prio_medium_high() { Assembler::or_unchecked(R5, R5, R5); }
|
||||
inline void Assembler::smt_prio_high() { Assembler::or_unchecked(R3, R3, R3); }
|
||||
// >= Power7
|
||||
inline void Assembler::smt_yield() { Assembler::or_unchecked(R27, R27, R27); }
|
||||
inline void Assembler::smt_mdoio() { Assembler::or_unchecked(R29, R29, R29); }
|
||||
inline void Assembler::smt_mdoom() { Assembler::or_unchecked(R30, R30, R30); }
|
||||
|
||||
inline void Assembler::twi_0(Register a) { twi_unchecked(0, a, 0);}
|
||||
|
||||
@ -778,7 +824,8 @@ inline void Assembler::tbegin_() { emit_int32( TB
|
||||
inline void Assembler::tbeginrot_() { emit_int32( TBEGIN_OPCODE | /*R=1*/ 1u << (31-10) | rc(1)); }
|
||||
inline void Assembler::tend_() { emit_int32( TEND_OPCODE | rc(1)); }
|
||||
inline void Assembler::tendall_() { emit_int32( TEND_OPCODE | /*A=1*/ 1u << (31-6) | rc(1)); }
|
||||
inline void Assembler::tabort_(Register a) { emit_int32( TABORT_OPCODE | ra(a) | rc(1)); }
|
||||
inline void Assembler::tabort_() { emit_int32( TABORT_OPCODE | rc(1)); }
|
||||
inline void Assembler::tabort_(Register a) { assert(a != R0, "r0 not allowed"); emit_int32( TABORT_OPCODE | ra(a) | rc(1)); }
|
||||
inline void Assembler::tabortwc_(int t, Register a, Register b) { emit_int32( TABORTWC_OPCODE | to(t) | ra(a) | rb(b) | rc(1)); }
|
||||
inline void Assembler::tabortwci_(int t, Register a, int si) { emit_int32( TABORTWCI_OPCODE | to(t) | ra(a) | sh1620(si) | rc(1)); }
|
||||
inline void Assembler::tabortdc_(int t, Register a, Register b) { emit_int32( TABORTDC_OPCODE | to(t) | ra(a) | rb(b) | rc(1)); }
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2012, 2014 SAP AG. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2012, 2015 SAP AG. 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
|
||||
@ -1712,7 +1712,7 @@ void InterpreterMacroAssembler::profile_obj_type(Register obj, Register mdo_addr
|
||||
andi_(R0, klass, TypeEntries::type_unknown);
|
||||
// Already unknown. Nothing to do anymore.
|
||||
//bne(CCR0, do_nothing);
|
||||
crorc(/*CCR0 eq*/2, /*CCR1 eq*/4+2, /*CCR0 eq*/2); // cr0 eq = cr1 eq or cr0 ne
|
||||
crorc(CCR0, Assembler::equal, CCR1, Assembler::equal); // cr0 eq = cr1 eq or cr0 ne
|
||||
beq(CCR0, do_nothing);
|
||||
|
||||
clrrdi_(R0, tmp, exact_log2(-TypeEntries::type_mask));
|
||||
@ -1826,9 +1826,9 @@ void InterpreterMacroAssembler::profile_return_type(Register ret, Register tmp1,
|
||||
lbz(tmp2, Method::intrinsic_id_offset_in_bytes(), R19_method);
|
||||
cmpwi(CCR0, tmp1, Bytecodes::_invokedynamic);
|
||||
cmpwi(CCR1, tmp1, Bytecodes::_invokehandle);
|
||||
cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
|
||||
cror(CCR0, Assembler::equal, CCR1, Assembler::equal);
|
||||
cmpwi(CCR1, tmp2, vmIntrinsics::_compiledLambdaForm);
|
||||
cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
|
||||
cror(CCR0, Assembler::equal, CCR1, Assembler::equal);
|
||||
bne(CCR0, profile_continue);
|
||||
}
|
||||
|
||||
|
@ -567,16 +567,21 @@ class MacroAssembler: public Assembler {
|
||||
inline void load_with_trap_null_check(Register d, int si16, Register s1);
|
||||
|
||||
// Load heap oop and decompress. Loaded oop may not be null.
|
||||
inline void load_heap_oop_not_null(Register d, RegisterOrConstant offs, Register s1 = noreg);
|
||||
// Specify tmp to save one cycle.
|
||||
inline void load_heap_oop_not_null(Register d, RegisterOrConstant offs, Register s1 = noreg,
|
||||
Register tmp = noreg);
|
||||
// Store heap oop and decompress. Decompressed oop may not be null.
|
||||
// Specify tmp register if d should not be changed.
|
||||
inline void store_heap_oop_not_null(Register d, RegisterOrConstant offs, Register s1,
|
||||
/*specify if d must stay uncompressed*/ Register tmp = noreg);
|
||||
Register tmp = noreg);
|
||||
|
||||
// Null allowed.
|
||||
inline void load_heap_oop(Register d, RegisterOrConstant offs, Register s1 = noreg);
|
||||
|
||||
// Encode/decode heap oop. Oop may not be null, else en/decoding goes wrong.
|
||||
// src == d allowed.
|
||||
inline Register encode_heap_oop_not_null(Register d, Register src = noreg);
|
||||
inline void decode_heap_oop_not_null(Register d);
|
||||
inline Register decode_heap_oop_not_null(Register d, Register src = noreg);
|
||||
|
||||
// Null allowed.
|
||||
inline void decode_heap_oop(Register d);
|
||||
|
@ -311,11 +311,14 @@ inline void MacroAssembler::load_with_trap_null_check(Register d, int si16, Regi
|
||||
ld(d, si16, s1);
|
||||
}
|
||||
|
||||
inline void MacroAssembler::load_heap_oop_not_null(Register d, RegisterOrConstant offs, Register s1) {
|
||||
inline void MacroAssembler::load_heap_oop_not_null(Register d, RegisterOrConstant offs, Register s1, Register tmp) {
|
||||
if (UseCompressedOops) {
|
||||
lwz(d, offs, s1);
|
||||
// In disjoint mode decoding can save a cycle if src != dst.
|
||||
Register narrowOop = (tmp != noreg && Universe::narrow_oop_base_disjoint()) ? tmp : d;
|
||||
lwz(narrowOop, offs, s1);
|
||||
// Attention: no null check here!
|
||||
decode_heap_oop_not_null(d);
|
||||
Register res = decode_heap_oop_not_null(d, narrowOop);
|
||||
assert(res == d, "caller will not consume loaded value");
|
||||
} else {
|
||||
ld(d, offs, s1);
|
||||
}
|
||||
@ -340,26 +343,36 @@ inline void MacroAssembler::load_heap_oop(Register d, RegisterOrConstant offs, R
|
||||
}
|
||||
|
||||
inline Register MacroAssembler::encode_heap_oop_not_null(Register d, Register src) {
|
||||
Register current = (src!=noreg) ? src : d; // Compressed oop is in d if no src provided.
|
||||
if (Universe::narrow_oop_base() != NULL) {
|
||||
Register current = (src != noreg) ? src : d; // Oop to be compressed is in d if no src provided.
|
||||
if (Universe::narrow_oop_base_overlaps()) {
|
||||
sub(d, current, R30);
|
||||
current = d;
|
||||
}
|
||||
if (Universe::narrow_oop_shift() != 0) {
|
||||
srdi(d, current, LogMinObjAlignmentInBytes);
|
||||
rldicl(d, current, 64-Universe::narrow_oop_shift(), 32); // Clears the upper bits.
|
||||
current = d;
|
||||
}
|
||||
return current; // Encoded oop is in this register.
|
||||
}
|
||||
|
||||
inline void MacroAssembler::decode_heap_oop_not_null(Register d) {
|
||||
inline Register MacroAssembler::decode_heap_oop_not_null(Register d, Register src) {
|
||||
if (Universe::narrow_oop_base_disjoint() && src != noreg && src != d &&
|
||||
Universe::narrow_oop_shift() != 0) {
|
||||
mr(d, R30);
|
||||
rldimi(d, src, Universe::narrow_oop_shift(), 32-Universe::narrow_oop_shift());
|
||||
return d;
|
||||
}
|
||||
|
||||
Register current = (src != noreg) ? src : d; // Compressed oop is in d if no src provided.
|
||||
if (Universe::narrow_oop_shift() != 0) {
|
||||
assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
|
||||
sldi(d, d, LogMinObjAlignmentInBytes);
|
||||
sldi(d, current, Universe::narrow_oop_shift());
|
||||
current = d;
|
||||
}
|
||||
if (Universe::narrow_oop_base() != NULL) {
|
||||
add(d, d, R30);
|
||||
add(d, current, R30);
|
||||
current = d;
|
||||
}
|
||||
return current; // Decoded oop is in this register.
|
||||
}
|
||||
|
||||
inline void MacroAssembler::decode_heap_oop(Register d) {
|
||||
@ -368,13 +381,7 @@ inline void MacroAssembler::decode_heap_oop(Register d) {
|
||||
cmpwi(CCR0, d, 0);
|
||||
beq(CCR0, isNull);
|
||||
}
|
||||
if (Universe::narrow_oop_shift() != 0) {
|
||||
assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
|
||||
sldi(d, d, LogMinObjAlignmentInBytes);
|
||||
}
|
||||
if (Universe::narrow_oop_base() != NULL) {
|
||||
add(d, d, R30);
|
||||
}
|
||||
decode_heap_oop_not_null(d);
|
||||
bind(isNull);
|
||||
}
|
||||
|
||||
|
@ -172,15 +172,15 @@ void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
|
||||
|
||||
// Load the invoker, as MH -> MH.form -> LF.vmentry
|
||||
__ verify_oop(recv);
|
||||
__ load_heap_oop_not_null(method_temp, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes()), recv);
|
||||
__ load_heap_oop_not_null(method_temp, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes()), recv, temp2);
|
||||
__ verify_oop(method_temp);
|
||||
__ load_heap_oop_not_null(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes()), method_temp);
|
||||
__ load_heap_oop_not_null(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes()), method_temp, temp2);
|
||||
__ verify_oop(method_temp);
|
||||
// the following assumes that a Method* is normally compressed in the vmtarget field:
|
||||
// The following assumes that a Method* is normally compressed in the vmtarget field:
|
||||
__ ld(method_temp, NONZERO(java_lang_invoke_MemberName::vmtarget_offset_in_bytes()), method_temp);
|
||||
|
||||
if (VerifyMethodHandles && !for_compiler_entry) {
|
||||
// make sure recv is already on stack
|
||||
// Make sure recv is already on stack.
|
||||
__ ld(temp2, in_bytes(Method::const_offset()), method_temp);
|
||||
__ load_sized_value(temp2, in_bytes(ConstMethod::size_of_parameters_offset()), temp2,
|
||||
sizeof(u2), /*is_signed*/ false);
|
||||
@ -259,8 +259,9 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler*
|
||||
}
|
||||
|
||||
if (TraceMethodHandles) {
|
||||
if (tmp_mh != noreg)
|
||||
if (tmp_mh != noreg) {
|
||||
__ mr(R23_method_handle, tmp_mh); // make stub happy
|
||||
}
|
||||
trace_method_handle_interpreter_entry(_masm, iid);
|
||||
}
|
||||
|
||||
@ -332,7 +333,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
|
||||
if (VerifyMethodHandles && iid != vmIntrinsics::_linkToInterface) {
|
||||
Label L_ok;
|
||||
Register temp2_defc = temp2;
|
||||
__ load_heap_oop_not_null(temp2_defc, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()), member_reg);
|
||||
__ load_heap_oop_not_null(temp2_defc, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()), member_reg, temp3);
|
||||
load_klass_from_Class(_masm, temp2_defc, temp3, temp4);
|
||||
__ verify_klass_ptr(temp2_defc);
|
||||
__ check_klass_subtype(temp1_recv_klass, temp2_defc, temp3, temp4, L_ok);
|
||||
@ -407,7 +408,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
|
||||
}
|
||||
|
||||
Register temp2_intf = temp2;
|
||||
__ load_heap_oop_not_null(temp2_intf, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()), member_reg);
|
||||
__ load_heap_oop_not_null(temp2_intf, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()), member_reg, temp3);
|
||||
load_klass_from_Class(_masm, temp2_intf, temp3, temp4);
|
||||
__ verify_klass_ptr(temp2_intf);
|
||||
|
||||
@ -464,7 +465,7 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
strstr(adaptername, "linkTo") == NULL); // static linkers don't have MH
|
||||
const char* mh_reg_name = has_mh ? "R23_method_handle" : "G23";
|
||||
tty->print_cr("MH %s %s="INTPTR_FORMAT " sp=" INTPTR_FORMAT,
|
||||
adaptername, mh_reg_name, (intptr_t) mh, (intptr_t) entry_sp);
|
||||
adaptername, mh_reg_name, (intptr_t) mh, entry_sp);
|
||||
|
||||
if (Verbose) {
|
||||
tty->print_cr("Registers:");
|
||||
@ -535,23 +536,22 @@ void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adapt
|
||||
|
||||
BLOCK_COMMENT("trace_method_handle {");
|
||||
|
||||
int nbytes_save = 10 * 8; // 10 volatile gprs
|
||||
__ save_LR_CR(R0);
|
||||
__ mr(R0, R1_SP); // saved_sp
|
||||
assert(Assembler::is_simm(-nbytes_save, 16), "Overwriting R0");
|
||||
// Push_frame_reg_args only uses R0 if nbytes_save is wider than 16 bit.
|
||||
__ push_frame_reg_args(nbytes_save, R0);
|
||||
__ save_volatile_gprs(R1_SP, frame::abi_reg_args_size); // Except R0.
|
||||
const Register tmp = R11; // Will be preserved.
|
||||
const int nbytes_save = 11*8; // volatile gprs except R0
|
||||
__ save_volatile_gprs(R1_SP, -nbytes_save); // except R0
|
||||
__ save_LR_CR(tmp); // save in old frame
|
||||
|
||||
__ load_const(R3_ARG1, (address)adaptername);
|
||||
__ mr(R5_ARG3, R1_SP); // saved_sp
|
||||
__ push_frame_reg_args(nbytes_save, tmp);
|
||||
|
||||
__ load_const_optimized(R3_ARG1, (address)adaptername, tmp);
|
||||
__ mr(R4_ARG2, R23_method_handle);
|
||||
__ mr(R5_ARG3, R0); // saved_sp
|
||||
__ mr(R6_ARG4, R1_SP);
|
||||
__ call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub));
|
||||
|
||||
__ restore_volatile_gprs(R1_SP, 112); // Except R0.
|
||||
__ pop_frame();
|
||||
__ restore_LR_CR(R0);
|
||||
__ restore_LR_CR(tmp);
|
||||
__ restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
|
||||
|
||||
BLOCK_COMMENT("} trace_method_handle");
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
// Copyright 2012, 2014 SAP AG. All rights reserved.
|
||||
// Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
// Copyright 2012, 2015 SAP AG. 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
|
||||
@ -2698,7 +2698,7 @@ encode %{
|
||||
const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
|
||||
__ relocate(a.rspec());
|
||||
} else if (constant_reloc == relocInfo::metadata_type) {
|
||||
AddressLiteral a = __ allocate_metadata_address((Metadata *)val);
|
||||
AddressLiteral a = __ constant_metadata_address((Metadata *)val);
|
||||
const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
|
||||
__ relocate(a.rspec());
|
||||
} else {
|
||||
@ -2727,7 +2727,7 @@ encode %{
|
||||
const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
|
||||
__ relocate(a.rspec());
|
||||
} else if (constant_reloc == relocInfo::metadata_type) {
|
||||
AddressLiteral a = __ allocate_metadata_address((Metadata *)val);
|
||||
AddressLiteral a = __ constant_metadata_address((Metadata *)val);
|
||||
const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
|
||||
__ relocate(a.rspec());
|
||||
} else { // non-oop pointers, e.g. card mark base, heap top
|
||||
@ -6029,6 +6029,20 @@ instruct clearMs32b(iRegNdst dst, iRegNsrc src) %{
|
||||
ins_pipe(pipe_class_default);
|
||||
%}
|
||||
|
||||
// Optimize DecodeN for disjoint base.
|
||||
// Load base of compressed oops into a register
|
||||
instruct loadBase(iRegLdst dst) %{
|
||||
effect(DEF dst);
|
||||
|
||||
format %{ "MR $dst, r30_heapbase" %}
|
||||
size(4);
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_or);
|
||||
__ mr($dst$$Register, R30);
|
||||
%}
|
||||
ins_pipe(pipe_class_default);
|
||||
%}
|
||||
|
||||
// Loading ConN must be postalloc expanded so that edges between
|
||||
// the nodes are safe. They may not interfere with a safepoint.
|
||||
// GL TODO: This needs three instructions: better put this into the constant pool.
|
||||
@ -6351,58 +6365,6 @@ instruct loadConD_Ex(regD dst, immD src) %{
|
||||
// Prefetch instructions.
|
||||
// Must be safe to execute with invalid address (cannot fault).
|
||||
|
||||
instruct prefetchr(indirectMemory mem, iRegLsrc src) %{
|
||||
match(PrefetchRead (AddP mem src));
|
||||
ins_cost(MEMORY_REF_COST);
|
||||
|
||||
format %{ "PREFETCH $mem, 0, $src \t// Prefetch read-many" %}
|
||||
size(4);
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_dcbt);
|
||||
__ dcbt($src$$Register, $mem$$base$$Register);
|
||||
%}
|
||||
ins_pipe(pipe_class_memory);
|
||||
%}
|
||||
|
||||
instruct prefetchr_no_offset(indirectMemory mem) %{
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(MEMORY_REF_COST);
|
||||
|
||||
format %{ "PREFETCH $mem" %}
|
||||
size(4);
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_dcbt);
|
||||
__ dcbt($mem$$base$$Register);
|
||||
%}
|
||||
ins_pipe(pipe_class_memory);
|
||||
%}
|
||||
|
||||
instruct prefetchw(indirectMemory mem, iRegLsrc src) %{
|
||||
match(PrefetchWrite (AddP mem src));
|
||||
ins_cost(MEMORY_REF_COST);
|
||||
|
||||
format %{ "PREFETCH $mem, 2, $src \t// Prefetch write-many (and read)" %}
|
||||
size(4);
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_dcbtst);
|
||||
__ dcbtst($src$$Register, $mem$$base$$Register);
|
||||
%}
|
||||
ins_pipe(pipe_class_memory);
|
||||
%}
|
||||
|
||||
instruct prefetchw_no_offset(indirectMemory mem) %{
|
||||
match(PrefetchWrite mem);
|
||||
ins_cost(MEMORY_REF_COST);
|
||||
|
||||
format %{ "PREFETCH $mem" %}
|
||||
size(4);
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_dcbtst);
|
||||
__ dcbtst($mem$$base$$Register);
|
||||
%}
|
||||
ins_pipe(pipe_class_memory);
|
||||
%}
|
||||
|
||||
// Special prefetch versions which use the dcbz instruction.
|
||||
instruct prefetch_alloc_zero(indirectMemory mem, iRegLsrc src) %{
|
||||
match(PrefetchAllocation (AddP mem src));
|
||||
@ -6724,13 +6686,12 @@ instruct cond_set_0_oop(iRegNdst dst, flagsReg crx, iRegPsrc src1) %{
|
||||
ins_pipe(pipe_class_default);
|
||||
%}
|
||||
|
||||
// base != 0
|
||||
// 32G aligned narrow oop base.
|
||||
instruct encodeP_32GAligned(iRegNdst dst, iRegPsrc src) %{
|
||||
// Disjoint narrow oop base.
|
||||
instruct encodeP_Disjoint(iRegNdst dst, iRegPsrc src) %{
|
||||
match(Set dst (EncodeP src));
|
||||
predicate(false /* TODO: PPC port Universe::narrow_oop_base_disjoint()*/);
|
||||
predicate(Universe::narrow_oop_base_disjoint());
|
||||
|
||||
format %{ "EXTRDI $dst, $src, #32, #3 \t// encode with 32G aligned base" %}
|
||||
format %{ "EXTRDI $dst, $src, #32, #3 \t// encode with disjoint base" %}
|
||||
size(4);
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_rldicl);
|
||||
@ -6745,7 +6706,7 @@ instruct encodeP_Ex(iRegNdst dst, flagsReg crx, iRegPsrc src) %{
|
||||
effect(TEMP crx);
|
||||
predicate(n->bottom_type()->make_ptr()->ptr() != TypePtr::NotNull &&
|
||||
Universe::narrow_oop_shift() != 0 &&
|
||||
true /* TODO: PPC port Universe::narrow_oop_base_overlaps()*/);
|
||||
Universe::narrow_oop_base_overlaps());
|
||||
|
||||
format %{ "EncodeP $dst, $crx, $src \t// postalloc expanded" %}
|
||||
postalloc_expand( postalloc_expand_encode_oop(dst, src, crx));
|
||||
@ -6756,7 +6717,7 @@ instruct encodeP_not_null_Ex(iRegNdst dst, iRegPsrc src) %{
|
||||
match(Set dst (EncodeP src));
|
||||
predicate(n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull &&
|
||||
Universe::narrow_oop_shift() != 0 &&
|
||||
true /* TODO: PPC port Universe::narrow_oop_base_overlaps()*/);
|
||||
Universe::narrow_oop_base_overlaps());
|
||||
|
||||
format %{ "EncodeP $dst, $src\t// $src != Null, postalloc expanded" %}
|
||||
postalloc_expand( postalloc_expand_encode_oop_not_null(dst, src) );
|
||||
@ -6876,6 +6837,7 @@ instruct decodeN_Ex(iRegPdst dst, iRegNsrc src, flagsReg crx) %{
|
||||
n->bottom_type()->is_oopptr()->ptr() != TypePtr::Constant) &&
|
||||
Universe::narrow_oop_shift() != 0 &&
|
||||
Universe::narrow_oop_base() != 0);
|
||||
ins_cost(4 * DEFAULT_COST); // Should be more expensive than decodeN_Disjoint_isel_Ex.
|
||||
effect(TEMP crx);
|
||||
|
||||
format %{ "DecodeN $dst, $src \t// Kills $crx, postalloc expanded" %}
|
||||
@ -6897,6 +6859,106 @@ instruct decodeN_nullBase(iRegPdst dst, iRegNsrc src) %{
|
||||
ins_pipe(pipe_class_default);
|
||||
%}
|
||||
|
||||
// Optimize DecodeN for disjoint base.
|
||||
// Shift narrow oop and or it into register that already contains the heap base.
|
||||
// Base == dst must hold, and is assured by construction in postaloc_expand.
|
||||
instruct decodeN_mergeDisjoint(iRegPdst dst, iRegNsrc src, iRegLsrc base) %{
|
||||
match(Set dst (DecodeN src));
|
||||
effect(TEMP base);
|
||||
predicate(false);
|
||||
|
||||
format %{ "RLDIMI $dst, $src, shift, 32-shift \t// DecodeN (disjoint base)" %}
|
||||
size(4);
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_rldimi);
|
||||
__ rldimi($dst$$Register, $src$$Register, Universe::narrow_oop_shift(), 32-Universe::narrow_oop_shift());
|
||||
%}
|
||||
ins_pipe(pipe_class_default);
|
||||
%}
|
||||
|
||||
// Optimize DecodeN for disjoint base.
|
||||
// This node requires only one cycle on the critical path.
|
||||
// We must postalloc_expand as we can not express use_def effects where
|
||||
// the used register is L and the def'ed register P.
|
||||
instruct decodeN_Disjoint_notNull_Ex(iRegPdst dst, iRegNsrc src) %{
|
||||
match(Set dst (DecodeN src));
|
||||
effect(TEMP_DEF dst);
|
||||
predicate((n->bottom_type()->is_oopptr()->ptr() == TypePtr::NotNull ||
|
||||
n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) &&
|
||||
Universe::narrow_oop_base_disjoint());
|
||||
ins_cost(DEFAULT_COST);
|
||||
|
||||
format %{ "MOV $dst, R30 \t\n"
|
||||
"RLDIMI $dst, $src, shift, 32-shift \t// decode with disjoint base" %}
|
||||
postalloc_expand %{
|
||||
loadBaseNode *n1 = new loadBaseNode();
|
||||
n1->add_req(NULL);
|
||||
n1->_opnds[0] = op_dst;
|
||||
|
||||
decodeN_mergeDisjointNode *n2 = new decodeN_mergeDisjointNode();
|
||||
n2->add_req(n_region, n_src, n1);
|
||||
n2->_opnds[0] = op_dst;
|
||||
n2->_opnds[1] = op_src;
|
||||
n2->_opnds[2] = op_dst;
|
||||
n2->_bottom_type = _bottom_type;
|
||||
|
||||
ra_->set_pair(n1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
|
||||
ra_->set_pair(n2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
|
||||
|
||||
nodes->push(n1);
|
||||
nodes->push(n2);
|
||||
%}
|
||||
%}
|
||||
|
||||
instruct decodeN_Disjoint_isel_Ex(iRegPdst dst, iRegNsrc src, flagsReg crx) %{
|
||||
match(Set dst (DecodeN src));
|
||||
effect(TEMP_DEF dst, TEMP crx);
|
||||
predicate((n->bottom_type()->is_oopptr()->ptr() != TypePtr::NotNull &&
|
||||
n->bottom_type()->is_oopptr()->ptr() != TypePtr::Constant) &&
|
||||
Universe::narrow_oop_base_disjoint() && VM_Version::has_isel());
|
||||
ins_cost(3 * DEFAULT_COST);
|
||||
|
||||
format %{ "DecodeN $dst, $src \t// decode with disjoint base using isel" %}
|
||||
postalloc_expand %{
|
||||
loadBaseNode *n1 = new loadBaseNode();
|
||||
n1->add_req(NULL);
|
||||
n1->_opnds[0] = op_dst;
|
||||
|
||||
cmpN_reg_imm0Node *n_compare = new cmpN_reg_imm0Node();
|
||||
n_compare->add_req(n_region, n_src);
|
||||
n_compare->_opnds[0] = op_crx;
|
||||
n_compare->_opnds[1] = op_src;
|
||||
n_compare->_opnds[2] = new immN_0Oper(TypeNarrowOop::NULL_PTR);
|
||||
|
||||
decodeN_mergeDisjointNode *n2 = new decodeN_mergeDisjointNode();
|
||||
n2->add_req(n_region, n_src, n1);
|
||||
n2->_opnds[0] = op_dst;
|
||||
n2->_opnds[1] = op_src;
|
||||
n2->_opnds[2] = op_dst;
|
||||
n2->_bottom_type = _bottom_type;
|
||||
|
||||
cond_set_0_ptrNode *n_cond_set = new cond_set_0_ptrNode();
|
||||
n_cond_set->add_req(n_region, n_compare, n2);
|
||||
n_cond_set->_opnds[0] = op_dst;
|
||||
n_cond_set->_opnds[1] = op_crx;
|
||||
n_cond_set->_opnds[2] = op_dst;
|
||||
n_cond_set->_bottom_type = _bottom_type;
|
||||
|
||||
assert(ra_->is_oop(this) == true, "A decodeN node must produce an oop!");
|
||||
ra_->set_oop(n_cond_set, true);
|
||||
|
||||
ra_->set_pair(n1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
|
||||
ra_->set_pair(n_compare->_idx, ra_->get_reg_second(n_crx), ra_->get_reg_first(n_crx));
|
||||
ra_->set_pair(n2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
|
||||
ra_->set_pair(n_cond_set->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
|
||||
|
||||
nodes->push(n1);
|
||||
nodes->push(n_compare);
|
||||
nodes->push(n2);
|
||||
nodes->push(n_cond_set);
|
||||
%}
|
||||
%}
|
||||
|
||||
// src != 0, shift != 0, base != 0
|
||||
instruct decodeN_notNull_addBase_Ex(iRegPdst dst, iRegNsrc src) %{
|
||||
match(Set dst (DecodeN src));
|
||||
@ -6904,6 +6966,7 @@ instruct decodeN_notNull_addBase_Ex(iRegPdst dst, iRegNsrc src) %{
|
||||
n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) &&
|
||||
Universe::narrow_oop_shift() != 0 &&
|
||||
Universe::narrow_oop_base() != 0);
|
||||
ins_cost(2 * DEFAULT_COST);
|
||||
|
||||
format %{ "DecodeN $dst, $src \t// $src != NULL, postalloc expanded" %}
|
||||
postalloc_expand( postalloc_expand_decode_oop_not_null(dst, src));
|
||||
@ -6973,13 +7036,12 @@ instruct encodePKlass_sub_base(iRegPdst dst, iRegLsrc base, iRegPdst src) %{
|
||||
ins_pipe(pipe_class_default);
|
||||
%}
|
||||
|
||||
// base != 0
|
||||
// 32G aligned narrow oop base.
|
||||
instruct encodePKlass_32GAligned(iRegNdst dst, iRegPsrc src) %{
|
||||
// Disjoint narrow oop base.
|
||||
instruct encodePKlass_Disjoint(iRegNdst dst, iRegPsrc src) %{
|
||||
match(Set dst (EncodePKlass src));
|
||||
predicate(false /* TODO: PPC port Universe::narrow_klass_base_disjoint()*/);
|
||||
|
||||
format %{ "EXTRDI $dst, $src, #32, #3 \t// encode with 32G aligned base" %}
|
||||
format %{ "EXTRDI $dst, $src, #32, #3 \t// encode with disjoint base" %}
|
||||
size(4);
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_rldicl);
|
||||
@ -7486,7 +7548,7 @@ instruct storeLConditional_regP_regL_regL(flagsReg crx, indirect mem_ptr, iRegLs
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_compound);
|
||||
__ cmpxchgd($crx$$CondRegister, R0, $oldVal$$Register, $newVal$$Register, $mem_ptr$$Register,
|
||||
MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(),
|
||||
MacroAssembler::MemBarAcq, MacroAssembler::cmpxchgx_hint_atomic_update(),
|
||||
noreg, NULL, true);
|
||||
%}
|
||||
ins_pipe(pipe_class_default);
|
||||
@ -10476,7 +10538,7 @@ instruct cmpN_reg_reg(flagsReg crx, iRegNsrc src1, iRegNsrc src2) %{
|
||||
match(Set crx (CmpN src1 src2));
|
||||
|
||||
size(4);
|
||||
ins_cost(DEFAULT_COST);
|
||||
ins_cost(2);
|
||||
format %{ "CMPLW $crx, $src1, $src2 \t// compressed ptr" %}
|
||||
ins_encode %{
|
||||
// TODO: PPC port $archOpcode(ppc64Opcode_cmpl);
|
||||
@ -10488,7 +10550,7 @@ instruct cmpN_reg_reg(flagsReg crx, iRegNsrc src1, iRegNsrc src2) %{
|
||||
instruct cmpN_reg_imm0(flagsReg crx, iRegNsrc src1, immN_0 src2) %{
|
||||
match(Set crx (CmpN src1 src2));
|
||||
// Make this more expensive than zeroCheckN_iReg_imm0.
|
||||
ins_cost(DEFAULT_COST);
|
||||
ins_cost(2);
|
||||
|
||||
format %{ "CMPLWI $crx, $src1, $src2 \t// compressed ptr" %}
|
||||
size(4);
|
||||
@ -10508,6 +10570,7 @@ instruct zeroCheckP_reg_imm0(cmpOp cmp, iRegP_N2P value, immP_0 zero, label labl
|
||||
_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne &&
|
||||
_leaf->as_If()->_prob >= PROB_LIKELY_MAG(4) &&
|
||||
Matcher::branches_to_uncommon_trap(_leaf));
|
||||
ins_cost(1); // Should not be cheaper than zeroCheckN.
|
||||
|
||||
ins_is_TrapBasedCheckNode(true);
|
||||
|
||||
@ -10889,7 +10952,7 @@ instruct branchLoopEndSched(cmpOp cmp, flagsReg crx, label labl) %{
|
||||
instruct partialSubtypeCheck(iRegPdst result, iRegP_N2P subklass, iRegP_N2P superklass,
|
||||
iRegPdst tmp_klass, iRegPdst tmp_arrayptr) %{
|
||||
match(Set result (PartialSubtypeCheck subklass superklass));
|
||||
effect(TEMP result, TEMP tmp_klass, TEMP tmp_arrayptr);
|
||||
effect(TEMP_DEF result, TEMP tmp_klass, TEMP tmp_arrayptr);
|
||||
ins_cost(DEFAULT_COST*10);
|
||||
|
||||
format %{ "PartialSubtypeCheck $result = ($subklass instanceOf $superklass) tmp: $tmp_klass, $tmp_arrayptr" %}
|
||||
@ -11000,7 +11063,7 @@ instruct string_indexOf_imm1_char(iRegIdst result, iRegPsrc haystack, iRegIsrc h
|
||||
predicate(SpecialStringIndexOf); // type check implicit by parameter type, See Matcher::match_rule_supported
|
||||
match(Set result (StrIndexOf (Binary haystack haycnt) (Binary (AddP needleImm offsetImm) needlecntImm)));
|
||||
|
||||
effect(TEMP result, TEMP tmp1, TEMP tmp2, KILL cr0, KILL cr1);
|
||||
effect(TEMP_DEF result, TEMP tmp1, TEMP tmp2, KILL cr0, KILL cr1);
|
||||
|
||||
ins_cost(150);
|
||||
format %{ "String IndexOf CSCL1 $haystack[0..$haycnt], $needleImm+$offsetImm[0..$needlecntImm]"
|
||||
@ -11037,7 +11100,7 @@ instruct string_indexOf_imm1(iRegIdst result, iRegPsrc haystack, iRegIsrc haycnt
|
||||
iRegIdst tmp1, iRegIdst tmp2,
|
||||
flagsRegCR0 cr0, flagsRegCR1 cr1) %{
|
||||
match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecntImm)));
|
||||
effect(USE_KILL needle, /* TDEF needle, */ TEMP result,
|
||||
effect(USE_KILL needle, /* TDEF needle, */ TEMP_DEF result,
|
||||
TEMP tmp1, TEMP tmp2);
|
||||
// Required for EA: check if it is still a type_array.
|
||||
predicate(SpecialStringIndexOf && n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop() &&
|
||||
@ -11084,7 +11147,7 @@ instruct string_indexOf_imm(iRegIdst result, iRegPsrc haystack, rscratch1RegI ha
|
||||
iRegIdst tmp1, iRegIdst tmp2, iRegIdst tmp3, iRegIdst tmp4, iRegIdst tmp5,
|
||||
flagsRegCR0 cr0, flagsRegCR1 cr1, flagsRegCR6 cr6) %{
|
||||
match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecntImm)));
|
||||
effect(USE_KILL haycnt, /* better: TDEF haycnt, */ TEMP result,
|
||||
effect(USE_KILL haycnt, /* better: TDEF haycnt, */ TEMP_DEF result,
|
||||
TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, TEMP tmp5, KILL cr0, KILL cr1, KILL cr6);
|
||||
// Required for EA: check if it is still a type_array.
|
||||
predicate(SpecialStringIndexOf && n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop() &&
|
||||
@ -11118,7 +11181,7 @@ instruct string_indexOf(iRegIdst result, iRegPsrc haystack, rscratch1RegI haycnt
|
||||
flagsRegCR0 cr0, flagsRegCR1 cr1, flagsRegCR6 cr6) %{
|
||||
match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecnt)));
|
||||
effect(USE_KILL haycnt, USE_KILL needlecnt, /*better: TDEF haycnt, TDEF needlecnt,*/
|
||||
TEMP result,
|
||||
TEMP_DEF result,
|
||||
TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, KILL cr0, KILL cr1, KILL cr6);
|
||||
predicate(SpecialStringIndexOf); // See Matcher::match_rule_supported.
|
||||
ins_cost(300);
|
||||
@ -11142,7 +11205,7 @@ instruct string_equals_imm(iRegPsrc str1, iRegPsrc str2, uimmI15 cntImm, iRegIds
|
||||
iRegPdst tmp1, iRegPdst tmp2,
|
||||
flagsRegCR0 cr0, flagsRegCR6 cr6, regCTR ctr) %{
|
||||
match(Set result (StrEquals (Binary str1 str2) cntImm));
|
||||
effect(TEMP result, TEMP tmp1, TEMP tmp2,
|
||||
effect(TEMP_DEF result, TEMP tmp1, TEMP tmp2,
|
||||
KILL cr0, KILL cr6, KILL ctr);
|
||||
predicate(SpecialStringEquals); // See Matcher::match_rule_supported.
|
||||
ins_cost(250);
|
||||
@ -11165,7 +11228,7 @@ instruct string_equals(iRegPsrc str1, iRegPsrc str2, iRegIsrc cnt, iRegIdst resu
|
||||
iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3, iRegPdst tmp4, iRegPdst tmp5,
|
||||
flagsRegCR0 cr0, flagsRegCR1 cr1, flagsRegCR6 cr6, regCTR ctr) %{
|
||||
match(Set result (StrEquals (Binary str1 str2) cnt));
|
||||
effect(TEMP result, TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, TEMP tmp5,
|
||||
effect(TEMP_DEF result, TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, TEMP tmp5,
|
||||
KILL cr0, KILL cr1, KILL cr6, KILL ctr);
|
||||
predicate(SpecialStringEquals); // See Matcher::match_rule_supported.
|
||||
ins_cost(300);
|
||||
@ -11188,7 +11251,7 @@ instruct string_equals(iRegPsrc str1, iRegPsrc str2, iRegIsrc cnt, iRegIdst resu
|
||||
instruct string_compare(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result,
|
||||
iRegPdst tmp, flagsRegCR0 cr0, regCTR ctr) %{
|
||||
match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
|
||||
effect(USE_KILL cnt1, USE_KILL cnt2, USE_KILL str1, USE_KILL str2, TEMP result, TEMP tmp, KILL cr0, KILL ctr);
|
||||
effect(USE_KILL cnt1, USE_KILL cnt2, USE_KILL str1, USE_KILL str2, TEMP_DEF result, TEMP tmp, KILL cr0, KILL ctr);
|
||||
ins_cost(300);
|
||||
|
||||
ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted.
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2012, 2014 SAP AG. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2012, 2015 SAP AG. 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
|
||||
@ -1079,7 +1079,7 @@ class StubGenerator: public StubCodeGenerator {
|
||||
__ sldi(tmp2, R5_ARG3, log2_elem_size); // size in bytes
|
||||
__ cmpld(CCR0, R3_ARG1, R4_ARG2); // Use unsigned comparison!
|
||||
__ cmpld(CCR1, tmp1, tmp2);
|
||||
__ crand(/*CCR0 lt*/0, /*CCR1 lt*/4+0, /*CCR0 lt*/0);
|
||||
__ crand(CCR0, Assembler::less, CCR1, Assembler::less);
|
||||
__ blt(CCR0, l_overlap); // Src before dst and distance smaller than size.
|
||||
|
||||
// need to copy forwards
|
||||
|
@ -264,11 +264,11 @@ void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow, Label*
|
||||
__ cmpdi(CCR0, Rmdo, 0);
|
||||
__ beq(CCR0, no_mdo);
|
||||
|
||||
// Increment backedge counter in the MDO.
|
||||
const int mdo_bc_offs = in_bytes(MethodData::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
|
||||
__ lwz(Rscratch2, mdo_bc_offs, Rmdo);
|
||||
// Increment invocation counter in the MDO.
|
||||
const int mdo_ic_offs = in_bytes(MethodData::invocation_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
|
||||
__ lwz(Rscratch2, mdo_ic_offs, Rmdo);
|
||||
__ addi(Rscratch2, Rscratch2, increment);
|
||||
__ stw(Rscratch2, mdo_bc_offs, Rmdo);
|
||||
__ stw(Rscratch2, mdo_ic_offs, Rmdo);
|
||||
__ load_const_optimized(Rscratch1, mask, R0);
|
||||
__ and_(Rscratch1, Rscratch2, Rscratch1);
|
||||
__ bne(CCR0, done);
|
||||
@ -276,12 +276,12 @@ void TemplateInterpreterGenerator::generate_counter_incr(Label* overflow, Label*
|
||||
}
|
||||
|
||||
// Increment counter in MethodCounters*.
|
||||
const int mo_bc_offs = in_bytes(MethodCounters::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
|
||||
const int mo_ic_offs = in_bytes(MethodCounters::invocation_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
|
||||
__ bind(no_mdo);
|
||||
__ get_method_counters(R19_method, R3_counters, done);
|
||||
__ lwz(Rscratch2, mo_bc_offs, R3_counters);
|
||||
__ lwz(Rscratch2, mo_ic_offs, R3_counters);
|
||||
__ addi(Rscratch2, Rscratch2, increment);
|
||||
__ stw(Rscratch2, mo_bc_offs, R3_counters);
|
||||
__ stw(Rscratch2, mo_ic_offs, R3_counters);
|
||||
__ load_const_optimized(Rscratch1, mask, R0);
|
||||
__ and_(Rscratch1, Rscratch2, Rscratch1);
|
||||
__ beq(CCR0, *overflow);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2013, 2014 SAP AG. All rights reserved.
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2013, 2015 SAP AG. 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
|
||||
@ -143,7 +143,6 @@ static void do_oop_store(InterpreterMacroAssembler* _masm,
|
||||
}
|
||||
break;
|
||||
case BarrierSet::ModRef:
|
||||
case BarrierSet::Other:
|
||||
ShouldNotReachHere();
|
||||
break;
|
||||
default:
|
||||
@ -335,11 +334,11 @@ void TemplateTable::ldc(bool wide) {
|
||||
|
||||
__ cmpwi(CCR0, Rscratch2, JVM_CONSTANT_UnresolvedClass); // Unresolved class?
|
||||
__ cmpwi(CCR1, Rscratch2, JVM_CONSTANT_UnresolvedClassInError); // Unresolved class in error state?
|
||||
__ cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
|
||||
__ cror(CCR0, Assembler::equal, CCR1, Assembler::equal);
|
||||
|
||||
// Resolved class - need to call vm to get java mirror of the class.
|
||||
__ cmpwi(CCR1, Rscratch2, JVM_CONSTANT_Class);
|
||||
__ crnor(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2); // Neither resolved class nor unresolved case from above?
|
||||
__ crnor(CCR0, Assembler::equal, CCR1, Assembler::equal); // Neither resolved class nor unresolved case from above?
|
||||
__ beq(CCR0, notClass);
|
||||
|
||||
__ li(R4, wide ? 1 : 0);
|
||||
@ -2611,7 +2610,7 @@ void TemplateTable::jvmti_post_field_mod(Register Rcache, Register Rscratch, boo
|
||||
__ cmpwi(CCR0, Rflags, ltos);
|
||||
__ cmpwi(CCR1, Rflags, dtos);
|
||||
__ addi(base, R15_esp, Interpreter::expr_offset_in_bytes(1));
|
||||
__ crnor(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
|
||||
__ crnor(CCR0, Assembler::equal, CCR1, Assembler::equal);
|
||||
__ beq(CCR0, is_one_slot);
|
||||
__ addi(base, R15_esp, Interpreter::expr_offset_in_bytes(2));
|
||||
__ bind(is_one_slot);
|
||||
@ -3563,7 +3562,7 @@ void TemplateTable::_new() {
|
||||
// Make sure klass does not have has_finalizer, or is abstract, or interface or java/lang/Class.
|
||||
__ andi_(R0, Rinstance_size, Klass::_lh_instance_slow_path_bit); // slow path bit equals 0?
|
||||
|
||||
__ crnand(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2); // slow path bit set or not fully initialized?
|
||||
__ crnand(CCR0, Assembler::equal, CCR1, Assembler::equal); // slow path bit set or not fully initialized?
|
||||
__ beq(CCR0, Lslow_case);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 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
|
||||
@ -483,15 +483,6 @@ void G1PreBarrierStub::emit_code(LIR_Assembler* ce) {
|
||||
|
||||
}
|
||||
|
||||
jbyte* G1PostBarrierStub::_byte_map_base = NULL;
|
||||
|
||||
jbyte* G1PostBarrierStub::byte_map_base_slow() {
|
||||
BarrierSet* bs = Universe::heap()->barrier_set();
|
||||
assert(bs->is_a(BarrierSet::G1SATBCTLogging),
|
||||
"Must be if we're using this.");
|
||||
return ((G1SATBCardTableModRefBS*)bs)->byte_map_base;
|
||||
}
|
||||
|
||||
void G1PostBarrierStub::emit_code(LIR_Assembler* ce) {
|
||||
__ bind(_entry);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -1436,26 +1436,6 @@ void LIR_Assembler::mem2reg(LIR_Opr src_opr, LIR_Opr dest, BasicType type,
|
||||
}
|
||||
|
||||
|
||||
void LIR_Assembler::prefetchr(LIR_Opr src) {
|
||||
LIR_Address* addr = src->as_address_ptr();
|
||||
Address from_addr = as_Address(addr);
|
||||
|
||||
if (VM_Version::has_v9()) {
|
||||
__ prefetch(from_addr, Assembler::severalReads);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIR_Assembler::prefetchw(LIR_Opr src) {
|
||||
LIR_Address* addr = src->as_address_ptr();
|
||||
Address from_addr = as_Address(addr);
|
||||
|
||||
if (VM_Version::has_v9()) {
|
||||
__ prefetch(from_addr, Assembler::severalWritesAndPossiblyReads);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
|
||||
Address addr;
|
||||
if (src->is_single_word()) {
|
||||
|
@ -1374,6 +1374,7 @@ void InterpreterMacroAssembler::verify_method_data_pointer() {
|
||||
}
|
||||
|
||||
void InterpreterMacroAssembler::test_invocation_counter_for_mdp(Register invocation_count,
|
||||
Register method_counters,
|
||||
Register Rtmp,
|
||||
Label &profile_continue) {
|
||||
assert(ProfileInterpreter, "must be profiling interpreter");
|
||||
@ -1386,9 +1387,8 @@ void InterpreterMacroAssembler::test_invocation_counter_for_mdp(Register invocat
|
||||
br_notnull_short(ImethodDataPtr, Assembler::pn, done);
|
||||
|
||||
// Test to see if we should create a method data oop
|
||||
AddressLiteral profile_limit((address) &InvocationCounter::InterpreterProfileLimit);
|
||||
sethi(profile_limit, Rtmp);
|
||||
ld(Rtmp, profile_limit.low10(), Rtmp);
|
||||
Address profile_limit(method_counters, MethodCounters::interpreter_profile_limit_offset());
|
||||
ld(profile_limit, Rtmp);
|
||||
cmp(invocation_count, Rtmp);
|
||||
// Use long branches because call_VM() code and following code generated by
|
||||
// test_backedge_count_for_osr() is large in debug VM.
|
||||
@ -2375,6 +2375,7 @@ void InterpreterMacroAssembler::increment_backedge_counter( Register Rcounters,
|
||||
|
||||
#ifndef CC_INTERP
|
||||
void InterpreterMacroAssembler::test_backedge_count_for_osr( Register backedge_count,
|
||||
Register method_counters,
|
||||
Register branch_bcp,
|
||||
Register Rtmp ) {
|
||||
Label did_not_overflow;
|
||||
@ -2382,8 +2383,8 @@ void InterpreterMacroAssembler::test_backedge_count_for_osr( Register backedge_c
|
||||
assert_different_registers(backedge_count, Rtmp, branch_bcp);
|
||||
assert(UseOnStackReplacement,"Must UseOnStackReplacement to test_backedge_count_for_osr");
|
||||
|
||||
AddressLiteral limit(&InvocationCounter::InterpreterBackwardBranchLimit);
|
||||
load_contents(limit, Rtmp);
|
||||
Address limit(method_counters, in_bytes(MethodCounters::interpreter_backward_branch_limit_offset()));
|
||||
ld(limit, Rtmp);
|
||||
cmp_and_br_short(backedge_count, Rtmp, Assembler::lessUnsigned, Assembler::pt, did_not_overflow);
|
||||
|
||||
// When ProfileInterpreter is on, the backedge_count comes from the
|
||||
@ -2500,17 +2501,13 @@ void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
|
||||
|
||||
// Jump if ((*counter_addr += increment) & mask) satisfies the condition.
|
||||
void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr,
|
||||
int increment, int mask,
|
||||
int increment, Address mask_addr,
|
||||
Register scratch1, Register scratch2,
|
||||
Condition cond, Label *where) {
|
||||
ld(counter_addr, scratch1);
|
||||
add(scratch1, increment, scratch1);
|
||||
if (is_simm13(mask)) {
|
||||
andcc(scratch1, mask, G0);
|
||||
} else {
|
||||
set(mask, scratch2);
|
||||
andcc(scratch1, scratch2, G0);
|
||||
}
|
||||
ld(mask_addr, scratch2);
|
||||
andcc(scratch1, scratch2, G0);
|
||||
br(cond, false, Assembler::pn, *where);
|
||||
delayed()->st(scratch1, counter_addr);
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class InterpreterMacroAssembler: public MacroAssembler {
|
||||
void increment_invocation_counter( Register Rcounters, Register Rtmp, Register Rtmp2 );
|
||||
void increment_backedge_counter( Register Rcounters, Register Rtmp, Register Rtmp2 );
|
||||
#ifndef CC_INTERP
|
||||
void test_backedge_count_for_osr( Register backedge_count, Register branch_bcp, Register Rtmp );
|
||||
void test_backedge_count_for_osr(Register backedge_count, Register method_counters, Register branch_bcp, Register Rtmp );
|
||||
|
||||
#endif /* CC_INTERP */
|
||||
// Object locking
|
||||
@ -280,7 +280,7 @@ class InterpreterMacroAssembler: public MacroAssembler {
|
||||
void set_method_data_pointer_for_bcp();
|
||||
void test_method_data_pointer(Label& zero_continue);
|
||||
void verify_method_data_pointer();
|
||||
void test_invocation_counter_for_mdp(Register invocation_count, Register Rtmp, Label &profile_continue);
|
||||
void test_invocation_counter_for_mdp(Register invocation_count, Register method_counters, Register Rtmp, Label &profile_continue);
|
||||
|
||||
void set_mdp_data_at(int constant, Register value);
|
||||
void increment_mdp_data_at(Address counter, Register bumped_count,
|
||||
@ -291,7 +291,7 @@ class InterpreterMacroAssembler: public MacroAssembler {
|
||||
Register bumped_count, Register scratch2,
|
||||
bool decrement = false);
|
||||
void increment_mask_and_jump(Address counter_addr,
|
||||
int increment, int mask,
|
||||
int increment, Address mask_addr,
|
||||
Register scratch1, Register scratch2,
|
||||
Condition cond, Label *where);
|
||||
void set_mdp_flag_at(int flag_constant, Register scratch);
|
||||
|
@ -630,7 +630,12 @@ inline void MacroAssembler::ldf(FloatRegisterImpl::Width w, Register s1, Registe
|
||||
|
||||
inline void MacroAssembler::ldf(FloatRegisterImpl::Width w, const Address& a, FloatRegister d, int offset) {
|
||||
relocate(a.rspec(offset));
|
||||
ldf(w, a.base(), a.disp() + offset, d);
|
||||
if (a.has_index()) {
|
||||
assert(offset == 0, "");
|
||||
ldf(w, a.base(), a.index(), d);
|
||||
} else {
|
||||
ldf(w, a.base(), a.disp() + offset, d);
|
||||
}
|
||||
}
|
||||
|
||||
// returns if membar generates anything, obviously this code should mirror
|
||||
|
@ -36,11 +36,6 @@
|
||||
#include "c1/c1_Runtime1.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
bool NativeInstruction::is_dtrace_trap() {
|
||||
return !is_nop();
|
||||
}
|
||||
|
||||
void NativeInstruction::set_data64_sethi(address instaddr, intptr_t x) {
|
||||
ResourceMark rm;
|
||||
CodeBuffer buf(instaddr, 10 * BytesPerInstWord );
|
||||
|
@ -51,7 +51,6 @@ class NativeInstruction VALUE_OBJ_CLASS_SPEC {
|
||||
nop_instruction_size = 4
|
||||
};
|
||||
|
||||
bool is_dtrace_trap();
|
||||
bool is_nop() { return long_at(0) == nop_instruction(); }
|
||||
bool is_call() { return is_op(long_at(0), Assembler::call_op); }
|
||||
bool is_sethi() { return (is_op2(long_at(0), Assembler::sethi_op2)
|
||||
|
@ -2758,540 +2758,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_DTRACE_H
|
||||
// ---------------------------------------------------------------------------
|
||||
// Generate a dtrace nmethod for a given signature. The method takes arguments
|
||||
// in the Java compiled code convention, marshals them to the native
|
||||
// abi and then leaves nops at the position you would expect to call a native
|
||||
// function. When the probe is enabled the nops are replaced with a trap
|
||||
// instruction that dtrace inserts and the trace will cause a notification
|
||||
// to dtrace.
|
||||
//
|
||||
// The probes are only able to take primitive types and java/lang/String as
|
||||
// arguments. No other java types are allowed. Strings are converted to utf8
|
||||
// strings so that from dtrace point of view java strings are converted to C
|
||||
// strings. There is an arbitrary fixed limit on the total space that a method
|
||||
// can use for converting the strings. (256 chars per string in the signature).
|
||||
// So any java string larger then this is truncated.
|
||||
|
||||
static int fp_offset[ConcreteRegisterImpl::number_of_registers] = { 0 };
|
||||
static bool offsets_initialized = false;
|
||||
|
||||
nmethod *SharedRuntime::generate_dtrace_nmethod(
|
||||
MacroAssembler *masm, methodHandle method) {
|
||||
|
||||
|
||||
// generate_dtrace_nmethod is guarded by a mutex so we are sure to
|
||||
// be single threaded in this method.
|
||||
assert(AdapterHandlerLibrary_lock->owned_by_self(), "must be");
|
||||
|
||||
// Fill in the signature array, for the calling-convention call.
|
||||
int total_args_passed = method->size_of_parameters();
|
||||
|
||||
BasicType* in_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
|
||||
VMRegPair *in_regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
|
||||
|
||||
// The signature we are going to use for the trap that dtrace will see
|
||||
// java/lang/String is converted. We drop "this" and any other object
|
||||
// is converted to NULL. (A one-slot java/lang/Long object reference
|
||||
// is converted to a two-slot long, which is why we double the allocation).
|
||||
BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed * 2);
|
||||
VMRegPair* out_regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed * 2);
|
||||
|
||||
int i=0;
|
||||
int total_strings = 0;
|
||||
int first_arg_to_pass = 0;
|
||||
int total_c_args = 0;
|
||||
|
||||
// Skip the receiver as dtrace doesn't want to see it
|
||||
if( !method->is_static() ) {
|
||||
in_sig_bt[i++] = T_OBJECT;
|
||||
first_arg_to_pass = 1;
|
||||
}
|
||||
|
||||
SignatureStream ss(method->signature());
|
||||
for ( ; !ss.at_return_type(); ss.next()) {
|
||||
BasicType bt = ss.type();
|
||||
in_sig_bt[i++] = bt; // Collect remaining bits of signature
|
||||
out_sig_bt[total_c_args++] = bt;
|
||||
if( bt == T_OBJECT) {
|
||||
Symbol* s = ss.as_symbol_or_null();
|
||||
if (s == vmSymbols::java_lang_String()) {
|
||||
total_strings++;
|
||||
out_sig_bt[total_c_args-1] = T_ADDRESS;
|
||||
} else if (s == vmSymbols::java_lang_Boolean() ||
|
||||
s == vmSymbols::java_lang_Byte()) {
|
||||
out_sig_bt[total_c_args-1] = T_BYTE;
|
||||
} else if (s == vmSymbols::java_lang_Character() ||
|
||||
s == vmSymbols::java_lang_Short()) {
|
||||
out_sig_bt[total_c_args-1] = T_SHORT;
|
||||
} else if (s == vmSymbols::java_lang_Integer() ||
|
||||
s == vmSymbols::java_lang_Float()) {
|
||||
out_sig_bt[total_c_args-1] = T_INT;
|
||||
} else if (s == vmSymbols::java_lang_Long() ||
|
||||
s == vmSymbols::java_lang_Double()) {
|
||||
out_sig_bt[total_c_args-1] = T_LONG;
|
||||
out_sig_bt[total_c_args++] = T_VOID;
|
||||
}
|
||||
} else if ( bt == T_LONG || bt == T_DOUBLE ) {
|
||||
in_sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots
|
||||
// We convert double to long
|
||||
out_sig_bt[total_c_args-1] = T_LONG;
|
||||
out_sig_bt[total_c_args++] = T_VOID;
|
||||
} else if ( bt == T_FLOAT) {
|
||||
// We convert float to int
|
||||
out_sig_bt[total_c_args-1] = T_INT;
|
||||
}
|
||||
}
|
||||
|
||||
assert(i==total_args_passed, "validly parsed signature");
|
||||
|
||||
// Now get the compiled-Java layout as input arguments
|
||||
int comp_args_on_stack;
|
||||
comp_args_on_stack = SharedRuntime::java_calling_convention(
|
||||
in_sig_bt, in_regs, total_args_passed, false);
|
||||
|
||||
// We have received a description of where all the java arg are located
|
||||
// on entry to the wrapper. We need to convert these args to where
|
||||
// the a native (non-jni) function would expect them. To figure out
|
||||
// where they go we convert the java signature to a C signature and remove
|
||||
// T_VOID for any long/double we might have received.
|
||||
|
||||
|
||||
// Now figure out where the args must be stored and how much stack space
|
||||
// they require (neglecting out_preserve_stack_slots but space for storing
|
||||
// the 1st six register arguments). It's weird see int_stk_helper.
|
||||
//
|
||||
int out_arg_slots;
|
||||
out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
|
||||
|
||||
// Calculate the total number of stack slots we will need.
|
||||
|
||||
// First count the abi requirement plus all of the outgoing args
|
||||
int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
|
||||
|
||||
// Plus a temp for possible converion of float/double/long register args
|
||||
|
||||
int conversion_temp = stack_slots;
|
||||
stack_slots += 2;
|
||||
|
||||
|
||||
// Now space for the string(s) we must convert
|
||||
|
||||
int string_locs = stack_slots;
|
||||
stack_slots += total_strings *
|
||||
(max_dtrace_string_size / VMRegImpl::stack_slot_size);
|
||||
|
||||
// Ok The space we have allocated will look like:
|
||||
//
|
||||
//
|
||||
// FP-> | |
|
||||
// |---------------------|
|
||||
// | string[n] |
|
||||
// |---------------------| <- string_locs[n]
|
||||
// | string[n-1] |
|
||||
// |---------------------| <- string_locs[n-1]
|
||||
// | ... |
|
||||
// | ... |
|
||||
// |---------------------| <- string_locs[1]
|
||||
// | string[0] |
|
||||
// |---------------------| <- string_locs[0]
|
||||
// | temp |
|
||||
// |---------------------| <- conversion_temp
|
||||
// | outbound memory |
|
||||
// | based arguments |
|
||||
// | |
|
||||
// |---------------------|
|
||||
// | |
|
||||
// SP-> | out_preserved_slots |
|
||||
//
|
||||
//
|
||||
|
||||
// Now compute actual number of stack words we need rounding to make
|
||||
// stack properly aligned.
|
||||
stack_slots = round_to(stack_slots, 4 * VMRegImpl::slots_per_word);
|
||||
|
||||
int stack_size = stack_slots * VMRegImpl::stack_slot_size;
|
||||
|
||||
intptr_t start = (intptr_t)__ pc();
|
||||
|
||||
// First thing make an ic check to see if we should even be here
|
||||
|
||||
{
|
||||
Label L;
|
||||
const Register temp_reg = G3_scratch;
|
||||
AddressLiteral ic_miss(SharedRuntime::get_ic_miss_stub());
|
||||
__ verify_oop(O0);
|
||||
__ ld_ptr(O0, oopDesc::klass_offset_in_bytes(), temp_reg);
|
||||
__ cmp_and_brx_short(temp_reg, G5_inline_cache_reg, Assembler::equal, Assembler::pt, L);
|
||||
|
||||
__ jump_to(ic_miss, temp_reg);
|
||||
__ delayed()->nop();
|
||||
__ align(CodeEntryAlignment);
|
||||
__ bind(L);
|
||||
}
|
||||
|
||||
int vep_offset = ((intptr_t)__ pc()) - start;
|
||||
|
||||
|
||||
// The instruction at the verified entry point must be 5 bytes or longer
|
||||
// because it can be patched on the fly by make_non_entrant. The stack bang
|
||||
// instruction fits that requirement.
|
||||
|
||||
// Generate stack overflow check before creating frame
|
||||
__ generate_stack_overflow_check(stack_size);
|
||||
|
||||
assert(((intptr_t)__ pc() - start - vep_offset) >= 5,
|
||||
"valid size for make_non_entrant");
|
||||
|
||||
// Generate a new frame for the wrapper.
|
||||
__ save(SP, -stack_size, SP);
|
||||
|
||||
// Frame is now completed as far a size and linkage.
|
||||
|
||||
int frame_complete = ((intptr_t)__ pc()) - start;
|
||||
|
||||
#ifdef ASSERT
|
||||
bool reg_destroyed[RegisterImpl::number_of_registers];
|
||||
bool freg_destroyed[FloatRegisterImpl::number_of_registers];
|
||||
for ( int r = 0 ; r < RegisterImpl::number_of_registers ; r++ ) {
|
||||
reg_destroyed[r] = false;
|
||||
}
|
||||
for ( int f = 0 ; f < FloatRegisterImpl::number_of_registers ; f++ ) {
|
||||
freg_destroyed[f] = false;
|
||||
}
|
||||
|
||||
#endif /* ASSERT */
|
||||
|
||||
VMRegPair zero;
|
||||
const Register g0 = G0; // without this we get a compiler warning (why??)
|
||||
zero.set2(g0->as_VMReg());
|
||||
|
||||
int c_arg, j_arg;
|
||||
|
||||
Register conversion_off = noreg;
|
||||
|
||||
for (j_arg = first_arg_to_pass, c_arg = 0 ;
|
||||
j_arg < total_args_passed ; j_arg++, c_arg++ ) {
|
||||
|
||||
VMRegPair src = in_regs[j_arg];
|
||||
VMRegPair dst = out_regs[c_arg];
|
||||
|
||||
#ifdef ASSERT
|
||||
if (src.first()->is_Register()) {
|
||||
assert(!reg_destroyed[src.first()->as_Register()->encoding()], "ack!");
|
||||
} else if (src.first()->is_FloatRegister()) {
|
||||
assert(!freg_destroyed[src.first()->as_FloatRegister()->encoding(
|
||||
FloatRegisterImpl::S)], "ack!");
|
||||
}
|
||||
if (dst.first()->is_Register()) {
|
||||
reg_destroyed[dst.first()->as_Register()->encoding()] = true;
|
||||
} else if (dst.first()->is_FloatRegister()) {
|
||||
freg_destroyed[dst.first()->as_FloatRegister()->encoding(
|
||||
FloatRegisterImpl::S)] = true;
|
||||
}
|
||||
#endif /* ASSERT */
|
||||
|
||||
switch (in_sig_bt[j_arg]) {
|
||||
case T_ARRAY:
|
||||
case T_OBJECT:
|
||||
{
|
||||
if (out_sig_bt[c_arg] == T_BYTE || out_sig_bt[c_arg] == T_SHORT ||
|
||||
out_sig_bt[c_arg] == T_INT || out_sig_bt[c_arg] == T_LONG) {
|
||||
// need to unbox a one-slot value
|
||||
Register in_reg = L0;
|
||||
Register tmp = L2;
|
||||
if ( src.first()->is_reg() ) {
|
||||
in_reg = src.first()->as_Register();
|
||||
} else {
|
||||
assert(Assembler::is_simm13(reg2offset(src.first()) + STACK_BIAS),
|
||||
"must be");
|
||||
__ ld_ptr(FP, reg2offset(src.first()) + STACK_BIAS, in_reg);
|
||||
}
|
||||
// If the final destination is an acceptable register
|
||||
if ( dst.first()->is_reg() ) {
|
||||
if ( dst.is_single_phys_reg() || out_sig_bt[c_arg] != T_LONG ) {
|
||||
tmp = dst.first()->as_Register();
|
||||
}
|
||||
}
|
||||
|
||||
Label skipUnbox;
|
||||
if ( wordSize == 4 && out_sig_bt[c_arg] == T_LONG ) {
|
||||
__ mov(G0, tmp->successor());
|
||||
}
|
||||
__ br_null(in_reg, true, Assembler::pn, skipUnbox);
|
||||
__ delayed()->mov(G0, tmp);
|
||||
|
||||
BasicType bt = out_sig_bt[c_arg];
|
||||
int box_offset = java_lang_boxing_object::value_offset_in_bytes(bt);
|
||||
switch (bt) {
|
||||
case T_BYTE:
|
||||
__ ldub(in_reg, box_offset, tmp); break;
|
||||
case T_SHORT:
|
||||
__ lduh(in_reg, box_offset, tmp); break;
|
||||
case T_INT:
|
||||
__ ld(in_reg, box_offset, tmp); break;
|
||||
case T_LONG:
|
||||
__ ld_long(in_reg, box_offset, tmp); break;
|
||||
default: ShouldNotReachHere();
|
||||
}
|
||||
|
||||
__ bind(skipUnbox);
|
||||
// If tmp wasn't final destination copy to final destination
|
||||
if (tmp == L2) {
|
||||
VMRegPair tmp_as_VM = reg64_to_VMRegPair(L2);
|
||||
if (out_sig_bt[c_arg] == T_LONG) {
|
||||
long_move(masm, tmp_as_VM, dst);
|
||||
} else {
|
||||
move32_64(masm, tmp_as_VM, out_regs[c_arg]);
|
||||
}
|
||||
}
|
||||
if (out_sig_bt[c_arg] == T_LONG) {
|
||||
assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
|
||||
++c_arg; // move over the T_VOID to keep the loop indices in sync
|
||||
}
|
||||
} else if (out_sig_bt[c_arg] == T_ADDRESS) {
|
||||
Register s =
|
||||
src.first()->is_reg() ? src.first()->as_Register() : L2;
|
||||
Register d =
|
||||
dst.first()->is_reg() ? dst.first()->as_Register() : L2;
|
||||
|
||||
// We store the oop now so that the conversion pass can reach
|
||||
// while in the inner frame. This will be the only store if
|
||||
// the oop is NULL.
|
||||
if (s != L2) {
|
||||
// src is register
|
||||
if (d != L2) {
|
||||
// dst is register
|
||||
__ mov(s, d);
|
||||
} else {
|
||||
assert(Assembler::is_simm13(reg2offset(dst.first()) +
|
||||
STACK_BIAS), "must be");
|
||||
__ st_ptr(s, SP, reg2offset(dst.first()) + STACK_BIAS);
|
||||
}
|
||||
} else {
|
||||
// src not a register
|
||||
assert(Assembler::is_simm13(reg2offset(src.first()) +
|
||||
STACK_BIAS), "must be");
|
||||
__ ld_ptr(FP, reg2offset(src.first()) + STACK_BIAS, d);
|
||||
if (d == L2) {
|
||||
assert(Assembler::is_simm13(reg2offset(dst.first()) +
|
||||
STACK_BIAS), "must be");
|
||||
__ st_ptr(d, SP, reg2offset(dst.first()) + STACK_BIAS);
|
||||
}
|
||||
}
|
||||
} else if (out_sig_bt[c_arg] != T_VOID) {
|
||||
// Convert the arg to NULL
|
||||
if (dst.first()->is_reg()) {
|
||||
__ mov(G0, dst.first()->as_Register());
|
||||
} else {
|
||||
assert(Assembler::is_simm13(reg2offset(dst.first()) +
|
||||
STACK_BIAS), "must be");
|
||||
__ st_ptr(G0, SP, reg2offset(dst.first()) + STACK_BIAS);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case T_VOID:
|
||||
break;
|
||||
|
||||
case T_FLOAT:
|
||||
if (src.first()->is_stack()) {
|
||||
// Stack to stack/reg is simple
|
||||
move32_64(masm, src, dst);
|
||||
} else {
|
||||
if (dst.first()->is_reg()) {
|
||||
// freg -> reg
|
||||
int off =
|
||||
STACK_BIAS + conversion_temp * VMRegImpl::stack_slot_size;
|
||||
Register d = dst.first()->as_Register();
|
||||
if (Assembler::is_simm13(off)) {
|
||||
__ stf(FloatRegisterImpl::S, src.first()->as_FloatRegister(),
|
||||
SP, off);
|
||||
__ ld(SP, off, d);
|
||||
} else {
|
||||
if (conversion_off == noreg) {
|
||||
__ set(off, L6);
|
||||
conversion_off = L6;
|
||||
}
|
||||
__ stf(FloatRegisterImpl::S, src.first()->as_FloatRegister(),
|
||||
SP, conversion_off);
|
||||
__ ld(SP, conversion_off , d);
|
||||
}
|
||||
} else {
|
||||
// freg -> mem
|
||||
int off = STACK_BIAS + reg2offset(dst.first());
|
||||
if (Assembler::is_simm13(off)) {
|
||||
__ stf(FloatRegisterImpl::S, src.first()->as_FloatRegister(),
|
||||
SP, off);
|
||||
} else {
|
||||
if (conversion_off == noreg) {
|
||||
__ set(off, L6);
|
||||
conversion_off = L6;
|
||||
}
|
||||
__ stf(FloatRegisterImpl::S, src.first()->as_FloatRegister(),
|
||||
SP, conversion_off);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case T_DOUBLE:
|
||||
assert( j_arg + 1 < total_args_passed &&
|
||||
in_sig_bt[j_arg + 1] == T_VOID &&
|
||||
out_sig_bt[c_arg+1] == T_VOID, "bad arg list");
|
||||
if (src.first()->is_stack()) {
|
||||
// Stack to stack/reg is simple
|
||||
long_move(masm, src, dst);
|
||||
} else {
|
||||
Register d = dst.first()->is_reg() ? dst.first()->as_Register() : L2;
|
||||
|
||||
// Destination could be an odd reg on 32bit in which case
|
||||
// we can't load direct to the destination.
|
||||
|
||||
if (!d->is_even() && wordSize == 4) {
|
||||
d = L2;
|
||||
}
|
||||
int off = STACK_BIAS + conversion_temp * VMRegImpl::stack_slot_size;
|
||||
if (Assembler::is_simm13(off)) {
|
||||
__ stf(FloatRegisterImpl::D, src.first()->as_FloatRegister(),
|
||||
SP, off);
|
||||
__ ld_long(SP, off, d);
|
||||
} else {
|
||||
if (conversion_off == noreg) {
|
||||
__ set(off, L6);
|
||||
conversion_off = L6;
|
||||
}
|
||||
__ stf(FloatRegisterImpl::D, src.first()->as_FloatRegister(),
|
||||
SP, conversion_off);
|
||||
__ ld_long(SP, conversion_off, d);
|
||||
}
|
||||
if (d == L2) {
|
||||
long_move(masm, reg64_to_VMRegPair(L2), dst);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case T_LONG :
|
||||
// 32bit can't do a split move of something like g1 -> O0, O1
|
||||
// so use a memory temp
|
||||
if (src.is_single_phys_reg() && wordSize == 4) {
|
||||
Register tmp = L2;
|
||||
if (dst.first()->is_reg() &&
|
||||
(wordSize == 8 || dst.first()->as_Register()->is_even())) {
|
||||
tmp = dst.first()->as_Register();
|
||||
}
|
||||
|
||||
int off = STACK_BIAS + conversion_temp * VMRegImpl::stack_slot_size;
|
||||
if (Assembler::is_simm13(off)) {
|
||||
__ stx(src.first()->as_Register(), SP, off);
|
||||
__ ld_long(SP, off, tmp);
|
||||
} else {
|
||||
if (conversion_off == noreg) {
|
||||
__ set(off, L6);
|
||||
conversion_off = L6;
|
||||
}
|
||||
__ stx(src.first()->as_Register(), SP, conversion_off);
|
||||
__ ld_long(SP, conversion_off, tmp);
|
||||
}
|
||||
|
||||
if (tmp == L2) {
|
||||
long_move(masm, reg64_to_VMRegPair(L2), dst);
|
||||
}
|
||||
} else {
|
||||
long_move(masm, src, dst);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_ADDRESS: assert(false, "found T_ADDRESS in java args");
|
||||
|
||||
default:
|
||||
move32_64(masm, src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If we have any strings we must store any register based arg to the stack
|
||||
// This includes any still live xmm registers too.
|
||||
|
||||
if (total_strings > 0 ) {
|
||||
|
||||
// protect all the arg registers
|
||||
__ save_frame(0);
|
||||
__ mov(G2_thread, L7_thread_cache);
|
||||
const Register L2_string_off = L2;
|
||||
|
||||
// Get first string offset
|
||||
__ set(string_locs * VMRegImpl::stack_slot_size, L2_string_off);
|
||||
|
||||
for (c_arg = 0 ; c_arg < total_c_args ; c_arg++ ) {
|
||||
if (out_sig_bt[c_arg] == T_ADDRESS) {
|
||||
|
||||
VMRegPair dst = out_regs[c_arg];
|
||||
const Register d = dst.first()->is_reg() ?
|
||||
dst.first()->as_Register()->after_save() : noreg;
|
||||
|
||||
// It's a string the oop and it was already copied to the out arg
|
||||
// position
|
||||
if (d != noreg) {
|
||||
__ mov(d, O0);
|
||||
} else {
|
||||
assert(Assembler::is_simm13(reg2offset(dst.first()) + STACK_BIAS),
|
||||
"must be");
|
||||
__ ld_ptr(FP, reg2offset(dst.first()) + STACK_BIAS, O0);
|
||||
}
|
||||
Label skip;
|
||||
|
||||
__ br_null(O0, false, Assembler::pn, skip);
|
||||
__ delayed()->add(FP, L2_string_off, O1);
|
||||
|
||||
if (d != noreg) {
|
||||
__ mov(O1, d);
|
||||
} else {
|
||||
assert(Assembler::is_simm13(reg2offset(dst.first()) + STACK_BIAS),
|
||||
"must be");
|
||||
__ st_ptr(O1, FP, reg2offset(dst.first()) + STACK_BIAS);
|
||||
}
|
||||
|
||||
__ call(CAST_FROM_FN_PTR(address, SharedRuntime::get_utf),
|
||||
relocInfo::runtime_call_type);
|
||||
__ delayed()->add(L2_string_off, max_dtrace_string_size, L2_string_off);
|
||||
|
||||
__ bind(skip);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
__ mov(L7_thread_cache, G2_thread);
|
||||
__ restore();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Ok now we are done. Need to place the nop that dtrace wants in order to
|
||||
// patch in the trap
|
||||
|
||||
int patch_offset = ((intptr_t)__ pc()) - start;
|
||||
|
||||
__ nop();
|
||||
|
||||
|
||||
// Return
|
||||
|
||||
__ ret();
|
||||
__ delayed()->restore();
|
||||
|
||||
__ flush();
|
||||
|
||||
nmethod *nm = nmethod::new_dtrace_nmethod(
|
||||
method, masm->code(), vep_offset, patch_offset, frame_complete,
|
||||
stack_slots / VMRegImpl::slots_per_word);
|
||||
return nm;
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_DTRACE_H
|
||||
|
||||
// this function returns the adjust size (in number of words) to a c2i adapter
|
||||
// activation for use during deoptimization
|
||||
int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
// Copyright (c) 1998, 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
|
||||
@ -889,8 +889,6 @@ void emit_form3_mem_reg(CodeBuffer &cbuf, PhaseRegAlloc* ra, const MachNode* n,
|
||||
!(n->ideal_Opcode()==Op_LoadD_unaligned && ld_op==Op_LoadF) &&
|
||||
!(n->ideal_Opcode()==Op_ConvI2F && ld_op==Op_LoadF) &&
|
||||
!(n->ideal_Opcode()==Op_ConvI2D && ld_op==Op_LoadF) &&
|
||||
!(n->ideal_Opcode()==Op_PrefetchRead && ld_op==Op_LoadI) &&
|
||||
!(n->ideal_Opcode()==Op_PrefetchWrite && ld_op==Op_LoadI) &&
|
||||
!(n->ideal_Opcode()==Op_PrefetchAllocation && ld_op==Op_LoadI) &&
|
||||
!(n->ideal_Opcode()==Op_LoadVector && ld_op==Op_LoadD) &&
|
||||
!(n->rule() == loadUB_rule)) {
|
||||
@ -2996,7 +2994,7 @@ enc_class Fast_Unlock(iRegP oop, iRegP box, o7RegP scratch, iRegP scratch2) %{
|
||||
%}
|
||||
|
||||
enc_class enc_String_Equals(o0RegP str1, o1RegP str2, g3RegI cnt, notemp_iRegI result) %{
|
||||
Label Lword_loop, Lpost_word, Lchar, Lchar_loop, Ldone;
|
||||
Label Lchar, Lchar_loop, Ldone;
|
||||
MacroAssembler _masm(&cbuf);
|
||||
|
||||
Register str1_reg = reg_to_register_object($str1$$reg);
|
||||
@ -6316,32 +6314,8 @@ instruct loadConD(regD dst, immD con, o7RegI tmp) %{
|
||||
ins_pipe(loadConFD);
|
||||
%}
|
||||
|
||||
// Prefetch instructions.
|
||||
// Must be safe to execute with invalid address (cannot fault).
|
||||
|
||||
instruct prefetchr( memory mem ) %{
|
||||
match( PrefetchRead mem );
|
||||
ins_cost(MEMORY_REF_COST);
|
||||
size(4);
|
||||
|
||||
format %{ "PREFETCH $mem,0\t! Prefetch read-many" %}
|
||||
opcode(Assembler::prefetch_op3);
|
||||
ins_encode( form3_mem_prefetch_read( mem ) );
|
||||
ins_pipe(iload_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchw( memory mem ) %{
|
||||
match( PrefetchWrite mem );
|
||||
ins_cost(MEMORY_REF_COST);
|
||||
size(4);
|
||||
|
||||
format %{ "PREFETCH $mem,2\t! Prefetch write-many (and read)" %}
|
||||
opcode(Assembler::prefetch_op3);
|
||||
ins_encode( form3_mem_prefetch_write( mem ) );
|
||||
ins_pipe(iload_mem);
|
||||
%}
|
||||
|
||||
// Prefetch instructions for allocation.
|
||||
// Must be safe to execute with invalid address (cannot fault).
|
||||
|
||||
instruct prefetchAlloc( memory mem ) %{
|
||||
predicate(AllocatePrefetchInstr == 0);
|
||||
|
@ -282,12 +282,11 @@ address TemplateInterpreterGenerator::generate_continuation_for(TosState state)
|
||||
void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
|
||||
// Note: In tiered we increment either counters in MethodCounters* or in
|
||||
// MDO depending if we're profiling or not.
|
||||
const Register Rcounters = G3_scratch;
|
||||
const Register G3_method_counters = G3_scratch;
|
||||
Label done;
|
||||
|
||||
if (TieredCompilation) {
|
||||
const int increment = InvocationCounter::count_increment;
|
||||
const int mask = ((1 << Tier0InvokeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
|
||||
Label no_mdo;
|
||||
if (ProfileInterpreter) {
|
||||
// If no method data exists, go to profile_continue.
|
||||
@ -297,6 +296,7 @@ void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile
|
||||
Address mdo_invocation_counter(G4_scratch,
|
||||
in_bytes(MethodData::invocation_counter_offset()) +
|
||||
in_bytes(InvocationCounter::counter_offset()));
|
||||
Address mask(G4_scratch, in_bytes(MethodData::invoke_mask_offset()));
|
||||
__ increment_mask_and_jump(mdo_invocation_counter, increment, mask,
|
||||
G3_scratch, Lscratch,
|
||||
Assembler::zero, overflow);
|
||||
@ -305,20 +305,21 @@ void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile
|
||||
|
||||
// Increment counter in MethodCounters*
|
||||
__ bind(no_mdo);
|
||||
Address invocation_counter(Rcounters,
|
||||
Address invocation_counter(G3_method_counters,
|
||||
in_bytes(MethodCounters::invocation_counter_offset()) +
|
||||
in_bytes(InvocationCounter::counter_offset()));
|
||||
__ get_method_counters(Lmethod, Rcounters, done);
|
||||
__ get_method_counters(Lmethod, G3_method_counters, done);
|
||||
Address mask(G3_method_counters, in_bytes(MethodCounters::invoke_mask_offset()));
|
||||
__ increment_mask_and_jump(invocation_counter, increment, mask,
|
||||
G4_scratch, Lscratch,
|
||||
Assembler::zero, overflow);
|
||||
__ bind(done);
|
||||
} else {
|
||||
} else { // not TieredCompilation
|
||||
// Update standard invocation counters
|
||||
__ get_method_counters(Lmethod, Rcounters, done);
|
||||
__ increment_invocation_counter(Rcounters, O0, G4_scratch);
|
||||
__ get_method_counters(Lmethod, G3_method_counters, done);
|
||||
__ increment_invocation_counter(G3_method_counters, O0, G4_scratch);
|
||||
if (ProfileInterpreter) {
|
||||
Address interpreter_invocation_counter(Rcounters,
|
||||
Address interpreter_invocation_counter(G3_method_counters,
|
||||
in_bytes(MethodCounters::interpreter_invocation_counter_offset()));
|
||||
__ ld(interpreter_invocation_counter, G4_scratch);
|
||||
__ inc(G4_scratch);
|
||||
@ -327,16 +328,16 @@ void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile
|
||||
|
||||
if (ProfileInterpreter && profile_method != NULL) {
|
||||
// Test to see if we should create a method data oop
|
||||
AddressLiteral profile_limit((address)&InvocationCounter::InterpreterProfileLimit);
|
||||
__ load_contents(profile_limit, G3_scratch);
|
||||
__ cmp_and_br_short(O0, G3_scratch, Assembler::lessUnsigned, Assembler::pn, *profile_method_continue);
|
||||
Address profile_limit(G3_method_counters, in_bytes(MethodCounters::interpreter_profile_limit_offset()));
|
||||
__ ld(profile_limit, G1_scratch);
|
||||
__ cmp_and_br_short(O0, G1_scratch, Assembler::lessUnsigned, Assembler::pn, *profile_method_continue);
|
||||
|
||||
// if no method data exists, go to profile_method
|
||||
__ test_method_data_pointer(*profile_method);
|
||||
}
|
||||
|
||||
AddressLiteral invocation_limit((address)&InvocationCounter::InterpreterInvocationLimit);
|
||||
__ load_contents(invocation_limit, G3_scratch);
|
||||
Address invocation_limit(G3_method_counters, in_bytes(MethodCounters::interpreter_invocation_limit_offset()));
|
||||
__ ld(invocation_limit, G3_scratch);
|
||||
__ cmp(O0, G3_scratch);
|
||||
__ br(Assembler::greaterEqualUnsigned, false, Assembler::pn, *overflow); // Far distance
|
||||
__ delayed()->nop();
|
||||
|
@ -115,7 +115,6 @@ static void do_oop_store(InterpreterMacroAssembler* _masm,
|
||||
}
|
||||
break;
|
||||
case BarrierSet::ModRef:
|
||||
case BarrierSet::Other:
|
||||
ShouldNotReachHere();
|
||||
break;
|
||||
default :
|
||||
@ -1599,13 +1598,12 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
// Bump bytecode pointer by displacement (take the branch)
|
||||
__ delayed()->add( O1_disp, Lbcp, Lbcp ); // add to bc addr
|
||||
|
||||
const Register Rcounters = G3_scratch;
|
||||
__ get_method_counters(Lmethod, Rcounters, Lforward);
|
||||
const Register G3_method_counters = G3_scratch;
|
||||
__ get_method_counters(Lmethod, G3_method_counters, Lforward);
|
||||
|
||||
if (TieredCompilation) {
|
||||
Label Lno_mdo, Loverflow;
|
||||
int increment = InvocationCounter::count_increment;
|
||||
int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
|
||||
if (ProfileInterpreter) {
|
||||
// If no method data exists, go to profile_continue.
|
||||
__ ld_ptr(Lmethod, Method::method_data_offset(), G4_scratch);
|
||||
@ -1614,6 +1612,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
// Increment backedge counter in the MDO
|
||||
Address mdo_backedge_counter(G4_scratch, in_bytes(MethodData::backedge_counter_offset()) +
|
||||
in_bytes(InvocationCounter::counter_offset()));
|
||||
Address mask(G4_scratch, in_bytes(MethodData::backedge_mask_offset()));
|
||||
__ increment_mask_and_jump(mdo_backedge_counter, increment, mask, G3_scratch, O0,
|
||||
Assembler::notZero, &Lforward);
|
||||
__ ba_short(Loverflow);
|
||||
@ -1621,9 +1620,10 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
|
||||
// If there's no MDO, increment counter in MethodCounters*
|
||||
__ bind(Lno_mdo);
|
||||
Address backedge_counter(Rcounters,
|
||||
Address backedge_counter(G3_method_counters,
|
||||
in_bytes(MethodCounters::backedge_counter_offset()) +
|
||||
in_bytes(InvocationCounter::counter_offset()));
|
||||
Address mask(G3_method_counters, in_bytes(MethodCounters::backedge_mask_offset()));
|
||||
__ increment_mask_and_jump(backedge_counter, increment, mask, G4_scratch, O0,
|
||||
Assembler::notZero, &Lforward);
|
||||
__ bind(Loverflow);
|
||||
@ -1663,18 +1663,19 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
__ jmp(O2, G0);
|
||||
__ delayed()->nop();
|
||||
|
||||
} else {
|
||||
} else { // not TieredCompilation
|
||||
// Update Backedge branch separately from invocations
|
||||
const Register G4_invoke_ctr = G4;
|
||||
__ increment_backedge_counter(Rcounters, G4_invoke_ctr, G1_scratch);
|
||||
__ increment_backedge_counter(G3_method_counters, G4_invoke_ctr, G1_scratch);
|
||||
if (ProfileInterpreter) {
|
||||
__ test_invocation_counter_for_mdp(G4_invoke_ctr, G3_scratch, Lforward);
|
||||
__ test_invocation_counter_for_mdp(G4_invoke_ctr, G3_method_counters, G1_scratch, Lforward);
|
||||
if (UseOnStackReplacement) {
|
||||
__ test_backedge_count_for_osr(O2_bumped_count, l_cur_bcp, G3_scratch);
|
||||
|
||||
__ test_backedge_count_for_osr(O2_bumped_count, G3_method_counters, l_cur_bcp, G1_scratch);
|
||||
}
|
||||
} else {
|
||||
if (UseOnStackReplacement) {
|
||||
__ test_backedge_count_for_osr(G4_invoke_ctr, l_cur_bcp, G3_scratch);
|
||||
__ test_backedge_count_for_osr(G4_invoke_ctr, G3_method_counters, l_cur_bcp, G1_scratch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 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
|
||||
@ -541,15 +541,6 @@ void G1PreBarrierStub::emit_code(LIR_Assembler* ce) {
|
||||
|
||||
}
|
||||
|
||||
jbyte* G1PostBarrierStub::_byte_map_base = NULL;
|
||||
|
||||
jbyte* G1PostBarrierStub::byte_map_base_slow() {
|
||||
BarrierSet* bs = Universe::heap()->barrier_set();
|
||||
assert(bs->is_a(BarrierSet::G1SATBCTLogging),
|
||||
"Must be if we're using this.");
|
||||
return ((G1SATBCardTableModRefBS*)bs)->byte_map_base;
|
||||
}
|
||||
|
||||
void G1PostBarrierStub::emit_code(LIR_Assembler* ce) {
|
||||
__ bind(_entry);
|
||||
assert(addr()->is_register(), "Precondition.");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -1398,50 +1398,6 @@ void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_Patch
|
||||
}
|
||||
|
||||
|
||||
void LIR_Assembler::prefetchr(LIR_Opr src) {
|
||||
LIR_Address* addr = src->as_address_ptr();
|
||||
Address from_addr = as_Address(addr);
|
||||
|
||||
if (VM_Version::supports_sse()) {
|
||||
switch (ReadPrefetchInstr) {
|
||||
case 0:
|
||||
__ prefetchnta(from_addr); break;
|
||||
case 1:
|
||||
__ prefetcht0(from_addr); break;
|
||||
case 2:
|
||||
__ prefetcht2(from_addr); break;
|
||||
default:
|
||||
ShouldNotReachHere(); break;
|
||||
}
|
||||
} else if (VM_Version::supports_3dnow_prefetch()) {
|
||||
__ prefetchr(from_addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIR_Assembler::prefetchw(LIR_Opr src) {
|
||||
LIR_Address* addr = src->as_address_ptr();
|
||||
Address from_addr = as_Address(addr);
|
||||
|
||||
if (VM_Version::supports_sse()) {
|
||||
switch (AllocatePrefetchInstr) {
|
||||
case 0:
|
||||
__ prefetchnta(from_addr); break;
|
||||
case 1:
|
||||
__ prefetcht0(from_addr); break;
|
||||
case 2:
|
||||
__ prefetcht2(from_addr); break;
|
||||
case 3:
|
||||
__ prefetchw(from_addr); break;
|
||||
default:
|
||||
ShouldNotReachHere(); break;
|
||||
}
|
||||
} else if (VM_Version::supports_3dnow_prefetch()) {
|
||||
__ prefetchw(from_addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NEEDS_CLEANUP; // This could be static?
|
||||
Address::ScaleFactor LIR_Assembler::array_element_size(BasicType type) const {
|
||||
int elem_size = type2aelembytes(type);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
@ -123,7 +123,9 @@ bool frame::safe_for_sender(JavaThread *thread) {
|
||||
}
|
||||
|
||||
intptr_t* sender_sp = NULL;
|
||||
intptr_t* sender_unextended_sp = NULL;
|
||||
address sender_pc = NULL;
|
||||
intptr_t* saved_fp = NULL;
|
||||
|
||||
if (is_interpreted_frame()) {
|
||||
// fp must be safe
|
||||
@ -132,7 +134,12 @@ bool frame::safe_for_sender(JavaThread *thread) {
|
||||
}
|
||||
|
||||
sender_pc = (address) this->fp()[return_addr_offset];
|
||||
// for interpreted frames, the value below is the sender "raw" sp,
|
||||
// which can be different from the sender unextended sp (the sp seen
|
||||
// by the sender) because of current frame local variables
|
||||
sender_sp = (intptr_t*) addr_at(sender_sp_offset);
|
||||
sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
|
||||
saved_fp = (intptr_t*) this->fp()[link_offset];
|
||||
|
||||
} else {
|
||||
// must be some sort of compiled/runtime frame
|
||||
@ -144,8 +151,11 @@ bool frame::safe_for_sender(JavaThread *thread) {
|
||||
}
|
||||
|
||||
sender_sp = _unextended_sp + _cb->frame_size();
|
||||
sender_unextended_sp = sender_sp;
|
||||
// On Intel the return_address is always the word on the stack
|
||||
sender_pc = (address) *(sender_sp-1);
|
||||
// Note: frame::sender_sp_offset is only valid for compiled frame
|
||||
saved_fp = (intptr_t*) *(sender_sp - frame::sender_sp_offset);
|
||||
}
|
||||
|
||||
|
||||
@ -156,7 +166,6 @@ bool frame::safe_for_sender(JavaThread *thread) {
|
||||
// only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved ebp
|
||||
// is really a frame pointer.
|
||||
|
||||
intptr_t *saved_fp = (intptr_t*)*(sender_sp - frame::sender_sp_offset);
|
||||
bool saved_fp_safe = ((address)saved_fp < thread->stack_base()) && (saved_fp > sender_sp);
|
||||
|
||||
if (!saved_fp_safe) {
|
||||
@ -165,7 +174,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
|
||||
|
||||
// construct the potential sender
|
||||
|
||||
frame sender(sender_sp, saved_fp, sender_pc);
|
||||
frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc);
|
||||
|
||||
return sender.is_interpreted_frame_valid(thread);
|
||||
|
||||
@ -194,7 +203,6 @@ bool frame::safe_for_sender(JavaThread *thread) {
|
||||
|
||||
// Could be the call_stub
|
||||
if (StubRoutines::returns_to_call_stub(sender_pc)) {
|
||||
intptr_t *saved_fp = (intptr_t*)*(sender_sp - frame::sender_sp_offset);
|
||||
bool saved_fp_safe = ((address)saved_fp < thread->stack_base()) && (saved_fp > sender_sp);
|
||||
|
||||
if (!saved_fp_safe) {
|
||||
@ -203,7 +211,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
|
||||
|
||||
// construct the potential sender
|
||||
|
||||
frame sender(sender_sp, saved_fp, sender_pc);
|
||||
frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc);
|
||||
|
||||
// Validate the JavaCallWrapper an entry frame must have
|
||||
address jcw = (address)sender.entry_frame_call_wrapper();
|
||||
@ -568,8 +576,11 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
|
||||
if (!m->is_valid_method()) return false;
|
||||
|
||||
// stack frames shouldn't be much larger than max_stack elements
|
||||
|
||||
if (fp() - sp() > 1024 + m->max_stack()*Interpreter::stackElementSize) {
|
||||
// this test requires the use the unextended_sp which is the sp as seen by
|
||||
// the current frame, and not sp which is the "raw" pc which could point
|
||||
// further because of local variables of the callee method inserted after
|
||||
// method arguments
|
||||
if (fp() - unextended_sp() > 1024 + m->max_stack()*Interpreter::stackElementSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -90,9 +90,6 @@ define_pd_global(uintx, TypeProfileLevel, 111);
|
||||
product(intx, FenceInstruction, 0, \
|
||||
"(Unsafe,Unstable) Experimental") \
|
||||
\
|
||||
product(intx, ReadPrefetchInstr, 0, \
|
||||
"Prefetch instruction to prefetch ahead") \
|
||||
\
|
||||
product(bool, UseStoreImmI16, true, \
|
||||
"Use store immediate 16-bits value instruction on x86") \
|
||||
\
|
||||
|
@ -1360,7 +1360,7 @@ void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
|
||||
|
||||
// Jump if ((*counter_addr += increment) & mask) satisfies the condition.
|
||||
void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr,
|
||||
int increment, int mask,
|
||||
int increment, Address mask,
|
||||
Register scratch, bool preloaded,
|
||||
Condition cond, Label* where) {
|
||||
if (!preloaded) {
|
||||
|
@ -182,7 +182,7 @@
|
||||
void increment_mdp_data_at(Register mdp_in, Register reg, int constant,
|
||||
bool decrement = false);
|
||||
void increment_mask_and_jump(Address counter_addr,
|
||||
int increment, int mask,
|
||||
int increment, Address mask,
|
||||
Register scratch, bool preloaded,
|
||||
Condition cond, Label* where);
|
||||
void set_mdp_flag_at(Register mdp_in, int flag_constant);
|
||||
|
@ -1426,7 +1426,7 @@ void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
|
||||
|
||||
// Jump if ((*counter_addr += increment) & mask) satisfies the condition.
|
||||
void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr,
|
||||
int increment, int mask,
|
||||
int increment, Address mask,
|
||||
Register scratch, bool preloaded,
|
||||
Condition cond, Label* where) {
|
||||
if (!preloaded) {
|
||||
|
@ -191,7 +191,7 @@
|
||||
void increment_mdp_data_at(Register mdp_in, Register reg, int constant,
|
||||
bool decrement = false);
|
||||
void increment_mask_and_jump(Address counter_addr,
|
||||
int increment, int mask,
|
||||
int increment, Address mask,
|
||||
Register scratch, bool preloaded,
|
||||
Condition cond, Label* where);
|
||||
void set_mdp_flag_at(Register mdp_in, int flag_constant);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
@ -3184,7 +3184,24 @@ void MacroAssembler::pow_or_exp(bool is_exp, int num_fpu_regs_in_use) {
|
||||
jmp(done);
|
||||
} else {
|
||||
// Stack: X Y
|
||||
Label x_negative, y_odd;
|
||||
Label x_negative, y_not_2;
|
||||
|
||||
static double two = 2.0;
|
||||
ExternalAddress two_addr((address)&two);
|
||||
|
||||
// constant maybe too far on 64 bit
|
||||
lea(tmp2, two_addr);
|
||||
fld_d(Address(tmp2, 0)); // Stack: 2 X Y
|
||||
fcmp(tmp, 2, true, false); // Stack: X Y
|
||||
jcc(Assembler::parity, y_not_2);
|
||||
jcc(Assembler::notEqual, y_not_2);
|
||||
|
||||
fxch(); fpop(); // Stack: X
|
||||
fmul(0); // Stack: X*X
|
||||
|
||||
jmp(done);
|
||||
|
||||
bind(y_not_2);
|
||||
|
||||
fldz(); // Stack: 0 X Y
|
||||
fcmp(tmp, 1, true, false); // Stack: X Y
|
||||
@ -6177,7 +6194,7 @@ void MacroAssembler::string_indexofC8(Register str1, Register str2,
|
||||
ShortBranchVerifier sbv(this);
|
||||
assert(UseSSE42Intrinsics, "SSE4.2 is required");
|
||||
|
||||
// This method uses pcmpestri inxtruction with bound registers
|
||||
// This method uses pcmpestri instruction with bound registers
|
||||
// inputs:
|
||||
// xmm - substring
|
||||
// rax - substring length (elements count)
|
||||
@ -6338,7 +6355,7 @@ void MacroAssembler::string_indexof(Register str1, Register str2,
|
||||
//
|
||||
assert(int_cnt2 == -1 || (0 < int_cnt2 && int_cnt2 < 8), "should be != 0");
|
||||
|
||||
// This method uses pcmpestri inxtruction with bound registers
|
||||
// This method uses pcmpestri instruction with bound registers
|
||||
// inputs:
|
||||
// xmm - substring
|
||||
// rax - substring length (elements count)
|
||||
@ -6627,7 +6644,6 @@ void MacroAssembler::string_compare(Register str1, Register str2,
|
||||
// start from first character again because it has aligned address.
|
||||
int stride2 = 16;
|
||||
int adr_stride = stride << scale;
|
||||
int adr_stride2 = stride2 << scale;
|
||||
|
||||
assert(result == rax && cnt2 == rdx && cnt1 == rcx, "pcmpestri");
|
||||
// rax and rdx are used by pcmpestri as elements counters
|
||||
@ -6726,7 +6742,7 @@ void MacroAssembler::string_compare(Register str1, Register str2,
|
||||
// inputs:
|
||||
// vec1- substring
|
||||
// rax - negative string length (elements count)
|
||||
// mem - scaned string
|
||||
// mem - scanned string
|
||||
// rdx - string length (elements count)
|
||||
// pcmpmask - cmp mode: 11000 (string compare with negated result)
|
||||
// + 00 (unsigned bytes) or + 01 (unsigned shorts)
|
||||
|
@ -602,7 +602,3 @@ address NativeGeneralJump::jump_destination() const {
|
||||
else
|
||||
return addr_at(0) + length + sbyte_at(offset);
|
||||
}
|
||||
|
||||
bool NativeInstruction::is_dtrace_trap() {
|
||||
return (*(int32_t*)this & 0xff) == 0xcc;
|
||||
}
|
||||
|
@ -59,7 +59,6 @@ class NativeInstruction VALUE_OBJ_CLASS_SPEC {
|
||||
};
|
||||
|
||||
bool is_nop() { return ubyte_at(0) == nop_instruction_code; }
|
||||
bool is_dtrace_trap();
|
||||
inline bool is_call();
|
||||
inline bool is_illegal();
|
||||
inline bool is_return();
|
||||
|
@ -2415,381 +2415,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_DTRACE_H
|
||||
// ---------------------------------------------------------------------------
|
||||
// Generate a dtrace nmethod for a given signature. The method takes arguments
|
||||
// in the Java compiled code convention, marshals them to the native
|
||||
// abi and then leaves nops at the position you would expect to call a native
|
||||
// function. When the probe is enabled the nops are replaced with a trap
|
||||
// instruction that dtrace inserts and the trace will cause a notification
|
||||
// to dtrace.
|
||||
//
|
||||
// The probes are only able to take primitive types and java/lang/String as
|
||||
// arguments. No other java types are allowed. Strings are converted to utf8
|
||||
// strings so that from dtrace point of view java strings are converted to C
|
||||
// strings. There is an arbitrary fixed limit on the total space that a method
|
||||
// can use for converting the strings. (256 chars per string in the signature).
|
||||
// So any java string larger then this is truncated.
|
||||
|
||||
nmethod *SharedRuntime::generate_dtrace_nmethod(
|
||||
MacroAssembler *masm, methodHandle method) {
|
||||
|
||||
// generate_dtrace_nmethod is guarded by a mutex so we are sure to
|
||||
// be single threaded in this method.
|
||||
assert(AdapterHandlerLibrary_lock->owned_by_self(), "must be");
|
||||
|
||||
// Fill in the signature array, for the calling-convention call.
|
||||
int total_args_passed = method->size_of_parameters();
|
||||
|
||||
BasicType* in_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
|
||||
VMRegPair *in_regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
|
||||
|
||||
// The signature we are going to use for the trap that dtrace will see
|
||||
// java/lang/String is converted. We drop "this" and any other object
|
||||
// is converted to NULL. (A one-slot java/lang/Long object reference
|
||||
// is converted to a two-slot long, which is why we double the allocation).
|
||||
BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed * 2);
|
||||
VMRegPair* out_regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed * 2);
|
||||
|
||||
int i=0;
|
||||
int total_strings = 0;
|
||||
int first_arg_to_pass = 0;
|
||||
int total_c_args = 0;
|
||||
|
||||
if( !method->is_static() ) { // Pass in receiver first
|
||||
in_sig_bt[i++] = T_OBJECT;
|
||||
first_arg_to_pass = 1;
|
||||
}
|
||||
|
||||
// We need to convert the java args to where a native (non-jni) function
|
||||
// would expect them. To figure out where they go we convert the java
|
||||
// signature to a C signature.
|
||||
|
||||
SignatureStream ss(method->signature());
|
||||
for ( ; !ss.at_return_type(); ss.next()) {
|
||||
BasicType bt = ss.type();
|
||||
in_sig_bt[i++] = bt; // Collect remaining bits of signature
|
||||
out_sig_bt[total_c_args++] = bt;
|
||||
if( bt == T_OBJECT) {
|
||||
Symbol* s = ss.as_symbol_or_null(); // symbol is created
|
||||
if (s == vmSymbols::java_lang_String()) {
|
||||
total_strings++;
|
||||
out_sig_bt[total_c_args-1] = T_ADDRESS;
|
||||
} else if (s == vmSymbols::java_lang_Boolean() ||
|
||||
s == vmSymbols::java_lang_Character() ||
|
||||
s == vmSymbols::java_lang_Byte() ||
|
||||
s == vmSymbols::java_lang_Short() ||
|
||||
s == vmSymbols::java_lang_Integer() ||
|
||||
s == vmSymbols::java_lang_Float()) {
|
||||
out_sig_bt[total_c_args-1] = T_INT;
|
||||
} else if (s == vmSymbols::java_lang_Long() ||
|
||||
s == vmSymbols::java_lang_Double()) {
|
||||
out_sig_bt[total_c_args-1] = T_LONG;
|
||||
out_sig_bt[total_c_args++] = T_VOID;
|
||||
}
|
||||
} else if ( bt == T_LONG || bt == T_DOUBLE ) {
|
||||
in_sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots
|
||||
out_sig_bt[total_c_args++] = T_VOID;
|
||||
}
|
||||
}
|
||||
|
||||
assert(i==total_args_passed, "validly parsed signature");
|
||||
|
||||
// Now get the compiled-Java layout as input arguments
|
||||
int comp_args_on_stack;
|
||||
comp_args_on_stack = SharedRuntime::java_calling_convention(
|
||||
in_sig_bt, in_regs, total_args_passed, false);
|
||||
|
||||
// Now figure out where the args must be stored and how much stack space
|
||||
// they require (neglecting out_preserve_stack_slots).
|
||||
|
||||
int out_arg_slots;
|
||||
out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
|
||||
|
||||
// Calculate the total number of stack slots we will need.
|
||||
|
||||
// First count the abi requirement plus all of the outgoing args
|
||||
int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
|
||||
|
||||
// Now space for the string(s) we must convert
|
||||
|
||||
int* string_locs = NEW_RESOURCE_ARRAY(int, total_strings + 1);
|
||||
for (i = 0; i < total_strings ; i++) {
|
||||
string_locs[i] = stack_slots;
|
||||
stack_slots += max_dtrace_string_size / VMRegImpl::stack_slot_size;
|
||||
}
|
||||
|
||||
// + 2 for return address (which we own) and saved rbp,
|
||||
|
||||
stack_slots += 2;
|
||||
|
||||
// Ok The space we have allocated will look like:
|
||||
//
|
||||
//
|
||||
// FP-> | |
|
||||
// |---------------------|
|
||||
// | string[n] |
|
||||
// |---------------------| <- string_locs[n]
|
||||
// | string[n-1] |
|
||||
// |---------------------| <- string_locs[n-1]
|
||||
// | ... |
|
||||
// | ... |
|
||||
// |---------------------| <- string_locs[1]
|
||||
// | string[0] |
|
||||
// |---------------------| <- string_locs[0]
|
||||
// | outbound memory |
|
||||
// | based arguments |
|
||||
// | |
|
||||
// |---------------------|
|
||||
// | |
|
||||
// SP-> | out_preserved_slots |
|
||||
//
|
||||
//
|
||||
|
||||
// Now compute actual number of stack words we need rounding to make
|
||||
// stack properly aligned.
|
||||
stack_slots = round_to(stack_slots, 2 * VMRegImpl::slots_per_word);
|
||||
|
||||
int stack_size = stack_slots * VMRegImpl::stack_slot_size;
|
||||
|
||||
intptr_t start = (intptr_t)__ pc();
|
||||
|
||||
// First thing make an ic check to see if we should even be here
|
||||
|
||||
// We are free to use all registers as temps without saving them and
|
||||
// restoring them except rbp. rbp, is the only callee save register
|
||||
// as far as the interpreter and the compiler(s) are concerned.
|
||||
|
||||
const Register ic_reg = rax;
|
||||
const Register receiver = rcx;
|
||||
Label hit;
|
||||
Label exception_pending;
|
||||
|
||||
|
||||
__ verify_oop(receiver);
|
||||
__ cmpl(ic_reg, Address(receiver, oopDesc::klass_offset_in_bytes()));
|
||||
__ jcc(Assembler::equal, hit);
|
||||
|
||||
__ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
|
||||
|
||||
// verified entry must be aligned for code patching.
|
||||
// and the first 5 bytes must be in the same cache line
|
||||
// if we align at 8 then we will be sure 5 bytes are in the same line
|
||||
__ align(8);
|
||||
|
||||
__ bind(hit);
|
||||
|
||||
int vep_offset = ((intptr_t)__ pc()) - start;
|
||||
|
||||
|
||||
// The instruction at the verified entry point must be 5 bytes or longer
|
||||
// because it can be patched on the fly by make_non_entrant. The stack bang
|
||||
// instruction fits that requirement.
|
||||
|
||||
// Generate stack overflow check
|
||||
|
||||
|
||||
if (UseStackBanging) {
|
||||
if (stack_size <= StackShadowPages*os::vm_page_size()) {
|
||||
__ bang_stack_with_offset(StackShadowPages*os::vm_page_size());
|
||||
} else {
|
||||
__ movl(rax, stack_size);
|
||||
__ bang_stack_size(rax, rbx);
|
||||
}
|
||||
} else {
|
||||
// need a 5 byte instruction to allow MT safe patching to non-entrant
|
||||
__ fat_nop();
|
||||
}
|
||||
|
||||
assert(((int)__ pc() - start - vep_offset) >= 5,
|
||||
"valid size for make_non_entrant");
|
||||
|
||||
// Generate a new frame for the wrapper.
|
||||
__ enter();
|
||||
|
||||
// -2 because return address is already present and so is saved rbp,
|
||||
if (stack_size - 2*wordSize != 0) {
|
||||
__ subl(rsp, stack_size - 2*wordSize);
|
||||
}
|
||||
|
||||
// Frame is now completed as far a size and linkage.
|
||||
|
||||
int frame_complete = ((intptr_t)__ pc()) - start;
|
||||
|
||||
// First thing we do store all the args as if we are doing the call.
|
||||
// Since the C calling convention is stack based that ensures that
|
||||
// all the Java register args are stored before we need to convert any
|
||||
// string we might have.
|
||||
|
||||
int sid = 0;
|
||||
int c_arg, j_arg;
|
||||
int string_reg = 0;
|
||||
|
||||
for (j_arg = first_arg_to_pass, c_arg = 0 ;
|
||||
j_arg < total_args_passed ; j_arg++, c_arg++ ) {
|
||||
|
||||
VMRegPair src = in_regs[j_arg];
|
||||
VMRegPair dst = out_regs[c_arg];
|
||||
assert(dst.first()->is_stack() || in_sig_bt[j_arg] == T_VOID,
|
||||
"stack based abi assumed");
|
||||
|
||||
switch (in_sig_bt[j_arg]) {
|
||||
|
||||
case T_ARRAY:
|
||||
case T_OBJECT:
|
||||
if (out_sig_bt[c_arg] == T_ADDRESS) {
|
||||
// Any register based arg for a java string after the first
|
||||
// will be destroyed by the call to get_utf so we store
|
||||
// the original value in the location the utf string address
|
||||
// will eventually be stored.
|
||||
if (src.first()->is_reg()) {
|
||||
if (string_reg++ != 0) {
|
||||
simple_move32(masm, src, dst);
|
||||
}
|
||||
}
|
||||
} else if (out_sig_bt[c_arg] == T_INT || out_sig_bt[c_arg] == T_LONG) {
|
||||
// need to unbox a one-word value
|
||||
Register in_reg = rax;
|
||||
if ( src.first()->is_reg() ) {
|
||||
in_reg = src.first()->as_Register();
|
||||
} else {
|
||||
simple_move32(masm, src, in_reg->as_VMReg());
|
||||
}
|
||||
Label skipUnbox;
|
||||
__ movl(Address(rsp, reg2offset_out(dst.first())), NULL_WORD);
|
||||
if ( out_sig_bt[c_arg] == T_LONG ) {
|
||||
__ movl(Address(rsp, reg2offset_out(dst.second())), NULL_WORD);
|
||||
}
|
||||
__ testl(in_reg, in_reg);
|
||||
__ jcc(Assembler::zero, skipUnbox);
|
||||
assert(dst.first()->is_stack() &&
|
||||
(!dst.second()->is_valid() || dst.second()->is_stack()),
|
||||
"value(s) must go into stack slots");
|
||||
|
||||
BasicType bt = out_sig_bt[c_arg];
|
||||
int box_offset = java_lang_boxing_object::value_offset_in_bytes(bt);
|
||||
if ( bt == T_LONG ) {
|
||||
__ movl(rbx, Address(in_reg,
|
||||
box_offset + VMRegImpl::stack_slot_size));
|
||||
__ movl(Address(rsp, reg2offset_out(dst.second())), rbx);
|
||||
}
|
||||
__ movl(in_reg, Address(in_reg, box_offset));
|
||||
__ movl(Address(rsp, reg2offset_out(dst.first())), in_reg);
|
||||
__ bind(skipUnbox);
|
||||
} else {
|
||||
// Convert the arg to NULL
|
||||
__ movl(Address(rsp, reg2offset_out(dst.first())), NULL_WORD);
|
||||
}
|
||||
if (out_sig_bt[c_arg] == T_LONG) {
|
||||
assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
|
||||
++c_arg; // Move over the T_VOID To keep the loop indices in sync
|
||||
}
|
||||
break;
|
||||
|
||||
case T_VOID:
|
||||
break;
|
||||
|
||||
case T_FLOAT:
|
||||
float_move(masm, src, dst);
|
||||
break;
|
||||
|
||||
case T_DOUBLE:
|
||||
assert( j_arg + 1 < total_args_passed &&
|
||||
in_sig_bt[j_arg + 1] == T_VOID, "bad arg list");
|
||||
double_move(masm, src, dst);
|
||||
break;
|
||||
|
||||
case T_LONG :
|
||||
long_move(masm, src, dst);
|
||||
break;
|
||||
|
||||
case T_ADDRESS: assert(false, "found T_ADDRESS in java args");
|
||||
|
||||
default:
|
||||
simple_move32(masm, src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
// Now we must convert any string we have to utf8
|
||||
//
|
||||
|
||||
for (sid = 0, j_arg = first_arg_to_pass, c_arg = 0 ;
|
||||
sid < total_strings ; j_arg++, c_arg++ ) {
|
||||
|
||||
if (out_sig_bt[c_arg] == T_ADDRESS) {
|
||||
|
||||
Address utf8_addr = Address(
|
||||
rsp, string_locs[sid++] * VMRegImpl::stack_slot_size);
|
||||
__ leal(rax, utf8_addr);
|
||||
|
||||
// The first string we find might still be in the original java arg
|
||||
// register
|
||||
VMReg orig_loc = in_regs[j_arg].first();
|
||||
Register string_oop;
|
||||
|
||||
// This is where the argument will eventually reside
|
||||
Address dest = Address(rsp, reg2offset_out(out_regs[c_arg].first()));
|
||||
|
||||
if (sid == 1 && orig_loc->is_reg()) {
|
||||
string_oop = orig_loc->as_Register();
|
||||
assert(string_oop != rax, "smashed arg");
|
||||
} else {
|
||||
|
||||
if (orig_loc->is_reg()) {
|
||||
// Get the copy of the jls object
|
||||
__ movl(rcx, dest);
|
||||
} else {
|
||||
// arg is still in the original location
|
||||
__ movl(rcx, Address(rbp, reg2offset_in(orig_loc)));
|
||||
}
|
||||
string_oop = rcx;
|
||||
|
||||
}
|
||||
Label nullString;
|
||||
__ movl(dest, NULL_WORD);
|
||||
__ testl(string_oop, string_oop);
|
||||
__ jcc(Assembler::zero, nullString);
|
||||
|
||||
// Now we can store the address of the utf string as the argument
|
||||
__ movl(dest, rax);
|
||||
|
||||
// And do the conversion
|
||||
__ call_VM_leaf(CAST_FROM_FN_PTR(
|
||||
address, SharedRuntime::get_utf), string_oop, rax);
|
||||
__ bind(nullString);
|
||||
}
|
||||
|
||||
if (in_sig_bt[j_arg] == T_OBJECT && out_sig_bt[c_arg] == T_LONG) {
|
||||
assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
|
||||
++c_arg; // Move over the T_VOID To keep the loop indices in sync
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Ok now we are done. Need to place the nop that dtrace wants in order to
|
||||
// patch in the trap
|
||||
|
||||
int patch_offset = ((intptr_t)__ pc()) - start;
|
||||
|
||||
__ nop();
|
||||
|
||||
|
||||
// Return
|
||||
|
||||
__ leave();
|
||||
__ ret(0);
|
||||
|
||||
__ flush();
|
||||
|
||||
nmethod *nm = nmethod::new_dtrace_nmethod(
|
||||
method, masm->code(), vep_offset, patch_offset, frame_complete,
|
||||
stack_slots / VMRegImpl::slots_per_word);
|
||||
return nm;
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_DTRACE_H
|
||||
|
||||
// this function returns the adjust size (in number of words) to a c2i adapter
|
||||
// activation for use during deoptimization
|
||||
int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals ) {
|
||||
|
@ -2650,630 +2650,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_DTRACE_H
|
||||
// ---------------------------------------------------------------------------
|
||||
// Generate a dtrace nmethod for a given signature. The method takes arguments
|
||||
// in the Java compiled code convention, marshals them to the native
|
||||
// abi and then leaves nops at the position you would expect to call a native
|
||||
// function. When the probe is enabled the nops are replaced with a trap
|
||||
// instruction that dtrace inserts and the trace will cause a notification
|
||||
// to dtrace.
|
||||
//
|
||||
// The probes are only able to take primitive types and java/lang/String as
|
||||
// arguments. No other java types are allowed. Strings are converted to utf8
|
||||
// strings so that from dtrace point of view java strings are converted to C
|
||||
// strings. There is an arbitrary fixed limit on the total space that a method
|
||||
// can use for converting the strings. (256 chars per string in the signature).
|
||||
// So any java string larger then this is truncated.
|
||||
|
||||
static int fp_offset[ConcreteRegisterImpl::number_of_registers] = { 0 };
|
||||
static bool offsets_initialized = false;
|
||||
|
||||
|
||||
nmethod *SharedRuntime::generate_dtrace_nmethod(MacroAssembler *masm,
|
||||
methodHandle method) {
|
||||
|
||||
|
||||
// generate_dtrace_nmethod is guarded by a mutex so we are sure to
|
||||
// be single threaded in this method.
|
||||
assert(AdapterHandlerLibrary_lock->owned_by_self(), "must be");
|
||||
|
||||
if (!offsets_initialized) {
|
||||
fp_offset[c_rarg0->as_VMReg()->value()] = -1 * wordSize;
|
||||
fp_offset[c_rarg1->as_VMReg()->value()] = -2 * wordSize;
|
||||
fp_offset[c_rarg2->as_VMReg()->value()] = -3 * wordSize;
|
||||
fp_offset[c_rarg3->as_VMReg()->value()] = -4 * wordSize;
|
||||
fp_offset[c_rarg4->as_VMReg()->value()] = -5 * wordSize;
|
||||
fp_offset[c_rarg5->as_VMReg()->value()] = -6 * wordSize;
|
||||
|
||||
fp_offset[c_farg0->as_VMReg()->value()] = -7 * wordSize;
|
||||
fp_offset[c_farg1->as_VMReg()->value()] = -8 * wordSize;
|
||||
fp_offset[c_farg2->as_VMReg()->value()] = -9 * wordSize;
|
||||
fp_offset[c_farg3->as_VMReg()->value()] = -10 * wordSize;
|
||||
fp_offset[c_farg4->as_VMReg()->value()] = -11 * wordSize;
|
||||
fp_offset[c_farg5->as_VMReg()->value()] = -12 * wordSize;
|
||||
fp_offset[c_farg6->as_VMReg()->value()] = -13 * wordSize;
|
||||
fp_offset[c_farg7->as_VMReg()->value()] = -14 * wordSize;
|
||||
|
||||
offsets_initialized = true;
|
||||
}
|
||||
// Fill in the signature array, for the calling-convention call.
|
||||
int total_args_passed = method->size_of_parameters();
|
||||
|
||||
BasicType* in_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
|
||||
VMRegPair *in_regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
|
||||
|
||||
// The signature we are going to use for the trap that dtrace will see
|
||||
// java/lang/String is converted. We drop "this" and any other object
|
||||
// is converted to NULL. (A one-slot java/lang/Long object reference
|
||||
// is converted to a two-slot long, which is why we double the allocation).
|
||||
BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed * 2);
|
||||
VMRegPair* out_regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed * 2);
|
||||
|
||||
int i=0;
|
||||
int total_strings = 0;
|
||||
int first_arg_to_pass = 0;
|
||||
int total_c_args = 0;
|
||||
|
||||
// Skip the receiver as dtrace doesn't want to see it
|
||||
if( !method->is_static() ) {
|
||||
in_sig_bt[i++] = T_OBJECT;
|
||||
first_arg_to_pass = 1;
|
||||
}
|
||||
|
||||
// We need to convert the java args to where a native (non-jni) function
|
||||
// would expect them. To figure out where they go we convert the java
|
||||
// signature to a C signature.
|
||||
|
||||
SignatureStream ss(method->signature());
|
||||
for ( ; !ss.at_return_type(); ss.next()) {
|
||||
BasicType bt = ss.type();
|
||||
in_sig_bt[i++] = bt; // Collect remaining bits of signature
|
||||
out_sig_bt[total_c_args++] = bt;
|
||||
if( bt == T_OBJECT) {
|
||||
Symbol* s = ss.as_symbol_or_null(); // symbol is created
|
||||
if (s == vmSymbols::java_lang_String()) {
|
||||
total_strings++;
|
||||
out_sig_bt[total_c_args-1] = T_ADDRESS;
|
||||
} else if (s == vmSymbols::java_lang_Boolean() ||
|
||||
s == vmSymbols::java_lang_Character() ||
|
||||
s == vmSymbols::java_lang_Byte() ||
|
||||
s == vmSymbols::java_lang_Short() ||
|
||||
s == vmSymbols::java_lang_Integer() ||
|
||||
s == vmSymbols::java_lang_Float()) {
|
||||
out_sig_bt[total_c_args-1] = T_INT;
|
||||
} else if (s == vmSymbols::java_lang_Long() ||
|
||||
s == vmSymbols::java_lang_Double()) {
|
||||
out_sig_bt[total_c_args-1] = T_LONG;
|
||||
out_sig_bt[total_c_args++] = T_VOID;
|
||||
}
|
||||
} else if ( bt == T_LONG || bt == T_DOUBLE ) {
|
||||
in_sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots
|
||||
// We convert double to long
|
||||
out_sig_bt[total_c_args-1] = T_LONG;
|
||||
out_sig_bt[total_c_args++] = T_VOID;
|
||||
} else if ( bt == T_FLOAT) {
|
||||
// We convert float to int
|
||||
out_sig_bt[total_c_args-1] = T_INT;
|
||||
}
|
||||
}
|
||||
|
||||
assert(i==total_args_passed, "validly parsed signature");
|
||||
|
||||
// Now get the compiled-Java layout as input arguments
|
||||
int comp_args_on_stack;
|
||||
comp_args_on_stack = SharedRuntime::java_calling_convention(
|
||||
in_sig_bt, in_regs, total_args_passed, false);
|
||||
|
||||
// Now figure out where the args must be stored and how much stack space
|
||||
// they require (neglecting out_preserve_stack_slots but space for storing
|
||||
// the 1st six register arguments). It's weird see int_stk_helper.
|
||||
|
||||
int out_arg_slots;
|
||||
out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
|
||||
|
||||
// Calculate the total number of stack slots we will need.
|
||||
|
||||
// First count the abi requirement plus all of the outgoing args
|
||||
int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
|
||||
|
||||
// Now space for the string(s) we must convert
|
||||
int* string_locs = NEW_RESOURCE_ARRAY(int, total_strings + 1);
|
||||
for (i = 0; i < total_strings ; i++) {
|
||||
string_locs[i] = stack_slots;
|
||||
stack_slots += max_dtrace_string_size / VMRegImpl::stack_slot_size;
|
||||
}
|
||||
|
||||
// Plus the temps we might need to juggle register args
|
||||
// regs take two slots each
|
||||
stack_slots += (Argument::n_int_register_parameters_c +
|
||||
Argument::n_float_register_parameters_c) * 2;
|
||||
|
||||
|
||||
// + 4 for return address (which we own) and saved rbp,
|
||||
|
||||
stack_slots += 4;
|
||||
|
||||
// Ok The space we have allocated will look like:
|
||||
//
|
||||
//
|
||||
// FP-> | |
|
||||
// |---------------------|
|
||||
// | string[n] |
|
||||
// |---------------------| <- string_locs[n]
|
||||
// | string[n-1] |
|
||||
// |---------------------| <- string_locs[n-1]
|
||||
// | ... |
|
||||
// | ... |
|
||||
// |---------------------| <- string_locs[1]
|
||||
// | string[0] |
|
||||
// |---------------------| <- string_locs[0]
|
||||
// | outbound memory |
|
||||
// | based arguments |
|
||||
// | |
|
||||
// |---------------------|
|
||||
// | |
|
||||
// SP-> | out_preserved_slots |
|
||||
//
|
||||
//
|
||||
|
||||
// Now compute actual number of stack words we need rounding to make
|
||||
// stack properly aligned.
|
||||
stack_slots = round_to(stack_slots, 4 * VMRegImpl::slots_per_word);
|
||||
|
||||
int stack_size = stack_slots * VMRegImpl::stack_slot_size;
|
||||
|
||||
intptr_t start = (intptr_t)__ pc();
|
||||
|
||||
// First thing make an ic check to see if we should even be here
|
||||
|
||||
// We are free to use all registers as temps without saving them and
|
||||
// restoring them except rbp. rbp, is the only callee save register
|
||||
// as far as the interpreter and the compiler(s) are concerned.
|
||||
|
||||
const Register ic_reg = rax;
|
||||
const Register receiver = rcx;
|
||||
Label hit;
|
||||
Label exception_pending;
|
||||
|
||||
|
||||
__ verify_oop(receiver);
|
||||
__ cmpl(ic_reg, Address(receiver, oopDesc::klass_offset_in_bytes()));
|
||||
__ jcc(Assembler::equal, hit);
|
||||
|
||||
__ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
|
||||
|
||||
// verified entry must be aligned for code patching.
|
||||
// and the first 5 bytes must be in the same cache line
|
||||
// if we align at 8 then we will be sure 5 bytes are in the same line
|
||||
__ align(8);
|
||||
|
||||
__ bind(hit);
|
||||
|
||||
int vep_offset = ((intptr_t)__ pc()) - start;
|
||||
|
||||
|
||||
// The instruction at the verified entry point must be 5 bytes or longer
|
||||
// because it can be patched on the fly by make_non_entrant. The stack bang
|
||||
// instruction fits that requirement.
|
||||
|
||||
// Generate stack overflow check
|
||||
|
||||
if (UseStackBanging) {
|
||||
if (stack_size <= StackShadowPages*os::vm_page_size()) {
|
||||
__ bang_stack_with_offset(StackShadowPages*os::vm_page_size());
|
||||
} else {
|
||||
__ movl(rax, stack_size);
|
||||
__ bang_stack_size(rax, rbx);
|
||||
}
|
||||
} else {
|
||||
// need a 5 byte instruction to allow MT safe patching to non-entrant
|
||||
__ fat_nop();
|
||||
}
|
||||
|
||||
assert(((uintptr_t)__ pc() - start - vep_offset) >= 5,
|
||||
"valid size for make_non_entrant");
|
||||
|
||||
// Generate a new frame for the wrapper.
|
||||
__ enter();
|
||||
|
||||
// -4 because return address is already present and so is saved rbp,
|
||||
if (stack_size - 2*wordSize != 0) {
|
||||
__ subq(rsp, stack_size - 2*wordSize);
|
||||
}
|
||||
|
||||
// Frame is now completed as far a size and linkage.
|
||||
|
||||
int frame_complete = ((intptr_t)__ pc()) - start;
|
||||
|
||||
int c_arg, j_arg;
|
||||
|
||||
// State of input register args
|
||||
|
||||
bool live[ConcreteRegisterImpl::number_of_registers];
|
||||
|
||||
live[j_rarg0->as_VMReg()->value()] = false;
|
||||
live[j_rarg1->as_VMReg()->value()] = false;
|
||||
live[j_rarg2->as_VMReg()->value()] = false;
|
||||
live[j_rarg3->as_VMReg()->value()] = false;
|
||||
live[j_rarg4->as_VMReg()->value()] = false;
|
||||
live[j_rarg5->as_VMReg()->value()] = false;
|
||||
|
||||
live[j_farg0->as_VMReg()->value()] = false;
|
||||
live[j_farg1->as_VMReg()->value()] = false;
|
||||
live[j_farg2->as_VMReg()->value()] = false;
|
||||
live[j_farg3->as_VMReg()->value()] = false;
|
||||
live[j_farg4->as_VMReg()->value()] = false;
|
||||
live[j_farg5->as_VMReg()->value()] = false;
|
||||
live[j_farg6->as_VMReg()->value()] = false;
|
||||
live[j_farg7->as_VMReg()->value()] = false;
|
||||
|
||||
|
||||
bool rax_is_zero = false;
|
||||
|
||||
// All args (except strings) destined for the stack are moved first
|
||||
for (j_arg = first_arg_to_pass, c_arg = 0 ;
|
||||
j_arg < total_args_passed ; j_arg++, c_arg++ ) {
|
||||
VMRegPair src = in_regs[j_arg];
|
||||
VMRegPair dst = out_regs[c_arg];
|
||||
|
||||
// Get the real reg value or a dummy (rsp)
|
||||
|
||||
int src_reg = src.first()->is_reg() ?
|
||||
src.first()->value() :
|
||||
rsp->as_VMReg()->value();
|
||||
|
||||
bool useless = in_sig_bt[j_arg] == T_ARRAY ||
|
||||
(in_sig_bt[j_arg] == T_OBJECT &&
|
||||
out_sig_bt[c_arg] != T_INT &&
|
||||
out_sig_bt[c_arg] != T_ADDRESS &&
|
||||
out_sig_bt[c_arg] != T_LONG);
|
||||
|
||||
live[src_reg] = !useless;
|
||||
|
||||
if (dst.first()->is_stack()) {
|
||||
|
||||
// Even though a string arg in a register is still live after this loop
|
||||
// after the string conversion loop (next) it will be dead so we take
|
||||
// advantage of that now for simpler code to manage live.
|
||||
|
||||
live[src_reg] = false;
|
||||
switch (in_sig_bt[j_arg]) {
|
||||
|
||||
case T_ARRAY:
|
||||
case T_OBJECT:
|
||||
{
|
||||
Address stack_dst(rsp, reg2offset_out(dst.first()));
|
||||
|
||||
if (out_sig_bt[c_arg] == T_INT || out_sig_bt[c_arg] == T_LONG) {
|
||||
// need to unbox a one-word value
|
||||
Register in_reg = rax;
|
||||
if ( src.first()->is_reg() ) {
|
||||
in_reg = src.first()->as_Register();
|
||||
} else {
|
||||
__ movq(rax, Address(rbp, reg2offset_in(src.first())));
|
||||
rax_is_zero = false;
|
||||
}
|
||||
Label skipUnbox;
|
||||
__ movptr(Address(rsp, reg2offset_out(dst.first())),
|
||||
(int32_t)NULL_WORD);
|
||||
__ testq(in_reg, in_reg);
|
||||
__ jcc(Assembler::zero, skipUnbox);
|
||||
|
||||
BasicType bt = out_sig_bt[c_arg];
|
||||
int box_offset = java_lang_boxing_object::value_offset_in_bytes(bt);
|
||||
Address src1(in_reg, box_offset);
|
||||
if ( bt == T_LONG ) {
|
||||
__ movq(in_reg, src1);
|
||||
__ movq(stack_dst, in_reg);
|
||||
assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
|
||||
++c_arg; // skip over T_VOID to keep the loop indices in sync
|
||||
} else {
|
||||
__ movl(in_reg, src1);
|
||||
__ movl(stack_dst, in_reg);
|
||||
}
|
||||
|
||||
__ bind(skipUnbox);
|
||||
} else if (out_sig_bt[c_arg] != T_ADDRESS) {
|
||||
// Convert the arg to NULL
|
||||
if (!rax_is_zero) {
|
||||
__ xorq(rax, rax);
|
||||
rax_is_zero = true;
|
||||
}
|
||||
__ movq(stack_dst, rax);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case T_VOID:
|
||||
break;
|
||||
|
||||
case T_FLOAT:
|
||||
// This does the right thing since we know it is destined for the
|
||||
// stack
|
||||
float_move(masm, src, dst);
|
||||
break;
|
||||
|
||||
case T_DOUBLE:
|
||||
// This does the right thing since we know it is destined for the
|
||||
// stack
|
||||
double_move(masm, src, dst);
|
||||
break;
|
||||
|
||||
case T_LONG :
|
||||
long_move(masm, src, dst);
|
||||
break;
|
||||
|
||||
case T_ADDRESS: assert(false, "found T_ADDRESS in java args");
|
||||
|
||||
default:
|
||||
move32_64(masm, src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If we have any strings we must store any register based arg to the stack
|
||||
// This includes any still live xmm registers too.
|
||||
|
||||
int sid = 0;
|
||||
|
||||
if (total_strings > 0 ) {
|
||||
for (j_arg = first_arg_to_pass, c_arg = 0 ;
|
||||
j_arg < total_args_passed ; j_arg++, c_arg++ ) {
|
||||
VMRegPair src = in_regs[j_arg];
|
||||
VMRegPair dst = out_regs[c_arg];
|
||||
|
||||
if (src.first()->is_reg()) {
|
||||
Address src_tmp(rbp, fp_offset[src.first()->value()]);
|
||||
|
||||
// string oops were left untouched by the previous loop even if the
|
||||
// eventual (converted) arg is destined for the stack so park them
|
||||
// away now (except for first)
|
||||
|
||||
if (out_sig_bt[c_arg] == T_ADDRESS) {
|
||||
Address utf8_addr = Address(
|
||||
rsp, string_locs[sid++] * VMRegImpl::stack_slot_size);
|
||||
if (sid != 1) {
|
||||
// The first string arg won't be killed until after the utf8
|
||||
// conversion
|
||||
__ movq(utf8_addr, src.first()->as_Register());
|
||||
}
|
||||
} else if (dst.first()->is_reg()) {
|
||||
if (in_sig_bt[j_arg] == T_FLOAT || in_sig_bt[j_arg] == T_DOUBLE) {
|
||||
|
||||
// Convert the xmm register to an int and store it in the reserved
|
||||
// location for the eventual c register arg
|
||||
XMMRegister f = src.first()->as_XMMRegister();
|
||||
if (in_sig_bt[j_arg] == T_FLOAT) {
|
||||
__ movflt(src_tmp, f);
|
||||
} else {
|
||||
__ movdbl(src_tmp, f);
|
||||
}
|
||||
} else {
|
||||
// If the arg is an oop type we don't support don't bother to store
|
||||
// it remember string was handled above.
|
||||
bool useless = in_sig_bt[j_arg] == T_ARRAY ||
|
||||
(in_sig_bt[j_arg] == T_OBJECT &&
|
||||
out_sig_bt[c_arg] != T_INT &&
|
||||
out_sig_bt[c_arg] != T_LONG);
|
||||
|
||||
if (!useless) {
|
||||
__ movq(src_tmp, src.first()->as_Register());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (in_sig_bt[j_arg] == T_OBJECT && out_sig_bt[c_arg] == T_LONG) {
|
||||
assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
|
||||
++c_arg; // skip over T_VOID to keep the loop indices in sync
|
||||
}
|
||||
}
|
||||
|
||||
// Now that the volatile registers are safe, convert all the strings
|
||||
sid = 0;
|
||||
|
||||
for (j_arg = first_arg_to_pass, c_arg = 0 ;
|
||||
j_arg < total_args_passed ; j_arg++, c_arg++ ) {
|
||||
if (out_sig_bt[c_arg] == T_ADDRESS) {
|
||||
// It's a string
|
||||
Address utf8_addr = Address(
|
||||
rsp, string_locs[sid++] * VMRegImpl::stack_slot_size);
|
||||
// The first string we find might still be in the original java arg
|
||||
// register
|
||||
|
||||
VMReg src = in_regs[j_arg].first();
|
||||
|
||||
// We will need to eventually save the final argument to the trap
|
||||
// in the von-volatile location dedicated to src. This is the offset
|
||||
// from fp we will use.
|
||||
int src_off = src->is_reg() ?
|
||||
fp_offset[src->value()] : reg2offset_in(src);
|
||||
|
||||
// This is where the argument will eventually reside
|
||||
VMRegPair dst = out_regs[c_arg];
|
||||
|
||||
if (src->is_reg()) {
|
||||
if (sid == 1) {
|
||||
__ movq(c_rarg0, src->as_Register());
|
||||
} else {
|
||||
__ movq(c_rarg0, utf8_addr);
|
||||
}
|
||||
} else {
|
||||
// arg is still in the original location
|
||||
__ movq(c_rarg0, Address(rbp, reg2offset_in(src)));
|
||||
}
|
||||
Label done, convert;
|
||||
|
||||
// see if the oop is NULL
|
||||
__ testq(c_rarg0, c_rarg0);
|
||||
__ jcc(Assembler::notEqual, convert);
|
||||
|
||||
if (dst.first()->is_reg()) {
|
||||
// Save the ptr to utf string in the origina src loc or the tmp
|
||||
// dedicated to it
|
||||
__ movq(Address(rbp, src_off), c_rarg0);
|
||||
} else {
|
||||
__ movq(Address(rsp, reg2offset_out(dst.first())), c_rarg0);
|
||||
}
|
||||
__ jmp(done);
|
||||
|
||||
__ bind(convert);
|
||||
|
||||
__ lea(c_rarg1, utf8_addr);
|
||||
if (dst.first()->is_reg()) {
|
||||
__ movq(Address(rbp, src_off), c_rarg1);
|
||||
} else {
|
||||
__ movq(Address(rsp, reg2offset_out(dst.first())), c_rarg1);
|
||||
}
|
||||
// And do the conversion
|
||||
__ call(RuntimeAddress(
|
||||
CAST_FROM_FN_PTR(address, SharedRuntime::get_utf)));
|
||||
|
||||
__ bind(done);
|
||||
}
|
||||
if (in_sig_bt[j_arg] == T_OBJECT && out_sig_bt[c_arg] == T_LONG) {
|
||||
assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
|
||||
++c_arg; // skip over T_VOID to keep the loop indices in sync
|
||||
}
|
||||
}
|
||||
// The get_utf call killed all the c_arg registers
|
||||
live[c_rarg0->as_VMReg()->value()] = false;
|
||||
live[c_rarg1->as_VMReg()->value()] = false;
|
||||
live[c_rarg2->as_VMReg()->value()] = false;
|
||||
live[c_rarg3->as_VMReg()->value()] = false;
|
||||
live[c_rarg4->as_VMReg()->value()] = false;
|
||||
live[c_rarg5->as_VMReg()->value()] = false;
|
||||
|
||||
live[c_farg0->as_VMReg()->value()] = false;
|
||||
live[c_farg1->as_VMReg()->value()] = false;
|
||||
live[c_farg2->as_VMReg()->value()] = false;
|
||||
live[c_farg3->as_VMReg()->value()] = false;
|
||||
live[c_farg4->as_VMReg()->value()] = false;
|
||||
live[c_farg5->as_VMReg()->value()] = false;
|
||||
live[c_farg6->as_VMReg()->value()] = false;
|
||||
live[c_farg7->as_VMReg()->value()] = false;
|
||||
}
|
||||
|
||||
// Now we can finally move the register args to their desired locations
|
||||
|
||||
rax_is_zero = false;
|
||||
|
||||
for (j_arg = first_arg_to_pass, c_arg = 0 ;
|
||||
j_arg < total_args_passed ; j_arg++, c_arg++ ) {
|
||||
|
||||
VMRegPair src = in_regs[j_arg];
|
||||
VMRegPair dst = out_regs[c_arg];
|
||||
|
||||
// Only need to look for args destined for the interger registers (since we
|
||||
// convert float/double args to look like int/long outbound)
|
||||
if (dst.first()->is_reg()) {
|
||||
Register r = dst.first()->as_Register();
|
||||
|
||||
// Check if the java arg is unsupported and thereofre useless
|
||||
bool useless = in_sig_bt[j_arg] == T_ARRAY ||
|
||||
(in_sig_bt[j_arg] == T_OBJECT &&
|
||||
out_sig_bt[c_arg] != T_INT &&
|
||||
out_sig_bt[c_arg] != T_ADDRESS &&
|
||||
out_sig_bt[c_arg] != T_LONG);
|
||||
|
||||
|
||||
// If we're going to kill an existing arg save it first
|
||||
if (live[dst.first()->value()]) {
|
||||
// you can't kill yourself
|
||||
if (src.first() != dst.first()) {
|
||||
__ movq(Address(rbp, fp_offset[dst.first()->value()]), r);
|
||||
}
|
||||
}
|
||||
if (src.first()->is_reg()) {
|
||||
if (live[src.first()->value()] ) {
|
||||
if (in_sig_bt[j_arg] == T_FLOAT) {
|
||||
__ movdl(r, src.first()->as_XMMRegister());
|
||||
} else if (in_sig_bt[j_arg] == T_DOUBLE) {
|
||||
__ movdq(r, src.first()->as_XMMRegister());
|
||||
} else if (r != src.first()->as_Register()) {
|
||||
if (!useless) {
|
||||
__ movq(r, src.first()->as_Register());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If the arg is an oop type we don't support don't bother to store
|
||||
// it
|
||||
if (!useless) {
|
||||
if (in_sig_bt[j_arg] == T_DOUBLE ||
|
||||
in_sig_bt[j_arg] == T_LONG ||
|
||||
in_sig_bt[j_arg] == T_OBJECT ) {
|
||||
__ movq(r, Address(rbp, fp_offset[src.first()->value()]));
|
||||
} else {
|
||||
__ movl(r, Address(rbp, fp_offset[src.first()->value()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
live[src.first()->value()] = false;
|
||||
} else if (!useless) {
|
||||
// full sized move even for int should be ok
|
||||
__ movq(r, Address(rbp, reg2offset_in(src.first())));
|
||||
}
|
||||
|
||||
// At this point r has the original java arg in the final location
|
||||
// (assuming it wasn't useless). If the java arg was an oop
|
||||
// we have a bit more to do
|
||||
|
||||
if (in_sig_bt[j_arg] == T_ARRAY || in_sig_bt[j_arg] == T_OBJECT ) {
|
||||
if (out_sig_bt[c_arg] == T_INT || out_sig_bt[c_arg] == T_LONG) {
|
||||
// need to unbox a one-word value
|
||||
Label skip;
|
||||
__ testq(r, r);
|
||||
__ jcc(Assembler::equal, skip);
|
||||
BasicType bt = out_sig_bt[c_arg];
|
||||
int box_offset = java_lang_boxing_object::value_offset_in_bytes(bt);
|
||||
Address src1(r, box_offset);
|
||||
if ( bt == T_LONG ) {
|
||||
__ movq(r, src1);
|
||||
} else {
|
||||
__ movl(r, src1);
|
||||
}
|
||||
__ bind(skip);
|
||||
|
||||
} else if (out_sig_bt[c_arg] != T_ADDRESS) {
|
||||
// Convert the arg to NULL
|
||||
__ xorq(r, r);
|
||||
}
|
||||
}
|
||||
|
||||
// dst can longer be holding an input value
|
||||
live[dst.first()->value()] = false;
|
||||
}
|
||||
if (in_sig_bt[j_arg] == T_OBJECT && out_sig_bt[c_arg] == T_LONG) {
|
||||
assert(out_sig_bt[c_arg+1] == T_VOID, "must be");
|
||||
++c_arg; // skip over T_VOID to keep the loop indices in sync
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Ok now we are done. Need to place the nop that dtrace wants in order to
|
||||
// patch in the trap
|
||||
int patch_offset = ((intptr_t)__ pc()) - start;
|
||||
|
||||
__ nop();
|
||||
|
||||
|
||||
// Return
|
||||
|
||||
__ leave();
|
||||
__ ret(0);
|
||||
|
||||
__ flush();
|
||||
|
||||
nmethod *nm = nmethod::new_dtrace_nmethod(
|
||||
method, masm->code(), vep_offset, patch_offset, frame_complete,
|
||||
stack_slots / VMRegImpl::slots_per_word);
|
||||
return nm;
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_DTRACE_H
|
||||
|
||||
// this function returns the adjust size (in number of words) to a c2i adapter
|
||||
// activation for use during deoptimization
|
||||
int Deoptimization::last_frame_adjust(int callee_parameters, int callee_locals ) {
|
||||
|
@ -346,7 +346,6 @@ void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile
|
||||
// depending if we're profiling or not.
|
||||
if (TieredCompilation) {
|
||||
int increment = InvocationCounter::count_increment;
|
||||
int mask = ((1 << Tier0InvokeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
|
||||
Label no_mdo;
|
||||
if (ProfileInterpreter) {
|
||||
// Are we profiling?
|
||||
@ -356,6 +355,7 @@ void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile
|
||||
// Increment counter in the MDO
|
||||
const Address mdo_invocation_counter(rax, in_bytes(MethodData::invocation_counter_offset()) +
|
||||
in_bytes(InvocationCounter::counter_offset()));
|
||||
const Address mask(rax, in_bytes(MethodData::invoke_mask_offset()));
|
||||
__ increment_mask_and_jump(mdo_invocation_counter, increment, mask, rcx, false, Assembler::zero, overflow);
|
||||
__ jmp(done);
|
||||
}
|
||||
@ -366,11 +366,12 @@ void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile
|
||||
InvocationCounter::counter_offset());
|
||||
|
||||
__ get_method_counters(rbx, rax, done);
|
||||
const Address mask(rax, in_bytes(MethodCounters::invoke_mask_offset()));
|
||||
__ increment_mask_and_jump(invocation_counter, increment, mask,
|
||||
rcx, false, Assembler::zero, overflow);
|
||||
__ bind(done);
|
||||
} else {
|
||||
const Address backedge_counter (rax,
|
||||
} else { // not TieredCompilation
|
||||
const Address backedge_counter(rax,
|
||||
MethodCounters::backedge_counter_offset() +
|
||||
InvocationCounter::counter_offset());
|
||||
const Address invocation_counter(rax,
|
||||
@ -400,16 +401,16 @@ void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile
|
||||
|
||||
if (ProfileInterpreter && profile_method != NULL) {
|
||||
// Test to see if we should create a method data oop
|
||||
__ cmp32(rcx,
|
||||
ExternalAddress((address)&InvocationCounter::InterpreterProfileLimit));
|
||||
__ movptr(rax, Address(rbx, Method::method_counters_offset()));
|
||||
__ cmp32(rcx, Address(rax, in_bytes(MethodCounters::interpreter_profile_limit_offset())));
|
||||
__ jcc(Assembler::less, *profile_method_continue);
|
||||
|
||||
// if no method data exists, go to profile_method
|
||||
__ test_method_data_pointer(rax, *profile_method);
|
||||
}
|
||||
|
||||
__ cmp32(rcx,
|
||||
ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit));
|
||||
__ movptr(rax, Address(rbx, Method::method_counters_offset()));
|
||||
__ cmp32(rcx, Address(rax, in_bytes(MethodCounters::interpreter_invocation_limit_offset())));
|
||||
__ jcc(Assembler::aboveEqual, *overflow);
|
||||
__ bind(done);
|
||||
}
|
||||
|
@ -299,7 +299,6 @@ void InterpreterGenerator::generate_counter_incr(
|
||||
// Note: In tiered we increment either counters in Method* or in MDO depending if we're profiling or not.
|
||||
if (TieredCompilation) {
|
||||
int increment = InvocationCounter::count_increment;
|
||||
int mask = ((1 << Tier0InvokeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
|
||||
Label no_mdo;
|
||||
if (ProfileInterpreter) {
|
||||
// Are we profiling?
|
||||
@ -309,6 +308,7 @@ void InterpreterGenerator::generate_counter_incr(
|
||||
// Increment counter in the MDO
|
||||
const Address mdo_invocation_counter(rax, in_bytes(MethodData::invocation_counter_offset()) +
|
||||
in_bytes(InvocationCounter::counter_offset()));
|
||||
const Address mask(rax, in_bytes(MethodData::invoke_mask_offset()));
|
||||
__ increment_mask_and_jump(mdo_invocation_counter, increment, mask, rcx, false, Assembler::zero, overflow);
|
||||
__ jmp(done);
|
||||
}
|
||||
@ -318,10 +318,11 @@ void InterpreterGenerator::generate_counter_incr(
|
||||
MethodCounters::invocation_counter_offset() +
|
||||
InvocationCounter::counter_offset());
|
||||
__ get_method_counters(rbx, rax, done);
|
||||
const Address mask(rax, in_bytes(MethodCounters::invoke_mask_offset()));
|
||||
__ increment_mask_and_jump(invocation_counter, increment, mask, rcx,
|
||||
false, Assembler::zero, overflow);
|
||||
__ bind(done);
|
||||
} else {
|
||||
} else { // not TieredCompilation
|
||||
const Address backedge_counter(rax,
|
||||
MethodCounters::backedge_counter_offset() +
|
||||
InvocationCounter::counter_offset());
|
||||
@ -350,14 +351,16 @@ void InterpreterGenerator::generate_counter_incr(
|
||||
|
||||
if (ProfileInterpreter && profile_method != NULL) {
|
||||
// Test to see if we should create a method data oop
|
||||
__ cmp32(rcx, ExternalAddress((address)&InvocationCounter::InterpreterProfileLimit));
|
||||
__ movptr(rax, Address(rbx, Method::method_counters_offset()));
|
||||
__ cmp32(rcx, Address(rax, in_bytes(MethodCounters::interpreter_profile_limit_offset())));
|
||||
__ jcc(Assembler::less, *profile_method_continue);
|
||||
|
||||
// if no method data exists, go to profile_method
|
||||
__ test_method_data_pointer(rax, *profile_method);
|
||||
}
|
||||
|
||||
__ cmp32(rcx, ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit));
|
||||
__ movptr(rax, Address(rbx, Method::method_counters_offset()));
|
||||
__ cmp32(rcx, Address(rax, in_bytes(MethodCounters::interpreter_invocation_limit_offset())));
|
||||
__ jcc(Assembler::aboveEqual, *overflow);
|
||||
__ bind(done);
|
||||
}
|
||||
|
@ -185,7 +185,6 @@ static void do_oop_store(InterpreterMacroAssembler* _masm,
|
||||
}
|
||||
break;
|
||||
case BarrierSet::ModRef:
|
||||
case BarrierSet::Other:
|
||||
if (val == noreg) {
|
||||
__ movptr(obj, NULL_WORD);
|
||||
} else {
|
||||
@ -1621,7 +1620,6 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
if (TieredCompilation) {
|
||||
Label no_mdo;
|
||||
int increment = InvocationCounter::count_increment;
|
||||
int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
|
||||
if (ProfileInterpreter) {
|
||||
// Are we profiling?
|
||||
__ movptr(rbx, Address(rcx, in_bytes(Method::method_data_offset())));
|
||||
@ -1630,6 +1628,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
// Increment the MDO backedge counter
|
||||
const Address mdo_backedge_counter(rbx, in_bytes(MethodData::backedge_counter_offset()) +
|
||||
in_bytes(InvocationCounter::counter_offset()));
|
||||
const Address mask(rbx, in_bytes(MethodData::backedge_mask_offset()));
|
||||
__ increment_mask_and_jump(mdo_backedge_counter, increment, mask,
|
||||
rax, false, Assembler::zero, &backedge_counter_overflow);
|
||||
__ jmp(dispatch);
|
||||
@ -1637,9 +1636,10 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
__ bind(no_mdo);
|
||||
// Increment backedge counter in MethodCounters*
|
||||
__ movptr(rcx, Address(rcx, Method::method_counters_offset()));
|
||||
const Address mask(rcx, in_bytes(MethodCounters::backedge_mask_offset()));
|
||||
__ increment_mask_and_jump(Address(rcx, be_offset), increment, mask,
|
||||
rax, false, Assembler::zero, &backedge_counter_overflow);
|
||||
} else {
|
||||
} else { // not TieredCompilation
|
||||
// increment counter
|
||||
__ movptr(rcx, Address(rcx, Method::method_counters_offset()));
|
||||
__ movl(rax, Address(rcx, be_offset)); // load backedge counter
|
||||
@ -1653,8 +1653,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
|
||||
if (ProfileInterpreter) {
|
||||
// Test to see if we should create a method data oop
|
||||
__ cmp32(rax,
|
||||
ExternalAddress((address) &InvocationCounter::InterpreterProfileLimit));
|
||||
__ cmp32(rax, Address(rcx, in_bytes(MethodCounters::interpreter_profile_limit_offset())));
|
||||
__ jcc(Assembler::less, dispatch);
|
||||
|
||||
// if no method data exists, go to profile method
|
||||
@ -1662,8 +1661,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
|
||||
if (UseOnStackReplacement) {
|
||||
// check for overflow against rbx, which is the MDO taken count
|
||||
__ cmp32(rbx,
|
||||
ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit));
|
||||
__ cmp32(rbx, Address(rcx, in_bytes(MethodCounters::interpreter_backward_branch_limit_offset())));
|
||||
__ jcc(Assembler::below, dispatch);
|
||||
|
||||
// When ProfileInterpreter is on, the backedge_count comes from the
|
||||
@ -1678,8 +1676,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
} else {
|
||||
if (UseOnStackReplacement) {
|
||||
// check for overflow against rax, which is the sum of the counters
|
||||
__ cmp32(rax,
|
||||
ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit));
|
||||
__ cmp32(rax, Address(rcx, in_bytes(MethodCounters::interpreter_backward_branch_limit_offset())));
|
||||
__ jcc(Assembler::aboveEqual, backedge_counter_overflow);
|
||||
|
||||
}
|
||||
|
@ -189,7 +189,6 @@ static void do_oop_store(InterpreterMacroAssembler* _masm,
|
||||
}
|
||||
break;
|
||||
case BarrierSet::ModRef:
|
||||
case BarrierSet::Other:
|
||||
if (val == noreg) {
|
||||
__ store_heap_oop_null(obj);
|
||||
} else {
|
||||
@ -1642,7 +1641,6 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
if (TieredCompilation) {
|
||||
Label no_mdo;
|
||||
int increment = InvocationCounter::count_increment;
|
||||
int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
|
||||
if (ProfileInterpreter) {
|
||||
// Are we profiling?
|
||||
__ movptr(rbx, Address(rcx, in_bytes(Method::method_data_offset())));
|
||||
@ -1651,6 +1649,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
// Increment the MDO backedge counter
|
||||
const Address mdo_backedge_counter(rbx, in_bytes(MethodData::backedge_counter_offset()) +
|
||||
in_bytes(InvocationCounter::counter_offset()));
|
||||
const Address mask(rbx, in_bytes(MethodData::backedge_mask_offset()));
|
||||
__ increment_mask_and_jump(mdo_backedge_counter, increment, mask,
|
||||
rax, false, Assembler::zero, &backedge_counter_overflow);
|
||||
__ jmp(dispatch);
|
||||
@ -1658,9 +1657,10 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
__ bind(no_mdo);
|
||||
// Increment backedge counter in MethodCounters*
|
||||
__ movptr(rcx, Address(rcx, Method::method_counters_offset()));
|
||||
const Address mask(rcx, in_bytes(MethodCounters::backedge_mask_offset()));
|
||||
__ increment_mask_and_jump(Address(rcx, be_offset), increment, mask,
|
||||
rax, false, Assembler::zero, &backedge_counter_overflow);
|
||||
} else {
|
||||
} else { // not TieredCompilation
|
||||
// increment counter
|
||||
__ movptr(rcx, Address(rcx, Method::method_counters_offset()));
|
||||
__ movl(rax, Address(rcx, be_offset)); // load backedge counter
|
||||
@ -1674,8 +1674,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
|
||||
if (ProfileInterpreter) {
|
||||
// Test to see if we should create a method data oop
|
||||
__ cmp32(rax,
|
||||
ExternalAddress((address) &InvocationCounter::InterpreterProfileLimit));
|
||||
__ cmp32(rax, Address(rcx, in_bytes(MethodCounters::interpreter_profile_limit_offset())));
|
||||
__ jcc(Assembler::less, dispatch);
|
||||
|
||||
// if no method data exists, go to profile method
|
||||
@ -1683,8 +1682,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
|
||||
if (UseOnStackReplacement) {
|
||||
// check for overflow against ebx which is the MDO taken count
|
||||
__ cmp32(rbx,
|
||||
ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit));
|
||||
__ cmp32(rbx, Address(rcx, in_bytes(MethodCounters::interpreter_backward_branch_limit_offset())));
|
||||
__ jcc(Assembler::below, dispatch);
|
||||
|
||||
// When ProfileInterpreter is on, the backedge_count comes
|
||||
@ -1702,8 +1700,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
|
||||
if (UseOnStackReplacement) {
|
||||
// check for overflow against eax, which is the sum of the
|
||||
// counters
|
||||
__ cmp32(rax,
|
||||
ExternalAddress((address) &InvocationCounter::InterpreterBackwardBranchLimit));
|
||||
__ cmp32(rax, Address(rcx, in_bytes(MethodCounters::interpreter_backward_branch_limit_offset())));
|
||||
__ jcc(Assembler::aboveEqual, backedge_counter_overflow);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
@ -924,15 +924,9 @@ void VM_Version::get_processor_features() {
|
||||
}
|
||||
#endif // COMPILER2
|
||||
|
||||
assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value");
|
||||
assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value");
|
||||
|
||||
// set valid Prefetch instruction
|
||||
if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0;
|
||||
if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3;
|
||||
if( ReadPrefetchInstr == 3 && !supports_3dnow_prefetch() ) ReadPrefetchInstr = 0;
|
||||
if( !supports_sse() && supports_3dnow_prefetch() ) ReadPrefetchInstr = 3;
|
||||
|
||||
if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
|
||||
if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3;
|
||||
if( AllocatePrefetchInstr == 3 && !supports_3dnow_prefetch() ) AllocatePrefetchInstr=0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
// Copyright (c) 1997, 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
|
||||
@ -6061,102 +6061,8 @@ instruct loadSSD(regDPR dst, stackSlotD src) %{
|
||||
ins_pipe( fpu_reg_mem );
|
||||
%}
|
||||
|
||||
// Prefetch instructions.
|
||||
// Must be safe to execute with invalid address (cannot fault).
|
||||
|
||||
instruct prefetchr0( memory mem ) %{
|
||||
predicate(UseSSE==0 && !VM_Version::supports_3dnow_prefetch());
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(0);
|
||||
size(0);
|
||||
format %{ "PREFETCHR (non-SSE is empty encoding)" %}
|
||||
ins_encode();
|
||||
ins_pipe(empty);
|
||||
%}
|
||||
|
||||
instruct prefetchr( memory mem ) %{
|
||||
predicate(UseSSE==0 && VM_Version::supports_3dnow_prefetch() || ReadPrefetchInstr==3);
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(100);
|
||||
|
||||
format %{ "PREFETCHR $mem\t! Prefetch into level 1 cache for read" %}
|
||||
ins_encode %{
|
||||
__ prefetchr($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchrNTA( memory mem ) %{
|
||||
predicate(UseSSE>=1 && ReadPrefetchInstr==0);
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(100);
|
||||
|
||||
format %{ "PREFETCHNTA $mem\t! Prefetch into non-temporal cache for read" %}
|
||||
ins_encode %{
|
||||
__ prefetchnta($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchrT0( memory mem ) %{
|
||||
predicate(UseSSE>=1 && ReadPrefetchInstr==1);
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(100);
|
||||
|
||||
format %{ "PREFETCHT0 $mem\t! Prefetch into L1 and L2 caches for read" %}
|
||||
ins_encode %{
|
||||
__ prefetcht0($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchrT2( memory mem ) %{
|
||||
predicate(UseSSE>=1 && ReadPrefetchInstr==2);
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(100);
|
||||
|
||||
format %{ "PREFETCHT2 $mem\t! Prefetch into L2 cache for read" %}
|
||||
ins_encode %{
|
||||
__ prefetcht2($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchw0( memory mem ) %{
|
||||
predicate(UseSSE==0 && !VM_Version::supports_3dnow_prefetch());
|
||||
match(PrefetchWrite mem);
|
||||
ins_cost(0);
|
||||
size(0);
|
||||
format %{ "Prefetch (non-SSE is empty encoding)" %}
|
||||
ins_encode();
|
||||
ins_pipe(empty);
|
||||
%}
|
||||
|
||||
instruct prefetchw( memory mem ) %{
|
||||
predicate(UseSSE==0 && VM_Version::supports_3dnow_prefetch());
|
||||
match( PrefetchWrite mem );
|
||||
ins_cost(100);
|
||||
|
||||
format %{ "PREFETCHW $mem\t! Prefetch into L1 cache and mark modified" %}
|
||||
ins_encode %{
|
||||
__ prefetchw($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchwNTA( memory mem ) %{
|
||||
predicate(UseSSE>=1);
|
||||
match(PrefetchWrite mem);
|
||||
ins_cost(100);
|
||||
|
||||
format %{ "PREFETCHNTA $mem\t! Prefetch into non-temporal cache for write" %}
|
||||
ins_encode %{
|
||||
__ prefetchnta($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
// Prefetch instructions for allocation.
|
||||
// Must be safe to execute with invalid address (cannot fault).
|
||||
|
||||
instruct prefetchAlloc0( memory mem ) %{
|
||||
predicate(UseSSE==0 && AllocatePrefetchInstr!=3);
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
// Copyright (c) 2003, 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
|
||||
@ -5319,69 +5319,8 @@ instruct loadSSD(regD dst, stackSlotD src)
|
||||
ins_pipe(pipe_slow); // XXX
|
||||
%}
|
||||
|
||||
// Prefetch instructions.
|
||||
// Must be safe to execute with invalid address (cannot fault).
|
||||
|
||||
instruct prefetchr( memory mem ) %{
|
||||
predicate(ReadPrefetchInstr==3);
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(125);
|
||||
|
||||
format %{ "PREFETCHR $mem\t# Prefetch into level 1 cache" %}
|
||||
ins_encode %{
|
||||
__ prefetchr($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchrNTA( memory mem ) %{
|
||||
predicate(ReadPrefetchInstr==0);
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(125);
|
||||
|
||||
format %{ "PREFETCHNTA $mem\t# Prefetch into non-temporal cache for read" %}
|
||||
ins_encode %{
|
||||
__ prefetchnta($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchrT0( memory mem ) %{
|
||||
predicate(ReadPrefetchInstr==1);
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(125);
|
||||
|
||||
format %{ "PREFETCHT0 $mem\t# prefetch into L1 and L2 caches for read" %}
|
||||
ins_encode %{
|
||||
__ prefetcht0($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchrT2( memory mem ) %{
|
||||
predicate(ReadPrefetchInstr==2);
|
||||
match(PrefetchRead mem);
|
||||
ins_cost(125);
|
||||
|
||||
format %{ "PREFETCHT2 $mem\t# prefetch into L2 caches for read" %}
|
||||
ins_encode %{
|
||||
__ prefetcht2($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
instruct prefetchwNTA( memory mem ) %{
|
||||
match(PrefetchWrite mem);
|
||||
ins_cost(125);
|
||||
|
||||
format %{ "PREFETCHNTA $mem\t# Prefetch to non-temporal cache for write" %}
|
||||
ins_encode %{
|
||||
__ prefetchnta($mem$$Address);
|
||||
%}
|
||||
ins_pipe(ialu_mem);
|
||||
%}
|
||||
|
||||
// Prefetch instructions for allocation.
|
||||
// Must be safe to execute with invalid address (cannot fault).
|
||||
|
||||
instruct prefetchAlloc( memory mem ) %{
|
||||
predicate(AllocatePrefetchInstr==3);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2012, 2014 SAP AG. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -1115,6 +1115,15 @@ jlong os::javaTimeMillis() {
|
||||
return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
|
||||
}
|
||||
|
||||
void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
|
||||
timeval time;
|
||||
int status = gettimeofday(&time, NULL);
|
||||
assert(status != -1, "aix error at gettimeofday()");
|
||||
seconds = jlong(time.tv_sec);
|
||||
nanos = jlong(time.tv_usec) * 1000;
|
||||
}
|
||||
|
||||
|
||||
// We need to manually declare mread_real_time,
|
||||
// because IBM didn't provide a prototype in time.h.
|
||||
// (they probably only ever tested in C, not C++)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "os_aix.inline.hpp"
|
||||
#include "runtime/handles.inline.hpp"
|
||||
#include "runtime/perfMemory.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
#include "utilities/exceptions.hpp"
|
||||
|
||||
// put OS-includes here
|
||||
@ -196,12 +197,37 @@ static pid_t filename_to_pid(const char* filename) {
|
||||
return pid;
|
||||
}
|
||||
|
||||
// Check if the given statbuf is considered a secure directory for
|
||||
// the backing store files. Returns true if the directory is considered
|
||||
// a secure location. Returns false if the statbuf is a symbolic link or
|
||||
// if an error occurred.
|
||||
static bool is_statbuf_secure(struct stat *statp) {
|
||||
if (S_ISLNK(statp->st_mode) || !S_ISDIR(statp->st_mode)) {
|
||||
// The path represents a link or some non-directory file type,
|
||||
// which is not what we expected. Declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
// We have an existing directory, check if the permissions are safe.
|
||||
if ((statp->st_mode & (S_IWGRP|S_IWOTH)) != 0) {
|
||||
// The directory is open for writing and could be subjected
|
||||
// to a symlink or a hard link attack. Declare it insecure.
|
||||
return false;
|
||||
}
|
||||
// See if the uid of the directory matches the effective uid of the process.
|
||||
//
|
||||
if (statp->st_uid != geteuid()) {
|
||||
// The directory was not created by this user, declare it insecure.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// check if the given path is considered a secure directory for
|
||||
|
||||
// Check if the given path is considered a secure directory for
|
||||
// the backing store files. Returns true if the directory exists
|
||||
// and is considered a secure location. Returns false if the path
|
||||
// is a symbolic link or if an error occurred.
|
||||
//
|
||||
static bool is_directory_secure(const char* path) {
|
||||
struct stat statbuf;
|
||||
int result = 0;
|
||||
@ -211,38 +237,276 @@ static bool is_directory_secure(const char* path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// the path exists, now check it's mode
|
||||
if (S_ISLNK(statbuf.st_mode) || !S_ISDIR(statbuf.st_mode)) {
|
||||
// the path represents a link or some non-directory file type,
|
||||
// which is not what we expected. declare it insecure.
|
||||
//
|
||||
// The path exists, see if it is secure.
|
||||
return is_statbuf_secure(&statbuf);
|
||||
}
|
||||
|
||||
// (Taken over from Solaris to support the O_NOFOLLOW case on AIX.)
|
||||
// Check if the given directory file descriptor is considered a secure
|
||||
// directory for the backing store files. Returns true if the directory
|
||||
// exists and is considered a secure location. Returns false if the path
|
||||
// is a symbolic link or if an error occurred.
|
||||
static bool is_dirfd_secure(int dir_fd) {
|
||||
struct stat statbuf;
|
||||
int result = 0;
|
||||
|
||||
RESTARTABLE(::fstat(dir_fd, &statbuf), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// we have an existing directory, check if the permissions are safe.
|
||||
//
|
||||
if ((statbuf.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
|
||||
// the directory is open for writing and could be subjected
|
||||
// to a symlnk attack. declare it insecure.
|
||||
//
|
||||
return false;
|
||||
|
||||
// The path exists, now check its mode.
|
||||
return is_statbuf_secure(&statbuf);
|
||||
}
|
||||
|
||||
|
||||
// Check to make sure fd1 and fd2 are referencing the same file system object.
|
||||
static bool is_same_fsobject(int fd1, int fd2) {
|
||||
struct stat statbuf1;
|
||||
struct stat statbuf2;
|
||||
int result = 0;
|
||||
|
||||
RESTARTABLE(::fstat(fd1, &statbuf1), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
RESTARTABLE(::fstat(fd2, &statbuf2), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((statbuf1.st_ino == statbuf2.st_ino) &&
|
||||
(statbuf1.st_dev == statbuf2.st_dev)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper functions for open without O_NOFOLLOW which is not present on AIX 5.3/6.1.
|
||||
// We use the jdk6 implementation here.
|
||||
#ifndef O_NOFOLLOW
|
||||
// The O_NOFOLLOW oflag doesn't exist before solaris 5.10, this is to simulate that behaviour
|
||||
// was done in jdk 5/6 hotspot by Oracle this way
|
||||
static int open_o_nofollow_impl(const char* path, int oflag, mode_t mode, bool use_mode) {
|
||||
struct stat orig_st;
|
||||
struct stat new_st;
|
||||
bool create;
|
||||
int error;
|
||||
int fd;
|
||||
|
||||
create = false;
|
||||
|
||||
if (lstat(path, &orig_st) != 0) {
|
||||
if (errno == ENOENT && (oflag & O_CREAT) != 0) {
|
||||
// File doesn't exist, but_we want to create it, add O_EXCL flag
|
||||
// to make sure no-one creates it (or a symlink) before us
|
||||
// This works as we expect with symlinks, from posix man page:
|
||||
// 'If O_EXCL and O_CREAT are set, and path names a symbolic
|
||||
// link, open() shall fail and set errno to [EEXIST]'.
|
||||
oflag |= O_EXCL;
|
||||
create = true;
|
||||
} else {
|
||||
// File doesn't exist, and we are not creating it.
|
||||
return OS_ERR;
|
||||
}
|
||||
} else {
|
||||
// Lstat success, check if existing file is a link.
|
||||
if ((orig_st.st_mode & S_IFMT) == S_IFLNK) {
|
||||
// File is a symlink.
|
||||
errno = ELOOP;
|
||||
return OS_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
if (use_mode == true) {
|
||||
fd = open(path, oflag, mode);
|
||||
} else {
|
||||
fd = open(path, oflag);
|
||||
}
|
||||
|
||||
if (fd == OS_ERR) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
// Can't do inode checks on before/after if we created the file.
|
||||
if (create == false) {
|
||||
if (fstat(fd, &new_st) != 0) {
|
||||
// Keep errno from fstat, in case close also fails.
|
||||
error = errno;
|
||||
::close(fd);
|
||||
errno = error;
|
||||
return OS_ERR;
|
||||
}
|
||||
|
||||
if (orig_st.st_dev != new_st.st_dev || orig_st.st_ino != new_st.st_ino) {
|
||||
// File was tampered with during race window.
|
||||
::close(fd);
|
||||
errno = EEXIST;
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("possible file tampering attempt detected when opening %s", path);
|
||||
}
|
||||
return OS_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int open_o_nofollow(const char* path, int oflag, mode_t mode) {
|
||||
return open_o_nofollow_impl(path, oflag, mode, true);
|
||||
}
|
||||
|
||||
static int open_o_nofollow(const char* path, int oflag) {
|
||||
return open_o_nofollow_impl(path, oflag, 0, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Open the directory of the given path and validate it.
|
||||
// Return a DIR * of the open directory.
|
||||
static DIR *open_directory_secure(const char* dirname) {
|
||||
// Open the directory using open() so that it can be verified
|
||||
// to be secure by calling is_dirfd_secure(), opendir() and then check
|
||||
// to see if they are the same file system object. This method does not
|
||||
// introduce a window of opportunity for the directory to be attacked that
|
||||
// calling opendir() and is_directory_secure() does.
|
||||
int result;
|
||||
DIR *dirp = NULL;
|
||||
|
||||
// No O_NOFOLLOW defined at buildtime, and it is not documented for open;
|
||||
// so provide a workaround in this case.
|
||||
#ifdef O_NOFOLLOW
|
||||
RESTARTABLE(::open(dirname, O_RDONLY|O_NOFOLLOW), result);
|
||||
#else
|
||||
// workaround (jdk6 coding)
|
||||
RESTARTABLE(::open_o_nofollow(dirname, O_RDONLY), result);
|
||||
#endif
|
||||
|
||||
if (result == OS_ERR) {
|
||||
// Directory doesn't exist or is a symlink, so there is nothing to cleanup.
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
if (errno == ELOOP) {
|
||||
warning("directory %s is a symlink and is not secure\n", dirname);
|
||||
} else {
|
||||
warning("could not open directory %s: %s\n", dirname, strerror(errno));
|
||||
}
|
||||
}
|
||||
return dirp;
|
||||
}
|
||||
int fd = result;
|
||||
|
||||
// Determine if the open directory is secure.
|
||||
if (!is_dirfd_secure(fd)) {
|
||||
// The directory is not a secure directory.
|
||||
os::close(fd);
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Open the directory.
|
||||
dirp = ::opendir(dirname);
|
||||
if (dirp == NULL) {
|
||||
// The directory doesn't exist, close fd and return.
|
||||
os::close(fd);
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Check to make sure fd and dirp are referencing the same file system object.
|
||||
if (!is_same_fsobject(fd, dirp->dd_fd)) {
|
||||
// The directory is not secure.
|
||||
os::close(fd);
|
||||
os::closedir(dirp);
|
||||
dirp = NULL;
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Close initial open now that we know directory is secure
|
||||
os::close(fd);
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// NOTE: The code below uses fchdir(), open() and unlink() because
|
||||
// fdopendir(), openat() and unlinkat() are not supported on all
|
||||
// versions. Once the support for fdopendir(), openat() and unlinkat()
|
||||
// is available on all supported versions the code can be changed
|
||||
// to use these functions.
|
||||
|
||||
// Open the directory of the given path, validate it and set the
|
||||
// current working directory to it.
|
||||
// Return a DIR * of the open directory and the saved cwd fd.
|
||||
//
|
||||
static DIR *open_directory_secure_cwd(const char* dirname, int *saved_cwd_fd) {
|
||||
|
||||
// Open the directory.
|
||||
DIR* dirp = open_directory_secure(dirname);
|
||||
if (dirp == NULL) {
|
||||
// Directory doesn't exist or is insecure, so there is nothing to cleanup.
|
||||
return dirp;
|
||||
}
|
||||
int fd = dirp->dd_fd;
|
||||
|
||||
// Open a fd to the cwd and save it off.
|
||||
int result;
|
||||
RESTARTABLE(::open(".", O_RDONLY), result);
|
||||
if (result == OS_ERR) {
|
||||
*saved_cwd_fd = -1;
|
||||
} else {
|
||||
*saved_cwd_fd = result;
|
||||
}
|
||||
|
||||
// Set the current directory to dirname by using the fd of the directory.
|
||||
result = fchdir(fd);
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Close the directory and restore the current working directory.
|
||||
static void close_directory_secure_cwd(DIR* dirp, int saved_cwd_fd) {
|
||||
|
||||
int result;
|
||||
// If we have a saved cwd change back to it and close the fd.
|
||||
if (saved_cwd_fd != -1) {
|
||||
result = fchdir(saved_cwd_fd);
|
||||
::close(saved_cwd_fd);
|
||||
}
|
||||
|
||||
// Close the directory.
|
||||
os::closedir(dirp);
|
||||
}
|
||||
|
||||
// Check if the given file descriptor is considered a secure.
|
||||
static bool is_file_secure(int fd, const char *filename) {
|
||||
|
||||
int result;
|
||||
struct stat statbuf;
|
||||
|
||||
// Determine if the file is secure.
|
||||
RESTARTABLE(::fstat(fd, &statbuf), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("fstat failed on %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (statbuf.st_nlink > 1) {
|
||||
// A file with multiple links is not expected.
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("file %s has multiple links\n", filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// return the user name for the given user id
|
||||
//
|
||||
// the caller is expected to free the allocated memory.
|
||||
// Return the user name for the given user id.
|
||||
//
|
||||
// The caller is expected to free the allocated memory.
|
||||
static char* get_user_name(uid_t uid) {
|
||||
|
||||
struct passwd pwent;
|
||||
|
||||
// determine the max pwbuf size from sysconf, and hardcode
|
||||
// Determine the max pwbuf size from sysconf, and hardcode
|
||||
// a default if this not available through sysconf.
|
||||
//
|
||||
long bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||
if (bufsize == -1)
|
||||
bufsize = 1024;
|
||||
@ -344,7 +608,8 @@ static char* get_user_name_slow(int vmid, TRAPS) {
|
||||
strcat(usrdir_name, "/");
|
||||
strcat(usrdir_name, dentry->d_name);
|
||||
|
||||
DIR* subdirp = os::opendir(usrdir_name);
|
||||
// Open the user directory.
|
||||
DIR* subdirp = open_directory_secure(usrdir_name);
|
||||
|
||||
if (subdirp == NULL) {
|
||||
FREE_C_HEAP_ARRAY(char, usrdir_name);
|
||||
@ -464,28 +729,7 @@ static void remove_file(const char* path) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove file
|
||||
//
|
||||
// this method removes the file with the given file name in the
|
||||
// named directory.
|
||||
//
|
||||
static void remove_file(const char* dirname, const char* filename) {
|
||||
|
||||
size_t nbytes = strlen(dirname) + strlen(filename) + 2;
|
||||
char* path = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
||||
|
||||
strcpy(path, dirname);
|
||||
strcat(path, "/");
|
||||
strcat(path, filename);
|
||||
|
||||
remove_file(path);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, path);
|
||||
}
|
||||
|
||||
|
||||
// cleanup stale shared memory resources
|
||||
// Cleanup stale shared memory resources
|
||||
//
|
||||
// This method attempts to remove all stale shared memory files in
|
||||
// the named user temporary directory. It scans the named directory
|
||||
@ -493,33 +737,26 @@ static void remove_file(const char* dirname, const char* filename) {
|
||||
// process id is extracted from the file name and a test is run to
|
||||
// determine if the process is alive. If the process is not alive,
|
||||
// any stale file resources are removed.
|
||||
//
|
||||
static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
|
||||
// open the user temp directory
|
||||
DIR* dirp = os::opendir(dirname);
|
||||
|
||||
int saved_cwd_fd;
|
||||
// Open the directory.
|
||||
DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
|
||||
if (dirp == NULL) {
|
||||
// directory doesn't exist, so there is nothing to cleanup
|
||||
// Directory doesn't exist or is insecure, so there is nothing to cleanup.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_directory_secure(dirname)) {
|
||||
// the directory is not a secure directory
|
||||
os::closedir(dirp);
|
||||
return;
|
||||
}
|
||||
|
||||
// for each entry in the directory that matches the expected file
|
||||
// For each entry in the directory that matches the expected file
|
||||
// name pattern, determine if the file resources are stale and if
|
||||
// so, remove the file resources. Note, instrumented HotSpot processes
|
||||
// for this user may start and/or terminate during this search and
|
||||
// remove or create new files in this directory. The behavior of this
|
||||
// loop under these conditions is dependent upon the implementation of
|
||||
// opendir/readdir.
|
||||
//
|
||||
struct dirent* entry;
|
||||
char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
|
||||
|
||||
errno = 0;
|
||||
while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
|
||||
|
||||
@ -529,56 +766,55 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
|
||||
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
|
||||
|
||||
// attempt to remove all unexpected files, except "." and ".."
|
||||
remove_file(dirname, entry->d_name);
|
||||
// Attempt to remove all unexpected files, except "." and "..".
|
||||
unlink(entry->d_name);
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// we now have a file name that converts to a valid integer
|
||||
// We now have a file name that converts to a valid integer
|
||||
// that could represent a process id . if this process id
|
||||
// matches the current process id or the process is not running,
|
||||
// then remove the stale file resources.
|
||||
//
|
||||
// process liveness is detected by sending signal number 0 to
|
||||
// Process liveness is detected by sending signal number 0 to
|
||||
// the process id (see kill(2)). if kill determines that the
|
||||
// process does not exist, then the file resources are removed.
|
||||
// if kill determines that that we don't have permission to
|
||||
// signal the process, then the file resources are assumed to
|
||||
// be stale and are removed because the resources for such a
|
||||
// process should be in a different user specific directory.
|
||||
//
|
||||
if ((pid == os::current_process_id()) ||
|
||||
(kill(pid, 0) == OS_ERR && (errno == ESRCH || errno == EPERM))) {
|
||||
|
||||
remove_file(dirname, entry->d_name);
|
||||
unlink(entry->d_name);
|
||||
}
|
||||
errno = 0;
|
||||
}
|
||||
os::closedir(dirp);
|
||||
FREE_C_HEAP_ARRAY(char, dbuf);
|
||||
|
||||
// Close the directory and reset the current working directory.
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
|
||||
}
|
||||
|
||||
// make the user specific temporary directory. Returns true if
|
||||
// Make the user specific temporary directory. Returns true if
|
||||
// the directory exists and is secure upon return. Returns false
|
||||
// if the directory exists but is either a symlink, is otherwise
|
||||
// insecure, or if an error occurred.
|
||||
//
|
||||
static bool make_user_tmp_dir(const char* dirname) {
|
||||
|
||||
// create the directory with 0755 permissions. note that the directory
|
||||
// Create the directory with 0755 permissions. note that the directory
|
||||
// will be owned by euid::egid, which may not be the same as uid::gid.
|
||||
//
|
||||
if (mkdir(dirname, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) == OS_ERR) {
|
||||
if (errno == EEXIST) {
|
||||
// The directory already exists and was probably created by another
|
||||
// JVM instance. However, this could also be the result of a
|
||||
// deliberate symlink. Verify that the existing directory is safe.
|
||||
//
|
||||
if (!is_directory_secure(dirname)) {
|
||||
// directory is not secure
|
||||
// Directory is not secure.
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("%s directory is insecure\n", dirname);
|
||||
}
|
||||
@ -614,19 +850,63 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result;
|
||||
|
||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("could not create file %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
int saved_cwd_fd;
|
||||
// Open the directory and set the current working directory to it.
|
||||
DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
|
||||
if (dirp == NULL) {
|
||||
// Directory doesn't exist or is insecure, so cannot create shared
|
||||
// memory file.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Open the filename in the current directory.
|
||||
// Cannot use O_TRUNC here; truncation of an existing file has to happen
|
||||
// after the is_file_secure() check below.
|
||||
int result;
|
||||
|
||||
// No O_NOFOLLOW defined at buildtime, and it is not documented for open;
|
||||
// so provide a workaround in this case.
|
||||
#ifdef O_NOFOLLOW
|
||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_NOFOLLOW, S_IREAD|S_IWRITE), result);
|
||||
#else
|
||||
// workaround function (jdk6 code)
|
||||
RESTARTABLE(::open_o_nofollow(filename, O_RDWR|O_CREAT, S_IREAD|S_IWRITE), result);
|
||||
#endif
|
||||
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
if (errno == ELOOP) {
|
||||
warning("file %s is a symlink and is not secure\n", filename);
|
||||
} else {
|
||||
warning("could not create file %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
}
|
||||
// Close the directory and reset the current working directory.
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
return -1;
|
||||
}
|
||||
// Close the directory and reset the current working directory.
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
// save the file descriptor
|
||||
int fd = result;
|
||||
|
||||
// Check to see if the file is secure.
|
||||
if (!is_file_secure(fd, filename)) {
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Truncate the file to get rid of any existing data.
|
||||
RESTARTABLE(::ftruncate(fd, (off_t)0), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("could not truncate shared memory file: %s\n", strerror(errno));
|
||||
}
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
// set the file size
|
||||
RESTARTABLE(::ftruncate(fd, (off_t)size), result);
|
||||
if (result == OS_ERR) {
|
||||
@ -648,7 +928,14 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
|
||||
|
||||
// open the file
|
||||
int result;
|
||||
// No O_NOFOLLOW defined at buildtime, and it is not documented for open;
|
||||
// so provide a workaround in this case
|
||||
#ifdef O_NOFOLLOW
|
||||
RESTARTABLE(::open(filename, oflags), result);
|
||||
#else
|
||||
RESTARTABLE(::open_o_nofollow(filename, oflags), result);
|
||||
#endif
|
||||
|
||||
if (result == OS_ERR) {
|
||||
if (errno == ENOENT) {
|
||||
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
|
||||
@ -662,8 +949,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
|
||||
THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno));
|
||||
}
|
||||
}
|
||||
int fd = result;
|
||||
|
||||
return result;
|
||||
// Check to see if the file is secure.
|
||||
if (!is_file_secure(fd, filename)) {
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
// create a named shared memory region. returns the address of the
|
||||
@ -695,13 +989,21 @@ static char* mmap_create_shared(size_t size) {
|
||||
char* dirname = get_user_tmp_dir(user_name);
|
||||
char* filename = get_sharedmem_filename(dirname, vmid);
|
||||
|
||||
// Get the short filename.
|
||||
char* short_filename = strrchr(filename, '/');
|
||||
if (short_filename == NULL) {
|
||||
short_filename = filename;
|
||||
} else {
|
||||
short_filename++;
|
||||
}
|
||||
|
||||
// cleanup any stale shared memory files
|
||||
cleanup_sharedmem_resources(dirname);
|
||||
|
||||
assert(((size > 0) && (size % os::vm_page_size() == 0)),
|
||||
"unexpected PerfMemory region size");
|
||||
|
||||
fd = create_sharedmem_resources(dirname, filename, size);
|
||||
fd = create_sharedmem_resources(dirname, short_filename, size);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, user_name);
|
||||
FREE_C_HEAP_ARRAY(char, dirname);
|
||||
@ -733,6 +1035,9 @@ static char* mmap_create_shared(size_t size) {
|
||||
// clear the shared memory region
|
||||
(void)::memset((void*) mapAddress, 0, size);
|
||||
|
||||
// It does not go through os api, the operation has to record from here.
|
||||
MemTracker::record_virtual_memory_reserve((address)mapAddress, size, CURRENT_PC, mtInternal);
|
||||
|
||||
return mapAddress;
|
||||
}
|
||||
|
||||
@ -807,7 +1112,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
char* mapAddress;
|
||||
int result;
|
||||
int fd;
|
||||
size_t size;
|
||||
size_t size = 0;
|
||||
const char* luser = NULL;
|
||||
|
||||
int mmap_prot;
|
||||
@ -819,12 +1124,18 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
// constructs for the file and the shared memory mapping.
|
||||
if (mode == PerfMemory::PERF_MODE_RO) {
|
||||
mmap_prot = PROT_READ;
|
||||
|
||||
// No O_NOFOLLOW defined at buildtime, and it is not documented for open.
|
||||
#ifdef O_NOFOLLOW
|
||||
file_flags = O_RDONLY | O_NOFOLLOW;
|
||||
#else
|
||||
file_flags = O_RDONLY;
|
||||
#endif
|
||||
}
|
||||
else if (mode == PerfMemory::PERF_MODE_RW) {
|
||||
#ifdef LATER
|
||||
mmap_prot = PROT_READ | PROT_WRITE;
|
||||
file_flags = O_RDWR;
|
||||
file_flags = O_RDWR | O_NOFOLLOW;
|
||||
#else
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
|
||||
"Unsupported access mode");
|
||||
@ -853,9 +1164,9 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
// store file, we don't follow them when attaching either.
|
||||
//
|
||||
if (!is_directory_secure(dirname)) {
|
||||
FREE_C_HEAP_ARRAY(char, dirname);
|
||||
FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
|
||||
if (luser != user) {
|
||||
FREE_C_HEAP_ARRAY(char, luser);
|
||||
FREE_C_HEAP_ARRAY(char, luser, mtInternal);
|
||||
}
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
|
||||
"Process not found");
|
||||
@ -901,6 +1212,9 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
"Could not map PerfMemory");
|
||||
}
|
||||
|
||||
// It does not go through os api, the operation has to record from here.
|
||||
MemTracker::record_virtual_memory_reserve((address)mapAddress, size, CURRENT_PC, mtInternal);
|
||||
|
||||
*addr = mapAddress;
|
||||
*sizep = size;
|
||||
|
||||
|
@ -80,7 +80,6 @@ static void save_signal(int idx, int sig) {
|
||||
}
|
||||
|
||||
int VMError::get_resetted_sigflags(int sig) {
|
||||
// Handle all program errors.
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
if (SIGNALS[i] == sig) {
|
||||
return resettedSigflags[i];
|
||||
@ -90,7 +89,6 @@ int VMError::get_resetted_sigflags(int sig) {
|
||||
}
|
||||
|
||||
address VMError::get_resetted_sighandler(int sig) {
|
||||
// Handle all program errors.
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
if (SIGNALS[i] == sig) {
|
||||
return resettedSighandler[i];
|
||||
@ -100,12 +98,19 @@ address VMError::get_resetted_sighandler(int sig) {
|
||||
}
|
||||
|
||||
static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
|
||||
|
||||
// Unmask current signal.
|
||||
sigset_t newset;
|
||||
sigemptyset(&newset);
|
||||
sigaddset(&newset, sig);
|
||||
// and all other synchronous signals too.
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
sigaddset(&newset, SIGNALS[i]);
|
||||
}
|
||||
sigthreadmask(SIG_UNBLOCK, &newset, NULL);
|
||||
|
||||
Unimplemented();
|
||||
VMError err(NULL, sig, NULL, info, ucVoid);
|
||||
err.report_and_die();
|
||||
}
|
||||
|
||||
void VMError::reset_signal_handlers() {
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, 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 "classfile/javaClasses.hpp"
|
||||
#include "code/codeBlob.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "prims/jvm.h"
|
||||
#include "runtime/dtraceJSDT.hpp"
|
||||
#include "runtime/jniHandles.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "runtime/signature.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
/*
|
||||
* JSDT java dtrace probes have never been implemented in macosx. It is unknown if the solaris implementation
|
||||
* is close or if significant implementation work is necessary. The future of the solaris implementation also
|
||||
* appears to be unclear since compiling code with JSDT probes produces the following warning:
|
||||
* "warning: ProviderFactory is internal proprietary API and may be removed in a future release"
|
||||
*/
|
||||
|
||||
int DTraceJSDT::pd_activate(
|
||||
void* baseAddress, jstring module,
|
||||
jint providers_count, JVM_DTraceProvider* providers) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DTraceJSDT::pd_dispose(int handle) {
|
||||
}
|
||||
|
||||
jboolean DTraceJSDT::pd_is_supported() {
|
||||
return false;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 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
|
||||
@ -984,6 +984,14 @@ jlong os::javaTimeMillis() {
|
||||
return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
|
||||
}
|
||||
|
||||
void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
|
||||
timeval time;
|
||||
int status = gettimeofday(&time, NULL);
|
||||
assert(status != -1, "bsd error");
|
||||
seconds = jlong(time.tv_sec);
|
||||
nanos = jlong(time.tv_usec) * 1000;
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
#ifndef CLOCK_MONOTONIC
|
||||
#define CLOCK_MONOTONIC (1)
|
||||
|
@ -197,7 +197,38 @@ static pid_t filename_to_pid(const char* filename) {
|
||||
}
|
||||
|
||||
|
||||
// check if the given path is considered a secure directory for
|
||||
// Check if the given statbuf is considered a secure directory for
|
||||
// the backing store files. Returns true if the directory is considered
|
||||
// a secure location. Returns false if the statbuf is a symbolic link or
|
||||
// if an error occurred.
|
||||
//
|
||||
static bool is_statbuf_secure(struct stat *statp) {
|
||||
if (S_ISLNK(statp->st_mode) || !S_ISDIR(statp->st_mode)) {
|
||||
// The path represents a link or some non-directory file type,
|
||||
// which is not what we expected. Declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
// We have an existing directory, check if the permissions are safe.
|
||||
//
|
||||
if ((statp->st_mode & (S_IWGRP|S_IWOTH)) != 0) {
|
||||
// The directory is open for writing and could be subjected
|
||||
// to a symlink or a hard link attack. Declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
// See if the uid of the directory matches the effective uid of the process.
|
||||
//
|
||||
if (statp->st_uid != geteuid()) {
|
||||
// The directory was not created by this user, declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Check if the given path is considered a secure directory for
|
||||
// the backing store files. Returns true if the directory exists
|
||||
// and is considered a secure location. Returns false if the path
|
||||
// is a symbolic link or if an error occurred.
|
||||
@ -211,27 +242,185 @@ static bool is_directory_secure(const char* path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// the path exists, now check it's mode
|
||||
if (S_ISLNK(statbuf.st_mode) || !S_ISDIR(statbuf.st_mode)) {
|
||||
// the path represents a link or some non-directory file type,
|
||||
// which is not what we expected. declare it insecure.
|
||||
//
|
||||
// The path exists, see if it is secure.
|
||||
return is_statbuf_secure(&statbuf);
|
||||
}
|
||||
|
||||
|
||||
// Check if the given directory file descriptor is considered a secure
|
||||
// directory for the backing store files. Returns true if the directory
|
||||
// exists and is considered a secure location. Returns false if the path
|
||||
// is a symbolic link or if an error occurred.
|
||||
//
|
||||
static bool is_dirfd_secure(int dir_fd) {
|
||||
struct stat statbuf;
|
||||
int result = 0;
|
||||
|
||||
RESTARTABLE(::fstat(dir_fd, &statbuf), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// we have an existing directory, check if the permissions are safe.
|
||||
//
|
||||
if ((statbuf.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
|
||||
// the directory is open for writing and could be subjected
|
||||
// to a symlnk attack. declare it insecure.
|
||||
//
|
||||
return false;
|
||||
|
||||
// The path exists, now check its mode.
|
||||
return is_statbuf_secure(&statbuf);
|
||||
}
|
||||
|
||||
|
||||
// Check to make sure fd1 and fd2 are referencing the same file system object.
|
||||
//
|
||||
static bool is_same_fsobject(int fd1, int fd2) {
|
||||
struct stat statbuf1;
|
||||
struct stat statbuf2;
|
||||
int result = 0;
|
||||
|
||||
RESTARTABLE(::fstat(fd1, &statbuf1), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
RESTARTABLE(::fstat(fd2, &statbuf2), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((statbuf1.st_ino == statbuf2.st_ino) &&
|
||||
(statbuf1.st_dev == statbuf2.st_dev)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Open the directory of the given path and validate it.
|
||||
// Return a DIR * of the open directory.
|
||||
//
|
||||
static DIR *open_directory_secure(const char* dirname) {
|
||||
// Open the directory using open() so that it can be verified
|
||||
// to be secure by calling is_dirfd_secure(), opendir() and then check
|
||||
// to see if they are the same file system object. This method does not
|
||||
// introduce a window of opportunity for the directory to be attacked that
|
||||
// calling opendir() and is_directory_secure() does.
|
||||
int result;
|
||||
DIR *dirp = NULL;
|
||||
RESTARTABLE(::open(dirname, O_RDONLY|O_NOFOLLOW), result);
|
||||
if (result == OS_ERR) {
|
||||
// Directory doesn't exist or is a symlink, so there is nothing to cleanup.
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
if (errno == ELOOP) {
|
||||
warning("directory %s is a symlink and is not secure\n", dirname);
|
||||
} else {
|
||||
warning("could not open directory %s: %s\n", dirname, strerror(errno));
|
||||
}
|
||||
}
|
||||
return dirp;
|
||||
}
|
||||
int fd = result;
|
||||
|
||||
// Determine if the open directory is secure.
|
||||
if (!is_dirfd_secure(fd)) {
|
||||
// The directory is not a secure directory.
|
||||
os::close(fd);
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Open the directory.
|
||||
dirp = ::opendir(dirname);
|
||||
if (dirp == NULL) {
|
||||
// The directory doesn't exist, close fd and return.
|
||||
os::close(fd);
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Check to make sure fd and dirp are referencing the same file system object.
|
||||
if (!is_same_fsobject(fd, dirfd(dirp))) {
|
||||
// The directory is not secure.
|
||||
os::close(fd);
|
||||
os::closedir(dirp);
|
||||
dirp = NULL;
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Close initial open now that we know directory is secure
|
||||
os::close(fd);
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// NOTE: The code below uses fchdir(), open() and unlink() because
|
||||
// fdopendir(), openat() and unlinkat() are not supported on all
|
||||
// versions. Once the support for fdopendir(), openat() and unlinkat()
|
||||
// is available on all supported versions the code can be changed
|
||||
// to use these functions.
|
||||
|
||||
// Open the directory of the given path, validate it and set the
|
||||
// current working directory to it.
|
||||
// Return a DIR * of the open directory and the saved cwd fd.
|
||||
//
|
||||
static DIR *open_directory_secure_cwd(const char* dirname, int *saved_cwd_fd) {
|
||||
|
||||
// Open the directory.
|
||||
DIR* dirp = open_directory_secure(dirname);
|
||||
if (dirp == NULL) {
|
||||
// Directory doesn't exist or is insecure, so there is nothing to cleanup.
|
||||
return dirp;
|
||||
}
|
||||
int fd = dirfd(dirp);
|
||||
|
||||
// Open a fd to the cwd and save it off.
|
||||
int result;
|
||||
RESTARTABLE(::open(".", O_RDONLY), result);
|
||||
if (result == OS_ERR) {
|
||||
*saved_cwd_fd = -1;
|
||||
} else {
|
||||
*saved_cwd_fd = result;
|
||||
}
|
||||
|
||||
// Set the current directory to dirname by using the fd of the directory.
|
||||
result = fchdir(fd);
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Close the directory and restore the current working directory.
|
||||
//
|
||||
static void close_directory_secure_cwd(DIR* dirp, int saved_cwd_fd) {
|
||||
|
||||
int result;
|
||||
// If we have a saved cwd change back to it and close the fd.
|
||||
if (saved_cwd_fd != -1) {
|
||||
result = fchdir(saved_cwd_fd);
|
||||
::close(saved_cwd_fd);
|
||||
}
|
||||
|
||||
// Close the directory.
|
||||
os::closedir(dirp);
|
||||
}
|
||||
|
||||
// Check if the given file descriptor is considered a secure.
|
||||
//
|
||||
static bool is_file_secure(int fd, const char *filename) {
|
||||
|
||||
int result;
|
||||
struct stat statbuf;
|
||||
|
||||
// Determine if the file is secure.
|
||||
RESTARTABLE(::fstat(fd, &statbuf), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("fstat failed on %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (statbuf.st_nlink > 1) {
|
||||
// A file with multiple links is not expected.
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("file %s has multiple links\n", filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// return the user name for the given user id
|
||||
//
|
||||
// the caller is expected to free the allocated memory.
|
||||
@ -317,9 +506,11 @@ static char* get_user_name_slow(int vmid, TRAPS) {
|
||||
|
||||
const char* tmpdirname = os::get_temp_directory();
|
||||
|
||||
// open the temp directory
|
||||
DIR* tmpdirp = os::opendir(tmpdirname);
|
||||
|
||||
if (tmpdirp == NULL) {
|
||||
// Cannot open the directory to get the user name, return.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -344,25 +535,14 @@ static char* get_user_name_slow(int vmid, TRAPS) {
|
||||
strcat(usrdir_name, "/");
|
||||
strcat(usrdir_name, dentry->d_name);
|
||||
|
||||
DIR* subdirp = os::opendir(usrdir_name);
|
||||
// open the user directory
|
||||
DIR* subdirp = open_directory_secure(usrdir_name);
|
||||
|
||||
if (subdirp == NULL) {
|
||||
FREE_C_HEAP_ARRAY(char, usrdir_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Since we don't create the backing store files in directories
|
||||
// pointed to by symbolic links, we also don't follow them when
|
||||
// looking for the files. We check for a symbolic link after the
|
||||
// call to opendir in order to eliminate a small window where the
|
||||
// symlink can be exploited.
|
||||
//
|
||||
if (!is_directory_secure(usrdir_name)) {
|
||||
FREE_C_HEAP_ARRAY(char, usrdir_name);
|
||||
os::closedir(subdirp);
|
||||
continue;
|
||||
}
|
||||
|
||||
struct dirent* udentry;
|
||||
char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name), mtInternal);
|
||||
errno = 0;
|
||||
@ -465,26 +645,6 @@ static void remove_file(const char* path) {
|
||||
}
|
||||
|
||||
|
||||
// remove file
|
||||
//
|
||||
// this method removes the file with the given file name in the
|
||||
// named directory.
|
||||
//
|
||||
static void remove_file(const char* dirname, const char* filename) {
|
||||
|
||||
size_t nbytes = strlen(dirname) + strlen(filename) + 2;
|
||||
char* path = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
||||
|
||||
strcpy(path, dirname);
|
||||
strcat(path, "/");
|
||||
strcat(path, filename);
|
||||
|
||||
remove_file(path);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, path);
|
||||
}
|
||||
|
||||
|
||||
// cleanup stale shared memory resources
|
||||
//
|
||||
// This method attempts to remove all stale shared memory files in
|
||||
@ -496,17 +656,11 @@ static void remove_file(const char* dirname, const char* filename) {
|
||||
//
|
||||
static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
|
||||
// open the user temp directory
|
||||
DIR* dirp = os::opendir(dirname);
|
||||
|
||||
int saved_cwd_fd;
|
||||
// open the directory and set the current working directory to it
|
||||
DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
|
||||
if (dirp == NULL) {
|
||||
// directory doesn't exist, so there is nothing to cleanup
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_directory_secure(dirname)) {
|
||||
// the directory is not a secure directory
|
||||
os::closedir(dirp);
|
||||
// directory doesn't exist or is insecure, so there is nothing to cleanup
|
||||
return;
|
||||
}
|
||||
|
||||
@ -520,6 +674,7 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
//
|
||||
struct dirent* entry;
|
||||
char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
|
||||
|
||||
errno = 0;
|
||||
while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
|
||||
|
||||
@ -530,7 +685,7 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
|
||||
|
||||
// attempt to remove all unexpected files, except "." and ".."
|
||||
remove_file(dirname, entry->d_name);
|
||||
unlink(entry->d_name);
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
@ -553,11 +708,14 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
if ((pid == os::current_process_id()) ||
|
||||
(kill(pid, 0) == OS_ERR && (errno == ESRCH || errno == EPERM))) {
|
||||
|
||||
remove_file(dirname, entry->d_name);
|
||||
unlink(entry->d_name);
|
||||
}
|
||||
errno = 0;
|
||||
}
|
||||
os::closedir(dirp);
|
||||
|
||||
// close the directory and reset the current working directory
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, dbuf);
|
||||
}
|
||||
|
||||
@ -614,19 +772,54 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result;
|
||||
|
||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("could not create file %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
int saved_cwd_fd;
|
||||
// open the directory and set the current working directory to it
|
||||
DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
|
||||
if (dirp == NULL) {
|
||||
// Directory doesn't exist or is insecure, so cannot create shared
|
||||
// memory file.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Open the filename in the current directory.
|
||||
// Cannot use O_TRUNC here; truncation of an existing file has to happen
|
||||
// after the is_file_secure() check below.
|
||||
int result;
|
||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_NOFOLLOW, S_IREAD|S_IWRITE), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
if (errno == ELOOP) {
|
||||
warning("file %s is a symlink and is not secure\n", filename);
|
||||
} else {
|
||||
warning("could not create file %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
}
|
||||
// close the directory and reset the current working directory
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
return -1;
|
||||
}
|
||||
// close the directory and reset the current working directory
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
// save the file descriptor
|
||||
int fd = result;
|
||||
|
||||
// check to see if the file is secure
|
||||
if (!is_file_secure(fd, filename)) {
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// truncate the file to get rid of any existing data
|
||||
RESTARTABLE(::ftruncate(fd, (off_t)0), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("could not truncate shared memory file: %s\n", strerror(errno));
|
||||
}
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
// set the file size
|
||||
RESTARTABLE(::ftruncate(fd, (off_t)size), result);
|
||||
if (result == OS_ERR) {
|
||||
@ -684,8 +877,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
|
||||
THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
|
||||
}
|
||||
}
|
||||
int fd = result;
|
||||
|
||||
return result;
|
||||
// check to see if the file is secure
|
||||
if (!is_file_secure(fd, filename)) {
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
// create a named shared memory region. returns the address of the
|
||||
@ -717,13 +917,21 @@ static char* mmap_create_shared(size_t size) {
|
||||
char* dirname = get_user_tmp_dir(user_name);
|
||||
char* filename = get_sharedmem_filename(dirname, vmid);
|
||||
|
||||
// get the short filename
|
||||
char* short_filename = strrchr(filename, '/');
|
||||
if (short_filename == NULL) {
|
||||
short_filename = filename;
|
||||
} else {
|
||||
short_filename++;
|
||||
}
|
||||
|
||||
// cleanup any stale shared memory files
|
||||
cleanup_sharedmem_resources(dirname);
|
||||
|
||||
assert(((size > 0) && (size % os::vm_page_size() == 0)),
|
||||
"unexpected PerfMemory region size");
|
||||
|
||||
fd = create_sharedmem_resources(dirname, filename, size);
|
||||
fd = create_sharedmem_resources(dirname, short_filename, size);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, user_name);
|
||||
FREE_C_HEAP_ARRAY(char, dirname);
|
||||
@ -838,12 +1046,12 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
// constructs for the file and the shared memory mapping.
|
||||
if (mode == PerfMemory::PERF_MODE_RO) {
|
||||
mmap_prot = PROT_READ;
|
||||
file_flags = O_RDONLY;
|
||||
file_flags = O_RDONLY | O_NOFOLLOW;
|
||||
}
|
||||
else if (mode == PerfMemory::PERF_MODE_RW) {
|
||||
#ifdef LATER
|
||||
mmap_prot = PROT_READ | PROT_WRITE;
|
||||
file_flags = O_RDWR;
|
||||
file_flags = O_RDWR | O_NOFOLLOW;
|
||||
#else
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
|
||||
"Unsupported access mode");
|
||||
|
@ -63,9 +63,15 @@ void VMError::show_message_box(char *buf, int buflen) {
|
||||
} while (yes);
|
||||
}
|
||||
|
||||
// handle all synchronous program error signals which may happen during error
|
||||
// reporting. They must be unblocked, caught, handled.
|
||||
|
||||
static const int SIGNALS[] = { SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP }; // add more if needed
|
||||
static const int NUM_SIGNALS = sizeof(SIGNALS) / sizeof(int);
|
||||
|
||||
// Space for our "saved" signal flags and handlers
|
||||
static int resettedSigflags[2];
|
||||
static address resettedSighandler[2];
|
||||
static int resettedSigflags[NUM_SIGNALS];
|
||||
static address resettedSighandler[NUM_SIGNALS];
|
||||
|
||||
static void save_signal(int idx, int sig)
|
||||
{
|
||||
@ -78,19 +84,19 @@ static void save_signal(int idx, int sig)
|
||||
}
|
||||
|
||||
int VMError::get_resetted_sigflags(int sig) {
|
||||
if(SIGSEGV == sig) {
|
||||
return resettedSigflags[0];
|
||||
} else if(SIGBUS == sig) {
|
||||
return resettedSigflags[1];
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
if (SIGNALS[i] == sig) {
|
||||
return resettedSigflags[i];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
address VMError::get_resetted_sighandler(int sig) {
|
||||
if(SIGSEGV == sig) {
|
||||
return resettedSighandler[0];
|
||||
} else if(SIGBUS == sig) {
|
||||
return resettedSighandler[1];
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
if (SIGNALS[i] == sig) {
|
||||
return resettedSighandler[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -100,16 +106,25 @@ static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
|
||||
sigset_t newset;
|
||||
sigemptyset(&newset);
|
||||
sigaddset(&newset, sig);
|
||||
sigprocmask(SIG_UNBLOCK, &newset, NULL);
|
||||
// also unmask other synchronous signals
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
sigaddset(&newset, SIGNALS[i]);
|
||||
}
|
||||
pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
|
||||
|
||||
VMError err(NULL, sig, NULL, info, ucVoid);
|
||||
err.report_and_die();
|
||||
}
|
||||
|
||||
void VMError::reset_signal_handlers() {
|
||||
// Save sigflags for resetted signals
|
||||
save_signal(0, SIGSEGV);
|
||||
save_signal(1, SIGBUS);
|
||||
os::signal(SIGSEGV, CAST_FROM_FN_PTR(void *, crash_handler));
|
||||
os::signal(SIGBUS, CAST_FROM_FN_PTR(void *, crash_handler));
|
||||
// install signal handlers for all synchronous program error signals
|
||||
sigset_t newset;
|
||||
sigemptyset(&newset);
|
||||
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
save_signal(i, SIGNALS[i]);
|
||||
os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
|
||||
sigaddset(&newset, SIGNALS[i]);
|
||||
}
|
||||
pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 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
|
||||
@ -1322,6 +1322,15 @@ jlong os::javaTimeMillis() {
|
||||
return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
|
||||
}
|
||||
|
||||
void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
|
||||
timeval time;
|
||||
int status = gettimeofday(&time, NULL);
|
||||
assert(status != -1, "linux error");
|
||||
seconds = jlong(time.tv_sec);
|
||||
nanos = jlong(time.tv_usec) * 1000;
|
||||
}
|
||||
|
||||
|
||||
#ifndef CLOCK_MONOTONIC
|
||||
#define CLOCK_MONOTONIC (1)
|
||||
#endif
|
||||
|
@ -197,7 +197,38 @@ static pid_t filename_to_pid(const char* filename) {
|
||||
}
|
||||
|
||||
|
||||
// check if the given path is considered a secure directory for
|
||||
// Check if the given statbuf is considered a secure directory for
|
||||
// the backing store files. Returns true if the directory is considered
|
||||
// a secure location. Returns false if the statbuf is a symbolic link or
|
||||
// if an error occurred.
|
||||
//
|
||||
static bool is_statbuf_secure(struct stat *statp) {
|
||||
if (S_ISLNK(statp->st_mode) || !S_ISDIR(statp->st_mode)) {
|
||||
// The path represents a link or some non-directory file type,
|
||||
// which is not what we expected. Declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
// We have an existing directory, check if the permissions are safe.
|
||||
//
|
||||
if ((statp->st_mode & (S_IWGRP|S_IWOTH)) != 0) {
|
||||
// The directory is open for writing and could be subjected
|
||||
// to a symlink or a hard link attack. Declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
// See if the uid of the directory matches the effective uid of the process.
|
||||
//
|
||||
if (statp->st_uid != geteuid()) {
|
||||
// The directory was not created by this user, declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Check if the given path is considered a secure directory for
|
||||
// the backing store files. Returns true if the directory exists
|
||||
// and is considered a secure location. Returns false if the path
|
||||
// is a symbolic link or if an error occurred.
|
||||
@ -211,22 +242,180 @@ static bool is_directory_secure(const char* path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// the path exists, now check it's mode
|
||||
if (S_ISLNK(statbuf.st_mode) || !S_ISDIR(statbuf.st_mode)) {
|
||||
// the path represents a link or some non-directory file type,
|
||||
// which is not what we expected. declare it insecure.
|
||||
//
|
||||
// The path exists, see if it is secure.
|
||||
return is_statbuf_secure(&statbuf);
|
||||
}
|
||||
|
||||
|
||||
// Check if the given directory file descriptor is considered a secure
|
||||
// directory for the backing store files. Returns true if the directory
|
||||
// exists and is considered a secure location. Returns false if the path
|
||||
// is a symbolic link or if an error occurred.
|
||||
//
|
||||
static bool is_dirfd_secure(int dir_fd) {
|
||||
struct stat statbuf;
|
||||
int result = 0;
|
||||
|
||||
RESTARTABLE(::fstat(dir_fd, &statbuf), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// we have an existing directory, check if the permissions are safe.
|
||||
//
|
||||
if ((statbuf.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
|
||||
// the directory is open for writing and could be subjected
|
||||
// to a symlnk attack. declare it insecure.
|
||||
//
|
||||
return false;
|
||||
|
||||
// The path exists, now check its mode.
|
||||
return is_statbuf_secure(&statbuf);
|
||||
}
|
||||
|
||||
|
||||
// Check to make sure fd1 and fd2 are referencing the same file system object.
|
||||
//
|
||||
static bool is_same_fsobject(int fd1, int fd2) {
|
||||
struct stat statbuf1;
|
||||
struct stat statbuf2;
|
||||
int result = 0;
|
||||
|
||||
RESTARTABLE(::fstat(fd1, &statbuf1), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
RESTARTABLE(::fstat(fd2, &statbuf2), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((statbuf1.st_ino == statbuf2.st_ino) &&
|
||||
(statbuf1.st_dev == statbuf2.st_dev)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Open the directory of the given path and validate it.
|
||||
// Return a DIR * of the open directory.
|
||||
//
|
||||
static DIR *open_directory_secure(const char* dirname) {
|
||||
// Open the directory using open() so that it can be verified
|
||||
// to be secure by calling is_dirfd_secure(), opendir() and then check
|
||||
// to see if they are the same file system object. This method does not
|
||||
// introduce a window of opportunity for the directory to be attacked that
|
||||
// calling opendir() and is_directory_secure() does.
|
||||
int result;
|
||||
DIR *dirp = NULL;
|
||||
RESTARTABLE(::open(dirname, O_RDONLY|O_NOFOLLOW), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
if (errno == ELOOP) {
|
||||
warning("directory %s is a symlink and is not secure\n", dirname);
|
||||
} else {
|
||||
warning("could not open directory %s: %s\n", dirname, strerror(errno));
|
||||
}
|
||||
}
|
||||
return dirp;
|
||||
}
|
||||
int fd = result;
|
||||
|
||||
// Determine if the open directory is secure.
|
||||
if (!is_dirfd_secure(fd)) {
|
||||
// The directory is not a secure directory.
|
||||
os::close(fd);
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Open the directory.
|
||||
dirp = ::opendir(dirname);
|
||||
if (dirp == NULL) {
|
||||
// The directory doesn't exist, close fd and return.
|
||||
os::close(fd);
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Check to make sure fd and dirp are referencing the same file system object.
|
||||
if (!is_same_fsobject(fd, dirfd(dirp))) {
|
||||
// The directory is not secure.
|
||||
os::close(fd);
|
||||
os::closedir(dirp);
|
||||
dirp = NULL;
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Close initial open now that we know directory is secure
|
||||
os::close(fd);
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// NOTE: The code below uses fchdir(), open() and unlink() because
|
||||
// fdopendir(), openat() and unlinkat() are not supported on all
|
||||
// versions. Once the support for fdopendir(), openat() and unlinkat()
|
||||
// is available on all supported versions the code can be changed
|
||||
// to use these functions.
|
||||
|
||||
// Open the directory of the given path, validate it and set the
|
||||
// current working directory to it.
|
||||
// Return a DIR * of the open directory and the saved cwd fd.
|
||||
//
|
||||
static DIR *open_directory_secure_cwd(const char* dirname, int *saved_cwd_fd) {
|
||||
|
||||
// Open the directory.
|
||||
DIR* dirp = open_directory_secure(dirname);
|
||||
if (dirp == NULL) {
|
||||
// Directory doesn't exist or is insecure, so there is nothing to cleanup.
|
||||
return dirp;
|
||||
}
|
||||
int fd = dirfd(dirp);
|
||||
|
||||
// Open a fd to the cwd and save it off.
|
||||
int result;
|
||||
RESTARTABLE(::open(".", O_RDONLY), result);
|
||||
if (result == OS_ERR) {
|
||||
*saved_cwd_fd = -1;
|
||||
} else {
|
||||
*saved_cwd_fd = result;
|
||||
}
|
||||
|
||||
// Set the current directory to dirname by using the fd of the directory.
|
||||
result = fchdir(fd);
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Close the directory and restore the current working directory.
|
||||
//
|
||||
static void close_directory_secure_cwd(DIR* dirp, int saved_cwd_fd) {
|
||||
|
||||
int result;
|
||||
// If we have a saved cwd change back to it and close the fd.
|
||||
if (saved_cwd_fd != -1) {
|
||||
result = fchdir(saved_cwd_fd);
|
||||
::close(saved_cwd_fd);
|
||||
}
|
||||
|
||||
// Close the directory.
|
||||
os::closedir(dirp);
|
||||
}
|
||||
|
||||
// Check if the given file descriptor is considered a secure.
|
||||
//
|
||||
static bool is_file_secure(int fd, const char *filename) {
|
||||
|
||||
int result;
|
||||
struct stat statbuf;
|
||||
|
||||
// Determine if the file is secure.
|
||||
RESTARTABLE(::fstat(fd, &statbuf), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("fstat failed on %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (statbuf.st_nlink > 1) {
|
||||
// A file with multiple links is not expected.
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("file %s has multiple links\n", filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -317,9 +506,11 @@ static char* get_user_name_slow(int vmid, TRAPS) {
|
||||
|
||||
const char* tmpdirname = os::get_temp_directory();
|
||||
|
||||
// open the temp directory
|
||||
DIR* tmpdirp = os::opendir(tmpdirname);
|
||||
|
||||
if (tmpdirp == NULL) {
|
||||
// Cannot open the directory to get the user name, return.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -344,7 +535,8 @@ static char* get_user_name_slow(int vmid, TRAPS) {
|
||||
strcat(usrdir_name, "/");
|
||||
strcat(usrdir_name, dentry->d_name);
|
||||
|
||||
DIR* subdirp = os::opendir(usrdir_name);
|
||||
// open the user directory
|
||||
DIR* subdirp = open_directory_secure(usrdir_name);
|
||||
|
||||
if (subdirp == NULL) {
|
||||
FREE_C_HEAP_ARRAY(char, usrdir_name);
|
||||
@ -465,26 +657,6 @@ static void remove_file(const char* path) {
|
||||
}
|
||||
|
||||
|
||||
// remove file
|
||||
//
|
||||
// this method removes the file with the given file name in the
|
||||
// named directory.
|
||||
//
|
||||
static void remove_file(const char* dirname, const char* filename) {
|
||||
|
||||
size_t nbytes = strlen(dirname) + strlen(filename) + 2;
|
||||
char* path = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
||||
|
||||
strcpy(path, dirname);
|
||||
strcat(path, "/");
|
||||
strcat(path, filename);
|
||||
|
||||
remove_file(path);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, path);
|
||||
}
|
||||
|
||||
|
||||
// cleanup stale shared memory resources
|
||||
//
|
||||
// This method attempts to remove all stale shared memory files in
|
||||
@ -496,17 +668,11 @@ static void remove_file(const char* dirname, const char* filename) {
|
||||
//
|
||||
static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
|
||||
// open the user temp directory
|
||||
DIR* dirp = os::opendir(dirname);
|
||||
|
||||
int saved_cwd_fd;
|
||||
// open the directory
|
||||
DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
|
||||
if (dirp == NULL) {
|
||||
// directory doesn't exist, so there is nothing to cleanup
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_directory_secure(dirname)) {
|
||||
// the directory is not a secure directory
|
||||
os::closedir(dirp);
|
||||
// directory doesn't exist or is insecure, so there is nothing to cleanup
|
||||
return;
|
||||
}
|
||||
|
||||
@ -520,6 +686,7 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
//
|
||||
struct dirent* entry;
|
||||
char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
|
||||
|
||||
errno = 0;
|
||||
while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
|
||||
|
||||
@ -528,9 +695,8 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
if (pid == 0) {
|
||||
|
||||
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
|
||||
|
||||
// attempt to remove all unexpected files, except "." and ".."
|
||||
remove_file(dirname, entry->d_name);
|
||||
unlink(entry->d_name);
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
@ -552,12 +718,14 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
//
|
||||
if ((pid == os::current_process_id()) ||
|
||||
(kill(pid, 0) == OS_ERR && (errno == ESRCH || errno == EPERM))) {
|
||||
|
||||
remove_file(dirname, entry->d_name);
|
||||
unlink(entry->d_name);
|
||||
}
|
||||
errno = 0;
|
||||
}
|
||||
os::closedir(dirp);
|
||||
|
||||
// close the directory and reset the current working directory
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, dbuf);
|
||||
}
|
||||
|
||||
@ -614,19 +782,54 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result;
|
||||
|
||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("could not create file %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
int saved_cwd_fd;
|
||||
// open the directory and set the current working directory to it
|
||||
DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
|
||||
if (dirp == NULL) {
|
||||
// Directory doesn't exist or is insecure, so cannot create shared
|
||||
// memory file.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Open the filename in the current directory.
|
||||
// Cannot use O_TRUNC here; truncation of an existing file has to happen
|
||||
// after the is_file_secure() check below.
|
||||
int result;
|
||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_NOFOLLOW, S_IREAD|S_IWRITE), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
if (errno == ELOOP) {
|
||||
warning("file %s is a symlink and is not secure\n", filename);
|
||||
} else {
|
||||
warning("could not create file %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
}
|
||||
// close the directory and reset the current working directory
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
return -1;
|
||||
}
|
||||
// close the directory and reset the current working directory
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
// save the file descriptor
|
||||
int fd = result;
|
||||
|
||||
// check to see if the file is secure
|
||||
if (!is_file_secure(fd, filename)) {
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// truncate the file to get rid of any existing data
|
||||
RESTARTABLE(::ftruncate(fd, (off_t)0), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("could not truncate shared memory file: %s\n", strerror(errno));
|
||||
}
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
// set the file size
|
||||
RESTARTABLE(::ftruncate(fd, (off_t)size), result);
|
||||
if (result == OS_ERR) {
|
||||
@ -684,8 +887,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
|
||||
THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
|
||||
}
|
||||
}
|
||||
int fd = result;
|
||||
|
||||
return result;
|
||||
// check to see if the file is secure
|
||||
if (!is_file_secure(fd, filename)) {
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
// create a named shared memory region. returns the address of the
|
||||
@ -716,6 +926,13 @@ static char* mmap_create_shared(size_t size) {
|
||||
|
||||
char* dirname = get_user_tmp_dir(user_name);
|
||||
char* filename = get_sharedmem_filename(dirname, vmid);
|
||||
// get the short filename
|
||||
char* short_filename = strrchr(filename, '/');
|
||||
if (short_filename == NULL) {
|
||||
short_filename = filename;
|
||||
} else {
|
||||
short_filename++;
|
||||
}
|
||||
|
||||
// cleanup any stale shared memory files
|
||||
cleanup_sharedmem_resources(dirname);
|
||||
@ -723,7 +940,7 @@ static char* mmap_create_shared(size_t size) {
|
||||
assert(((size > 0) && (size % os::vm_page_size() == 0)),
|
||||
"unexpected PerfMemory region size");
|
||||
|
||||
fd = create_sharedmem_resources(dirname, filename, size);
|
||||
fd = create_sharedmem_resources(dirname, short_filename, size);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, user_name);
|
||||
FREE_C_HEAP_ARRAY(char, dirname);
|
||||
@ -838,12 +1055,12 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
// constructs for the file and the shared memory mapping.
|
||||
if (mode == PerfMemory::PERF_MODE_RO) {
|
||||
mmap_prot = PROT_READ;
|
||||
file_flags = O_RDONLY;
|
||||
file_flags = O_RDONLY | O_NOFOLLOW;
|
||||
}
|
||||
else if (mode == PerfMemory::PERF_MODE_RW) {
|
||||
#ifdef LATER
|
||||
mmap_prot = PROT_READ | PROT_WRITE;
|
||||
file_flags = O_RDWR;
|
||||
file_flags = O_RDWR | O_NOFOLLOW;
|
||||
#else
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
|
||||
"Unsupported access mode");
|
||||
|
@ -63,9 +63,15 @@ void VMError::show_message_box(char *buf, int buflen) {
|
||||
} while (yes);
|
||||
}
|
||||
|
||||
// handle all synchronous program error signals which may happen during error
|
||||
// reporting. They must be unblocked, caught, handled.
|
||||
|
||||
static const int SIGNALS[] = { SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP }; // add more if needed
|
||||
static const int NUM_SIGNALS = sizeof(SIGNALS) / sizeof(int);
|
||||
|
||||
// Space for our "saved" signal flags and handlers
|
||||
static int resettedSigflags[2];
|
||||
static address resettedSighandler[2];
|
||||
static int resettedSigflags[NUM_SIGNALS];
|
||||
static address resettedSighandler[NUM_SIGNALS];
|
||||
|
||||
static void save_signal(int idx, int sig)
|
||||
{
|
||||
@ -78,19 +84,19 @@ static void save_signal(int idx, int sig)
|
||||
}
|
||||
|
||||
int VMError::get_resetted_sigflags(int sig) {
|
||||
if(SIGSEGV == sig) {
|
||||
return resettedSigflags[0];
|
||||
} else if(SIGBUS == sig) {
|
||||
return resettedSigflags[1];
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
if (SIGNALS[i] == sig) {
|
||||
return resettedSigflags[i];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
address VMError::get_resetted_sighandler(int sig) {
|
||||
if(SIGSEGV == sig) {
|
||||
return resettedSighandler[0];
|
||||
} else if(SIGBUS == sig) {
|
||||
return resettedSighandler[1];
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
if (SIGNALS[i] == sig) {
|
||||
return resettedSighandler[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -100,16 +106,26 @@ static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
|
||||
sigset_t newset;
|
||||
sigemptyset(&newset);
|
||||
sigaddset(&newset, sig);
|
||||
sigprocmask(SIG_UNBLOCK, &newset, NULL);
|
||||
// also unmask other synchronous signals
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
sigaddset(&newset, SIGNALS[i]);
|
||||
}
|
||||
pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
|
||||
|
||||
VMError err(NULL, sig, NULL, info, ucVoid);
|
||||
err.report_and_die();
|
||||
}
|
||||
|
||||
void VMError::reset_signal_handlers() {
|
||||
// Save sigflags for resetted signals
|
||||
save_signal(0, SIGSEGV);
|
||||
save_signal(1, SIGBUS);
|
||||
os::signal(SIGSEGV, CAST_FROM_FN_PTR(void *, crash_handler));
|
||||
os::signal(SIGBUS, CAST_FROM_FN_PTR(void *, crash_handler));
|
||||
// install signal handlers for all synchronous program error signals
|
||||
sigset_t newset;
|
||||
sigemptyset(&newset);
|
||||
|
||||
for (int i = 0; i < NUM_SIGNALS; i++) {
|
||||
save_signal(i, SIGNALS[i]);
|
||||
os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
|
||||
sigaddset(&newset, SIGNALS[i]);
|
||||
}
|
||||
pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
|
||||
|
||||
}
|
||||
|
@ -1,655 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, 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 "classfile/javaClasses.hpp"
|
||||
#include "code/codeBlob.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "prims/jvm.h"
|
||||
#include "runtime/dtraceJSDT.hpp"
|
||||
#include "runtime/jniHandles.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "runtime/signature.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
#ifdef HAVE_DTRACE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dtrace.h>
|
||||
|
||||
static const char* devname = "/dev/dtrace/helper";
|
||||
static const char* olddevname = "/devices/pseudo/dtrace@0:helper";
|
||||
|
||||
static const char* string_sig = "uintptr_t";
|
||||
static const char* int_sig = "long";
|
||||
static const char* long_sig = "long long";
|
||||
|
||||
static void printDOFHelper(dof_helper_t* helper);
|
||||
|
||||
static int dofhelper_open() {
|
||||
int fd;
|
||||
if ((fd = open64(devname, O_RDWR)) < 0) {
|
||||
// Optimize next calls
|
||||
devname = olddevname;
|
||||
if ((fd = open64(devname, O_RDWR)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
static jint dof_register(jstring module, uint8_t* dof, void* modaddr) {
|
||||
int probe;
|
||||
dof_helper_t dh;
|
||||
int fd;
|
||||
|
||||
memset(&dh, 0, sizeof(dh));
|
||||
|
||||
char* module_name = java_lang_String::as_utf8_string(
|
||||
JNIHandles::resolve_non_null(module));
|
||||
jio_snprintf(dh.dofhp_mod, sizeof(dh.dofhp_mod), "%s", module_name);
|
||||
dh.dofhp_dof = (uint64_t)dof;
|
||||
dh.dofhp_addr = (uint64_t)modaddr;
|
||||
|
||||
fd = dofhelper_open();
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
probe = ioctl(fd, DTRACEHIOC_ADDDOF, &dh);
|
||||
close(fd);
|
||||
if (PrintDTraceDOF) {
|
||||
printDOFHelper(&dh);
|
||||
tty->print_cr("DOF helper id = %d", probe);
|
||||
}
|
||||
return probe;
|
||||
}
|
||||
|
||||
int DTraceJSDT::pd_activate(
|
||||
void* moduleBaseAddress, jstring module,
|
||||
jint providers_count, JVM_DTraceProvider* providers) {
|
||||
|
||||
// We need sections:
|
||||
// (1) STRTAB
|
||||
// (
|
||||
// (2) PROVIDER
|
||||
// (3) PROBES
|
||||
// (4) PROBOFFS
|
||||
// (5) PROBARGS
|
||||
// ) * Number of Providers
|
||||
|
||||
// Type of sections we create
|
||||
enum {
|
||||
STRTAB = 0,
|
||||
PROVIDERS = 1,
|
||||
PROBES = 2,
|
||||
PROBE_OFFSETS = 3,
|
||||
ARG_OFFSETS = 4,
|
||||
NUM_SECTIONS = 5
|
||||
};
|
||||
|
||||
static int alignment_for[NUM_SECTIONS] = { 1, 4, 8, 4, 1 };
|
||||
|
||||
ResourceMark rm;
|
||||
|
||||
uint32_t num_sections = 1 + 4 * providers_count;
|
||||
uint32_t offset = sizeof(dof_hdr_t) + (num_sections * sizeof(dof_sec_t));
|
||||
uint32_t* secoffs = NEW_RESOURCE_ARRAY(uint32_t, num_sections);
|
||||
uint32_t* secsize = NEW_RESOURCE_ARRAY(uint32_t, num_sections);
|
||||
|
||||
// Store offsets of all strings here in such order:
|
||||
// zero-string (always 0)
|
||||
// provider1-name
|
||||
// probe1-function
|
||||
// probe1-name
|
||||
// arg-1
|
||||
// arg-2
|
||||
// ...
|
||||
// probe2-function
|
||||
// probe2-name
|
||||
// arg-1
|
||||
// arg-2
|
||||
// provider2-name
|
||||
// ...
|
||||
|
||||
uint32_t strcount = 0;
|
||||
// Count the number of strings we'll need
|
||||
for(int prvc = 0; prvc < providers_count; ++prvc) {
|
||||
JVM_DTraceProvider* provider = &providers[prvc];
|
||||
// Provider name
|
||||
++strcount;
|
||||
for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
|
||||
JVM_DTraceProbe* p = &(provider->probes[prbc]);
|
||||
Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
|
||||
// function + name + one per argument
|
||||
strcount += 2 + ArgumentCount(sig).size();
|
||||
}
|
||||
}
|
||||
|
||||
// Create place for string offsets
|
||||
uint32_t* stroffs = NEW_RESOURCE_ARRAY(uint32_t, strcount + 1);
|
||||
uint32_t string_index = 0;
|
||||
uint32_t curstr = 0;
|
||||
|
||||
// First we need an empty string: ""
|
||||
stroffs[curstr++] = string_index;
|
||||
string_index += strlen("") + 1;
|
||||
|
||||
for(int prvc = 0; prvc < providers_count; ++prvc) {
|
||||
JVM_DTraceProvider* provider = &providers[prvc];
|
||||
char* provider_name = java_lang_String::as_utf8_string(
|
||||
JNIHandles::resolve_non_null(provider->name));
|
||||
stroffs[curstr++] = string_index;
|
||||
string_index += strlen(provider_name) + 1;
|
||||
|
||||
// All probes
|
||||
for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
|
||||
JVM_DTraceProbe* p = &(provider->probes[prbc]);
|
||||
|
||||
char* function = java_lang_String::as_utf8_string(
|
||||
JNIHandles::resolve_non_null(p->function));
|
||||
stroffs[curstr++] = string_index;
|
||||
string_index += strlen(function) + 1;
|
||||
|
||||
char* name = java_lang_String::as_utf8_string(
|
||||
JNIHandles::resolve_non_null(p->name));
|
||||
stroffs[curstr++] = string_index;
|
||||
string_index += strlen(name) + 1;
|
||||
|
||||
Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
|
||||
SignatureStream ss(sig);
|
||||
for ( ; !ss.at_return_type(); ss.next()) {
|
||||
BasicType bt = ss.type();
|
||||
const char* t = NULL;
|
||||
if (bt == T_OBJECT &&
|
||||
ss.as_symbol_or_null() == vmSymbols::java_lang_String()) {
|
||||
t = string_sig;
|
||||
} else if (bt == T_LONG) {
|
||||
t = long_sig;
|
||||
} else {
|
||||
t = int_sig;
|
||||
}
|
||||
stroffs[curstr++] = string_index;
|
||||
string_index += strlen(t) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
secoffs[STRTAB] = offset;
|
||||
secsize[STRTAB] = string_index;
|
||||
offset += string_index;
|
||||
|
||||
// Calculate the size of the rest
|
||||
for(int prvc = 0; prvc < providers_count; ++prvc) {
|
||||
JVM_DTraceProvider* provider = &providers[prvc];
|
||||
size_t provider_sec = PROVIDERS + prvc * 4;
|
||||
size_t probe_sec = PROBES + prvc * 4;
|
||||
size_t probeoffs_sec = PROBE_OFFSETS + prvc * 4;
|
||||
size_t argoffs_sec = ARG_OFFSETS + prvc * 4;
|
||||
|
||||
// Allocate space for the provider data struction
|
||||
secoffs[provider_sec] = align_size_up(offset, alignment_for[PROVIDERS]);
|
||||
secsize[provider_sec] = sizeof(dof_provider_t);
|
||||
offset = secoffs[provider_sec] + secsize[provider_sec];
|
||||
|
||||
// Allocate space for all the probes
|
||||
secoffs[probe_sec] = align_size_up(offset, alignment_for[PROBES]);
|
||||
secsize[probe_sec] = sizeof(dof_probe_t) * provider->probe_count;
|
||||
offset = secoffs[probe_sec] + secsize[probe_sec];
|
||||
|
||||
// Allocate space for the probe offsets
|
||||
secoffs[probeoffs_sec] = align_size_up(offset, alignment_for[PROBE_OFFSETS]);
|
||||
secsize[probeoffs_sec] = sizeof(uint32_t) * provider->probe_count;
|
||||
offset = secoffs[probeoffs_sec] + secsize[probeoffs_sec];
|
||||
|
||||
// We need number of arguments argoffs
|
||||
uint32_t argscount = 0;
|
||||
for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
|
||||
JVM_DTraceProbe* p = &(provider->probes[prbc]);
|
||||
Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
|
||||
argscount += ArgumentCount(sig).size();
|
||||
}
|
||||
secoffs[argoffs_sec] = align_size_up(offset, alignment_for[ARG_OFFSETS]);
|
||||
secsize[argoffs_sec] = sizeof(uint8_t) * argscount;
|
||||
offset = secoffs[argoffs_sec] + secsize[argoffs_sec];
|
||||
}
|
||||
|
||||
uint32_t size = offset;
|
||||
|
||||
uint8_t* dof = NEW_RESOURCE_ARRAY(uint8_t, size);
|
||||
if (!dof) {
|
||||
return -1;
|
||||
}
|
||||
memset((void*)dof, 0, size);
|
||||
|
||||
// Fill memory with proper values
|
||||
dof_hdr_t* hdr = (dof_hdr_t*)dof;
|
||||
hdr->dofh_ident[DOF_ID_MAG0] = DOF_MAG_MAG0;
|
||||
hdr->dofh_ident[DOF_ID_MAG1] = DOF_MAG_MAG1;
|
||||
hdr->dofh_ident[DOF_ID_MAG2] = DOF_MAG_MAG2;
|
||||
hdr->dofh_ident[DOF_ID_MAG3] = DOF_MAG_MAG3;
|
||||
hdr->dofh_ident[DOF_ID_MODEL] = DOF_MODEL_NATIVE; // No variants
|
||||
hdr->dofh_ident[DOF_ID_ENCODING] = DOF_ENCODE_NATIVE; // No variants
|
||||
hdr->dofh_ident[DOF_ID_VERSION] = DOF_VERSION_1; // No variants
|
||||
hdr->dofh_ident[DOF_ID_DIFVERS] = DIF_VERSION_2; // No variants
|
||||
// all other fields of ident to zero
|
||||
|
||||
hdr->dofh_flags = 0;
|
||||
hdr->dofh_hdrsize = sizeof(dof_hdr_t);
|
||||
hdr->dofh_secsize = sizeof(dof_sec_t);
|
||||
hdr->dofh_secnum = num_sections;
|
||||
hdr->dofh_secoff = sizeof(dof_hdr_t);
|
||||
hdr->dofh_loadsz = size;
|
||||
hdr->dofh_filesz = size;
|
||||
|
||||
// First section: STRTAB
|
||||
dof_sec_t* sec = (dof_sec_t*)(dof + sizeof(dof_hdr_t));
|
||||
sec->dofs_type = DOF_SECT_STRTAB;
|
||||
sec->dofs_align = alignment_for[STRTAB];
|
||||
sec->dofs_flags = DOF_SECF_LOAD;
|
||||
sec->dofs_entsize = 0;
|
||||
sec->dofs_offset = secoffs[STRTAB];
|
||||
sec->dofs_size = secsize[STRTAB];
|
||||
// Make data for this section
|
||||
char* str = (char*)(dof + sec->dofs_offset);
|
||||
|
||||
*str = 0; str += 1; // ""
|
||||
|
||||
// Run through all strings again
|
||||
for(int prvc = 0; prvc < providers_count; ++prvc) {
|
||||
JVM_DTraceProvider* provider = &providers[prvc];
|
||||
char* provider_name = java_lang_String::as_utf8_string(
|
||||
JNIHandles::resolve_non_null(provider->name));
|
||||
strcpy(str, provider_name);
|
||||
str += strlen(provider_name) + 1;
|
||||
|
||||
// All probes
|
||||
for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
|
||||
JVM_DTraceProbe* p = &(provider->probes[prbc]);
|
||||
|
||||
char* function = java_lang_String::as_utf8_string(
|
||||
JNIHandles::resolve_non_null(p->function));
|
||||
strcpy(str, function);
|
||||
str += strlen(str) + 1;
|
||||
|
||||
char* name = java_lang_String::as_utf8_string(
|
||||
JNIHandles::resolve_non_null(p->name));
|
||||
strcpy(str, name);
|
||||
str += strlen(name) + 1;
|
||||
|
||||
Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
|
||||
SignatureStream ss(sig);
|
||||
for ( ; !ss.at_return_type(); ss.next()) {
|
||||
BasicType bt = ss.type();
|
||||
const char* t;
|
||||
if (bt == T_OBJECT &&
|
||||
ss.as_symbol_or_null() == vmSymbols::java_lang_String()) {
|
||||
t = string_sig;
|
||||
} else if (bt == T_LONG) {
|
||||
t = long_sig;
|
||||
} else {
|
||||
t = int_sig;
|
||||
}
|
||||
strcpy(str, t);
|
||||
str += strlen(t) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
curstr = 1;
|
||||
for(int prvc = 0; prvc < providers_count; ++prvc) {
|
||||
JVM_DTraceProvider* provider = &providers[prvc];
|
||||
size_t provider_sec = PROVIDERS + prvc * 4;
|
||||
size_t probe_sec = PROBES + prvc * 4;
|
||||
size_t probeoffs_sec = PROBE_OFFSETS + prvc * 4;
|
||||
size_t argoffs_sec = ARG_OFFSETS + prvc * 4;
|
||||
|
||||
// PROVIDER ///////////////////////////////////////////////////////////////
|
||||
// Section header
|
||||
sec = (dof_sec_t*)
|
||||
(dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * provider_sec);
|
||||
sec->dofs_type = DOF_SECT_PROVIDER;
|
||||
sec->dofs_align = alignment_for[PROVIDERS];
|
||||
sec->dofs_flags = DOF_SECF_LOAD;
|
||||
sec->dofs_entsize = 0;
|
||||
sec->dofs_offset = secoffs[provider_sec];
|
||||
sec->dofs_size = secsize[provider_sec];
|
||||
// Make provider decriiption
|
||||
dof_provider_t* prv = (dof_provider_t*)(dof + sec->dofs_offset);
|
||||
prv->dofpv_strtab = STRTAB;
|
||||
prv->dofpv_probes = probe_sec;
|
||||
prv->dofpv_prargs = argoffs_sec;
|
||||
prv->dofpv_proffs = probeoffs_sec;
|
||||
prv->dofpv_name = stroffs[curstr++]; // Index in string table
|
||||
prv->dofpv_provattr = DOF_ATTR(
|
||||
provider->providerAttributes.nameStability,
|
||||
provider->providerAttributes.dataStability,
|
||||
provider->providerAttributes.dependencyClass);
|
||||
prv->dofpv_modattr = DOF_ATTR(
|
||||
provider->moduleAttributes.nameStability,
|
||||
provider->moduleAttributes.dataStability,
|
||||
provider->moduleAttributes.dependencyClass);
|
||||
prv->dofpv_funcattr = DOF_ATTR(
|
||||
provider->functionAttributes.nameStability,
|
||||
provider->functionAttributes.dataStability,
|
||||
provider->functionAttributes.dependencyClass);
|
||||
prv->dofpv_nameattr = DOF_ATTR(
|
||||
provider->nameAttributes.nameStability,
|
||||
provider->nameAttributes.dataStability,
|
||||
provider->nameAttributes.dependencyClass);
|
||||
prv->dofpv_argsattr = DOF_ATTR(
|
||||
provider->argsAttributes.nameStability,
|
||||
provider->argsAttributes.dataStability,
|
||||
provider->argsAttributes.dependencyClass);
|
||||
|
||||
// PROBES /////////////////////////////////////////////////////////////////
|
||||
// Section header
|
||||
sec = (dof_sec_t*)
|
||||
(dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * probe_sec);
|
||||
sec->dofs_type = DOF_SECT_PROBES;
|
||||
sec->dofs_align = alignment_for[PROBES];
|
||||
sec->dofs_flags = DOF_SECF_LOAD;
|
||||
sec->dofs_entsize = sizeof(dof_probe_t);
|
||||
sec->dofs_offset = secoffs[probe_sec];
|
||||
sec->dofs_size = secsize[probe_sec];
|
||||
// Make probes descriptions
|
||||
uint32_t argsoffs = 0;
|
||||
for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
|
||||
JVM_DTraceProbe* probe = &(provider->probes[prbc]);
|
||||
Method* m = Method::resolve_jmethod_id(probe->method);
|
||||
int arg_count = ArgumentCount(m->signature()).size();
|
||||
assert(m->code() != NULL, "must have an nmethod");
|
||||
|
||||
dof_probe_t* prb =
|
||||
(dof_probe_t*)(dof + sec->dofs_offset + prbc * sizeof(dof_probe_t));
|
||||
|
||||
prb->dofpr_addr = (uint64_t)m->code()->entry_point();
|
||||
prb->dofpr_func = stroffs[curstr++]; // Index in string table
|
||||
prb->dofpr_name = stroffs[curstr++]; // Index in string table
|
||||
prb->dofpr_nargv = stroffs[curstr ]; // Index in string table
|
||||
// We spent siglen strings here
|
||||
curstr += arg_count;
|
||||
prb->dofpr_xargv = prb->dofpr_nargv; // Same bunch of strings
|
||||
prb->dofpr_argidx = argsoffs;
|
||||
prb->dofpr_offidx = prbc;
|
||||
prb->dofpr_nargc = arg_count;
|
||||
prb->dofpr_xargc = arg_count;
|
||||
prb->dofpr_noffs = 1; // Number of offsets
|
||||
// Next bunch of offsets
|
||||
argsoffs += arg_count;
|
||||
}
|
||||
|
||||
// PROFFS /////////////////////////////////////////////////////////////////
|
||||
// Section header
|
||||
sec = (dof_sec_t*)
|
||||
(dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * probeoffs_sec);
|
||||
sec->dofs_type = DOF_SECT_PROFFS;
|
||||
sec->dofs_align = alignment_for[PROBE_OFFSETS];
|
||||
sec->dofs_flags = DOF_SECF_LOAD;
|
||||
sec->dofs_entsize = sizeof(uint32_t);
|
||||
sec->dofs_offset = secoffs[probeoffs_sec];
|
||||
sec->dofs_size = secsize[probeoffs_sec];
|
||||
// Make offsets
|
||||
for (int prbc = 0; prbc < provider->probe_count; ++prbc) {
|
||||
uint32_t* pof =
|
||||
(uint32_t*)(dof + sec->dofs_offset + sizeof(uint32_t) * prbc);
|
||||
JVM_DTraceProbe* probe = &(provider->probes[prbc]);
|
||||
Method* m = Method::resolve_jmethod_id(probe->method);
|
||||
*pof = m->code()->trap_offset();
|
||||
}
|
||||
|
||||
// PRARGS /////////////////////////////////////////////////////////////////
|
||||
// Section header
|
||||
sec = (dof_sec_t*)
|
||||
(dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * argoffs_sec);
|
||||
sec->dofs_type = DOF_SECT_PRARGS;
|
||||
sec->dofs_align = alignment_for[ARG_OFFSETS];
|
||||
sec->dofs_flags = DOF_SECF_LOAD;
|
||||
sec->dofs_entsize = sizeof(uint8_t);
|
||||
sec->dofs_offset = secoffs[argoffs_sec];
|
||||
sec->dofs_size = secsize[argoffs_sec];
|
||||
// Make arguments
|
||||
uint8_t* par = (uint8_t*)(dof + sec->dofs_offset);
|
||||
for (int prbc = 0; prbc < provider->probe_count; ++prbc) {
|
||||
JVM_DTraceProbe* p = &(provider->probes[prbc]);
|
||||
Symbol* sig = Method::resolve_jmethod_id(p->method)->signature();
|
||||
uint8_t count = (uint8_t)ArgumentCount(sig).size();
|
||||
for (uint8_t i = 0; i < count; ++i) {
|
||||
*par++ = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register module
|
||||
return dof_register(module, dof, moduleBaseAddress);
|
||||
}
|
||||
|
||||
|
||||
void DTraceJSDT::pd_dispose(int handle) {
|
||||
int fd;
|
||||
if (handle == -1) {
|
||||
return;
|
||||
}
|
||||
fd = dofhelper_open();
|
||||
if (fd < 0)
|
||||
return;
|
||||
ioctl(fd, DTRACEHIOC_REMOVE, handle);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
jboolean DTraceJSDT::pd_is_supported() {
|
||||
int fd = dofhelper_open();
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char* dofSecTypeFor(uint32_t type) {
|
||||
switch (type) {
|
||||
case 0: return "DOF_SECT_NONE";
|
||||
case 1: return "DOF_SECT_COMMENTS";
|
||||
case 2: return "DOF_SECT_SOURCE";
|
||||
case 3: return "DOF_SECT_ECBDESC";
|
||||
case 4: return "DOF_SECT_PROBEDESC";
|
||||
case 5: return "DOF_SECT_ACTDESC";
|
||||
case 6: return "DOF_SECT_DIFOHDR";
|
||||
case 7: return "DOF_SECT_DIF";
|
||||
case 8: return "DOF_SECT_STRTAB";
|
||||
case 9: return "DOF_SECT_VARTAB";
|
||||
case 10: return "DOF_SECT_RELTAB";
|
||||
case 11: return "DOF_SECT_TYPETAB";
|
||||
case 12: return "DOF_SECT_URELHDR";
|
||||
case 13: return "DOF_SECT_KRELHDR";
|
||||
case 14: return "DOF_SECT_OPTDESC";
|
||||
case 15: return "DOF_SECT_PROVIDER";
|
||||
case 16: return "DOF_SECT_PROBES";
|
||||
case 17: return "DOF_SECT_PRARGS";
|
||||
case 18: return "DOF_SECT_PROFFS";
|
||||
case 19: return "DOF_SECT_INTTAB";
|
||||
case 20: return "DOF_SECT_UTSNAME";
|
||||
case 21: return "DOF_SECT_XLTAB";
|
||||
case 22: return "DOF_SECT_XLMEMBERS";
|
||||
case 23: return "DOF_SECT_XLIMPORT";
|
||||
case 24: return "DOF_SECT_XLEXPORT";
|
||||
case 25: return "DOF_SECT_PREXPORT";
|
||||
case 26: return "DOF_SECT_PRENOFFS";
|
||||
default: return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
static void printDOFStringTabSec(void* dof, dof_sec_t* sec) {
|
||||
size_t tab = sec->dofs_offset;
|
||||
size_t limit = sec->dofs_size;
|
||||
tty->print_cr("// String Table:");
|
||||
for (size_t idx = 0; idx < limit; /*empty*/) {
|
||||
char* str = ((char*)dof) + tab + idx;
|
||||
tty->print_cr("// [0x%x + 0x%x] '%s'", tab, idx, str);
|
||||
idx += strlen(str) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void printDOFProviderSec(void* dof, dof_sec_t* sec) {
|
||||
dof_provider_t* prov = (dof_provider_t*)((char*)dof + sec->dofs_offset);
|
||||
tty->print_cr("// dof_provider_t {");
|
||||
tty->print_cr("// dofpv_strtab = %d", prov->dofpv_strtab);
|
||||
tty->print_cr("// dofpv_probes = %d", prov->dofpv_probes);
|
||||
tty->print_cr("// dofpv_prargs = %d", prov->dofpv_prargs);
|
||||
tty->print_cr("// dofpv_proffs = %d", prov->dofpv_proffs);
|
||||
tty->print_cr("// dofpv_name = 0x%x", prov->dofpv_name);
|
||||
tty->print_cr("// dofpv_provattr = 0x%08x", prov->dofpv_provattr);
|
||||
tty->print_cr("// dofpv_modattr = 0x%08x", prov->dofpv_modattr);
|
||||
tty->print_cr("// dofpv_funcattr = 0x%08x", prov->dofpv_funcattr);
|
||||
tty->print_cr("// dofpv_nameattr = 0x%08x", prov->dofpv_nameattr);
|
||||
tty->print_cr("// dofpv_argsattr = 0x%08x", prov->dofpv_argsattr);
|
||||
tty->print_cr("// }");
|
||||
}
|
||||
|
||||
static void printDOFProbesSec(void* dof, dof_sec_t* sec) {
|
||||
size_t idx = sec->dofs_offset;
|
||||
size_t limit = idx + sec->dofs_size;
|
||||
for (size_t idx = sec->dofs_offset; idx < limit; idx += sec->dofs_entsize) {
|
||||
dof_probe_t* prb = (dof_probe_t*)((char*)dof + idx);
|
||||
tty->print_cr("// dof_probe_t {");
|
||||
tty->print_cr("// dofpr_addr = 0x%016llx", prb->dofpr_addr);
|
||||
tty->print_cr("// dofpr_func = 0x%x", prb->dofpr_func);
|
||||
tty->print_cr("// dofpr_name = 0x%x", prb->dofpr_name);
|
||||
tty->print_cr("// dofpr_nargv = 0x%x", prb->dofpr_nargv);
|
||||
tty->print_cr("// dofpr_xargv = 0x%x", prb->dofpr_xargv);
|
||||
tty->print_cr("// dofpr_argidx = 0x%x", prb->dofpr_argidx);
|
||||
tty->print_cr("// dofpr_offidx = 0x%x", prb->dofpr_offidx);
|
||||
tty->print_cr("// dofpr_nargc = %d", prb->dofpr_nargc);
|
||||
tty->print_cr("// dofpr_xargc = %d", prb->dofpr_xargc);
|
||||
tty->print_cr("// dofpr_noffs = %d", prb->dofpr_noffs);
|
||||
tty->print_cr("// }");
|
||||
}
|
||||
}
|
||||
|
||||
static void printDOFOffsetsSec(void* dof, dof_sec_t* sec) {
|
||||
size_t tab = sec->dofs_offset;
|
||||
size_t limit = sec->dofs_size;
|
||||
tty->print_cr("// Offsets:");
|
||||
for (size_t idx = 0; idx < limit; idx += sec->dofs_entsize) {
|
||||
uint32_t* off = (uint32_t*)((char*)dof + tab + idx);
|
||||
tty->print_cr("// [0x%x + 0x%x]: %d", tab, idx, *off);
|
||||
}
|
||||
}
|
||||
|
||||
static void printDOFArgsSec(void* dof, dof_sec_t* sec) {
|
||||
size_t tab = sec->dofs_offset;
|
||||
size_t limit = sec->dofs_size;
|
||||
tty->print_cr("// Arguments:");
|
||||
for (size_t idx = 0; idx < limit; idx += sec->dofs_entsize) {
|
||||
uint8_t* arg = (uint8_t*)((char*)dof + tab + idx);
|
||||
tty->print_cr("// [0x%x + 0x%x]: %d", tab, idx, *arg);
|
||||
}
|
||||
}
|
||||
|
||||
static void printDOFSection(void* dof, dof_sec_t* sec) {
|
||||
tty->print_cr("// dof_sec_t {");
|
||||
tty->print_cr("// dofs_type = 0x%x /* %s */",
|
||||
sec->dofs_type, dofSecTypeFor(sec->dofs_type));
|
||||
tty->print_cr("// dofs_align = %d", sec->dofs_align);
|
||||
tty->print_cr("// dofs_flags = 0x%x", sec->dofs_flags);
|
||||
tty->print_cr("// dofs_entsize = %d", sec->dofs_entsize);
|
||||
tty->print_cr("// dofs_offset = 0x%llx", sec->dofs_offset);
|
||||
tty->print_cr("// dofs_size = %lld", sec->dofs_size);
|
||||
tty->print_cr("// }");
|
||||
switch (sec->dofs_type) {
|
||||
case DOF_SECT_STRTAB: printDOFStringTabSec(dof, sec); break;
|
||||
case DOF_SECT_PROVIDER: printDOFProviderSec(dof, sec); break;
|
||||
case DOF_SECT_PROBES: printDOFProbesSec(dof, sec); break;
|
||||
case DOF_SECT_PROFFS: printDOFOffsetsSec(dof, sec); break;
|
||||
case DOF_SECT_PRARGS: printDOFArgsSec(dof, sec); break;
|
||||
default: tty->print_cr("// <section type not recognized>");
|
||||
}
|
||||
}
|
||||
|
||||
static void printDOFHeader(dof_hdr_t* hdr) {
|
||||
tty->print_cr("// dof_hdr_t {");
|
||||
tty->print_cr("// dofh_ident[DOF_ID_MAG0] = 0x%x",
|
||||
hdr->dofh_ident[DOF_ID_MAG0]);
|
||||
tty->print_cr("// dofh_ident[DOF_ID_MAG1] = 0x%x",
|
||||
hdr->dofh_ident[DOF_ID_MAG1]);
|
||||
tty->print_cr("// dofh_ident[DOF_ID_MAG2] = 0x%x",
|
||||
hdr->dofh_ident[DOF_ID_MAG2]);
|
||||
tty->print_cr("// dofh_ident[DOF_ID_MAG3] = 0x%x",
|
||||
hdr->dofh_ident[DOF_ID_MAG3]);
|
||||
tty->print_cr("// dofh_ident[DOF_ID_MODEL] = 0x%x",
|
||||
hdr->dofh_ident[DOF_ID_MODEL]);
|
||||
tty->print_cr("// dofh_ident[DOF_ID_ENCODING] = 0x%x",
|
||||
hdr->dofh_ident[DOF_ID_ENCODING]);
|
||||
tty->print_cr("// dofh_ident[DOF_ID_VERSION] = 0x%x",
|
||||
hdr->dofh_ident[DOF_ID_VERSION]);
|
||||
tty->print_cr("// dofh_ident[DOF_ID_DIFVERS] = 0x%x",
|
||||
hdr->dofh_ident[DOF_ID_DIFVERS]);
|
||||
tty->print_cr("// dofh_flags = 0x%x", hdr->dofh_flags);
|
||||
tty->print_cr("// dofh_hdrsize = %d", hdr->dofh_hdrsize);
|
||||
tty->print_cr("// dofh_secsize = %d", hdr->dofh_secsize);
|
||||
tty->print_cr("// dofh_secnum = %d", hdr->dofh_secnum);
|
||||
tty->print_cr("// dofh_secoff = %lld", hdr->dofh_secoff);
|
||||
tty->print_cr("// dofh_loadsz = %lld", hdr->dofh_loadsz);
|
||||
tty->print_cr("// dofh_filesz = %lld", hdr->dofh_filesz);
|
||||
tty->print_cr("// }");
|
||||
}
|
||||
|
||||
static void printDOF(void* dof) {
|
||||
dof_hdr_t* hdr = (dof_hdr_t*)dof;
|
||||
printDOFHeader(hdr);
|
||||
for (int i = 0; i < hdr->dofh_secnum; ++i) {
|
||||
dof_sec_t* sec =
|
||||
(dof_sec_t*)((char*)dof + sizeof(dof_hdr_t) + i * sizeof(dof_sec_t));
|
||||
tty->print_cr("// [Section #%d]", i);
|
||||
printDOFSection(dof, sec);
|
||||
}
|
||||
}
|
||||
|
||||
static void printDOFHelper(dof_helper_t* helper) {
|
||||
tty->print_cr("// dof_helper_t {");
|
||||
tty->print_cr("// dofhp_mod = \"%s\"", helper->dofhp_mod);
|
||||
tty->print_cr("// dofhp_addr = 0x%016llx", helper->dofhp_addr);
|
||||
tty->print_cr("// dofhp_dof = 0x%016llx", helper->dofhp_dof);
|
||||
printDOF((void*)helper->dofhp_dof);
|
||||
tty->print_cr("// }");
|
||||
size_t len = ((dof_hdr_t*)helper)->dofh_loadsz;
|
||||
tty->print_data((void*)helper->dofhp_dof, len, true);
|
||||
}
|
||||
|
||||
#else // ndef HAVE_DTRACE_H
|
||||
|
||||
// Get here if we're not building on at least Solaris 10
|
||||
int DTraceJSDT::pd_activate(
|
||||
void* baseAddress, jstring module,
|
||||
jint provider_count, JVM_DTraceProvider* providers) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DTraceJSDT::pd_dispose(int handle) {
|
||||
}
|
||||
|
||||
jboolean DTraceJSDT::pd_is_supported() {
|
||||
return false;
|
||||
}
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
@ -1475,6 +1475,16 @@ jlong os::javaTimeMillis() {
|
||||
return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000;
|
||||
}
|
||||
|
||||
void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
|
||||
timeval t;
|
||||
if (gettimeofday(&t, NULL) == -1) {
|
||||
fatal(err_msg("os::javaTimeSystemUTC: gettimeofday (%s)", strerror(errno)));
|
||||
}
|
||||
seconds = jlong(t.tv_sec);
|
||||
nanos = jlong(t.tv_usec) * 1000;
|
||||
}
|
||||
|
||||
|
||||
jlong os::javaTimeNanos() {
|
||||
return (jlong)getTimeNanos();
|
||||
}
|
||||
|
@ -199,7 +199,38 @@ static pid_t filename_to_pid(const char* filename) {
|
||||
}
|
||||
|
||||
|
||||
// check if the given path is considered a secure directory for
|
||||
// Check if the given statbuf is considered a secure directory for
|
||||
// the backing store files. Returns true if the directory is considered
|
||||
// a secure location. Returns false if the statbuf is a symbolic link or
|
||||
// if an error occurred.
|
||||
//
|
||||
static bool is_statbuf_secure(struct stat *statp) {
|
||||
if (S_ISLNK(statp->st_mode) || !S_ISDIR(statp->st_mode)) {
|
||||
// The path represents a link or some non-directory file type,
|
||||
// which is not what we expected. Declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
// We have an existing directory, check if the permissions are safe.
|
||||
//
|
||||
if ((statp->st_mode & (S_IWGRP|S_IWOTH)) != 0) {
|
||||
// The directory is open for writing and could be subjected
|
||||
// to a symlink or a hard link attack. Declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
// See if the uid of the directory matches the effective uid of the process.
|
||||
//
|
||||
if (statp->st_uid != geteuid()) {
|
||||
// The directory was not created by this user, declare it insecure.
|
||||
//
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Check if the given path is considered a secure directory for
|
||||
// the backing store files. Returns true if the directory exists
|
||||
// and is considered a secure location. Returns false if the path
|
||||
// is a symbolic link or if an error occurred.
|
||||
@ -213,27 +244,185 @@ static bool is_directory_secure(const char* path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// the path exists, now check it's mode
|
||||
if (S_ISLNK(statbuf.st_mode) || !S_ISDIR(statbuf.st_mode)) {
|
||||
// the path represents a link or some non-directory file type,
|
||||
// which is not what we expected. declare it insecure.
|
||||
//
|
||||
// The path exists, see if it is secure.
|
||||
return is_statbuf_secure(&statbuf);
|
||||
}
|
||||
|
||||
|
||||
// Check if the given directory file descriptor is considered a secure
|
||||
// directory for the backing store files. Returns true if the directory
|
||||
// exists and is considered a secure location. Returns false if the path
|
||||
// is a symbolic link or if an error occurred.
|
||||
//
|
||||
static bool is_dirfd_secure(int dir_fd) {
|
||||
struct stat statbuf;
|
||||
int result = 0;
|
||||
|
||||
RESTARTABLE(::fstat(dir_fd, &statbuf), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// we have an existing directory, check if the permissions are safe.
|
||||
//
|
||||
if ((statbuf.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
|
||||
// the directory is open for writing and could be subjected
|
||||
// to a symlnk attack. declare it insecure.
|
||||
//
|
||||
return false;
|
||||
|
||||
// The path exists, now check its mode.
|
||||
return is_statbuf_secure(&statbuf);
|
||||
}
|
||||
|
||||
|
||||
// Check to make sure fd1 and fd2 are referencing the same file system object.
|
||||
//
|
||||
static bool is_same_fsobject(int fd1, int fd2) {
|
||||
struct stat statbuf1;
|
||||
struct stat statbuf2;
|
||||
int result = 0;
|
||||
|
||||
RESTARTABLE(::fstat(fd1, &statbuf1), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
RESTARTABLE(::fstat(fd2, &statbuf2), result);
|
||||
if (result == OS_ERR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((statbuf1.st_ino == statbuf2.st_ino) &&
|
||||
(statbuf1.st_dev == statbuf2.st_dev)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Open the directory of the given path and validate it.
|
||||
// Return a DIR * of the open directory.
|
||||
//
|
||||
static DIR *open_directory_secure(const char* dirname) {
|
||||
// Open the directory using open() so that it can be verified
|
||||
// to be secure by calling is_dirfd_secure(), opendir() and then check
|
||||
// to see if they are the same file system object. This method does not
|
||||
// introduce a window of opportunity for the directory to be attacked that
|
||||
// calling opendir() and is_directory_secure() does.
|
||||
int result;
|
||||
DIR *dirp = NULL;
|
||||
RESTARTABLE(::open(dirname, O_RDONLY|O_NOFOLLOW), result);
|
||||
if (result == OS_ERR) {
|
||||
// Directory doesn't exist or is a symlink, so there is nothing to cleanup.
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
if (errno == ELOOP) {
|
||||
warning("directory %s is a symlink and is not secure\n", dirname);
|
||||
} else {
|
||||
warning("could not open directory %s: %s\n", dirname, strerror(errno));
|
||||
}
|
||||
}
|
||||
return dirp;
|
||||
}
|
||||
int fd = result;
|
||||
|
||||
// Determine if the open directory is secure.
|
||||
if (!is_dirfd_secure(fd)) {
|
||||
// The directory is not a secure directory.
|
||||
os::close(fd);
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Open the directory.
|
||||
dirp = ::opendir(dirname);
|
||||
if (dirp == NULL) {
|
||||
// The directory doesn't exist, close fd and return.
|
||||
os::close(fd);
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Check to make sure fd and dirp are referencing the same file system object.
|
||||
if (!is_same_fsobject(fd, dirp->dd_fd)) {
|
||||
// The directory is not secure.
|
||||
os::close(fd);
|
||||
os::closedir(dirp);
|
||||
dirp = NULL;
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Close initial open now that we know directory is secure
|
||||
os::close(fd);
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// NOTE: The code below uses fchdir(), open() and unlink() because
|
||||
// fdopendir(), openat() and unlinkat() are not supported on all
|
||||
// versions. Once the support for fdopendir(), openat() and unlinkat()
|
||||
// is available on all supported versions the code can be changed
|
||||
// to use these functions.
|
||||
|
||||
// Open the directory of the given path, validate it and set the
|
||||
// current working directory to it.
|
||||
// Return a DIR * of the open directory and the saved cwd fd.
|
||||
//
|
||||
static DIR *open_directory_secure_cwd(const char* dirname, int *saved_cwd_fd) {
|
||||
|
||||
// Open the directory.
|
||||
DIR* dirp = open_directory_secure(dirname);
|
||||
if (dirp == NULL) {
|
||||
// Directory doesn't exist or is insecure, so there is nothing to cleanup.
|
||||
return dirp;
|
||||
}
|
||||
int fd = dirp->dd_fd;
|
||||
|
||||
// Open a fd to the cwd and save it off.
|
||||
int result;
|
||||
RESTARTABLE(::open(".", O_RDONLY), result);
|
||||
if (result == OS_ERR) {
|
||||
*saved_cwd_fd = -1;
|
||||
} else {
|
||||
*saved_cwd_fd = result;
|
||||
}
|
||||
|
||||
// Set the current directory to dirname by using the fd of the directory.
|
||||
result = fchdir(fd);
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
// Close the directory and restore the current working directory.
|
||||
//
|
||||
static void close_directory_secure_cwd(DIR* dirp, int saved_cwd_fd) {
|
||||
|
||||
int result;
|
||||
// If we have a saved cwd change back to it and close the fd.
|
||||
if (saved_cwd_fd != -1) {
|
||||
result = fchdir(saved_cwd_fd);
|
||||
::close(saved_cwd_fd);
|
||||
}
|
||||
|
||||
// Close the directory.
|
||||
os::closedir(dirp);
|
||||
}
|
||||
|
||||
// Check if the given file descriptor is considered a secure.
|
||||
//
|
||||
static bool is_file_secure(int fd, const char *filename) {
|
||||
|
||||
int result;
|
||||
struct stat statbuf;
|
||||
|
||||
// Determine if the file is secure.
|
||||
RESTARTABLE(::fstat(fd, &statbuf), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("fstat failed on %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (statbuf.st_nlink > 1) {
|
||||
// A file with multiple links is not expected.
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("file %s has multiple links\n", filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// return the user name for the given user id
|
||||
//
|
||||
// the caller is expected to free the allocated memory.
|
||||
@ -308,9 +497,11 @@ static char* get_user_name_slow(int vmid, TRAPS) {
|
||||
|
||||
const char* tmpdirname = os::get_temp_directory();
|
||||
|
||||
// open the temp directory
|
||||
DIR* tmpdirp = os::opendir(tmpdirname);
|
||||
|
||||
if (tmpdirp == NULL) {
|
||||
// Cannot open the directory to get the user name, return.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -335,7 +526,8 @@ static char* get_user_name_slow(int vmid, TRAPS) {
|
||||
strcat(usrdir_name, "/");
|
||||
strcat(usrdir_name, dentry->d_name);
|
||||
|
||||
DIR* subdirp = os::opendir(usrdir_name);
|
||||
// open the user directory
|
||||
DIR* subdirp = open_directory_secure(usrdir_name);
|
||||
|
||||
if (subdirp == NULL) {
|
||||
FREE_C_HEAP_ARRAY(char, usrdir_name);
|
||||
@ -504,26 +696,6 @@ static void remove_file(const char* path) {
|
||||
}
|
||||
|
||||
|
||||
// remove file
|
||||
//
|
||||
// this method removes the file with the given file name in the
|
||||
// named directory.
|
||||
//
|
||||
static void remove_file(const char* dirname, const char* filename) {
|
||||
|
||||
size_t nbytes = strlen(dirname) + strlen(filename) + 2;
|
||||
char* path = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
|
||||
|
||||
strcpy(path, dirname);
|
||||
strcat(path, "/");
|
||||
strcat(path, filename);
|
||||
|
||||
remove_file(path);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, path);
|
||||
}
|
||||
|
||||
|
||||
// cleanup stale shared memory resources
|
||||
//
|
||||
// This method attempts to remove all stale shared memory files in
|
||||
@ -535,17 +707,11 @@ static void remove_file(const char* dirname, const char* filename) {
|
||||
//
|
||||
static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
|
||||
// open the user temp directory
|
||||
DIR* dirp = os::opendir(dirname);
|
||||
|
||||
int saved_cwd_fd;
|
||||
// open the directory
|
||||
DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
|
||||
if (dirp == NULL) {
|
||||
// directory doesn't exist, so there is nothing to cleanup
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_directory_secure(dirname)) {
|
||||
// the directory is not a secure directory
|
||||
os::closedir(dirp);
|
||||
// directory doesn't exist or is insecure, so there is nothing to cleanup
|
||||
return;
|
||||
}
|
||||
|
||||
@ -559,6 +725,7 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
//
|
||||
struct dirent* entry;
|
||||
char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname), mtInternal);
|
||||
|
||||
errno = 0;
|
||||
while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
|
||||
|
||||
@ -569,7 +736,7 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
|
||||
|
||||
// attempt to remove all unexpected files, except "." and ".."
|
||||
remove_file(dirname, entry->d_name);
|
||||
unlink(entry->d_name);
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
@ -592,11 +759,14 @@ static void cleanup_sharedmem_resources(const char* dirname) {
|
||||
if ((pid == os::current_process_id()) ||
|
||||
(kill(pid, 0) == OS_ERR && (errno == ESRCH || errno == EPERM))) {
|
||||
|
||||
remove_file(dirname, entry->d_name);
|
||||
unlink(entry->d_name);
|
||||
}
|
||||
errno = 0;
|
||||
}
|
||||
os::closedir(dirp);
|
||||
|
||||
// close the directory and reset the current working directory
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, dbuf);
|
||||
}
|
||||
|
||||
@ -653,19 +823,54 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result;
|
||||
|
||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("could not create file %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
int saved_cwd_fd;
|
||||
// open the directory and set the current working directory to it
|
||||
DIR* dirp = open_directory_secure_cwd(dirname, &saved_cwd_fd);
|
||||
if (dirp == NULL) {
|
||||
// Directory doesn't exist or is insecure, so cannot create shared
|
||||
// memory file.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Open the filename in the current directory.
|
||||
// Cannot use O_TRUNC here; truncation of an existing file has to happen
|
||||
// after the is_file_secure() check below.
|
||||
int result;
|
||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_NOFOLLOW, S_IREAD|S_IWRITE), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
if (errno == ELOOP) {
|
||||
warning("file %s is a symlink and is not secure\n", filename);
|
||||
} else {
|
||||
warning("could not create file %s: %s\n", filename, strerror(errno));
|
||||
}
|
||||
}
|
||||
// close the directory and reset the current working directory
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
return -1;
|
||||
}
|
||||
// close the directory and reset the current working directory
|
||||
close_directory_secure_cwd(dirp, saved_cwd_fd);
|
||||
|
||||
// save the file descriptor
|
||||
int fd = result;
|
||||
|
||||
// check to see if the file is secure
|
||||
if (!is_file_secure(fd, filename)) {
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// truncate the file to get rid of any existing data
|
||||
RESTARTABLE(::ftruncate(fd, (off_t)0), result);
|
||||
if (result == OS_ERR) {
|
||||
if (PrintMiscellaneous && Verbose) {
|
||||
warning("could not truncate shared memory file: %s\n", strerror(errno));
|
||||
}
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
// set the file size
|
||||
RESTARTABLE(::ftruncate(fd, (off_t)size), result);
|
||||
if (result == OS_ERR) {
|
||||
@ -701,8 +906,15 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
|
||||
THROW_MSG_(vmSymbols::java_io_IOException(), strerror(errno), OS_ERR);
|
||||
}
|
||||
}
|
||||
int fd = result;
|
||||
|
||||
return result;
|
||||
// check to see if the file is secure
|
||||
if (!is_file_secure(fd, filename)) {
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
// create a named shared memory region. returns the address of the
|
||||
@ -734,13 +946,21 @@ static char* mmap_create_shared(size_t size) {
|
||||
char* dirname = get_user_tmp_dir(user_name);
|
||||
char* filename = get_sharedmem_filename(dirname, vmid);
|
||||
|
||||
// get the short filename
|
||||
char* short_filename = strrchr(filename, '/');
|
||||
if (short_filename == NULL) {
|
||||
short_filename = filename;
|
||||
} else {
|
||||
short_filename++;
|
||||
}
|
||||
|
||||
// cleanup any stale shared memory files
|
||||
cleanup_sharedmem_resources(dirname);
|
||||
|
||||
assert(((size > 0) && (size % os::vm_page_size() == 0)),
|
||||
"unexpected PerfMemory region size");
|
||||
|
||||
fd = create_sharedmem_resources(dirname, filename, size);
|
||||
fd = create_sharedmem_resources(dirname, short_filename, size);
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, user_name);
|
||||
FREE_C_HEAP_ARRAY(char, dirname);
|
||||
@ -856,12 +1076,12 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
|
||||
// constructs for the file and the shared memory mapping.
|
||||
if (mode == PerfMemory::PERF_MODE_RO) {
|
||||
mmap_prot = PROT_READ;
|
||||
file_flags = O_RDONLY;
|
||||
file_flags = O_RDONLY | O_NOFOLLOW;
|
||||
}
|
||||
else if (mode == PerfMemory::PERF_MODE_RW) {
|
||||
#ifdef LATER
|
||||
mmap_prot = PROT_READ | PROT_WRITE;
|
||||
file_flags = O_RDWR;
|
||||
file_flags = O_RDWR | O_NOFOLLOW;
|
||||
#else
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
|
||||
"Unsupported access mode");
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user