Merge
This commit is contained in:
commit
dad1968ad6
2
.hgtags
2
.hgtags
@ -226,3 +226,5 @@ edb01c460d4cab21ff0ff13512df7b746efaa0e7 jdk8-b101
|
||||
bbe43d712fe08e650808d774861b256ccb34e500 jdk8-b102
|
||||
30a1d677a20c6a95f98043d8f20ce570304e3818 jdk8-b103
|
||||
b5ed503c26ad38869c247c5e32debec217fd056b jdk8-b104
|
||||
589f4fdc584e373a47cde0162e9eceec9165c381 jdk8-b105
|
||||
514b0b69fb9683ef52062fd962a3e0644431f64d jdk8-b106
|
||||
|
@ -226,3 +226,5 @@ d2dcb110e9dbaf9903c05b211df800e78e4b394e jdk8-b100
|
||||
5eb3c1dc348f72a7f84f7d9d07834e8bbe09a799 jdk8-b102
|
||||
b7e64be81c8a7690703df5711f4fc2375da8a9cb jdk8-b103
|
||||
96c1b9b7524b52c3fcefc90ffad4c767396727c8 jdk8-b104
|
||||
5166118c59178b5d31001bc4058e92486ee07d9b jdk8-b105
|
||||
8e7b4d9fb00fdf1334376aeac050c9bca6d1b383 jdk8-b106
|
||||
|
@ -69,11 +69,11 @@ else
|
||||
# Run the makefile with an arbitraty SPEC using -p -q (quiet dry-run and dump rules) to find
|
||||
# available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
|
||||
all_phony_targets=$(filter-out $(global_targets) bundles-only, $(strip $(shell \
|
||||
$(MAKE) -p -q -f common/makefiles/Main.gmk SPEC=$(firstword $(SPEC)) | \
|
||||
$(MAKE) -p -q -f common/makefiles/Main.gmk FRC SPEC=$(firstword $(SPEC)) | \
|
||||
grep ^.PHONY: | head -n 1 | cut -d " " -f 2-)))
|
||||
|
||||
$(all_phony_targets):
|
||||
$(foreach spec,$(SPEC),($(MAKE) -f NewMakefile.gmk SPEC=$(spec) \
|
||||
@$(foreach spec,$(SPEC),($(MAKE) -f NewMakefile.gmk SPEC=$(spec) \
|
||||
$(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $@) &&) true
|
||||
|
||||
.PHONY: $(all_phony_targets)
|
||||
@ -98,6 +98,7 @@ help:
|
||||
$(info . # corba and jdk)
|
||||
$(info . make all # Compile everything, all repos and images)
|
||||
$(info . make images # Create complete j2sdk and j2re images)
|
||||
$(info . make docs # Create javadocs)
|
||||
$(info . make overlay-images # Create limited images for sparc 64 bit platforms)
|
||||
$(info . make profiles # Create complete j2re compact profile images)
|
||||
$(info . make bootcycle-images # Build images twice, second time with newly build JDK)
|
||||
@ -109,7 +110,7 @@ help:
|
||||
$(info . make test # Run tests, default is all tests (see TEST below))
|
||||
$(info )
|
||||
$(info Targets for specific components)
|
||||
$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, images or overlay-images))
|
||||
$(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, nashorn, images, overlay-images, docs or test))
|
||||
$(info . make <component> # Build <component> and everything it depends on. )
|
||||
$(info . make <component>-only # Build <component> only, without dependencies. This)
|
||||
$(info . # is faster but can result in incorrect build results!)
|
||||
|
@ -1210,19 +1210,18 @@
|
||||
<blockquote>
|
||||
|
||||
<p>
|
||||
<b>Q:</b> The <code>configure</code> file looks horrible!
|
||||
<b>Q:</b> The <code>generated-configure.sh</code> file looks horrible!
|
||||
How are you going to edit it?
|
||||
<br>
|
||||
<b>A:</b> The <code>configure</code> file is generated (think
|
||||
<b>A:</b> The <code>generated-configure.sh</code> file is generated (think
|
||||
"compiled") by the autoconf tools. The source code is
|
||||
in <code>configure.ac</code> various .m4 files in common/autoconf,
|
||||
which are
|
||||
much more readable.
|
||||
in <code>configure.ac</code> and various .m4 files in common/autoconf,
|
||||
which are much more readable.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Q:</b>
|
||||
Why is the <code>configure</code> file checked in,
|
||||
Why is the <code>generated-configure.sh</code> file checked in,
|
||||
if it is generated?
|
||||
<br>
|
||||
<b>A:</b>
|
||||
@ -1237,13 +1236,29 @@
|
||||
<p>
|
||||
<b>Q:</b>
|
||||
Do you require a specific version of autoconf for regenerating
|
||||
<code>configure</code>?
|
||||
<code>generated-configure.sh</code>?
|
||||
<br>
|
||||
<b>A:</b>
|
||||
Currently, no, but this will likely be the case when things have
|
||||
settled down a bit more. (The reason for this is to avoid
|
||||
large spurious changes in <code>configure</code>
|
||||
in commits that made small changes to <code>configure.ac</code>).
|
||||
Yes, version 2.69 is required and should be easy
|
||||
enough to aquire on all supported operating
|
||||
systems. The reason for this is to avoid
|
||||
large spurious changes in <code>generated-configure.sh</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Q:</b>
|
||||
How do you regenerate <code>generated-configure.sh</code>
|
||||
after making changes to the input files?
|
||||
<br>
|
||||
<b>A:</b>
|
||||
Regnerating <code>generated-configure.sh</code>
|
||||
should always be done using the
|
||||
script <code>common/autoconf/autogen.sh</code> to
|
||||
ensure that the correct files get updated. This
|
||||
script should also be run after mercurial tries to
|
||||
merge <code>generated-configure.sh</code> as a
|
||||
merge of the generated file is not guaranteed to
|
||||
be correct.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@ -44,10 +44,8 @@ fi
|
||||
custom_hook=$custom_script_dir/custom-hook.m4
|
||||
|
||||
AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`"
|
||||
AUTOCONF_267="`which autoconf-2.67 2> /dev/null | grep -v '^no autoconf-2.67 in'`"
|
||||
|
||||
echo "Autoconf found: ${AUTOCONF}"
|
||||
echo "Autoconf-2.67 found: ${AUTOCONF_267}"
|
||||
|
||||
if test "x${AUTOCONF}" = x; then
|
||||
echo You need autoconf installed to be able to regenerate the configure script
|
||||
@ -55,10 +53,6 @@ if test "x${AUTOCONF}" = x; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test "x${AUTOCONF_267}" != x; then
|
||||
AUTOCONF=${AUTOCONF_267};
|
||||
fi
|
||||
|
||||
echo Generating generated-configure.sh with ${AUTOCONF}
|
||||
cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | ${AUTOCONF} -W all -I$script_dir - > $script_dir/generated-configure.sh
|
||||
rm -rf autom4te.cache
|
||||
|
@ -30,7 +30,7 @@
|
||||
###############################################################################
|
||||
|
||||
|
||||
AC_PREREQ([2.61])
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT(OpenJDK, jdk8, build-dev@openjdk.java.net,,http://openjdk.java.net)
|
||||
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -83,7 +83,7 @@ apt_help() {
|
||||
pulse)
|
||||
PKGHANDLER_COMMAND="sudo apt-get install libpulse-dev" ;;
|
||||
x11)
|
||||
PKGHANDLER_COMMAND="sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev" ;;
|
||||
PKGHANDLER_COMMAND="sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev" ;;
|
||||
ccache)
|
||||
PKGHANDLER_COMMAND="sudo apt-get install ccache" ;;
|
||||
* )
|
||||
@ -102,11 +102,11 @@ yum_help() {
|
||||
cups)
|
||||
PKGHANDLER_COMMAND="sudo yum install cups-devel" ;;
|
||||
freetype2)
|
||||
PKGHANDLER_COMMAND="sudo yum install freetype2-devel" ;;
|
||||
PKGHANDLER_COMMAND="sudo yum install freetype-devel" ;;
|
||||
pulse)
|
||||
PKGHANDLER_COMMAND="sudo yum install pulseaudio-libs-devel" ;;
|
||||
x11)
|
||||
PKGHANDLER_COMMAND="sudo yum install libXtst-devel" ;;
|
||||
PKGHANDLER_COMMAND="sudo yum install libXtst-devel libXt-devel libXrender-devel" ;;
|
||||
ccache)
|
||||
PKGHANDLER_COMMAND="sudo yum install ccache" ;;
|
||||
* )
|
||||
|
@ -185,7 +185,7 @@ OLD_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $X_CFLAGS"
|
||||
|
||||
# Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
|
||||
AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h],
|
||||
AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
|
||||
[X11_A_OK=yes],
|
||||
[X11_A_OK=no; break],
|
||||
[ # include <X11/Xlib.h>
|
||||
@ -197,7 +197,7 @@ AC_LANG_POP(C)
|
||||
|
||||
if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then
|
||||
HELP_MSG_MISSING_DEPENDENCY([x11])
|
||||
AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h). $HELP_MSG])
|
||||
AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
|
||||
fi
|
||||
|
||||
AC_SUBST(X_CFLAGS)
|
||||
|
@ -60,6 +60,18 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
|
||||
VAR_CPU_BITS=64
|
||||
VAR_CPU_ENDIAN=big
|
||||
;;
|
||||
s390)
|
||||
VAR_CPU=s390
|
||||
VAR_CPU_ARCH=s390
|
||||
VAR_CPU_BITS=32
|
||||
VAR_CPU_ENDIAN=big
|
||||
;;
|
||||
s390x)
|
||||
VAR_CPU=s390x
|
||||
VAR_CPU_ARCH=s390
|
||||
VAR_CPU_BITS=64
|
||||
VAR_CPU_ENDIAN=big
|
||||
;;
|
||||
sparc)
|
||||
VAR_CPU=sparc
|
||||
VAR_CPU_ARCH=sparc
|
||||
|
@ -183,7 +183,7 @@ bootcycle-images-only: start-make
|
||||
test: images test-only
|
||||
test-only: start-make
|
||||
@$(call TargetEnter)
|
||||
@($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 -k MAKEFLAGS= JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_IMAGE_DIR) JPRT_JAVA_HOME=$(JDK_IMAGE_DIR) ALT_OUTPUTDIR=$(OUTPUT_ROOT) CONCURRENCY=$(JOBS) $(TEST)) || true
|
||||
@($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 -k MAKEFLAGS= JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_IMAGE_DIR) ALT_OUTPUTDIR=$(OUTPUT_ROOT) CONCURRENCY=$(JOBS) $(TEST)) || true
|
||||
@$(call TargetExit)
|
||||
|
||||
# Stores the tips for each repository. This file is be used when constructing the jdk image and can be
|
||||
@ -242,7 +242,7 @@ clean-test:
|
||||
|
||||
.PHONY: langtools corba jaxp jaxws hotspot jdk nashorn images overlay-images install test docs
|
||||
.PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only nashorn-only images-only overlay-images-only install-only test-only docs-only
|
||||
.PHONY: all clean dist-clean bootcycle-images start-make
|
||||
.PHONY: default all clean dist-clean bootcycle-images start-make
|
||||
.PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-nashorn clean-images clean-docs clean-test clean-overlay-images clean-bootcycle-build
|
||||
.PHONY: profiles profiles-only profiles-oscheck
|
||||
|
||||
|
@ -226,3 +226,5 @@ a013024b07475782f1fa8e196e950b34b4077663 jdk8-b101
|
||||
528c7e76eaeee022817ee085668459bc97cf5665 jdk8-b102
|
||||
49c4a777fdfd648d4c3fffc940fdb97a23108ca8 jdk8-b103
|
||||
d411c60a8c2fe8fdc572af907775e90f7eefd513 jdk8-b104
|
||||
4e38de7c767e34104fa147b5b346d9fe6b731279 jdk8-b105
|
||||
2e3a056c84a71eba78945c18b05397858ffd7ad0 jdk8-b106
|
||||
|
@ -371,3 +371,7 @@ c4697c1c448416108743b59118b4a2498b339d0c jdk8-b102
|
||||
580430d131ccd475e2f2ad4006531b8c4813d102 hs25-b46
|
||||
104743074675359cfbf7f4dcd9ab2a5974a16627 jdk8-b104
|
||||
c1604d5885a6f2adc0bcea2fa142a8f6bafad2f0 hs25-b47
|
||||
acac3bde66b2c22791c257a8d99611d6d08c6713 jdk8-b105
|
||||
18b4798adbc42c6fa16f5ecb7d5cd3ca130754bf hs25-b48
|
||||
aed585cafc0d9655726af6d1e1081d1c94cb3b5c jdk8-b106
|
||||
50794d8ac11c9579b41dec4de23b808fef9f34a1 hs25-b49
|
||||
|
@ -354,9 +354,16 @@ public class InstanceKlass extends Klass {
|
||||
public boolean getIsMarkedDependent() { return isMarkedDependent.getValue(this) != 0; }
|
||||
public long getVtableLen() { return vtableLen.getValue(this); }
|
||||
public long getItableLen() { return itableLen.getValue(this); }
|
||||
public Symbol getGenericSignature() { return getConstants().getSymbolAt(genericSignatureIndex.getValue(this)); }
|
||||
public long majorVersion() { return majorVersion.getValue(this); }
|
||||
public long minorVersion() { return minorVersion.getValue(this); }
|
||||
public Symbol getGenericSignature() {
|
||||
long index = genericSignatureIndex.getValue(this);
|
||||
if (index != 0) {
|
||||
return getConstants().getSymbolAt(index);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// "size helper" == instance size in words
|
||||
public long getSizeHelper() {
|
||||
|
@ -35,8 +35,9 @@ sapkg.c1 = sapkg.hotspot.c1;
|
||||
sapkg.code = sapkg.hotspot.code;
|
||||
sapkg.compiler = sapkg.hotspot.compiler;
|
||||
|
||||
// 'debugger' is a JavaScript keyword :-(
|
||||
// sapkg.debugger = sapkg.hotspot.debugger;
|
||||
// 'debugger' is a JavaScript keyword, but ES5 relaxes the
|
||||
// restriction of using keywords as property name
|
||||
sapkg.debugger = sapkg.hotspot.debugger;
|
||||
|
||||
sapkg.interpreter = sapkg.hotspot.interpreter;
|
||||
sapkg.jdi = sapkg.hotspot.jdi;
|
||||
@ -116,27 +117,36 @@ function main(globals, jvmarg) {
|
||||
return args;
|
||||
}
|
||||
|
||||
// Handle __has__ specially to avoid metacircularity problems
|
||||
// when called from __get__.
|
||||
// Calling
|
||||
// this.__has__(name)
|
||||
// will in turn call
|
||||
// this.__call__('__has__', name)
|
||||
// which is not handled below
|
||||
function __has__(name) {
|
||||
if (typeof(name) == 'number') {
|
||||
return so["has(int)"](name);
|
||||
} else {
|
||||
if (name == '__wrapped__') {
|
||||
return true;
|
||||
} else if (so["has(java.lang.String)"](name)) {
|
||||
return true;
|
||||
} else if (name.equals('toString')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (so instanceof sapkg.utilities.soql.ScriptObject) {
|
||||
return new JSAdapter() {
|
||||
__getIds__: function() {
|
||||
return so.getIds();
|
||||
__getIds__: function() {
|
||||
return so.getIds();
|
||||
},
|
||||
|
||||
__has__ : function(name) {
|
||||
if (typeof(name) == 'number') {
|
||||
return so["has(int)"](name);
|
||||
} else {
|
||||
if (name == '__wrapped__') {
|
||||
return true;
|
||||
} else if (so["has(java.lang.String)"](name)) {
|
||||
return true;
|
||||
} else if (name.equals('toString')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
__has__ : __has__,
|
||||
|
||||
__delete__ : function(name) {
|
||||
if (typeof(name) == 'number') {
|
||||
@ -147,7 +157,8 @@ function main(globals, jvmarg) {
|
||||
},
|
||||
|
||||
__get__ : function(name) {
|
||||
if (! this.__has__(name)) {
|
||||
// don't call this.__has__(name); see comments above function __has__
|
||||
if (! __has__.call(this, name)) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof(name) == 'number') {
|
||||
@ -162,7 +173,7 @@ function main(globals, jvmarg) {
|
||||
var args = prepareArgsArray(arguments);
|
||||
var r;
|
||||
try {
|
||||
r = value.call(args);
|
||||
r = value.call(Java.to(args, 'java.lang.Object[]'));
|
||||
} catch (e) {
|
||||
println("call to " + name + " failed!");
|
||||
throw e;
|
||||
@ -204,6 +215,18 @@ function main(globals, jvmarg) {
|
||||
}
|
||||
|
||||
// define "writeln" and "write" if not defined
|
||||
if (typeof(println) == 'undefined') {
|
||||
println = function (str) {
|
||||
java.lang.System.out.println(String(str));
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(print) == 'undefined') {
|
||||
print = function (str) {
|
||||
java.lang.System.out.print(String(str));
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(writeln) == 'undefined') {
|
||||
writeln = println;
|
||||
}
|
||||
@ -235,7 +258,7 @@ function main(globals, jvmarg) {
|
||||
|
||||
this.jclasses = function() {
|
||||
forEachKlass(function (clazz) {
|
||||
writeln(clazz.getName().asString() + " @" + clazz.getHandle().toString());
|
||||
writeln(clazz.getName().asString() + " @" + clazz.getAddress().toString());
|
||||
});
|
||||
}
|
||||
registerCommand("classes", "classes", "jclasses");
|
||||
@ -490,14 +513,14 @@ function systemLoader() {
|
||||
function forEachKlass(callback) {
|
||||
var VisitorClass = sapkg.memory.SystemDictionary.ClassVisitor;
|
||||
var visitor = new VisitorClass() { visit: callback };
|
||||
sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary$ClassVisitor)"](visitor);
|
||||
sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary.ClassVisitor)"](visitor);
|
||||
}
|
||||
|
||||
// iterate system dictionary for each 'Klass' and initiating loader
|
||||
function forEachKlassAndLoader(callback) {
|
||||
var VisitorClass = sapkg.memory.SystemDictionary.ClassAndLoaderVisitor;
|
||||
var visitor = new VisitorClass() { visit: callback };
|
||||
sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary$ClassAndLoaderVisitor)"](visitor);
|
||||
sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary.ClassAndLoaderVisitor)"](visitor);
|
||||
}
|
||||
|
||||
// iterate system dictionary for each primitive array klass
|
||||
@ -522,7 +545,12 @@ function obj2oop(obj) {
|
||||
|
||||
// iterates Java heap for each Oop
|
||||
function forEachOop(callback) {
|
||||
sa.objHeap.iterate(new sapkg.oops.HeapVisitor() { doObj: callback });
|
||||
function empty() { }
|
||||
sa.objHeap.iterate(new sapkg.oops.HeapVisitor() {
|
||||
prologue: empty,
|
||||
doObj: callback,
|
||||
epilogue: empty
|
||||
});
|
||||
}
|
||||
|
||||
// iterates Java heap for each Oop of given 'klass'.
|
||||
@ -536,8 +564,14 @@ function forEachOopOfKlass(callback, klass, includeSubtypes) {
|
||||
if (includeSubtypes == undefined) {
|
||||
includeSubtypes = true;
|
||||
}
|
||||
|
||||
function empty() { }
|
||||
sa.objHeap.iterateObjectsOfKlass(
|
||||
new sapkg.oops.HeapVisitor() { doObj: callback },
|
||||
new sapkg.oops.HeapVisitor() {
|
||||
prologue: empty,
|
||||
doObj: callback,
|
||||
epilogue: empty
|
||||
},
|
||||
klass, includeSubtypes);
|
||||
}
|
||||
|
||||
@ -746,9 +780,9 @@ while (tmp.itr.hasNext()) {
|
||||
// ignore;
|
||||
continue;
|
||||
} else {
|
||||
// some type names have ':'. replace to make it as a
|
||||
// some type names have ':', '<', '>', '*', ' '. replace to make it as a
|
||||
// JavaScript identifier
|
||||
tmp.name = tmp.name.replace(':', '_').replace('<', '_').replace('>', '_').replace('*', '_').replace(' ', '_');
|
||||
tmp.name = ("" + tmp.name).replace(/[:<>* ]/g, '_');
|
||||
eval("function read" + tmp.name + "(addr) {" +
|
||||
" return readVMType('" + tmp.name + "', addr);}");
|
||||
eval("function print" + tmp.name + "(addr) {" +
|
||||
|
@ -129,16 +129,21 @@ ifeq ($(USE_CLANG), true)
|
||||
|
||||
# We only use precompiled headers for the JVM build
|
||||
CFLAGS += $(VM_PCH_FLAG)
|
||||
|
||||
# There are some files which don't like precompiled headers
|
||||
# The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build.
|
||||
# But Clang doesn't support a precompiled header which was compiled with -O3
|
||||
# to be used in a compilation unit which uses '-O0'. We could also prepare an
|
||||
# extra '-O0' PCH file for the opt build and use it here, but it's probably
|
||||
# not worth the effort as long as only two files need this special handling.
|
||||
|
||||
# The following files are compiled at various optimization
|
||||
# levels due to optimization issues encountered at the
|
||||
# 'OPT_CFLAGS_DEFAULT' level. The Clang compiler issues a compile
|
||||
# time error if there is an optimization level specification
|
||||
# skew between the PCH file and the C++ file. Especially if the
|
||||
# PCH file is compiled at a higher optimization level than
|
||||
# the C++ file. One solution might be to prepare extra optimization
|
||||
# level specific PCH files for the opt build and use them here, but
|
||||
# it's probably not worth the effort as long as only a few files
|
||||
# need this special handling.
|
||||
PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH)
|
||||
PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH)
|
||||
PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH)
|
||||
PCH_FLAG/unsafe.o = $(PCH_FLAG/NO_PCH)
|
||||
|
||||
endif
|
||||
else # ($(USE_CLANG), true)
|
||||
@ -306,6 +311,7 @@ OPT_CFLAGS/NOOPT=-O0
|
||||
ifeq ($(USE_CLANG), true)
|
||||
ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1)
|
||||
OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
|
||||
OPT_CFLAGS/unsafe.o += -O1
|
||||
endif
|
||||
else
|
||||
# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
|
||||
|
@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013
|
||||
|
||||
HS_MAJOR_VER=25
|
||||
HS_MINOR_VER=0
|
||||
HS_BUILD_NUMBER=47
|
||||
HS_BUILD_NUMBER=49
|
||||
|
||||
JDK_MAJOR_VER=1
|
||||
JDK_MINOR_VER=8
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2003, 2013, 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
|
||||
@ -31,9 +31,4 @@ CFLAGS += -DVM_LITTLE_ENDIAN
|
||||
|
||||
CFLAGS += -D_LP64=1
|
||||
|
||||
# The serviceability agent relies on frame pointer (%rbp) to walk thread stack
|
||||
ifndef USE_SUNCC
|
||||
CFLAGS += -fno-omit-frame-pointer
|
||||
endif
|
||||
|
||||
OPT_CFLAGS/compactingPermGenGen.o = -O1
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 1999, 2013, 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
|
||||
@ -398,3 +398,10 @@ endif
|
||||
ifdef MINIMIZE_RAM_USAGE
|
||||
CFLAGS += -DMINIMIZE_RAM_USAGE
|
||||
endif
|
||||
|
||||
# Stack walking in the JVM relies on frame pointer (%rbp) to walk thread stack.
|
||||
# Explicitly specify -fno-omit-frame-pointer because it is off by default
|
||||
# starting with gcc 4.6.
|
||||
ifndef USE_SUNCC
|
||||
CFLAGS += -fno-omit-frame-pointer
|
||||
endif
|
||||
|
@ -42,8 +42,6 @@ else
|
||||
MKS_HOME=`dirname "$SH"`
|
||||
fi
|
||||
|
||||
echo "EXPORTS" > vm1.def
|
||||
|
||||
AWK="$MKS_HOME/awk.exe"
|
||||
if [ ! -e $AWK ]; then
|
||||
AWK="$MKS_HOME/gawk.exe"
|
||||
@ -55,6 +53,22 @@ CAT="$MKS_HOME/cat.exe"
|
||||
RM="$MKS_HOME/rm.exe"
|
||||
DUMPBIN="link.exe /dump"
|
||||
|
||||
if [ "$1" = "-nosa" ]; then
|
||||
echo EXPORTS > vm.def
|
||||
echo ""
|
||||
echo "***"
|
||||
echo "*** Not building SA: BUILD_WIN_SA != 1"
|
||||
echo "*** C++ Vtables NOT included in vm.def"
|
||||
echo "*** This jvm.dll will NOT work properly with SA."
|
||||
echo "***"
|
||||
echo "*** When in doubt, set BUILD_WIN_SA=1, clean and rebuild."
|
||||
echo "***"
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "EXPORTS" > vm1.def
|
||||
|
||||
# When called from IDE the first param should contain the link version, otherwise may be nill
|
||||
if [ "x$1" != "x" ]; then
|
||||
LD_VER="$1"
|
||||
|
@ -82,6 +82,7 @@ for /F %%i in ('sh %HotSpotWorkSpace%/make/windows/get_msc_ver.sh') do set %%i
|
||||
|
||||
echo **************************************************************
|
||||
set ProjectFile=%HotSpotBuildSpace%\jvm.vcproj
|
||||
echo MSC_VER = "%MSC_VER%"
|
||||
if "%MSC_VER%" == "1200" (
|
||||
set ProjectFile=%HotSpotBuildSpace%\jvm.dsp
|
||||
echo Will generate VC6 project {unsupported}
|
||||
@ -96,11 +97,17 @@ if "%MSC_VER%" == "1600" (
|
||||
echo Will generate VC10 {Visual Studio 2010}
|
||||
set ProjectFile=%HotSpotBuildSpace%\jvm.vcxproj
|
||||
) else (
|
||||
if "%MSC_VER%" == "1700" (
|
||||
echo Will generate VC10 {compatible with Visual Studio 2012}
|
||||
echo After opening in VS 2012, click "Update" when prompted.
|
||||
set ProjectFile=%HotSpotBuildSpace%\jvm.vcxproj
|
||||
) else (
|
||||
echo Will generate VC7 project {Visual Studio 2003 .NET}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
echo %ProjectFile%
|
||||
echo **************************************************************
|
||||
|
||||
|
@ -49,9 +49,6 @@ HS_BUILD_ID=$(HS_BUILD_VER)-debug
|
||||
# Force resources to be rebuilt every time
|
||||
$(Res_Files): FORCE
|
||||
|
||||
vm.def: $(Obj_Files)
|
||||
sh $(WorkSpace)/make/windows/build_vm_def.sh
|
||||
|
||||
$(AOUT): $(Res_Files) $(Obj_Files) vm.def
|
||||
$(LD) @<<
|
||||
$(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
|
||||
|
@ -48,9 +48,6 @@ HS_BUILD_ID=$(HS_BUILD_VER)-fastdebug
|
||||
# Force resources to be rebuilt every time
|
||||
$(Res_Files): FORCE
|
||||
|
||||
vm.def: $(Obj_Files)
|
||||
sh $(WorkSpace)/make/windows/build_vm_def.sh
|
||||
|
||||
$(AOUT): $(Res_Files) $(Obj_Files) vm.def
|
||||
$(LD) @<<
|
||||
$(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
|
||||
|
@ -51,9 +51,6 @@ HS_BUILD_ID=$(HS_BUILD_VER)
|
||||
# Force resources to be rebuilt every time
|
||||
$(Res_Files): FORCE
|
||||
|
||||
vm.def: $(Obj_Files)
|
||||
sh $(WorkSpace)/make/windows/build_vm_def.sh
|
||||
|
||||
$(AOUT): $(Res_Files) $(Obj_Files) vm.def
|
||||
$(LD) @<<
|
||||
$(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
|
||||
|
@ -92,6 +92,10 @@ ProjectCreatorIDEOptions = \
|
||||
-disablePch getThread_windows_$(Platform_arch).cpp \
|
||||
-disablePch_compiler2 opcodes.cpp
|
||||
|
||||
!if "$(BUILD_WIN_SA)" != "1"
|
||||
BUILD_VM_DEF_FLAG=-nosa
|
||||
!endif
|
||||
|
||||
# Common options for the IDE builds for c1, and c2
|
||||
ProjectCreatorIDEOptions=\
|
||||
$(ProjectCreatorIDEOptions) \
|
||||
@ -104,7 +108,7 @@ ProjectCreatorIDEOptions=\
|
||||
-jdkTargetRoot $(HOTSPOTJDKDIST) \
|
||||
-define ALIGN_STACK_FRAMES \
|
||||
-define VM_LITTLE_ENDIAN \
|
||||
-prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) set JAVA_HOME=$(HOTSPOTJDKDIST) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LD_VER)" \
|
||||
-prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) set JAVA_HOME=$(HOTSPOTJDKDIST) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(BUILD_VM_DEF_FLAG) $(LD_VER)" \
|
||||
-ignoreFile jsig.c \
|
||||
-ignoreFile jvmtiEnvRecommended.cpp \
|
||||
-ignoreFile jvmtiEnvStub.cpp \
|
||||
|
@ -69,6 +69,13 @@ VcVersion=VC9
|
||||
VcVersion=VC10
|
||||
ProjectFile=jvm.vcxproj
|
||||
|
||||
!elseif "$(MSC_VER)" == "1700"
|
||||
# This is VS2012, but it loads VS10 projects just fine (and will
|
||||
# upgrade them automatically to VS2012 format).
|
||||
|
||||
VcVersion=VC10
|
||||
ProjectFile=jvm.vcxproj
|
||||
|
||||
!else
|
||||
|
||||
VcVersion=VC7
|
||||
|
@ -393,3 +393,11 @@ default::
|
||||
_build_pch_file.obj:
|
||||
@echo #include "precompiled.hpp" > ../generated/_build_pch_file.cpp
|
||||
$(CXX) $(CXX_FLAGS) /Fp"vm.pch" /Yc"precompiled.hpp" /c ../generated/_build_pch_file.cpp
|
||||
|
||||
!if "$(BUILD_WIN_SA)" != "1"
|
||||
BUILD_VM_DEF_FLAG=-nosa
|
||||
!endif
|
||||
|
||||
vm.def: $(Obj_Files)
|
||||
sh $(WorkSpace)/make/windows/build_vm_def.sh $(BUILD_VM_DEF_FLAG)
|
||||
|
||||
|
@ -307,7 +307,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {
|
||||
assert(a_byte == *start++, "should be the same code");
|
||||
}
|
||||
#endif
|
||||
} else if (_id == load_mirror_id) {
|
||||
} else if (_id == load_mirror_id || _id == load_appendix_id) {
|
||||
// produce a copy of the load mirror instruction for use by the being initialized case
|
||||
#ifdef ASSERT
|
||||
address start = __ pc();
|
||||
@ -384,6 +384,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {
|
||||
case access_field_id: target = Runtime1::entry_for(Runtime1::access_field_patching_id); break;
|
||||
case load_klass_id: target = Runtime1::entry_for(Runtime1::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break;
|
||||
case load_mirror_id: target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break;
|
||||
case load_appendix_id: target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break;
|
||||
default: ShouldNotReachHere();
|
||||
}
|
||||
__ bind(call_patch);
|
||||
@ -397,7 +398,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {
|
||||
ce->add_call_info_here(_info);
|
||||
__ br(Assembler::always, false, Assembler::pt, _patch_site_entry);
|
||||
__ delayed()->nop();
|
||||
if (_id == load_klass_id || _id == load_mirror_id) {
|
||||
if (_id == load_klass_id || _id == load_mirror_id || _id == load_appendix_id) {
|
||||
CodeSection* cs = __ code_section();
|
||||
address pc = (address)_pc_start;
|
||||
RelocIterator iter(cs, pc, pc + 1);
|
||||
|
@ -520,7 +520,7 @@ void LIR_Assembler::jobject2reg(jobject o, Register reg) {
|
||||
void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo *info) {
|
||||
// Allocate a new index in table to hold the object once it's been patched
|
||||
int oop_index = __ oop_recorder()->allocate_oop_index(NULL);
|
||||
PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_mirror_id, oop_index);
|
||||
PatchingStub* patch = new PatchingStub(_masm, patching_id(info), oop_index);
|
||||
|
||||
AddressLiteral addrlit(NULL, oop_Relocation::spec(oop_index));
|
||||
assert(addrlit.rspec().type() == relocInfo::oop_type, "must be an oop reloc");
|
||||
|
@ -804,6 +804,12 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
|
||||
}
|
||||
break;
|
||||
|
||||
case load_appendix_patching_id:
|
||||
{ __ set_info("load_appendix_patching", dont_gc_arguments);
|
||||
oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching));
|
||||
}
|
||||
break;
|
||||
|
||||
case dtrace_object_alloc_id:
|
||||
{ // O0: object
|
||||
__ set_info("dtrace_object_alloc", dont_gc_arguments);
|
||||
|
@ -402,6 +402,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {
|
||||
case access_field_id: target = Runtime1::entry_for(Runtime1::access_field_patching_id); break;
|
||||
case load_klass_id: target = Runtime1::entry_for(Runtime1::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break;
|
||||
case load_mirror_id: target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break;
|
||||
case load_appendix_id: target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break;
|
||||
default: ShouldNotReachHere();
|
||||
}
|
||||
__ bind(call_patch);
|
||||
@ -419,7 +420,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {
|
||||
for (int j = __ offset() ; j < jmp_off + 5 ; j++ ) {
|
||||
__ nop();
|
||||
}
|
||||
if (_id == load_klass_id || _id == load_mirror_id) {
|
||||
if (_id == load_klass_id || _id == load_mirror_id || _id == load_appendix_id) {
|
||||
CodeSection* cs = __ code_section();
|
||||
RelocIterator iter(cs, (address)_pc_start, (address)(_pc_start + 1));
|
||||
relocInfo::change_reloc_info_for_address(&iter, (address) _pc_start, reloc_type, relocInfo::none);
|
||||
|
@ -362,7 +362,7 @@ int LIR_Assembler::check_icache() {
|
||||
|
||||
void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo* info) {
|
||||
jobject o = NULL;
|
||||
PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_mirror_id);
|
||||
PatchingStub* patch = new PatchingStub(_masm, patching_id(info));
|
||||
__ movoop(reg, o);
|
||||
patching_epilog(patch, lir_patch_normal, reg, info);
|
||||
}
|
||||
|
@ -1499,6 +1499,13 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
|
||||
}
|
||||
break;
|
||||
|
||||
case load_appendix_patching_id:
|
||||
{ StubFrame f(sasm, "load_appendix_patching", dont_gc_arguments);
|
||||
// we should set up register map
|
||||
oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching));
|
||||
}
|
||||
break;
|
||||
|
||||
case dtrace_object_alloc_id:
|
||||
{ // rax,: object
|
||||
StubFrame f(sasm, "dtrace_object_alloc", dont_gc_arguments);
|
||||
|
@ -642,13 +642,14 @@ objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NU
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
static uint64_t locate_unique_thread_id() {
|
||||
static uint64_t locate_unique_thread_id(mach_port_t mach_thread_port) {
|
||||
// Additional thread_id used to correlate threads in SA
|
||||
thread_identifier_info_data_t m_ident_info;
|
||||
mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
|
||||
|
||||
thread_info(::mach_thread_self(), THREAD_IDENTIFIER_INFO,
|
||||
thread_info(mach_thread_port, THREAD_IDENTIFIER_INFO,
|
||||
(thread_info_t) &m_ident_info, &count);
|
||||
|
||||
return m_ident_info.thread_id;
|
||||
}
|
||||
#endif
|
||||
@ -679,9 +680,14 @@ static void *java_start(Thread *thread) {
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// thread_id is mach thread on macos
|
||||
osthread->set_thread_id(::mach_thread_self());
|
||||
osthread->set_unique_thread_id(locate_unique_thread_id());
|
||||
// thread_id is mach thread on macos, which pthreads graciously caches and provides for us
|
||||
mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self());
|
||||
guarantee(thread_id != 0, "thread id missing from pthreads");
|
||||
osthread->set_thread_id(thread_id);
|
||||
|
||||
uint64_t unique_thread_id = locate_unique_thread_id(thread_id);
|
||||
guarantee(unique_thread_id != 0, "unique thread id was not found");
|
||||
osthread->set_unique_thread_id(unique_thread_id);
|
||||
#else
|
||||
// thread_id is pthread_id on BSD
|
||||
osthread->set_thread_id(::pthread_self());
|
||||
@ -843,8 +849,14 @@ bool os::create_attached_thread(JavaThread* thread) {
|
||||
|
||||
// Store pthread info into the OSThread
|
||||
#ifdef __APPLE__
|
||||
osthread->set_thread_id(::mach_thread_self());
|
||||
osthread->set_unique_thread_id(locate_unique_thread_id());
|
||||
// thread_id is mach thread on macos, which pthreads graciously caches and provides for us
|
||||
mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self());
|
||||
guarantee(thread_id != 0, "just checking");
|
||||
osthread->set_thread_id(thread_id);
|
||||
|
||||
uint64_t unique_thread_id = locate_unique_thread_id(thread_id);
|
||||
guarantee(unique_thread_id != 0, "just checking");
|
||||
osthread->set_unique_thread_id(unique_thread_id);
|
||||
#else
|
||||
osthread->set_thread_id(::pthread_self());
|
||||
#endif
|
||||
@ -1115,7 +1127,7 @@ size_t os::lasterror(char *buf, size_t len) {
|
||||
|
||||
intx os::current_thread_id() {
|
||||
#ifdef __APPLE__
|
||||
return (intx)::mach_thread_self();
|
||||
return (intx)::pthread_mach_thread_np(::pthread_self());
|
||||
#else
|
||||
return (intx)::pthread_self();
|
||||
#endif
|
||||
@ -2313,7 +2325,9 @@ void os::large_page_init() {
|
||||
}
|
||||
|
||||
|
||||
char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) {
|
||||
char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
||||
fatal("This code is not used or maintained.");
|
||||
|
||||
// "exec" is passed in but not used. Creating the shared image for
|
||||
// the code cache doesn't have an SHM_X executable permission to check.
|
||||
assert(UseLargePages && UseSHM, "only for SHM large pages");
|
||||
@ -3275,11 +3289,15 @@ void os::Bsd::install_signal_handlers() {
|
||||
// and if UserSignalHandler is installed all bets are off
|
||||
if (CheckJNICalls) {
|
||||
if (libjsig_is_loaded) {
|
||||
tty->print_cr("Info: libjsig is activated, all active signal checking is disabled");
|
||||
if (PrintJNIResolving) {
|
||||
tty->print_cr("Info: libjsig is activated, all active signal checking is disabled");
|
||||
}
|
||||
check_signals = false;
|
||||
}
|
||||
if (AllowUserSignalHandlers) {
|
||||
tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
|
||||
if (PrintJNIResolving) {
|
||||
tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
|
||||
}
|
||||
check_signals = false;
|
||||
}
|
||||
}
|
||||
@ -4736,3 +4754,8 @@ int os::get_core_path(char* buffer, size_t bufferSize) {
|
||||
return n;
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
void TestReserveMemorySpecial_test() {
|
||||
// No tests available for this platform
|
||||
}
|
||||
#endif
|
||||
|
@ -40,6 +40,9 @@
|
||||
product(bool, UseHugeTLBFS, false, \
|
||||
"Use MAP_HUGETLB for large pages") \
|
||||
\
|
||||
product(bool, UseTransparentHugePages, false, \
|
||||
"Use MADV_HUGEPAGE for large pages") \
|
||||
\
|
||||
product(bool, LoadExecStackDllInVMThread, true, \
|
||||
"Load DLLs with executable-stack attribute in the VM Thread") \
|
||||
\
|
||||
|
@ -2720,36 +2720,7 @@ void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec,
|
||||
|
||||
int os::Linux::commit_memory_impl(char* addr, size_t size,
|
||||
size_t alignment_hint, bool exec) {
|
||||
int err;
|
||||
if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
|
||||
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
|
||||
uintptr_t res =
|
||||
(uintptr_t) ::mmap(addr, size, prot,
|
||||
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_HUGETLB,
|
||||
-1, 0);
|
||||
if (res != (uintptr_t) MAP_FAILED) {
|
||||
if (UseNUMAInterleaving) {
|
||||
numa_make_global(addr, size);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = errno; // save errno from mmap() call above
|
||||
|
||||
if (!recoverable_mmap_error(err)) {
|
||||
// However, it is not clear that this loss of our reserved mapping
|
||||
// happens with large pages on Linux or that we cannot recover
|
||||
// from the loss. For now, we just issue a warning and we don't
|
||||
// call vm_exit_out_of_memory(). This issue is being tracked by
|
||||
// JBS-8007074.
|
||||
warn_fail_commit_memory(addr, size, alignment_hint, exec, err);
|
||||
// vm_exit_out_of_memory(size, OOM_MMAP_ERROR,
|
||||
// "committing reserved memory.");
|
||||
}
|
||||
// Fall through and try to use small pages
|
||||
}
|
||||
|
||||
err = os::Linux::commit_memory_impl(addr, size, exec);
|
||||
int err = os::Linux::commit_memory_impl(addr, size, exec);
|
||||
if (err == 0) {
|
||||
realign_memory(addr, size, alignment_hint);
|
||||
}
|
||||
@ -2774,7 +2745,7 @@ void os::pd_commit_memory_or_exit(char* addr, size_t size,
|
||||
}
|
||||
|
||||
void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
|
||||
if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
|
||||
if (UseTransparentHugePages && alignment_hint > (size_t)vm_page_size()) {
|
||||
// We don't check the return value: madvise(MADV_HUGEPAGE) may not
|
||||
// be supported or the memory may already be backed by huge pages.
|
||||
::madvise(addr, bytes, MADV_HUGEPAGE);
|
||||
@ -2787,7 +2758,7 @@ void os::pd_free_memory(char *addr, size_t bytes, size_t alignment_hint) {
|
||||
// uncommitted at all. We don't do anything in this case to avoid creating a segment with
|
||||
// small pages on top of the SHM segment. This method always works for small pages, so we
|
||||
// allow that in any case.
|
||||
if (alignment_hint <= (size_t)os::vm_page_size() || !UseSHM) {
|
||||
if (alignment_hint <= (size_t)os::vm_page_size() || can_commit_large_page_memory()) {
|
||||
commit_memory(addr, bytes, alignment_hint, !ExecMem);
|
||||
}
|
||||
}
|
||||
@ -2796,7 +2767,19 @@ void os::numa_make_global(char *addr, size_t bytes) {
|
||||
Linux::numa_interleave_memory(addr, bytes);
|
||||
}
|
||||
|
||||
// Define for numa_set_bind_policy(int). Setting the argument to 0 will set the
|
||||
// bind policy to MPOL_PREFERRED for the current thread.
|
||||
#define USE_MPOL_PREFERRED 0
|
||||
|
||||
void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) {
|
||||
// To make NUMA and large pages more robust when both enabled, we need to ease
|
||||
// the requirements on where the memory should be allocated. MPOL_BIND is the
|
||||
// default policy and it will force memory to be allocated on the specified
|
||||
// node. Changing this to MPOL_PREFERRED will prefer to allocate the memory on
|
||||
// the specified node, but will not force it. Using this policy will prevent
|
||||
// getting SIGBUS when trying to allocate large pages on NUMA nodes with no
|
||||
// free large pages.
|
||||
Linux::numa_set_bind_policy(USE_MPOL_PREFERRED);
|
||||
Linux::numa_tonode_memory(addr, bytes, lgrp_hint);
|
||||
}
|
||||
|
||||
@ -2898,6 +2881,8 @@ bool os::Linux::libnuma_init() {
|
||||
libnuma_dlsym(handle, "numa_tonode_memory")));
|
||||
set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t,
|
||||
libnuma_dlsym(handle, "numa_interleave_memory")));
|
||||
set_numa_set_bind_policy(CAST_TO_FN_PTR(numa_set_bind_policy_func_t,
|
||||
libnuma_dlsym(handle, "numa_set_bind_policy")));
|
||||
|
||||
|
||||
if (numa_available() != -1) {
|
||||
@ -2964,6 +2949,7 @@ os::Linux::numa_max_node_func_t os::Linux::_numa_max_node;
|
||||
os::Linux::numa_available_func_t os::Linux::_numa_available;
|
||||
os::Linux::numa_tonode_memory_func_t os::Linux::_numa_tonode_memory;
|
||||
os::Linux::numa_interleave_memory_func_t os::Linux::_numa_interleave_memory;
|
||||
os::Linux::numa_set_bind_policy_func_t os::Linux::_numa_set_bind_policy;
|
||||
unsigned long* os::Linux::_numa_all_nodes;
|
||||
|
||||
bool os::pd_uncommit_memory(char* addr, size_t size) {
|
||||
@ -2972,6 +2958,53 @@ bool os::pd_uncommit_memory(char* addr, size_t size) {
|
||||
return res != (uintptr_t) MAP_FAILED;
|
||||
}
|
||||
|
||||
static
|
||||
address get_stack_commited_bottom(address bottom, size_t size) {
|
||||
address nbot = bottom;
|
||||
address ntop = bottom + size;
|
||||
|
||||
size_t page_sz = os::vm_page_size();
|
||||
unsigned pages = size / page_sz;
|
||||
|
||||
unsigned char vec[1];
|
||||
unsigned imin = 1, imax = pages + 1, imid;
|
||||
int mincore_return_value;
|
||||
|
||||
while (imin < imax) {
|
||||
imid = (imax + imin) / 2;
|
||||
nbot = ntop - (imid * page_sz);
|
||||
|
||||
// Use a trick with mincore to check whether the page is mapped or not.
|
||||
// mincore sets vec to 1 if page resides in memory and to 0 if page
|
||||
// is swapped output but if page we are asking for is unmapped
|
||||
// it returns -1,ENOMEM
|
||||
mincore_return_value = mincore(nbot, page_sz, vec);
|
||||
|
||||
if (mincore_return_value == -1) {
|
||||
// Page is not mapped go up
|
||||
// to find first mapped page
|
||||
if (errno != EAGAIN) {
|
||||
assert(errno == ENOMEM, "Unexpected mincore errno");
|
||||
imax = imid;
|
||||
}
|
||||
} else {
|
||||
// Page is mapped go down
|
||||
// to find first not mapped page
|
||||
imin = imid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
nbot = nbot + page_sz;
|
||||
|
||||
// Adjust stack bottom one page up if last checked page is not mapped
|
||||
if (mincore_return_value == -1) {
|
||||
nbot = nbot + page_sz;
|
||||
}
|
||||
|
||||
return nbot;
|
||||
}
|
||||
|
||||
|
||||
// Linux uses a growable mapping for the stack, and if the mapping for
|
||||
// the stack guard pages is not removed when we detach a thread the
|
||||
// stack cannot grow beyond the pages where the stack guard was
|
||||
@ -2986,59 +3019,37 @@ bool os::pd_uncommit_memory(char* addr, size_t size) {
|
||||
// So, we need to know the extent of the stack mapping when
|
||||
// create_stack_guard_pages() is called.
|
||||
|
||||
// Find the bounds of the stack mapping. Return true for success.
|
||||
//
|
||||
// We only need this for stacks that are growable: at the time of
|
||||
// writing thread stacks don't use growable mappings (i.e. those
|
||||
// creeated with MAP_GROWSDOWN), and aren't marked "[stack]", so this
|
||||
// only applies to the main thread.
|
||||
|
||||
static
|
||||
bool get_stack_bounds(uintptr_t *bottom, uintptr_t *top) {
|
||||
|
||||
char buf[128];
|
||||
int fd, sz;
|
||||
|
||||
if ((fd = ::open("/proc/self/maps", O_RDONLY)) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char kw[] = "[stack]";
|
||||
const int kwlen = sizeof(kw)-1;
|
||||
|
||||
// Address part of /proc/self/maps couldn't be more than 128 bytes
|
||||
while ((sz = os::get_line_chars(fd, buf, sizeof(buf))) > 0) {
|
||||
if (sz > kwlen && ::memcmp(buf+sz-kwlen, kw, kwlen) == 0) {
|
||||
// Extract addresses
|
||||
if (sscanf(buf, "%" SCNxPTR "-%" SCNxPTR, bottom, top) == 2) {
|
||||
uintptr_t sp = (uintptr_t) __builtin_frame_address(0);
|
||||
if (sp >= *bottom && sp <= *top) {
|
||||
::close(fd);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// If the (growable) stack mapping already extends beyond the point
|
||||
// where we're going to put our guard pages, truncate the mapping at
|
||||
// that point by munmap()ping it. This ensures that when we later
|
||||
// munmap() the guard pages we don't leave a hole in the stack
|
||||
// mapping. This only affects the main/initial thread, but guard
|
||||
// against future OS changes
|
||||
// mapping. This only affects the main/initial thread
|
||||
|
||||
bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
|
||||
uintptr_t stack_extent, stack_base;
|
||||
bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true);
|
||||
if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
|
||||
assert(os::Linux::is_initial_thread(),
|
||||
"growable stack in non-initial thread");
|
||||
if (stack_extent < (uintptr_t)addr)
|
||||
::munmap((void*)stack_extent, (uintptr_t)addr - stack_extent);
|
||||
|
||||
if (os::Linux::is_initial_thread()) {
|
||||
// As we manually grow stack up to bottom inside create_attached_thread(),
|
||||
// it's likely that os::Linux::initial_thread_stack_bottom is mapped and
|
||||
// we don't need to do anything special.
|
||||
// Check it first, before calling heavy function.
|
||||
uintptr_t stack_extent = (uintptr_t) os::Linux::initial_thread_stack_bottom();
|
||||
unsigned char vec[1];
|
||||
|
||||
if (mincore((address)stack_extent, os::vm_page_size(), vec) == -1) {
|
||||
// Fallback to slow path on all errors, including EAGAIN
|
||||
stack_extent = (uintptr_t) get_stack_commited_bottom(
|
||||
os::Linux::initial_thread_stack_bottom(),
|
||||
(size_t)addr - stack_extent);
|
||||
}
|
||||
|
||||
if (stack_extent < (uintptr_t)addr) {
|
||||
::munmap((void*)stack_extent, (uintptr_t)(addr - stack_extent));
|
||||
}
|
||||
}
|
||||
|
||||
return os::commit_memory(addr, size, !ExecMem);
|
||||
@ -3047,13 +3058,13 @@ bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
|
||||
// If this is a growable mapping, remove the guard pages entirely by
|
||||
// munmap()ping them. If not, just call uncommit_memory(). This only
|
||||
// affects the main/initial thread, but guard against future OS changes
|
||||
// It's safe to always unmap guard pages for initial thread because we
|
||||
// always place it right after end of the mapped region
|
||||
|
||||
bool os::remove_stack_guard_pages(char* addr, size_t size) {
|
||||
uintptr_t stack_extent, stack_base;
|
||||
bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true);
|
||||
if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
|
||||
assert(os::Linux::is_initial_thread(),
|
||||
"growable stack in non-initial thread");
|
||||
|
||||
if (os::Linux::is_initial_thread()) {
|
||||
return ::munmap(addr, size) == 0;
|
||||
}
|
||||
|
||||
@ -3157,11 +3168,31 @@ bool os::unguard_memory(char* addr, size_t size) {
|
||||
return linux_mprotect(addr, size, PROT_READ|PROT_WRITE);
|
||||
}
|
||||
|
||||
bool os::Linux::transparent_huge_pages_sanity_check(bool warn, size_t page_size) {
|
||||
bool result = false;
|
||||
void *p = mmap(NULL, page_size * 2, PROT_READ|PROT_WRITE,
|
||||
MAP_ANONYMOUS|MAP_PRIVATE,
|
||||
-1, 0);
|
||||
if (p != MAP_FAILED) {
|
||||
void *aligned_p = align_ptr_up(p, page_size);
|
||||
|
||||
result = madvise(aligned_p, page_size, MADV_HUGEPAGE) == 0;
|
||||
|
||||
munmap(p, page_size * 2);
|
||||
}
|
||||
|
||||
if (warn && !result) {
|
||||
warning("TransparentHugePages is not supported by the operating system.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool os::Linux::hugetlbfs_sanity_check(bool warn, size_t page_size) {
|
||||
bool result = false;
|
||||
void *p = mmap (NULL, page_size, PROT_READ|PROT_WRITE,
|
||||
MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB,
|
||||
-1, 0);
|
||||
void *p = mmap(NULL, page_size, PROT_READ|PROT_WRITE,
|
||||
MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB,
|
||||
-1, 0);
|
||||
|
||||
if (p != MAP_FAILED) {
|
||||
// We don't know if this really is a huge page or not.
|
||||
@ -3182,12 +3213,10 @@ bool os::Linux::hugetlbfs_sanity_check(bool warn, size_t page_size) {
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
munmap (p, page_size);
|
||||
if (result)
|
||||
return true;
|
||||
munmap(p, page_size);
|
||||
}
|
||||
|
||||
if (warn) {
|
||||
if (warn && !result) {
|
||||
warning("HugeTLBFS is not supported by the operating system.");
|
||||
}
|
||||
|
||||
@ -3235,82 +3264,114 @@ static void set_coredump_filter(void) {
|
||||
|
||||
static size_t _large_page_size = 0;
|
||||
|
||||
void os::large_page_init() {
|
||||
if (!UseLargePages) {
|
||||
UseHugeTLBFS = false;
|
||||
UseSHM = false;
|
||||
return;
|
||||
}
|
||||
size_t os::Linux::find_large_page_size() {
|
||||
size_t large_page_size = 0;
|
||||
|
||||
if (FLAG_IS_DEFAULT(UseHugeTLBFS) && FLAG_IS_DEFAULT(UseSHM)) {
|
||||
// If UseLargePages is specified on the command line try both methods,
|
||||
// if it's default, then try only HugeTLBFS.
|
||||
if (FLAG_IS_DEFAULT(UseLargePages)) {
|
||||
UseHugeTLBFS = true;
|
||||
} else {
|
||||
UseHugeTLBFS = UseSHM = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (LargePageSizeInBytes) {
|
||||
_large_page_size = LargePageSizeInBytes;
|
||||
} else {
|
||||
// large_page_size on Linux is used to round up heap size. x86 uses either
|
||||
// 2M or 4M page, depending on whether PAE (Physical Address Extensions)
|
||||
// mode is enabled. AMD64/EM64T uses 2M page in 64bit mode. IA64 can use
|
||||
// page as large as 256M.
|
||||
//
|
||||
// Here we try to figure out page size by parsing /proc/meminfo and looking
|
||||
// for a line with the following format:
|
||||
// Hugepagesize: 2048 kB
|
||||
//
|
||||
// If we can't determine the value (e.g. /proc is not mounted, or the text
|
||||
// format has been changed), we'll use the largest page size supported by
|
||||
// the processor.
|
||||
// large_page_size on Linux is used to round up heap size. x86 uses either
|
||||
// 2M or 4M page, depending on whether PAE (Physical Address Extensions)
|
||||
// mode is enabled. AMD64/EM64T uses 2M page in 64bit mode. IA64 can use
|
||||
// page as large as 256M.
|
||||
//
|
||||
// Here we try to figure out page size by parsing /proc/meminfo and looking
|
||||
// for a line with the following format:
|
||||
// Hugepagesize: 2048 kB
|
||||
//
|
||||
// If we can't determine the value (e.g. /proc is not mounted, or the text
|
||||
// format has been changed), we'll use the largest page size supported by
|
||||
// the processor.
|
||||
|
||||
#ifndef ZERO
|
||||
_large_page_size = IA32_ONLY(4 * M) AMD64_ONLY(2 * M) IA64_ONLY(256 * M) SPARC_ONLY(4 * M)
|
||||
ARM_ONLY(2 * M) PPC_ONLY(4 * M);
|
||||
large_page_size = IA32_ONLY(4 * M) AMD64_ONLY(2 * M) IA64_ONLY(256 * M) SPARC_ONLY(4 * M)
|
||||
ARM_ONLY(2 * M) PPC_ONLY(4 * M);
|
||||
#endif // ZERO
|
||||
|
||||
FILE *fp = fopen("/proc/meminfo", "r");
|
||||
if (fp) {
|
||||
while (!feof(fp)) {
|
||||
int x = 0;
|
||||
char buf[16];
|
||||
if (fscanf(fp, "Hugepagesize: %d", &x) == 1) {
|
||||
if (x && fgets(buf, sizeof(buf), fp) && strcmp(buf, " kB\n") == 0) {
|
||||
_large_page_size = x * K;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// skip to next line
|
||||
for (;;) {
|
||||
int ch = fgetc(fp);
|
||||
if (ch == EOF || ch == (int)'\n') break;
|
||||
}
|
||||
FILE *fp = fopen("/proc/meminfo", "r");
|
||||
if (fp) {
|
||||
while (!feof(fp)) {
|
||||
int x = 0;
|
||||
char buf[16];
|
||||
if (fscanf(fp, "Hugepagesize: %d", &x) == 1) {
|
||||
if (x && fgets(buf, sizeof(buf), fp) && strcmp(buf, " kB\n") == 0) {
|
||||
large_page_size = x * K;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// skip to next line
|
||||
for (;;) {
|
||||
int ch = fgetc(fp);
|
||||
if (ch == EOF || ch == (int)'\n') break;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
// print a warning if any large page related flag is specified on command line
|
||||
bool warn_on_failure = !FLAG_IS_DEFAULT(UseHugeTLBFS);
|
||||
if (!FLAG_IS_DEFAULT(LargePageSizeInBytes) && LargePageSizeInBytes != large_page_size) {
|
||||
warning("Setting LargePageSizeInBytes has no effect on this OS. Large page size is "
|
||||
SIZE_FORMAT "%s.", byte_size_in_proper_unit(large_page_size),
|
||||
proper_unit_for_byte_size(large_page_size));
|
||||
}
|
||||
|
||||
return large_page_size;
|
||||
}
|
||||
|
||||
size_t os::Linux::setup_large_page_size() {
|
||||
_large_page_size = Linux::find_large_page_size();
|
||||
const size_t default_page_size = (size_t)Linux::page_size();
|
||||
if (_large_page_size > default_page_size) {
|
||||
_page_sizes[0] = _large_page_size;
|
||||
_page_sizes[1] = default_page_size;
|
||||
_page_sizes[2] = 0;
|
||||
}
|
||||
UseHugeTLBFS = UseHugeTLBFS &&
|
||||
Linux::hugetlbfs_sanity_check(warn_on_failure, _large_page_size);
|
||||
|
||||
if (UseHugeTLBFS)
|
||||
return _large_page_size;
|
||||
}
|
||||
|
||||
bool os::Linux::setup_large_page_type(size_t page_size) {
|
||||
if (FLAG_IS_DEFAULT(UseHugeTLBFS) &&
|
||||
FLAG_IS_DEFAULT(UseSHM) &&
|
||||
FLAG_IS_DEFAULT(UseTransparentHugePages)) {
|
||||
// If UseLargePages is specified on the command line try all methods,
|
||||
// if it's default, then try only UseTransparentHugePages.
|
||||
if (FLAG_IS_DEFAULT(UseLargePages)) {
|
||||
UseTransparentHugePages = true;
|
||||
} else {
|
||||
UseHugeTLBFS = UseTransparentHugePages = UseSHM = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (UseTransparentHugePages) {
|
||||
bool warn_on_failure = !FLAG_IS_DEFAULT(UseTransparentHugePages);
|
||||
if (transparent_huge_pages_sanity_check(warn_on_failure, page_size)) {
|
||||
UseHugeTLBFS = false;
|
||||
UseSHM = false;
|
||||
return true;
|
||||
}
|
||||
UseTransparentHugePages = false;
|
||||
}
|
||||
|
||||
if (UseHugeTLBFS) {
|
||||
bool warn_on_failure = !FLAG_IS_DEFAULT(UseHugeTLBFS);
|
||||
if (hugetlbfs_sanity_check(warn_on_failure, page_size)) {
|
||||
UseSHM = false;
|
||||
return true;
|
||||
}
|
||||
UseHugeTLBFS = false;
|
||||
}
|
||||
|
||||
return UseSHM;
|
||||
}
|
||||
|
||||
void os::large_page_init() {
|
||||
if (!UseLargePages) {
|
||||
UseHugeTLBFS = false;
|
||||
UseTransparentHugePages = false;
|
||||
UseSHM = false;
|
||||
return;
|
||||
}
|
||||
|
||||
UseLargePages = UseHugeTLBFS || UseSHM;
|
||||
size_t large_page_size = Linux::setup_large_page_size();
|
||||
UseLargePages = Linux::setup_large_page_type(large_page_size);
|
||||
|
||||
set_coredump_filter();
|
||||
}
|
||||
@ -3319,16 +3380,22 @@ void os::large_page_init() {
|
||||
#define SHM_HUGETLB 04000
|
||||
#endif
|
||||
|
||||
char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) {
|
||||
char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
||||
// "exec" is passed in but not used. Creating the shared image for
|
||||
// the code cache doesn't have an SHM_X executable permission to check.
|
||||
assert(UseLargePages && UseSHM, "only for SHM large pages");
|
||||
assert(is_ptr_aligned(req_addr, os::large_page_size()), "Unaligned address");
|
||||
|
||||
if (!is_size_aligned(bytes, os::large_page_size()) || alignment > os::large_page_size()) {
|
||||
return NULL; // Fallback to small pages.
|
||||
}
|
||||
|
||||
key_t key = IPC_PRIVATE;
|
||||
char *addr;
|
||||
|
||||
bool warn_on_failure = UseLargePages &&
|
||||
(!FLAG_IS_DEFAULT(UseLargePages) ||
|
||||
!FLAG_IS_DEFAULT(UseSHM) ||
|
||||
!FLAG_IS_DEFAULT(LargePageSizeInBytes)
|
||||
);
|
||||
char msg[128];
|
||||
@ -3376,42 +3443,219 @@ char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((addr != NULL) && UseNUMAInterleaving) {
|
||||
numa_make_global(addr, bytes);
|
||||
return addr;
|
||||
}
|
||||
|
||||
static void warn_on_large_pages_failure(char* req_addr, size_t bytes, int error) {
|
||||
assert(error == ENOMEM, "Only expect to fail if no memory is available");
|
||||
|
||||
bool warn_on_failure = UseLargePages &&
|
||||
(!FLAG_IS_DEFAULT(UseLargePages) ||
|
||||
!FLAG_IS_DEFAULT(UseHugeTLBFS) ||
|
||||
!FLAG_IS_DEFAULT(LargePageSizeInBytes));
|
||||
|
||||
if (warn_on_failure) {
|
||||
char msg[128];
|
||||
jio_snprintf(msg, sizeof(msg), "Failed to reserve large pages memory req_addr: "
|
||||
PTR_FORMAT " bytes: " SIZE_FORMAT " (errno = %d).", req_addr, bytes, error);
|
||||
warning(msg);
|
||||
}
|
||||
}
|
||||
|
||||
char* os::Linux::reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec) {
|
||||
assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages");
|
||||
assert(is_size_aligned(bytes, os::large_page_size()), "Unaligned size");
|
||||
assert(is_ptr_aligned(req_addr, os::large_page_size()), "Unaligned address");
|
||||
|
||||
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
|
||||
char* addr = (char*)::mmap(req_addr, bytes, prot,
|
||||
MAP_PRIVATE|MAP_ANONYMOUS|MAP_HUGETLB,
|
||||
-1, 0);
|
||||
|
||||
if (addr == MAP_FAILED) {
|
||||
warn_on_large_pages_failure(req_addr, bytes, errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// The memory is committed
|
||||
MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, mtNone, CALLER_PC);
|
||||
assert(is_ptr_aligned(addr, os::large_page_size()), "Must be");
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
char* os::Linux::reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
||||
size_t large_page_size = os::large_page_size();
|
||||
|
||||
assert(bytes >= large_page_size, "Shouldn't allocate large pages for small sizes");
|
||||
|
||||
// Allocate small pages.
|
||||
|
||||
char* start;
|
||||
if (req_addr != NULL) {
|
||||
assert(is_ptr_aligned(req_addr, alignment), "Must be");
|
||||
assert(is_size_aligned(bytes, alignment), "Must be");
|
||||
start = os::reserve_memory(bytes, req_addr);
|
||||
assert(start == NULL || start == req_addr, "Must be");
|
||||
} else {
|
||||
start = os::reserve_memory_aligned(bytes, alignment);
|
||||
}
|
||||
|
||||
if (start == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assert(is_ptr_aligned(start, alignment), "Must be");
|
||||
|
||||
// os::reserve_memory_special will record this memory area.
|
||||
// Need to release it here to prevent overlapping reservations.
|
||||
MemTracker::record_virtual_memory_release((address)start, bytes);
|
||||
|
||||
char* end = start + bytes;
|
||||
|
||||
// Find the regions of the allocated chunk that can be promoted to large pages.
|
||||
char* lp_start = (char*)align_ptr_up(start, large_page_size);
|
||||
char* lp_end = (char*)align_ptr_down(end, large_page_size);
|
||||
|
||||
size_t lp_bytes = lp_end - lp_start;
|
||||
|
||||
assert(is_size_aligned(lp_bytes, large_page_size), "Must be");
|
||||
|
||||
if (lp_bytes == 0) {
|
||||
// The mapped region doesn't even span the start and the end of a large page.
|
||||
// Fall back to allocate a non-special area.
|
||||
::munmap(start, end - start);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
|
||||
|
||||
|
||||
void* result;
|
||||
|
||||
if (start != lp_start) {
|
||||
result = ::mmap(start, lp_start - start, prot,
|
||||
MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,
|
||||
-1, 0);
|
||||
if (result == MAP_FAILED) {
|
||||
::munmap(lp_start, end - lp_start);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
result = ::mmap(lp_start, lp_bytes, prot,
|
||||
MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED|MAP_HUGETLB,
|
||||
-1, 0);
|
||||
if (result == MAP_FAILED) {
|
||||
warn_on_large_pages_failure(req_addr, bytes, errno);
|
||||
// If the mmap above fails, the large pages region will be unmapped and we
|
||||
// have regions before and after with small pages. Release these regions.
|
||||
//
|
||||
// | mapped | unmapped | mapped |
|
||||
// ^ ^ ^ ^
|
||||
// start lp_start lp_end end
|
||||
//
|
||||
::munmap(start, lp_start - start);
|
||||
::munmap(lp_end, end - lp_end);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (lp_end != end) {
|
||||
result = ::mmap(lp_end, end - lp_end, prot,
|
||||
MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,
|
||||
-1, 0);
|
||||
if (result == MAP_FAILED) {
|
||||
::munmap(start, lp_end - start);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
char* os::Linux::reserve_memory_special_huge_tlbfs(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
||||
assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages");
|
||||
assert(is_ptr_aligned(req_addr, alignment), "Must be");
|
||||
assert(is_power_of_2(alignment), "Must be");
|
||||
assert(is_power_of_2(os::large_page_size()), "Must be");
|
||||
assert(bytes >= os::large_page_size(), "Shouldn't allocate large pages for small sizes");
|
||||
|
||||
if (is_size_aligned(bytes, os::large_page_size()) && alignment <= os::large_page_size()) {
|
||||
return reserve_memory_special_huge_tlbfs_only(bytes, req_addr, exec);
|
||||
} else {
|
||||
return reserve_memory_special_huge_tlbfs_mixed(bytes, alignment, req_addr, exec);
|
||||
}
|
||||
}
|
||||
|
||||
char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
||||
assert(UseLargePages, "only for large pages");
|
||||
|
||||
char* addr;
|
||||
if (UseSHM) {
|
||||
addr = os::Linux::reserve_memory_special_shm(bytes, alignment, req_addr, exec);
|
||||
} else {
|
||||
assert(UseHugeTLBFS, "must be");
|
||||
addr = os::Linux::reserve_memory_special_huge_tlbfs(bytes, alignment, req_addr, exec);
|
||||
}
|
||||
|
||||
if (addr != NULL) {
|
||||
if (UseNUMAInterleaving) {
|
||||
numa_make_global(addr, bytes);
|
||||
}
|
||||
|
||||
// The memory is committed
|
||||
MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, mtNone, CALLER_PC);
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
bool os::Linux::release_memory_special_shm(char* base, size_t bytes) {
|
||||
// detaching the SHM segment will also delete it, see reserve_memory_special_shm()
|
||||
return shmdt(base) == 0;
|
||||
}
|
||||
|
||||
bool os::Linux::release_memory_special_huge_tlbfs(char* base, size_t bytes) {
|
||||
return pd_release_memory(base, bytes);
|
||||
}
|
||||
|
||||
bool os::release_memory_special(char* base, size_t bytes) {
|
||||
assert(UseLargePages, "only for large pages");
|
||||
|
||||
MemTracker::Tracker tkr = MemTracker::get_virtual_memory_release_tracker();
|
||||
// detaching the SHM segment will also delete it, see reserve_memory_special()
|
||||
int rslt = shmdt(base);
|
||||
if (rslt == 0) {
|
||||
|
||||
bool res;
|
||||
if (UseSHM) {
|
||||
res = os::Linux::release_memory_special_shm(base, bytes);
|
||||
} else {
|
||||
assert(UseHugeTLBFS, "must be");
|
||||
res = os::Linux::release_memory_special_huge_tlbfs(base, bytes);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
tkr.record((address)base, bytes);
|
||||
return true;
|
||||
} else {
|
||||
tkr.discard();
|
||||
return false;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
size_t os::large_page_size() {
|
||||
return _large_page_size;
|
||||
}
|
||||
|
||||
// HugeTLBFS allows application to commit large page memory on demand;
|
||||
// with SysV SHM the entire memory region must be allocated as shared
|
||||
// With SysV SHM the entire memory region must be allocated as shared
|
||||
// memory.
|
||||
// HugeTLBFS allows application to commit large page memory on demand.
|
||||
// However, when committing memory with HugeTLBFS fails, the region
|
||||
// that was supposed to be committed will lose the old reservation
|
||||
// and allow other threads to steal that memory region. Because of this
|
||||
// behavior we can't commit HugeTLBFS memory.
|
||||
bool os::can_commit_large_page_memory() {
|
||||
return UseHugeTLBFS;
|
||||
return UseTransparentHugePages;
|
||||
}
|
||||
|
||||
bool os::can_execute_large_page_memory() {
|
||||
return UseHugeTLBFS;
|
||||
return UseTransparentHugePages || UseHugeTLBFS;
|
||||
}
|
||||
|
||||
// Reserve memory at an arbitrary address, only if that area is
|
||||
@ -4563,21 +4807,23 @@ jint os::init_2(void)
|
||||
UseNUMA = false;
|
||||
}
|
||||
}
|
||||
// With SHM large pages we cannot uncommit a page, so there's not way
|
||||
// With SHM and HugeTLBFS large pages we cannot uncommit a page, so there's no way
|
||||
// we can make the adaptive lgrp chunk resizing work. If the user specified
|
||||
// both UseNUMA and UseLargePages (or UseSHM) on the command line - warn and
|
||||
// both UseNUMA and UseLargePages (or UseSHM/UseHugeTLBFS) on the command line - warn and
|
||||
// disable adaptive resizing.
|
||||
if (UseNUMA && UseLargePages && UseSHM) {
|
||||
if (!FLAG_IS_DEFAULT(UseNUMA)) {
|
||||
if (FLAG_IS_DEFAULT(UseLargePages) && FLAG_IS_DEFAULT(UseSHM)) {
|
||||
if (UseNUMA && UseLargePages && !can_commit_large_page_memory()) {
|
||||
if (FLAG_IS_DEFAULT(UseNUMA)) {
|
||||
UseNUMA = false;
|
||||
} else {
|
||||
if (FLAG_IS_DEFAULT(UseLargePages) &&
|
||||
FLAG_IS_DEFAULT(UseSHM) &&
|
||||
FLAG_IS_DEFAULT(UseHugeTLBFS)) {
|
||||
UseLargePages = false;
|
||||
} else {
|
||||
warning("UseNUMA is not fully compatible with SHM large pages, disabling adaptive resizing");
|
||||
warning("UseNUMA is not fully compatible with SHM/HugeTLBFS large pages, disabling adaptive resizing");
|
||||
UseAdaptiveSizePolicy = false;
|
||||
UseAdaptiveNUMAChunkSizing = false;
|
||||
}
|
||||
} else {
|
||||
UseNUMA = false;
|
||||
}
|
||||
}
|
||||
if (!UseNUMA && ForceNUMA) {
|
||||
@ -5848,3 +6094,149 @@ void MemNotifyThread::start() {
|
||||
}
|
||||
|
||||
#endif // JAVASE_EMBEDDED
|
||||
|
||||
|
||||
/////////////// Unit tests ///////////////
|
||||
|
||||
#ifndef PRODUCT
|
||||
|
||||
#define test_log(...) \
|
||||
do {\
|
||||
if (VerboseInternalVMTests) { \
|
||||
tty->print_cr(__VA_ARGS__); \
|
||||
tty->flush(); \
|
||||
}\
|
||||
} while (false)
|
||||
|
||||
class TestReserveMemorySpecial : AllStatic {
|
||||
public:
|
||||
static void small_page_write(void* addr, size_t size) {
|
||||
size_t page_size = os::vm_page_size();
|
||||
|
||||
char* end = (char*)addr + size;
|
||||
for (char* p = (char*)addr; p < end; p += page_size) {
|
||||
*p = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_reserve_memory_special_huge_tlbfs_only(size_t size) {
|
||||
if (!UseHugeTLBFS) {
|
||||
return;
|
||||
}
|
||||
|
||||
test_log("test_reserve_memory_special_huge_tlbfs_only(" SIZE_FORMAT ")", size);
|
||||
|
||||
char* addr = os::Linux::reserve_memory_special_huge_tlbfs_only(size, NULL, false);
|
||||
|
||||
if (addr != NULL) {
|
||||
small_page_write(addr, size);
|
||||
|
||||
os::Linux::release_memory_special_huge_tlbfs(addr, size);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_reserve_memory_special_huge_tlbfs_only() {
|
||||
if (!UseHugeTLBFS) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t lp = os::large_page_size();
|
||||
|
||||
for (size_t size = lp; size <= lp * 10; size += lp) {
|
||||
test_reserve_memory_special_huge_tlbfs_only(size);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_reserve_memory_special_huge_tlbfs_mixed(size_t size, size_t alignment) {
|
||||
if (!UseHugeTLBFS) {
|
||||
return;
|
||||
}
|
||||
|
||||
test_log("test_reserve_memory_special_huge_tlbfs_mixed(" SIZE_FORMAT ", " SIZE_FORMAT ")",
|
||||
size, alignment);
|
||||
|
||||
assert(size >= os::large_page_size(), "Incorrect input to test");
|
||||
|
||||
char* addr = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, NULL, false);
|
||||
|
||||
if (addr != NULL) {
|
||||
small_page_write(addr, size);
|
||||
|
||||
os::Linux::release_memory_special_huge_tlbfs(addr, size);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(size_t size) {
|
||||
size_t lp = os::large_page_size();
|
||||
size_t ag = os::vm_allocation_granularity();
|
||||
|
||||
for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) {
|
||||
test_reserve_memory_special_huge_tlbfs_mixed(size, alignment);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_reserve_memory_special_huge_tlbfs_mixed() {
|
||||
size_t lp = os::large_page_size();
|
||||
size_t ag = os::vm_allocation_granularity();
|
||||
|
||||
test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp);
|
||||
test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp + ag);
|
||||
test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp + lp / 2);
|
||||
test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2);
|
||||
test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 + ag);
|
||||
test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 - ag);
|
||||
test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 + lp / 2);
|
||||
test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 10);
|
||||
test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 10 + lp / 2);
|
||||
}
|
||||
|
||||
static void test_reserve_memory_special_huge_tlbfs() {
|
||||
if (!UseHugeTLBFS) {
|
||||
return;
|
||||
}
|
||||
|
||||
test_reserve_memory_special_huge_tlbfs_only();
|
||||
test_reserve_memory_special_huge_tlbfs_mixed();
|
||||
}
|
||||
|
||||
static void test_reserve_memory_special_shm(size_t size, size_t alignment) {
|
||||
if (!UseSHM) {
|
||||
return;
|
||||
}
|
||||
|
||||
test_log("test_reserve_memory_special_shm(" SIZE_FORMAT ", " SIZE_FORMAT ")", size, alignment);
|
||||
|
||||
char* addr = os::Linux::reserve_memory_special_shm(size, alignment, NULL, false);
|
||||
|
||||
if (addr != NULL) {
|
||||
assert(is_ptr_aligned(addr, alignment), "Check");
|
||||
assert(is_ptr_aligned(addr, os::large_page_size()), "Check");
|
||||
|
||||
small_page_write(addr, size);
|
||||
|
||||
os::Linux::release_memory_special_shm(addr, size);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_reserve_memory_special_shm() {
|
||||
size_t lp = os::large_page_size();
|
||||
size_t ag = os::vm_allocation_granularity();
|
||||
|
||||
for (size_t size = ag; size < lp * 3; size += ag) {
|
||||
for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) {
|
||||
test_reserve_memory_special_shm(size, alignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test() {
|
||||
test_reserve_memory_special_huge_tlbfs();
|
||||
test_reserve_memory_special_shm();
|
||||
}
|
||||
};
|
||||
|
||||
void TestReserveMemorySpecial_test() {
|
||||
TestReserveMemorySpecial::test();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -32,6 +32,7 @@ typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *);
|
||||
|
||||
class Linux {
|
||||
friend class os;
|
||||
friend class TestReserveMemorySpecial;
|
||||
|
||||
// For signal-chaining
|
||||
#define MAXSIGNUM 32
|
||||
@ -92,8 +93,21 @@ class Linux {
|
||||
static void rebuild_cpu_to_node_map();
|
||||
static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
|
||||
|
||||
static size_t find_large_page_size();
|
||||
static size_t setup_large_page_size();
|
||||
|
||||
static bool setup_large_page_type(size_t page_size);
|
||||
static bool transparent_huge_pages_sanity_check(bool warn, size_t pages_size);
|
||||
static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
|
||||
|
||||
static char* reserve_memory_special_shm(size_t bytes, size_t alignment, char* req_addr, bool exec);
|
||||
static char* reserve_memory_special_huge_tlbfs(size_t bytes, size_t alignment, char* req_addr, bool exec);
|
||||
static char* reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec);
|
||||
static char* reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec);
|
||||
|
||||
static bool release_memory_special_shm(char* base, size_t bytes);
|
||||
static bool release_memory_special_huge_tlbfs(char* base, size_t bytes);
|
||||
|
||||
static void print_full_memory_info(outputStream* st);
|
||||
static void print_distro_info(outputStream* st);
|
||||
static void print_libversion_info(outputStream* st);
|
||||
@ -221,6 +235,7 @@ private:
|
||||
typedef int (*numa_available_func_t)(void);
|
||||
typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
|
||||
typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
|
||||
typedef void (*numa_set_bind_policy_func_t)(int policy);
|
||||
|
||||
static sched_getcpu_func_t _sched_getcpu;
|
||||
static numa_node_to_cpus_func_t _numa_node_to_cpus;
|
||||
@ -228,6 +243,7 @@ private:
|
||||
static numa_available_func_t _numa_available;
|
||||
static numa_tonode_memory_func_t _numa_tonode_memory;
|
||||
static numa_interleave_memory_func_t _numa_interleave_memory;
|
||||
static numa_set_bind_policy_func_t _numa_set_bind_policy;
|
||||
static unsigned long* _numa_all_nodes;
|
||||
|
||||
static void set_sched_getcpu(sched_getcpu_func_t func) { _sched_getcpu = func; }
|
||||
@ -236,6 +252,7 @@ private:
|
||||
static void set_numa_available(numa_available_func_t func) { _numa_available = func; }
|
||||
static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
|
||||
static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
|
||||
static void set_numa_set_bind_policy(numa_set_bind_policy_func_t func) { _numa_set_bind_policy = func; }
|
||||
static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
|
||||
static int sched_getcpu_syscall(void);
|
||||
public:
|
||||
@ -253,6 +270,11 @@ public:
|
||||
_numa_interleave_memory(start, size, _numa_all_nodes);
|
||||
}
|
||||
}
|
||||
static void numa_set_bind_policy(int policy) {
|
||||
if (_numa_set_bind_policy != NULL) {
|
||||
_numa_set_bind_policy(policy);
|
||||
}
|
||||
}
|
||||
static int get_node_by_cpu(int cpu_id);
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2013, 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
|
||||
@ -30,6 +30,8 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
// Check core dump limit and report possible place where core can be found
|
||||
@ -260,6 +262,55 @@ FILE* os::open(int fd, const char* mode) {
|
||||
return ::fdopen(fd, mode);
|
||||
}
|
||||
|
||||
void* os::get_default_process_handle() {
|
||||
return (void*)::dlopen(NULL, RTLD_LAZY);
|
||||
}
|
||||
|
||||
// Builds a platform dependent Agent_OnLoad_<lib_name> function name
|
||||
// which is used to find statically linked in agents.
|
||||
// Parameters:
|
||||
// sym_name: Symbol in library we are looking for
|
||||
// lib_name: Name of library to look in, NULL for shared libs.
|
||||
// is_absolute_path == true if lib_name is absolute path to agent
|
||||
// such as "/a/b/libL.so"
|
||||
// == false if only the base name of the library is passed in
|
||||
// such as "L"
|
||||
char* os::build_agent_function_name(const char *sym_name, const char *lib_name,
|
||||
bool is_absolute_path) {
|
||||
char *agent_entry_name;
|
||||
size_t len;
|
||||
size_t name_len;
|
||||
size_t prefix_len = strlen(JNI_LIB_PREFIX);
|
||||
size_t suffix_len = strlen(JNI_LIB_SUFFIX);
|
||||
const char *start;
|
||||
|
||||
if (lib_name != NULL) {
|
||||
len = name_len = strlen(lib_name);
|
||||
if (is_absolute_path) {
|
||||
// Need to strip path, prefix and suffix
|
||||
if ((start = strrchr(lib_name, *os::file_separator())) != NULL) {
|
||||
lib_name = ++start;
|
||||
}
|
||||
if (len <= (prefix_len + suffix_len)) {
|
||||
return NULL;
|
||||
}
|
||||
lib_name += prefix_len;
|
||||
name_len = strlen(lib_name) - suffix_len;
|
||||
}
|
||||
}
|
||||
len = (lib_name != NULL ? name_len : 0) + strlen(sym_name) + 2;
|
||||
agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread);
|
||||
if (agent_entry_name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strcpy(agent_entry_name, sym_name);
|
||||
if (lib_name != NULL) {
|
||||
strcat(agent_entry_name, "_");
|
||||
strncat(agent_entry_name, lib_name, name_len);
|
||||
}
|
||||
return agent_entry_name;
|
||||
}
|
||||
|
||||
os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {
|
||||
assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread");
|
||||
}
|
||||
@ -271,11 +322,17 @@ os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {
|
||||
* The callback is supposed to provide the method that should be protected.
|
||||
*/
|
||||
bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) {
|
||||
sigset_t saved_sig_mask;
|
||||
|
||||
assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread");
|
||||
assert(!WatcherThread::watcher_thread()->has_crash_protection(),
|
||||
"crash_protection already set?");
|
||||
|
||||
if (sigsetjmp(_jmpbuf, 1) == 0) {
|
||||
// we cannot rely on sigsetjmp/siglongjmp to save/restore the signal mask
|
||||
// since on at least some systems (OS X) siglongjmp will restore the mask
|
||||
// for the process, not the thread
|
||||
pthread_sigmask(0, NULL, &saved_sig_mask);
|
||||
if (sigsetjmp(_jmpbuf, 0) == 0) {
|
||||
// make sure we can see in the signal handler that we have crash protection
|
||||
// installed
|
||||
WatcherThread::watcher_thread()->set_crash_protection(this);
|
||||
@ -285,6 +342,7 @@ bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) {
|
||||
return true;
|
||||
}
|
||||
// this happens when we siglongjmp() back
|
||||
pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL);
|
||||
WatcherThread::watcher_thread()->set_crash_protection(NULL);
|
||||
return false;
|
||||
}
|
||||
|
@ -3385,7 +3385,7 @@ bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) {
|
||||
return true;
|
||||
}
|
||||
|
||||
char* os::reserve_memory_special(size_t size, char* addr, bool exec) {
|
||||
char* os::reserve_memory_special(size_t size, size_t alignment, char* addr, bool exec) {
|
||||
fatal("os::reserve_memory_special should not be called on Solaris.");
|
||||
return NULL;
|
||||
}
|
||||
@ -6601,3 +6601,9 @@ int os::get_core_path(char* buffer, size_t bufferSize) {
|
||||
|
||||
return strlen(buffer);
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
void TestReserveMemorySpecial_test() {
|
||||
// No tests available for this platform
|
||||
}
|
||||
#endif
|
||||
|
@ -3156,7 +3156,12 @@ bool os::can_execute_large_page_memory() {
|
||||
return true;
|
||||
}
|
||||
|
||||
char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {
|
||||
char* os::reserve_memory_special(size_t bytes, size_t alignment, char* addr, bool exec) {
|
||||
assert(UseLargePages, "only for large pages");
|
||||
|
||||
if (!is_size_aligned(bytes, os::large_page_size()) || alignment > os::large_page_size()) {
|
||||
return NULL; // Fallback to small pages.
|
||||
}
|
||||
|
||||
const DWORD prot = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
||||
const DWORD flags = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
|
||||
@ -5394,6 +5399,75 @@ inline BOOL os::Advapi32Dll::AdvapiAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void* os::get_default_process_handle() {
|
||||
return (void*)GetModuleHandle(NULL);
|
||||
}
|
||||
|
||||
// Builds a platform dependent Agent_OnLoad_<lib_name> function name
|
||||
// which is used to find statically linked in agents.
|
||||
// Additionally for windows, takes into account __stdcall names.
|
||||
// Parameters:
|
||||
// sym_name: Symbol in library we are looking for
|
||||
// lib_name: Name of library to look in, NULL for shared libs.
|
||||
// is_absolute_path == true if lib_name is absolute path to agent
|
||||
// such as "C:/a/b/L.dll"
|
||||
// == false if only the base name of the library is passed in
|
||||
// such as "L"
|
||||
char* os::build_agent_function_name(const char *sym_name, const char *lib_name,
|
||||
bool is_absolute_path) {
|
||||
char *agent_entry_name;
|
||||
size_t len;
|
||||
size_t name_len;
|
||||
size_t prefix_len = strlen(JNI_LIB_PREFIX);
|
||||
size_t suffix_len = strlen(JNI_LIB_SUFFIX);
|
||||
const char *start;
|
||||
|
||||
if (lib_name != NULL) {
|
||||
len = name_len = strlen(lib_name);
|
||||
if (is_absolute_path) {
|
||||
// Need to strip path, prefix and suffix
|
||||
if ((start = strrchr(lib_name, *os::file_separator())) != NULL) {
|
||||
lib_name = ++start;
|
||||
} else {
|
||||
// Need to check for C:
|
||||
if ((start = strchr(lib_name, ':')) != NULL) {
|
||||
lib_name = ++start;
|
||||
}
|
||||
}
|
||||
if (len <= (prefix_len + suffix_len)) {
|
||||
return NULL;
|
||||
}
|
||||
lib_name += prefix_len;
|
||||
name_len = strlen(lib_name) - suffix_len;
|
||||
}
|
||||
}
|
||||
len = (lib_name != NULL ? name_len : 0) + strlen(sym_name) + 2;
|
||||
agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread);
|
||||
if (agent_entry_name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (lib_name != NULL) {
|
||||
const char *p = strrchr(sym_name, '@');
|
||||
if (p != NULL && p != sym_name) {
|
||||
// sym_name == _Agent_OnLoad@XX
|
||||
strncpy(agent_entry_name, sym_name, (p - sym_name));
|
||||
agent_entry_name[(p-sym_name)] = '\0';
|
||||
// agent_entry_name == _Agent_OnLoad
|
||||
strcat(agent_entry_name, "_");
|
||||
strncat(agent_entry_name, lib_name, name_len);
|
||||
strcat(agent_entry_name, p);
|
||||
// agent_entry_name == _Agent_OnLoad_lib_name@XX
|
||||
} else {
|
||||
strcpy(agent_entry_name, sym_name);
|
||||
strcat(agent_entry_name, "_");
|
||||
strncat(agent_entry_name, lib_name, name_len);
|
||||
}
|
||||
} else {
|
||||
strcpy(agent_entry_name, sym_name);
|
||||
}
|
||||
return agent_entry_name;
|
||||
}
|
||||
|
||||
#else
|
||||
// Kernel32 API
|
||||
typedef BOOL (WINAPI* SwitchToThread_Fn)(void);
|
||||
@ -5638,3 +5712,9 @@ BOOL os::Advapi32Dll::AdvapiAvailable() {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT
|
||||
void TestReserveMemorySpecial_test() {
|
||||
// No tests available for this platform
|
||||
}
|
||||
#endif
|
||||
|
@ -44,6 +44,6 @@ define_pd_global(uintx,JVMInvokeMethodSlack, 10*K);
|
||||
define_pd_global(intx, CompilerThreadStackSize, 0);
|
||||
|
||||
// Used on 64 bit platforms for UseCompressedOops base address
|
||||
define_pd_global(uintx,HeapBaseMinAddress, 256*M);
|
||||
define_pd_global(uintx,HeapBaseMinAddress, 2*G);
|
||||
|
||||
#endif // OS_CPU_SOLARIS_X86_VM_GLOBALS_SOLARIS_X86_HPP
|
||||
|
@ -106,10 +106,12 @@ public class CallSite {
|
||||
" (" + getMethod().getBytes() + " bytes) " + getReason());
|
||||
}
|
||||
}
|
||||
stream.printf(" (end time: %6.4f", getTimeStamp());
|
||||
if (getEndNodes() > 0) {
|
||||
stream.printf(" (end time: %6.4f nodes: %d live: %d)", getTimeStamp(), getEndNodes(), getEndLiveNodes());
|
||||
stream.printf(" nodes: %d live: %d", getEndNodes(), getEndLiveNodes());
|
||||
}
|
||||
stream.println("");
|
||||
stream.println(")");
|
||||
|
||||
if (getReceiver() != null) {
|
||||
emit(stream, indent + 4);
|
||||
// stream.println("type profile " + method.holder + " -> " + receiver + " (" +
|
||||
|
@ -207,7 +207,12 @@ public class LogParser extends DefaultHandler implements ErrorHandler, Constants
|
||||
}
|
||||
|
||||
String search(Attributes attr, String name) {
|
||||
return search(attr, name, null);
|
||||
String result = attr.getValue(name);
|
||||
if (result != null) {
|
||||
return result;
|
||||
} else {
|
||||
throw new InternalError("can't find " + name);
|
||||
}
|
||||
}
|
||||
|
||||
String search(Attributes attr, String name, String defaultValue) {
|
||||
@ -215,13 +220,7 @@ public class LogParser extends DefaultHandler implements ErrorHandler, Constants
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
if (defaultValue != null) {
|
||||
return defaultValue;
|
||||
}
|
||||
for (int i = 0; i < attr.getLength(); i++) {
|
||||
System.out.println(attr.getQName(i) + " " + attr.getValue(attr.getQName(i)));
|
||||
}
|
||||
throw new InternalError("can't find " + name);
|
||||
return defaultValue;
|
||||
}
|
||||
int indent = 0;
|
||||
|
||||
@ -268,17 +267,18 @@ public class LogParser extends DefaultHandler implements ErrorHandler, Constants
|
||||
Phase p = new Phase(search(atts, "name"),
|
||||
Double.parseDouble(search(atts, "stamp")),
|
||||
Integer.parseInt(search(atts, "nodes", "0")),
|
||||
Integer.parseInt(search(atts, "live")));
|
||||
Integer.parseInt(search(atts, "live", "0")));
|
||||
phaseStack.push(p);
|
||||
} else if (qname.equals("phase_done")) {
|
||||
Phase p = phaseStack.pop();
|
||||
if (! p.getId().equals(search(atts, "name"))) {
|
||||
String phaseName = search(atts, "name", null);
|
||||
if (phaseName != null && !p.getId().equals(phaseName)) {
|
||||
System.out.println("phase: " + p.getId());
|
||||
throw new InternalError("phase name mismatch");
|
||||
}
|
||||
p.setEnd(Double.parseDouble(search(atts, "stamp")));
|
||||
p.setEndNodes(Integer.parseInt(search(atts, "nodes", "0")));
|
||||
p.setEndLiveNodes(Integer.parseInt(search(atts, "live")));
|
||||
p.setEndLiveNodes(Integer.parseInt(search(atts, "live", "0")));
|
||||
compile.getPhases().add(p);
|
||||
} else if (qname.equals("task")) {
|
||||
compile = new Compilation(Integer.parseInt(search(atts, "compile_id", "-1")));
|
||||
@ -413,8 +413,8 @@ public class LogParser extends DefaultHandler implements ErrorHandler, Constants
|
||||
}
|
||||
} else if (qname.equals("parse_done")) {
|
||||
CallSite call = scopes.pop();
|
||||
call.setEndNodes(Integer.parseInt(search(atts, "nodes", "1")));
|
||||
call.setEndLiveNodes(Integer.parseInt(search(atts, "live", "1")));
|
||||
call.setEndNodes(Integer.parseInt(search(atts, "nodes", "0")));
|
||||
call.setEndLiveNodes(Integer.parseInt(search(atts, "live", "0")));
|
||||
call.setTimeStamp(Double.parseDouble(search(atts, "stamp")));
|
||||
scopes.push(call);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2013, 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
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
#include "adlc.hpp"
|
||||
|
||||
void* Chunk::operator new(size_t requested_size, size_t length) {
|
||||
void* Chunk::operator new(size_t requested_size, size_t length) throw() {
|
||||
return CHeapObj::operator new(requested_size + length);
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ bool Arena::contains( const void *ptr ) const {
|
||||
//-----------------------------------------------------------------------------
|
||||
// CHeapObj
|
||||
|
||||
void* CHeapObj::operator new(size_t size){
|
||||
void* CHeapObj::operator new(size_t size) throw() {
|
||||
return (void *) malloc(size);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2013, 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
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
class CHeapObj {
|
||||
public:
|
||||
void* operator new(size_t size);
|
||||
void* operator new(size_t size) throw();
|
||||
void operator delete(void* p);
|
||||
void* new_array(size_t size);
|
||||
};
|
||||
@ -53,7 +53,7 @@ class CHeapObj {
|
||||
|
||||
class ValueObj {
|
||||
public:
|
||||
void* operator new(size_t size);
|
||||
void* operator new(size_t size) throw();
|
||||
void operator delete(void* p);
|
||||
};
|
||||
|
||||
@ -61,7 +61,7 @@ class ValueObj {
|
||||
|
||||
class AllStatic {
|
||||
public:
|
||||
void* operator new(size_t size);
|
||||
void* operator new(size_t size) throw();
|
||||
void operator delete(void* p);
|
||||
};
|
||||
|
||||
@ -70,7 +70,7 @@ class AllStatic {
|
||||
// Linked list of raw memory chunks
|
||||
class Chunk: public CHeapObj {
|
||||
public:
|
||||
void* operator new(size_t size, size_t length);
|
||||
void* operator new(size_t size, size_t length) throw();
|
||||
void operator delete(void* p, size_t length);
|
||||
Chunk(size_t length);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -485,7 +485,7 @@ int get_legal_text(FileBuff &fbuf, char **legal_text)
|
||||
|
||||
// VS2005 has its own definition, identical to this one.
|
||||
#if !defined(_WIN32) || defined(_WIN64) || _MSC_VER < 1400
|
||||
void *operator new( size_t size, int, const char *, int ) {
|
||||
void *operator new( size_t size, int, const char *, int ) throw() {
|
||||
return ::operator new( size );
|
||||
}
|
||||
#endif
|
||||
|
@ -1095,7 +1095,7 @@ static void check_peepmatch_instruction_sequence(FILE *fp, PeepMatch *pmatch, Pe
|
||||
fprintf(fp, " // Identify previous instruction if inside this block\n");
|
||||
fprintf(fp, " if( ");
|
||||
print_block_index(fp, inst_position);
|
||||
fprintf(fp, " > 0 ) {\n Node *n = block->_nodes.at(");
|
||||
fprintf(fp, " > 0 ) {\n Node *n = block->get_node(");
|
||||
print_block_index(fp, inst_position);
|
||||
fprintf(fp, ");\n inst%d = (n->is_Mach()) ? ", inst_position);
|
||||
fprintf(fp, "n->as_Mach() : NULL;\n }\n");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -296,8 +296,8 @@ class CodeBuffer: public StackObj {
|
||||
// CodeBuffers must be allocated on the stack except for a single
|
||||
// special case during expansion which is handled internally. This
|
||||
// is done to guarantee proper cleanup of resources.
|
||||
void* operator new(size_t size) { return ResourceObj::operator new(size); }
|
||||
void operator delete(void* p) { ShouldNotCallThis(); }
|
||||
void* operator new(size_t size) throw() { return ResourceObj::operator new(size); }
|
||||
void operator delete(void* p) { ShouldNotCallThis(); }
|
||||
|
||||
public:
|
||||
typedef int csize_t; // code size type; would be size_t except for history
|
||||
|
@ -364,7 +364,8 @@ class PatchingStub: public CodeStub {
|
||||
enum PatchID {
|
||||
access_field_id,
|
||||
load_klass_id,
|
||||
load_mirror_id
|
||||
load_mirror_id,
|
||||
load_appendix_id
|
||||
};
|
||||
enum constants {
|
||||
patch_info_size = 3
|
||||
@ -417,7 +418,7 @@ class PatchingStub: public CodeStub {
|
||||
}
|
||||
NativeMovRegMem* n_move = nativeMovRegMem_at(pc_start());
|
||||
n_move->set_offset(field_offset);
|
||||
} else if (_id == load_klass_id || _id == load_mirror_id) {
|
||||
} else if (_id == load_klass_id || _id == load_mirror_id || _id == load_appendix_id) {
|
||||
assert(_obj != noreg, "must have register object for load_klass/load_mirror");
|
||||
#ifdef ASSERT
|
||||
// verify that we're pointing at a NativeMovConstReg
|
||||
|
@ -74,16 +74,19 @@ class PhaseTraceTime: public TraceTime {
|
||||
private:
|
||||
JavaThread* _thread;
|
||||
CompileLog* _log;
|
||||
TimerName _timer;
|
||||
|
||||
public:
|
||||
PhaseTraceTime(TimerName timer)
|
||||
: TraceTime("", &timers[timer], CITime || CITimeEach, Verbose), _log(NULL) {
|
||||
: TraceTime("", &timers[timer], CITime || CITimeEach, Verbose),
|
||||
_log(NULL), _timer(timer)
|
||||
{
|
||||
if (Compilation::current() != NULL) {
|
||||
_log = Compilation::current()->log();
|
||||
}
|
||||
|
||||
if (_log != NULL) {
|
||||
_log->begin_head("phase name='%s'", timer_name[timer]);
|
||||
_log->begin_head("phase name='%s'", timer_name[_timer]);
|
||||
_log->stamp();
|
||||
_log->end_head();
|
||||
}
|
||||
@ -91,7 +94,7 @@ class PhaseTraceTime: public TraceTime {
|
||||
|
||||
~PhaseTraceTime() {
|
||||
if (_log != NULL)
|
||||
_log->done("phase");
|
||||
_log->done("phase name='%s'", timer_name[_timer]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2013, 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
|
||||
@ -279,8 +279,8 @@ class InstructionMark: public StackObj {
|
||||
// Base class for objects allocated by the compiler in the compilation arena
|
||||
class CompilationResourceObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||
public:
|
||||
void* operator new(size_t size) { return Compilation::current()->arena()->Amalloc(size); }
|
||||
void* operator new(size_t size, Arena* arena) {
|
||||
void* operator new(size_t size) throw() { return Compilation::current()->arena()->Amalloc(size); }
|
||||
void* operator new(size_t size, Arena* arena) throw() {
|
||||
return arena->Amalloc(size);
|
||||
}
|
||||
void operator delete(void* p) {} // nothing to do
|
||||
|
@ -1583,7 +1583,7 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
|
||||
ObjectType* obj_type = obj->type()->as_ObjectType();
|
||||
if (obj_type->is_constant() && !PatchALot) {
|
||||
ciObject* const_oop = obj_type->constant_value();
|
||||
if (!const_oop->is_null_object()) {
|
||||
if (!const_oop->is_null_object() && const_oop->is_loaded()) {
|
||||
if (field->is_constant()) {
|
||||
ciConstant field_val = field->constant_value_of(const_oop);
|
||||
BasicType field_type = field_val.basic_type();
|
||||
@ -1667,9 +1667,8 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
|
||||
const Bytecodes::Code bc_raw = stream()->cur_bc_raw();
|
||||
assert(declared_signature != NULL, "cannot be null");
|
||||
|
||||
// FIXME bail out for now
|
||||
if (Bytecodes::has_optional_appendix(bc_raw) && !will_link) {
|
||||
BAILOUT("unlinked call site (FIXME needs patching or recompile support)");
|
||||
if (!C1PatchInvokeDynamic && Bytecodes::has_optional_appendix(bc_raw) && !will_link) {
|
||||
BAILOUT("unlinked call site (C1PatchInvokeDynamic is off)");
|
||||
}
|
||||
|
||||
// we have to make sure the argument size (incl. the receiver)
|
||||
@ -1713,10 +1712,23 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
|
||||
code = target->is_static() ? Bytecodes::_invokestatic : Bytecodes::_invokespecial;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (bc_raw == Bytecodes::_invokehandle) {
|
||||
assert(!will_link, "should come here only for unlinked call");
|
||||
code = Bytecodes::_invokespecial;
|
||||
}
|
||||
}
|
||||
|
||||
// Push appendix argument (MethodType, CallSite, etc.), if one.
|
||||
if (stream()->has_appendix()) {
|
||||
bool patch_for_appendix = false;
|
||||
int patching_appendix_arg = 0;
|
||||
if (C1PatchInvokeDynamic &&
|
||||
(Bytecodes::has_optional_appendix(bc_raw) && (!will_link || PatchALot))) {
|
||||
Value arg = append(new Constant(new ObjectConstant(compilation()->env()->unloaded_ciinstance()), copy_state_before()));
|
||||
apush(arg);
|
||||
patch_for_appendix = true;
|
||||
patching_appendix_arg = (will_link && stream()->has_appendix()) ? 0 : 1;
|
||||
} else if (stream()->has_appendix()) {
|
||||
ciObject* appendix = stream()->get_appendix();
|
||||
Value arg = append(new Constant(new ObjectConstant(appendix)));
|
||||
apush(arg);
|
||||
@ -1732,7 +1744,8 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
|
||||
if (UseCHA && DeoptC1 && klass->is_loaded() && target->is_loaded() &&
|
||||
!(// %%% FIXME: Are both of these relevant?
|
||||
target->is_method_handle_intrinsic() ||
|
||||
target->is_compiled_lambda_form())) {
|
||||
target->is_compiled_lambda_form()) &&
|
||||
!patch_for_appendix) {
|
||||
Value receiver = NULL;
|
||||
ciInstanceKlass* receiver_klass = NULL;
|
||||
bool type_is_exact = false;
|
||||
@ -1850,7 +1863,8 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
|
||||
// check if we could do inlining
|
||||
if (!PatchALot && Inline && klass->is_loaded() &&
|
||||
(klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized())
|
||||
&& target->is_loaded()) {
|
||||
&& target->is_loaded()
|
||||
&& !patch_for_appendix) {
|
||||
// callee is known => check if we have static binding
|
||||
assert(target->is_loaded(), "callee must be known");
|
||||
if (code == Bytecodes::_invokestatic ||
|
||||
@ -1901,7 +1915,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
|
||||
code == Bytecodes::_invokespecial ||
|
||||
code == Bytecodes::_invokevirtual ||
|
||||
code == Bytecodes::_invokeinterface;
|
||||
Values* args = state()->pop_arguments(target->arg_size_no_receiver());
|
||||
Values* args = state()->pop_arguments(target->arg_size_no_receiver() + patching_appendix_arg);
|
||||
Value recv = has_receiver ? apop() : NULL;
|
||||
int vtable_index = Method::invalid_vtable_index;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2013, 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
|
||||
@ -323,7 +323,7 @@ class Instruction: public CompilationResourceObj {
|
||||
}
|
||||
|
||||
public:
|
||||
void* operator new(size_t size) {
|
||||
void* operator new(size_t size) throw() {
|
||||
Compilation* c = Compilation::current();
|
||||
void* res = c->arena()->Amalloc(size);
|
||||
((Instruction*)res)->_id = c->get_next_id();
|
||||
@ -1611,7 +1611,7 @@ LEAF(BlockBegin, StateSplit)
|
||||
friend class SuxAndWeightAdjuster;
|
||||
|
||||
public:
|
||||
void* operator new(size_t size) {
|
||||
void* operator new(size_t size) throw() {
|
||||
Compilation* c = Compilation::current();
|
||||
void* res = c->arena()->Amalloc(size);
|
||||
((BlockBegin*)res)->_id = c->get_next_id();
|
||||
|
@ -1211,8 +1211,6 @@ class LIR_OpJavaCall: public LIR_OpCall {
|
||||
bool is_invokedynamic() const { return code() == lir_dynamic_call; }
|
||||
bool is_method_handle_invoke() const {
|
||||
return
|
||||
is_invokedynamic() // An invokedynamic is always a MethodHandle call site.
|
||||
||
|
||||
method()->is_compiled_lambda_form() // Java-generated adapter
|
||||
||
|
||||
method()->is_method_handle_intrinsic(); // JVM-generated MH intrinsic
|
||||
|
@ -93,12 +93,23 @@ void LIR_Assembler::patching_epilog(PatchingStub* patch, LIR_PatchCode patch_cod
|
||||
default:
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
} else if (patch->id() == PatchingStub::load_appendix_id) {
|
||||
Bytecodes::Code bc_raw = info->scope()->method()->raw_code_at_bci(info->stack()->bci());
|
||||
assert(Bytecodes::has_optional_appendix(bc_raw), "unexpected appendix resolution");
|
||||
} else {
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PatchingStub::PatchID LIR_Assembler::patching_id(CodeEmitInfo* info) {
|
||||
IRScope* scope = info->scope();
|
||||
Bytecodes::Code bc_raw = scope->method()->raw_code_at_bci(info->stack()->bci());
|
||||
if (Bytecodes::has_optional_appendix(bc_raw)) {
|
||||
return PatchingStub::load_appendix_id;
|
||||
}
|
||||
return PatchingStub::load_mirror_id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
@ -119,6 +119,8 @@ class LIR_Assembler: public CompilationResourceObj {
|
||||
|
||||
void comp_op(LIR_Condition condition, LIR_Opr src, LIR_Opr result, LIR_Op2* op);
|
||||
|
||||
PatchingStub::PatchID patching_id(CodeEmitInfo* info);
|
||||
|
||||
public:
|
||||
LIR_Assembler(Compilation* c);
|
||||
~LIR_Assembler();
|
||||
|
@ -819,6 +819,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
|
||||
KlassHandle init_klass(THREAD, NULL); // klass needed by load_klass_patching code
|
||||
KlassHandle load_klass(THREAD, NULL); // klass needed by load_klass_patching code
|
||||
Handle mirror(THREAD, NULL); // oop needed by load_mirror_patching code
|
||||
Handle appendix(THREAD, NULL); // oop needed by appendix_patching code
|
||||
bool load_klass_or_mirror_patch_id =
|
||||
(stub_id == Runtime1::load_klass_patching_id || stub_id == Runtime1::load_mirror_patching_id);
|
||||
|
||||
@ -888,10 +889,32 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
|
||||
mirror = Handle(THREAD, m);
|
||||
}
|
||||
break;
|
||||
default: Unimplemented();
|
||||
default: fatal("unexpected bytecode for load_klass_or_mirror_patch_id");
|
||||
}
|
||||
// convert to handle
|
||||
load_klass = KlassHandle(THREAD, k);
|
||||
} else if (stub_id == load_appendix_patching_id) {
|
||||
Bytecode_invoke bytecode(caller_method, bci);
|
||||
Bytecodes::Code bc = bytecode.invoke_code();
|
||||
|
||||
CallInfo info;
|
||||
constantPoolHandle pool(thread, caller_method->constants());
|
||||
int index = bytecode.index();
|
||||
LinkResolver::resolve_invoke(info, Handle(), pool, index, bc, CHECK);
|
||||
appendix = info.resolved_appendix();
|
||||
switch (bc) {
|
||||
case Bytecodes::_invokehandle: {
|
||||
int cache_index = ConstantPool::decode_cpcache_index(index, true);
|
||||
assert(cache_index >= 0 && cache_index < pool->cache()->length(), "unexpected cache index");
|
||||
pool->cache()->entry_at(cache_index)->set_method_handle(pool, info);
|
||||
break;
|
||||
}
|
||||
case Bytecodes::_invokedynamic: {
|
||||
pool->invokedynamic_cp_cache_entry_at(index)->set_dynamic_call(pool, info);
|
||||
break;
|
||||
}
|
||||
default: fatal("unexpected bytecode for load_appendix_patching_id");
|
||||
}
|
||||
} else {
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
@ -992,8 +1015,8 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
|
||||
n_copy->data() == (intptr_t)Universe::non_oop_word(),
|
||||
"illegal init value");
|
||||
if (stub_id == Runtime1::load_klass_patching_id) {
|
||||
assert(load_klass() != NULL, "klass not set");
|
||||
n_copy->set_data((intx) (load_klass()));
|
||||
assert(load_klass() != NULL, "klass not set");
|
||||
n_copy->set_data((intx) (load_klass()));
|
||||
} else {
|
||||
assert(mirror() != NULL, "klass not set");
|
||||
n_copy->set_data((intx) (mirror()));
|
||||
@ -1002,43 +1025,55 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
|
||||
if (TracePatching) {
|
||||
Disassembler::decode(copy_buff, copy_buff + *byte_count, tty);
|
||||
}
|
||||
}
|
||||
} else if (stub_id == Runtime1::load_appendix_patching_id) {
|
||||
NativeMovConstReg* n_copy = nativeMovConstReg_at(copy_buff);
|
||||
assert(n_copy->data() == 0 ||
|
||||
n_copy->data() == (intptr_t)Universe::non_oop_word(),
|
||||
"illegal init value");
|
||||
n_copy->set_data((intx) (appendix()));
|
||||
|
||||
#if defined(SPARC) || defined(PPC)
|
||||
// Update the location in the nmethod with the proper
|
||||
// metadata. When the code was generated, a NULL was stuffed
|
||||
// in the metadata table and that table needs to be update to
|
||||
// have the right value. On intel the value is kept
|
||||
// directly in the instruction instead of in the metadata
|
||||
// table, so set_data above effectively updated the value.
|
||||
nmethod* nm = CodeCache::find_nmethod(instr_pc);
|
||||
assert(nm != NULL, "invalid nmethod_pc");
|
||||
RelocIterator mds(nm, copy_buff, copy_buff + 1);
|
||||
bool found = false;
|
||||
while (mds.next() && !found) {
|
||||
if (mds.type() == relocInfo::oop_type) {
|
||||
assert(stub_id == Runtime1::load_mirror_patching_id, "wrong stub id");
|
||||
oop_Relocation* r = mds.oop_reloc();
|
||||
oop* oop_adr = r->oop_addr();
|
||||
*oop_adr = mirror();
|
||||
r->fix_oop_relocation();
|
||||
found = true;
|
||||
} else if (mds.type() == relocInfo::metadata_type) {
|
||||
assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id");
|
||||
metadata_Relocation* r = mds.metadata_reloc();
|
||||
Metadata** metadata_adr = r->metadata_addr();
|
||||
*metadata_adr = load_klass();
|
||||
r->fix_metadata_relocation();
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
assert(found, "the metadata must exist!");
|
||||
#endif
|
||||
|
||||
if (TracePatching) {
|
||||
Disassembler::decode(copy_buff, copy_buff + *byte_count, tty);
|
||||
}
|
||||
} else {
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
|
||||
#if defined(SPARC) || defined(PPC)
|
||||
if (load_klass_or_mirror_patch_id ||
|
||||
stub_id == Runtime1::load_appendix_patching_id) {
|
||||
// Update the location in the nmethod with the proper
|
||||
// metadata. When the code was generated, a NULL was stuffed
|
||||
// in the metadata table and that table needs to be update to
|
||||
// have the right value. On intel the value is kept
|
||||
// directly in the instruction instead of in the metadata
|
||||
// table, so set_data above effectively updated the value.
|
||||
nmethod* nm = CodeCache::find_nmethod(instr_pc);
|
||||
assert(nm != NULL, "invalid nmethod_pc");
|
||||
RelocIterator mds(nm, copy_buff, copy_buff + 1);
|
||||
bool found = false;
|
||||
while (mds.next() && !found) {
|
||||
if (mds.type() == relocInfo::oop_type) {
|
||||
assert(stub_id == Runtime1::load_mirror_patching_id ||
|
||||
stub_id == Runtime1::load_appendix_patching_id, "wrong stub id");
|
||||
oop_Relocation* r = mds.oop_reloc();
|
||||
oop* oop_adr = r->oop_addr();
|
||||
*oop_adr = stub_id == Runtime1::load_mirror_patching_id ? mirror() : appendix();
|
||||
r->fix_oop_relocation();
|
||||
found = true;
|
||||
} else if (mds.type() == relocInfo::metadata_type) {
|
||||
assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id");
|
||||
metadata_Relocation* r = mds.metadata_reloc();
|
||||
Metadata** metadata_adr = r->metadata_addr();
|
||||
*metadata_adr = load_klass();
|
||||
r->fix_metadata_relocation();
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
assert(found, "the metadata must exist!");
|
||||
}
|
||||
#endif
|
||||
if (do_patch) {
|
||||
// replace instructions
|
||||
// first replace the tail, then the call
|
||||
@ -1077,7 +1112,8 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
|
||||
ICache::invalidate_range(instr_pc, *byte_count);
|
||||
NativeGeneralJump::replace_mt_safe(instr_pc, copy_buff);
|
||||
|
||||
if (load_klass_or_mirror_patch_id) {
|
||||
if (load_klass_or_mirror_patch_id ||
|
||||
stub_id == Runtime1::load_appendix_patching_id) {
|
||||
relocInfo::relocType rtype =
|
||||
(stub_id == Runtime1::load_klass_patching_id) ?
|
||||
relocInfo::metadata_type :
|
||||
@ -1118,7 +1154,8 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
|
||||
|
||||
// If we are patching in a non-perm oop, make sure the nmethod
|
||||
// is on the right list.
|
||||
if (ScavengeRootsInCode && mirror.not_null() && mirror()->is_scavengable()) {
|
||||
if (ScavengeRootsInCode && ((mirror.not_null() && mirror()->is_scavengable()) ||
|
||||
(appendix.not_null() && appendix->is_scavengable()))) {
|
||||
MutexLockerEx ml_code (CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
||||
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
|
||||
guarantee(nm != NULL, "only nmethods can contain non-perm oops");
|
||||
@ -1179,6 +1216,24 @@ int Runtime1::move_mirror_patching(JavaThread* thread) {
|
||||
return caller_is_deopted();
|
||||
}
|
||||
|
||||
int Runtime1::move_appendix_patching(JavaThread* thread) {
|
||||
//
|
||||
// NOTE: we are still in Java
|
||||
//
|
||||
Thread* THREAD = thread;
|
||||
debug_only(NoHandleMark nhm;)
|
||||
{
|
||||
// Enter VM mode
|
||||
|
||||
ResetNoHandleMark rnhm;
|
||||
patch_code(thread, load_appendix_patching_id);
|
||||
}
|
||||
// Back in JAVA, use no oops DON'T safepoint
|
||||
|
||||
// Return true if calling code is deoptimized
|
||||
|
||||
return caller_is_deopted();
|
||||
}
|
||||
//
|
||||
// Entry point for compiled code. We want to patch a nmethod.
|
||||
// We don't do a normal VM transition here because we want to
|
||||
|
@ -67,6 +67,7 @@ class StubAssembler;
|
||||
stub(access_field_patching) \
|
||||
stub(load_klass_patching) \
|
||||
stub(load_mirror_patching) \
|
||||
stub(load_appendix_patching) \
|
||||
stub(g1_pre_barrier_slow) \
|
||||
stub(g1_post_barrier_slow) \
|
||||
stub(fpu2long_stub) \
|
||||
@ -160,6 +161,7 @@ class Runtime1: public AllStatic {
|
||||
static int access_field_patching(JavaThread* thread);
|
||||
static int move_klass_patching(JavaThread* thread);
|
||||
static int move_mirror_patching(JavaThread* thread);
|
||||
static int move_appendix_patching(JavaThread* thread);
|
||||
|
||||
static void patch_code(JavaThread* thread, StubID stub_id);
|
||||
|
||||
|
@ -25,4 +25,4 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "c1/c1_globals.hpp"
|
||||
|
||||
C1_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, MATERIALIZE_NOTPRODUCT_FLAG)
|
||||
C1_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG)
|
||||
|
@ -54,7 +54,7 @@
|
||||
//
|
||||
// Defines all global flags used by the client compiler.
|
||||
//
|
||||
#define C1_FLAGS(develop, develop_pd, product, product_pd, notproduct) \
|
||||
#define C1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct) \
|
||||
\
|
||||
/* Printing */ \
|
||||
notproduct(bool, PrintC1Statistics, false, \
|
||||
@ -333,15 +333,19 @@
|
||||
"Use CHA and exact type results at call sites when updating MDOs")\
|
||||
\
|
||||
product(bool, C1UpdateMethodData, trueInTiered, \
|
||||
"Update MethodData*s in Tier1-generated code") \
|
||||
"Update MethodData*s in Tier1-generated code") \
|
||||
\
|
||||
develop(bool, PrintCFGToFile, false, \
|
||||
"print control flow graph to a separate file during compilation") \
|
||||
\
|
||||
diagnostic(bool, C1PatchInvokeDynamic, true, \
|
||||
"Patch invokedynamic appendix not known at compile time") \
|
||||
\
|
||||
\
|
||||
|
||||
|
||||
// Read default values for c1 globals
|
||||
|
||||
C1_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_NOTPRODUCT_FLAG)
|
||||
C1_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_NOTPRODUCT_FLAG)
|
||||
|
||||
#endif // SHARE_VM_C1_C1_GLOBALS_HPP
|
||||
|
@ -1150,6 +1150,10 @@ void ciEnv::record_out_of_memory_failure() {
|
||||
record_method_not_compilable("out of memory");
|
||||
}
|
||||
|
||||
ciInstance* ciEnv::unloaded_ciinstance() {
|
||||
GUARDED_VM_ENTRY(return _factory->get_unloaded_object_constant();)
|
||||
}
|
||||
|
||||
void ciEnv::dump_replay_data(outputStream* out) {
|
||||
VM_ENTRY_MARK;
|
||||
MutexLocker ml(Compile_lock);
|
||||
|
@ -400,6 +400,7 @@ public:
|
||||
static ciInstanceKlass* unloaded_ciinstance_klass() {
|
||||
return _unloaded_ciinstance_klass;
|
||||
}
|
||||
ciInstance* unloaded_ciinstance();
|
||||
|
||||
ciKlass* find_system_klass(ciSymbol* klass_name);
|
||||
// Note: To find a class from its name string, use ciSymbol::make,
|
||||
|
@ -60,10 +60,10 @@ ciType* ciInstance::java_mirror_type() {
|
||||
//
|
||||
// Constant value of a field.
|
||||
ciConstant ciInstance::field_value(ciField* field) {
|
||||
assert(is_loaded() &&
|
||||
field->holder()->is_loaded() &&
|
||||
klass()->is_subclass_of(field->holder()),
|
||||
"invalid access");
|
||||
assert(is_loaded(), "invalid access - must be loaded");
|
||||
assert(field->holder()->is_loaded(), "invalid access - holder must be loaded");
|
||||
assert(klass()->is_subclass_of(field->holder()), "invalid access - must be subclass");
|
||||
|
||||
VM_ENTRY_MARK;
|
||||
ciConstant result;
|
||||
Handle obj = get_oop();
|
||||
|
@ -177,6 +177,10 @@ class ciMethod : public ciMetadata {
|
||||
address bcp = code() + bci;
|
||||
return Bytecodes::java_code_at(NULL, bcp);
|
||||
}
|
||||
Bytecodes::Code raw_code_at_bci(int bci) {
|
||||
address bcp = code() + bci;
|
||||
return Bytecodes::code_at(NULL, bcp);
|
||||
}
|
||||
BCEscapeAnalyzer *get_bcea();
|
||||
ciMethodBlocks *get_method_blocks();
|
||||
|
||||
|
@ -563,7 +563,10 @@ ciInstance* ciObjectFactory::get_unloaded_method_type_constant(ciSymbol* signatu
|
||||
return get_unloaded_instance(ciEnv::_MethodType_klass->as_instance_klass());
|
||||
}
|
||||
|
||||
|
||||
ciInstance* ciObjectFactory::get_unloaded_object_constant() {
|
||||
if (ciEnv::_Object_klass == NULL) return NULL;
|
||||
return get_unloaded_instance(ciEnv::_Object_klass->as_instance_klass());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// ciObjectFactory::get_empty_methodData
|
||||
|
@ -131,6 +131,8 @@ public:
|
||||
ciInstance* get_unloaded_method_type_constant(ciSymbol* signature);
|
||||
|
||||
|
||||
ciInstance* get_unloaded_object_constant();
|
||||
|
||||
// Get the ciMethodData representing the methodData for a method
|
||||
// with none.
|
||||
ciMethodData* get_empty_methodData();
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "classfile/classLoaderData.hpp"
|
||||
#include "classfile/classLoaderData.inline.hpp"
|
||||
#include "classfile/defaultMethods.hpp"
|
||||
#include "classfile/genericSignatures.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
@ -3039,35 +3038,6 @@ AnnotationArray* ClassFileParser::assemble_annotations(u1* runtime_visible_annot
|
||||
return annotations;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ASSERT
|
||||
static void parseAndPrintGenericSignatures(
|
||||
instanceKlassHandle this_klass, TRAPS) {
|
||||
assert(ParseAllGenericSignatures == true, "Shouldn't call otherwise");
|
||||
ResourceMark rm;
|
||||
|
||||
if (this_klass->generic_signature() != NULL) {
|
||||
using namespace generic;
|
||||
ClassDescriptor* spec = ClassDescriptor::parse_generic_signature(this_klass(), CHECK);
|
||||
|
||||
tty->print_cr("Parsing %s", this_klass->generic_signature()->as_C_string());
|
||||
spec->print_on(tty);
|
||||
|
||||
for (int i = 0; i < this_klass->methods()->length(); ++i) {
|
||||
Method* m = this_klass->methods()->at(i);
|
||||
MethodDescriptor* method_spec = MethodDescriptor::parse_generic_signature(m, spec);
|
||||
Symbol* sig = m->generic_signature();
|
||||
if (sig == NULL) {
|
||||
sig = m->signature();
|
||||
}
|
||||
tty->print_cr("Parsing %s", sig->as_C_string());
|
||||
method_spec->print_on(tty);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // def ASSERT
|
||||
|
||||
|
||||
instanceKlassHandle ClassFileParser::parse_super_class(int super_class_index,
|
||||
TRAPS) {
|
||||
instanceKlassHandle super_klass;
|
||||
@ -4060,12 +4030,6 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
|
||||
java_lang_Class::create_mirror(this_klass, protection_domain, CHECK_(nullHandle));
|
||||
|
||||
|
||||
#ifdef ASSERT
|
||||
if (ParseAllGenericSignatures) {
|
||||
parseAndPrintGenericSignatures(this_klass, CHECK_(nullHandle));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Generate any default methods - default methods are interface methods
|
||||
// that have a default implementation. This is new with Lambda project.
|
||||
if (has_default_methods && !access_flags.is_interface() &&
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -197,7 +197,7 @@ ClassPathDirEntry::ClassPathDirEntry(char* dir) : ClassPathEntry() {
|
||||
}
|
||||
|
||||
|
||||
ClassFileStream* ClassPathDirEntry::open_stream(const char* name) {
|
||||
ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) {
|
||||
// construct full path name
|
||||
char path[JVM_MAXPATHLEN];
|
||||
if (jio_snprintf(path, sizeof(path), "%s%s%s", _dir, os::file_separator(), name) == -1) {
|
||||
@ -240,7 +240,7 @@ ClassPathZipEntry::~ClassPathZipEntry() {
|
||||
FREE_C_HEAP_ARRAY(char, _zip_name, mtClass);
|
||||
}
|
||||
|
||||
ClassFileStream* ClassPathZipEntry::open_stream(const char* name) {
|
||||
ClassFileStream* ClassPathZipEntry::open_stream(const char* name, TRAPS) {
|
||||
// enable call to C land
|
||||
JavaThread* thread = JavaThread::current();
|
||||
ThreadToNativeFromVM ttn(thread);
|
||||
@ -284,24 +284,24 @@ void ClassPathZipEntry::contents_do(void f(const char* name, void* context), voi
|
||||
}
|
||||
}
|
||||
|
||||
LazyClassPathEntry::LazyClassPathEntry(char* path, struct stat st) : ClassPathEntry() {
|
||||
LazyClassPathEntry::LazyClassPathEntry(char* path, const struct stat* st) : ClassPathEntry() {
|
||||
_path = strdup(path);
|
||||
_st = st;
|
||||
_st = *st;
|
||||
_meta_index = NULL;
|
||||
_resolved_entry = NULL;
|
||||
_has_error = false;
|
||||
}
|
||||
|
||||
bool LazyClassPathEntry::is_jar_file() {
|
||||
return ((_st.st_mode & S_IFREG) == S_IFREG);
|
||||
}
|
||||
|
||||
ClassPathEntry* LazyClassPathEntry::resolve_entry() {
|
||||
ClassPathEntry* LazyClassPathEntry::resolve_entry(TRAPS) {
|
||||
if (_resolved_entry != NULL) {
|
||||
return (ClassPathEntry*) _resolved_entry;
|
||||
}
|
||||
ClassPathEntry* new_entry = NULL;
|
||||
ClassLoader::create_class_path_entry(_path, _st, &new_entry, false);
|
||||
assert(new_entry != NULL, "earlier code should have caught this");
|
||||
new_entry = ClassLoader::create_class_path_entry(_path, &_st, false, CHECK_NULL);
|
||||
{
|
||||
ThreadCritical tc;
|
||||
if (_resolved_entry == NULL) {
|
||||
@ -314,12 +314,21 @@ ClassPathEntry* LazyClassPathEntry::resolve_entry() {
|
||||
return (ClassPathEntry*) _resolved_entry;
|
||||
}
|
||||
|
||||
ClassFileStream* LazyClassPathEntry::open_stream(const char* name) {
|
||||
ClassFileStream* LazyClassPathEntry::open_stream(const char* name, TRAPS) {
|
||||
if (_meta_index != NULL &&
|
||||
!_meta_index->may_contain(name)) {
|
||||
return NULL;
|
||||
}
|
||||
return resolve_entry()->open_stream(name);
|
||||
if (_has_error) {
|
||||
return NULL;
|
||||
}
|
||||
ClassPathEntry* cpe = resolve_entry(THREAD);
|
||||
if (cpe == NULL) {
|
||||
_has_error = true;
|
||||
return NULL;
|
||||
} else {
|
||||
return cpe->open_stream(name, THREAD);
|
||||
}
|
||||
}
|
||||
|
||||
bool LazyClassPathEntry::is_lazy() {
|
||||
@ -465,20 +474,19 @@ void ClassLoader::setup_bootstrap_search_path() {
|
||||
}
|
||||
}
|
||||
|
||||
void ClassLoader::create_class_path_entry(char *path, struct stat st, ClassPathEntry **new_entry, bool lazy) {
|
||||
ClassPathEntry* ClassLoader::create_class_path_entry(char *path, const struct stat* st, bool lazy, TRAPS) {
|
||||
JavaThread* thread = JavaThread::current();
|
||||
if (lazy) {
|
||||
*new_entry = new LazyClassPathEntry(path, st);
|
||||
return;
|
||||
return new LazyClassPathEntry(path, st);
|
||||
}
|
||||
if ((st.st_mode & S_IFREG) == S_IFREG) {
|
||||
ClassPathEntry* new_entry = NULL;
|
||||
if ((st->st_mode & S_IFREG) == S_IFREG) {
|
||||
// Regular file, should be a zip file
|
||||
// Canonicalized filename
|
||||
char canonical_path[JVM_MAXPATHLEN];
|
||||
if (!get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
|
||||
// This matches the classic VM
|
||||
EXCEPTION_MARK;
|
||||
THROW_MSG(vmSymbols::java_io_IOException(), "Bad pathname");
|
||||
THROW_MSG_(vmSymbols::java_io_IOException(), "Bad pathname", NULL);
|
||||
}
|
||||
char* error_msg = NULL;
|
||||
jzfile* zip;
|
||||
@ -489,7 +497,7 @@ void ClassLoader::create_class_path_entry(char *path, struct stat st, ClassPathE
|
||||
zip = (*ZipOpen)(canonical_path, &error_msg);
|
||||
}
|
||||
if (zip != NULL && error_msg == NULL) {
|
||||
*new_entry = new ClassPathZipEntry(zip, path);
|
||||
new_entry = new ClassPathZipEntry(zip, path);
|
||||
if (TraceClassLoading) {
|
||||
tty->print_cr("[Opened %s]", path);
|
||||
}
|
||||
@ -504,16 +512,16 @@ void ClassLoader::create_class_path_entry(char *path, struct stat st, ClassPathE
|
||||
msg = NEW_RESOURCE_ARRAY(char, len); ;
|
||||
jio_snprintf(msg, len - 1, "error in opening JAR file <%s> %s", error_msg, path);
|
||||
}
|
||||
EXCEPTION_MARK;
|
||||
THROW_MSG(vmSymbols::java_lang_ClassNotFoundException(), msg);
|
||||
THROW_MSG_(vmSymbols::java_lang_ClassNotFoundException(), msg, NULL);
|
||||
}
|
||||
} else {
|
||||
// Directory
|
||||
*new_entry = new ClassPathDirEntry(path);
|
||||
new_entry = new ClassPathDirEntry(path);
|
||||
if (TraceClassLoading) {
|
||||
tty->print_cr("[Path %s]", path);
|
||||
}
|
||||
}
|
||||
return new_entry;
|
||||
}
|
||||
|
||||
|
||||
@ -572,13 +580,14 @@ void ClassLoader::add_to_list(ClassPathEntry *new_entry) {
|
||||
}
|
||||
}
|
||||
|
||||
void ClassLoader::update_class_path_entry_list(const char *path,
|
||||
void ClassLoader::update_class_path_entry_list(char *path,
|
||||
bool check_for_duplicates) {
|
||||
struct stat st;
|
||||
if (os::stat((char *)path, &st) == 0) {
|
||||
if (os::stat(path, &st) == 0) {
|
||||
// File or directory found
|
||||
ClassPathEntry* new_entry = NULL;
|
||||
create_class_path_entry((char *)path, st, &new_entry, LazyBootClassLoader);
|
||||
Thread* THREAD = Thread::current();
|
||||
new_entry = create_class_path_entry(path, &st, LazyBootClassLoader, CHECK);
|
||||
// The kernel VM adds dynamically to the end of the classloader path and
|
||||
// doesn't reorder the bootclasspath which would break java.lang.Package
|
||||
// (see PackageInfo).
|
||||
@ -897,7 +906,7 @@ instanceKlassHandle ClassLoader::load_classfile(Symbol* h_name, TRAPS) {
|
||||
PerfClassTraceTime::CLASS_LOAD);
|
||||
ClassPathEntry* e = _first_entry;
|
||||
while (e != NULL) {
|
||||
stream = e->open_stream(name);
|
||||
stream = e->open_stream(name, CHECK_NULL);
|
||||
if (stream != NULL) {
|
||||
break;
|
||||
}
|
||||
@ -1257,11 +1266,16 @@ bool ClassPathZipEntry::is_rt_jar12() {
|
||||
}
|
||||
|
||||
void LazyClassPathEntry::compile_the_world(Handle loader, TRAPS) {
|
||||
resolve_entry()->compile_the_world(loader, CHECK);
|
||||
ClassPathEntry* cpe = resolve_entry(THREAD);
|
||||
if (cpe != NULL) {
|
||||
cpe->compile_the_world(loader, CHECK);
|
||||
}
|
||||
}
|
||||
|
||||
bool LazyClassPathEntry::is_rt_jar() {
|
||||
return resolve_entry()->is_rt_jar();
|
||||
Thread* THREAD = Thread::current();
|
||||
ClassPathEntry* cpe = resolve_entry(THREAD);
|
||||
return (cpe != NULL) ? cpe->is_jar_file() : false;
|
||||
}
|
||||
|
||||
void ClassLoader::compile_the_world() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -63,7 +63,7 @@ class ClassPathEntry: public CHeapObj<mtClass> {
|
||||
ClassPathEntry();
|
||||
// Attempt to locate file_name through this class path entry.
|
||||
// Returns a class file parsing stream if successfull.
|
||||
virtual ClassFileStream* open_stream(const char* name) = 0;
|
||||
virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0;
|
||||
// Debugging
|
||||
NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;)
|
||||
NOT_PRODUCT(virtual bool is_rt_jar() = 0;)
|
||||
@ -77,7 +77,7 @@ class ClassPathDirEntry: public ClassPathEntry {
|
||||
bool is_jar_file() { return false; }
|
||||
const char* name() { return _dir; }
|
||||
ClassPathDirEntry(char* dir);
|
||||
ClassFileStream* open_stream(const char* name);
|
||||
ClassFileStream* open_stream(const char* name, TRAPS);
|
||||
// Debugging
|
||||
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
|
||||
NOT_PRODUCT(bool is_rt_jar();)
|
||||
@ -107,7 +107,7 @@ class ClassPathZipEntry: public ClassPathEntry {
|
||||
const char* name() { return _zip_name; }
|
||||
ClassPathZipEntry(jzfile* zip, const char* zip_name);
|
||||
~ClassPathZipEntry();
|
||||
ClassFileStream* open_stream(const char* name);
|
||||
ClassFileStream* open_stream(const char* name, TRAPS);
|
||||
void contents_do(void f(const char* name, void* context), void* context);
|
||||
// Debugging
|
||||
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
|
||||
@ -125,13 +125,14 @@ class LazyClassPathEntry: public ClassPathEntry {
|
||||
char* _path; // dir or file
|
||||
struct stat _st;
|
||||
MetaIndex* _meta_index;
|
||||
bool _has_error;
|
||||
volatile ClassPathEntry* _resolved_entry;
|
||||
ClassPathEntry* resolve_entry();
|
||||
ClassPathEntry* resolve_entry(TRAPS);
|
||||
public:
|
||||
bool is_jar_file();
|
||||
const char* name() { return _path; }
|
||||
LazyClassPathEntry(char* path, struct stat st);
|
||||
ClassFileStream* open_stream(const char* name);
|
||||
LazyClassPathEntry(char* path, const struct stat* st);
|
||||
ClassFileStream* open_stream(const char* name, TRAPS);
|
||||
void set_meta_index(MetaIndex* meta_index) { _meta_index = meta_index; }
|
||||
virtual bool is_lazy();
|
||||
// Debugging
|
||||
@ -207,14 +208,15 @@ class ClassLoader: AllStatic {
|
||||
static void setup_meta_index();
|
||||
static void setup_bootstrap_search_path();
|
||||
static void load_zip_library();
|
||||
static void create_class_path_entry(char *path, struct stat st, ClassPathEntry **new_entry, bool lazy);
|
||||
static ClassPathEntry* create_class_path_entry(char *path, const struct stat* st,
|
||||
bool lazy, TRAPS);
|
||||
|
||||
// Canonicalizes path names, so strcmp will work properly. This is mainly
|
||||
// to avoid confusing the zip library
|
||||
static bool get_canonical_path(char* orig, char* out, int len);
|
||||
public:
|
||||
// Used by the kernel jvm.
|
||||
static void update_class_path_entry_list(const char *path,
|
||||
static void update_class_path_entry_list(char *path,
|
||||
bool check_for_duplicates);
|
||||
static void print_bootclasspath();
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/bytecodeAssembler.hpp"
|
||||
#include "classfile/defaultMethods.hpp"
|
||||
#include "classfile/genericSignatures.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/metadataFactory.hpp"
|
||||
@ -75,14 +74,6 @@ class PseudoScope : public ResourceObj {
|
||||
}
|
||||
};
|
||||
|
||||
class ContextMark : public PseudoScopeMark {
|
||||
private:
|
||||
generic::Context::Mark _mark;
|
||||
public:
|
||||
ContextMark(const generic::Context::Mark& cm) : _mark(cm) {}
|
||||
virtual void destroy() { _mark.destroy(); }
|
||||
};
|
||||
|
||||
#ifndef PRODUCT
|
||||
static void print_slot(outputStream* str, Symbol* name, Symbol* signature) {
|
||||
ResourceMark rm;
|
||||
@ -503,38 +494,6 @@ Symbol* MethodFamily::generate_conflicts_message(GrowableArray<Method*>* methods
|
||||
return SymbolTable::new_symbol(ss.base(), (int)ss.size(), CHECK_NULL);
|
||||
}
|
||||
|
||||
// A generic method family contains a set of all methods that implement a single
|
||||
// language-level method. Because of erasure, these methods may have different
|
||||
// signatures. As members of the set are collected while walking over the
|
||||
// hierarchy, they are tagged with a qualification state. The qualification
|
||||
// state for an erased method is set to disqualified if there exists a path
|
||||
// from the root of hierarchy to the method that contains an interleaving
|
||||
// language-equivalent method defined in an interface.
|
||||
class GenericMethodFamily : public MethodFamily {
|
||||
private:
|
||||
|
||||
generic::MethodDescriptor* _descriptor; // language-level description
|
||||
|
||||
public:
|
||||
|
||||
GenericMethodFamily(generic::MethodDescriptor* canonical_desc)
|
||||
: _descriptor(canonical_desc) {}
|
||||
|
||||
generic::MethodDescriptor* descriptor() const { return _descriptor; }
|
||||
|
||||
bool descriptor_matches(generic::MethodDescriptor* md, generic::Context* ctx) {
|
||||
return descriptor()->covariant_match(md, ctx);
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
Symbol* get_generic_sig() const {
|
||||
|
||||
generic::Context ctx(NULL); // empty, as _descriptor already canonicalized
|
||||
TempNewSymbol sig = descriptor()->reify_signature(&ctx, Thread::current());
|
||||
return sig;
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
};
|
||||
|
||||
class StateRestorer;
|
||||
|
||||
@ -571,26 +530,6 @@ class StatefulMethodFamily : public ResourceObj {
|
||||
StateRestorer* record_method_and_dq_further(Method* mo);
|
||||
};
|
||||
|
||||
|
||||
// StatefulGenericMethodFamily is a wrapper around GenericMethodFamily that maintains the
|
||||
// qualification state during hierarchy visitation, and applies that state
|
||||
// when adding members to the GenericMethodFamily.
|
||||
class StatefulGenericMethodFamily : public StatefulMethodFamily {
|
||||
|
||||
public:
|
||||
StatefulGenericMethodFamily(generic::MethodDescriptor* md, generic::Context* ctx)
|
||||
: StatefulMethodFamily(new GenericMethodFamily(md->canonicalize(ctx))) {
|
||||
|
||||
}
|
||||
GenericMethodFamily* get_method_family() {
|
||||
return (GenericMethodFamily*)_method_family;
|
||||
}
|
||||
|
||||
bool descriptor_matches(generic::MethodDescriptor* md, generic::Context* ctx) {
|
||||
return get_method_family()->descriptor_matches(md, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
class StateRestorer : public PseudoScopeMark {
|
||||
private:
|
||||
StatefulMethodFamily* _method;
|
||||
@ -616,39 +555,6 @@ StateRestorer* StatefulMethodFamily::record_method_and_dq_further(Method* mo) {
|
||||
return mark;
|
||||
}
|
||||
|
||||
class StatefulGenericMethodFamilies : public ResourceObj {
|
||||
private:
|
||||
GrowableArray<StatefulGenericMethodFamily*> _methods;
|
||||
|
||||
public:
|
||||
StatefulGenericMethodFamily* find_matching(
|
||||
generic::MethodDescriptor* md, generic::Context* ctx) {
|
||||
for (int i = 0; i < _methods.length(); ++i) {
|
||||
StatefulGenericMethodFamily* existing = _methods.at(i);
|
||||
if (existing->descriptor_matches(md, ctx)) {
|
||||
return existing;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
StatefulGenericMethodFamily* find_matching_or_create(
|
||||
generic::MethodDescriptor* md, generic::Context* ctx) {
|
||||
StatefulGenericMethodFamily* method = find_matching(md, ctx);
|
||||
if (method == NULL) {
|
||||
method = new StatefulGenericMethodFamily(md, ctx);
|
||||
_methods.append(method);
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
void extract_families_into(GrowableArray<GenericMethodFamily*>* array) {
|
||||
for (int i = 0; i < _methods.length(); ++i) {
|
||||
array->append(_methods.at(i)->get_method_family());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Represents a location corresponding to a vtable slot for methods that
|
||||
// neither the class nor any of it's ancestors provide an implementaion.
|
||||
// Default methods may be present to fill this slot.
|
||||
@ -779,146 +685,11 @@ class FindMethodsByErasedSig : public HierarchyVisitor<FindMethodsByErasedSig> {
|
||||
|
||||
};
|
||||
|
||||
// Iterates over the type hierarchy looking for all methods with a specific
|
||||
// method name. The result of this is a set of method families each of
|
||||
// which is populated with a set of methods that implement the same
|
||||
// language-level signature.
|
||||
class FindMethodsByGenericSig : public HierarchyVisitor<FindMethodsByGenericSig> {
|
||||
private:
|
||||
// Context data
|
||||
Thread* THREAD;
|
||||
generic::DescriptorCache* _cache;
|
||||
Symbol* _method_name;
|
||||
generic::Context* _ctx;
|
||||
StatefulGenericMethodFamilies _families;
|
||||
|
||||
public:
|
||||
|
||||
FindMethodsByGenericSig(generic::DescriptorCache* cache, Symbol* name,
|
||||
generic::Context* ctx, Thread* thread) :
|
||||
_cache(cache), _method_name(name), _ctx(ctx), THREAD(thread) {}
|
||||
|
||||
void get_discovered_families(GrowableArray<GenericMethodFamily*>* methods) {
|
||||
_families.extract_families_into(methods);
|
||||
}
|
||||
|
||||
void* new_node_data(InstanceKlass* cls) { return new PseudoScope(); }
|
||||
void free_node_data(void* node_data) {
|
||||
PseudoScope::cast(node_data)->destroy();
|
||||
}
|
||||
|
||||
bool visit() {
|
||||
PseudoScope* scope = PseudoScope::cast(current_data());
|
||||
InstanceKlass* klass = current_class();
|
||||
InstanceKlass* sub = current_depth() > 0 ? class_at_depth(1) : NULL;
|
||||
|
||||
ContextMark* cm = new ContextMark(_ctx->mark());
|
||||
scope->add_mark(cm); // will restore context when scope is freed
|
||||
|
||||
_ctx->apply_type_arguments(sub, klass, THREAD);
|
||||
|
||||
int start, end = 0;
|
||||
start = klass->find_method_by_name(_method_name, &end);
|
||||
if (start != -1) {
|
||||
for (int i = start; i < end; ++i) {
|
||||
Method* m = klass->methods()->at(i);
|
||||
// This gets the method's parameter list with its generic type
|
||||
// parameters resolved
|
||||
generic::MethodDescriptor* md = _cache->descriptor_for(m, THREAD);
|
||||
|
||||
// Find all methods on this hierarchy that match this method
|
||||
// (name, signature). This class collects other families of this
|
||||
// method name.
|
||||
StatefulGenericMethodFamily* family =
|
||||
_families.find_matching_or_create(md, _ctx);
|
||||
|
||||
if (klass->is_interface()) {
|
||||
// ???
|
||||
StateRestorer* restorer = family->record_method_and_dq_further(m);
|
||||
scope->add_mark(restorer);
|
||||
} else {
|
||||
// This is the rule that methods in classes "win" (bad word) over
|
||||
// methods in interfaces. This works because of single inheritance
|
||||
family->set_target_if_empty(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef PRODUCT
|
||||
static void print_generic_families(
|
||||
GrowableArray<GenericMethodFamily*>* methods, Symbol* match) {
|
||||
streamIndentor si(tty, 4);
|
||||
if (methods->length() == 0) {
|
||||
tty->indent();
|
||||
tty->print_cr("No Logical Method found");
|
||||
}
|
||||
for (int i = 0; i < methods->length(); ++i) {
|
||||
tty->indent();
|
||||
GenericMethodFamily* lm = methods->at(i);
|
||||
if (lm->contains_signature(match)) {
|
||||
tty->print_cr("<Matching>");
|
||||
} else {
|
||||
tty->print_cr("<Non-Matching>");
|
||||
}
|
||||
lm->print_sig_on(tty, lm->get_generic_sig(), 1);
|
||||
}
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
|
||||
static void create_overpasses(
|
||||
GrowableArray<EmptyVtableSlot*>* slots, InstanceKlass* klass, TRAPS);
|
||||
|
||||
static void generate_generic_defaults(
|
||||
InstanceKlass* klass, GrowableArray<EmptyVtableSlot*>* empty_slots,
|
||||
EmptyVtableSlot* slot, int current_slot_index, TRAPS) {
|
||||
|
||||
if (slot->is_bound()) {
|
||||
#ifndef PRODUCT
|
||||
if (TraceDefaultMethods) {
|
||||
streamIndentor si(tty, 4);
|
||||
tty->indent().print_cr("Already bound to logical method:");
|
||||
GenericMethodFamily* lm = (GenericMethodFamily*)(slot->get_binding());
|
||||
lm->print_sig_on(tty, lm->get_generic_sig(), 1);
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
return; // covered by previous processing
|
||||
}
|
||||
|
||||
generic::DescriptorCache cache;
|
||||
|
||||
generic::Context ctx(&cache);
|
||||
FindMethodsByGenericSig visitor(&cache, slot->name(), &ctx, CHECK);
|
||||
visitor.run(klass);
|
||||
|
||||
GrowableArray<GenericMethodFamily*> discovered_families;
|
||||
visitor.get_discovered_families(&discovered_families);
|
||||
|
||||
#ifndef PRODUCT
|
||||
if (TraceDefaultMethods) {
|
||||
print_generic_families(&discovered_families, slot->signature());
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
|
||||
// Find and populate any other slots that match the discovered families
|
||||
for (int j = current_slot_index; j < empty_slots->length(); ++j) {
|
||||
EmptyVtableSlot* open_slot = empty_slots->at(j);
|
||||
|
||||
if (slot->name() == open_slot->name()) {
|
||||
for (int k = 0; k < discovered_families.length(); ++k) {
|
||||
GenericMethodFamily* lm = discovered_families.at(k);
|
||||
|
||||
if (lm->contains_signature(open_slot->signature())) {
|
||||
lm->determine_target(klass, CHECK);
|
||||
open_slot->bind_family(lm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void generate_erased_defaults(
|
||||
InstanceKlass* klass, GrowableArray<EmptyVtableSlot*>* empty_slots,
|
||||
EmptyVtableSlot* slot, TRAPS) {
|
||||
@ -943,21 +714,14 @@ static void merge_in_new_methods(InstanceKlass* klass,
|
||||
//
|
||||
// First if finds any name/signature slots that need any implementation (either
|
||||
// because they are miranda or a superclass's implementation is an overpass
|
||||
// itself). For each slot, iterate over the hierarchy, using generic signature
|
||||
// information to partition any methods that match the name into method families
|
||||
// where each family contains methods whose signatures are equivalent at the
|
||||
// language level (i.e., their reified parameters match and return values are
|
||||
// covariant). Check those sets to see if they contain a signature that matches
|
||||
// the slot we're looking at (if we're lucky, there might be other empty slots
|
||||
// that we can fill using the same analysis).
|
||||
// itself). For each slot, iterate over the hierarchy, to see if they contain a
|
||||
// signature that matches the slot we are looking at.
|
||||
//
|
||||
// For each slot filled, we generate an overpass method that either calls the
|
||||
// unique default method candidate using invokespecial, or throws an exception
|
||||
// (in the case of no default method candidates, or more than one valid
|
||||
// candidate). These methods are then added to the class's method list. If
|
||||
// the method set we're using contains methods (qualified or not) with a
|
||||
// different runtime signature than the method we're creating, then we have to
|
||||
// create bridges with those signatures too.
|
||||
// candidate). These methods are then added to the class's method list.
|
||||
// The JVM does not create bridges nor handle generic signatures here.
|
||||
void DefaultMethods::generate_default_methods(
|
||||
InstanceKlass* klass, GrowableArray<Method*>* mirandas, TRAPS) {
|
||||
|
||||
@ -997,11 +761,7 @@ void DefaultMethods::generate_default_methods(
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
|
||||
if (ParseGenericDefaults) {
|
||||
generate_generic_defaults(klass, empty_slots, slot, i, CHECK);
|
||||
} else {
|
||||
generate_erased_defaults(klass, empty_slots, slot, CHECK);
|
||||
}
|
||||
generate_erased_defaults(klass, empty_slots, slot, CHECK);
|
||||
}
|
||||
#ifndef PRODUCT
|
||||
if (TraceDefaultMethods) {
|
||||
@ -1019,13 +779,13 @@ void DefaultMethods::generate_default_methods(
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic analysis was used upon interface '_target' and found a unique
|
||||
* default method candidate with generic signature '_method_desc'. This
|
||||
* Interface inheritance rules were used to find a unique default method
|
||||
* candidate for the resolved class. This
|
||||
* method is only viable if it would also be in the set of default method
|
||||
* candidates if we ran a full analysis on the current class.
|
||||
*
|
||||
* The only reason that the method would not be in the set of candidates for
|
||||
* the current class is if that there's another covariantly matching method
|
||||
* the current class is if that there's another matching method
|
||||
* which is "more specific" than the found method -- i.e., one could find a
|
||||
* path in the interface hierarchy in which the matching method appears
|
||||
* before we get to '_target'.
|
||||
@ -1110,49 +870,6 @@ class ErasedShadowChecker : public ShadowChecker {
|
||||
: ShadowChecker(thread, name, holder, target) {}
|
||||
};
|
||||
|
||||
class GenericShadowChecker : public ShadowChecker {
|
||||
private:
|
||||
generic::DescriptorCache* _cache;
|
||||
generic::MethodDescriptor* _method_desc;
|
||||
|
||||
bool path_has_shadow() {
|
||||
generic::Context ctx(_cache);
|
||||
|
||||
for (int i = current_depth() - 1; i > 0; --i) {
|
||||
InstanceKlass* ik = class_at_depth(i);
|
||||
InstanceKlass* sub = class_at_depth(i + 1);
|
||||
ctx.apply_type_arguments(sub, ik, THREAD);
|
||||
|
||||
if (ik->is_interface()) {
|
||||
int end;
|
||||
int start = ik->find_method_by_name(_method_name, &end);
|
||||
if (start != -1) {
|
||||
for (int j = start; j < end; ++j) {
|
||||
Method* mo = ik->methods()->at(j);
|
||||
generic::MethodDescriptor* md = _cache->descriptor_for(mo, THREAD);
|
||||
if (_method_desc->covariant_match(md, &ctx)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
GenericShadowChecker(generic::DescriptorCache* cache, Thread* thread,
|
||||
Symbol* name, InstanceKlass* holder, generic::MethodDescriptor* desc,
|
||||
InstanceKlass* target)
|
||||
: ShadowChecker(thread, name, holder, target) {
|
||||
_cache = cache;
|
||||
_method_desc = desc;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Find the unique qualified candidate from the perspective of the super_class
|
||||
// which is the resolved_klass, which must be an immediate superinterface
|
||||
// of klass
|
||||
@ -1166,103 +883,48 @@ Method* find_erased_super_default(InstanceKlass* current_class, InstanceKlass* s
|
||||
|
||||
if (family != NULL) {
|
||||
family->determine_target(current_class, CHECK_NULL); // get target from current_class
|
||||
}
|
||||
|
||||
if (family->has_target()) {
|
||||
Method* target = family->get_selected_target();
|
||||
InstanceKlass* holder = InstanceKlass::cast(target->method_holder());
|
||||
if (family->has_target()) {
|
||||
Method* target = family->get_selected_target();
|
||||
InstanceKlass* holder = InstanceKlass::cast(target->method_holder());
|
||||
|
||||
// Verify that the identified method is valid from the context of
|
||||
// the current class, which is the caller class for invokespecial
|
||||
// link resolution, i.e. ensure there it is not shadowed.
|
||||
// You can use invokespecial to disambiguate interface methods, but
|
||||
// you can not use it to skip over an interface method that would shadow it.
|
||||
ErasedShadowChecker checker(THREAD, target->name(), holder, super_class);
|
||||
checker.run(current_class);
|
||||
// Verify that the identified method is valid from the context of
|
||||
// the current class, which is the caller class for invokespecial
|
||||
// link resolution, i.e. ensure there it is not shadowed.
|
||||
// You can use invokespecial to disambiguate interface methods, but
|
||||
// you can not use it to skip over an interface method that would shadow it.
|
||||
ErasedShadowChecker checker(THREAD, target->name(), holder, super_class);
|
||||
checker.run(current_class);
|
||||
|
||||
if (checker.found_shadow()) {
|
||||
if (checker.found_shadow()) {
|
||||
#ifndef PRODUCT
|
||||
if (TraceDefaultMethods) {
|
||||
tty->print_cr(" Only candidate found was shadowed.");
|
||||
}
|
||||
if (TraceDefaultMethods) {
|
||||
tty->print_cr(" Only candidate found was shadowed.");
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
THROW_MSG_(vmSymbols::java_lang_AbstractMethodError(),
|
||||
"Accessible default method not found", NULL);
|
||||
THROW_MSG_(vmSymbols::java_lang_AbstractMethodError(),
|
||||
"Accessible default method not found", NULL);
|
||||
} else {
|
||||
#ifndef PRODUCT
|
||||
if (TraceDefaultMethods) {
|
||||
family->print_sig_on(tty, target->signature(), 1);
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
return target;
|
||||
}
|
||||
} else {
|
||||
#ifndef PRODUCT
|
||||
if (TraceDefaultMethods) {
|
||||
family->print_sig_on(tty, target->signature(), 1);
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
return target;
|
||||
}
|
||||
assert(family->throws_exception(), "must have target or throw");
|
||||
THROW_MSG_(vmSymbols::java_lang_AbstractMethodError(),
|
||||
family->get_exception_message()->as_C_string(), NULL);
|
||||
}
|
||||
} else {
|
||||
assert(family->throws_exception(), "must have target or throw");
|
||||
THROW_MSG_(vmSymbols::java_lang_AbstractMethodError(),
|
||||
family->get_exception_message()->as_C_string(), NULL);
|
||||
// no method found
|
||||
ResourceMark rm(THREAD);
|
||||
THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(),
|
||||
Method::name_and_sig_as_C_string(current_class,
|
||||
method_name, sig), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// super_class is assumed to be the direct super of current_class
|
||||
Method* find_generic_super_default( InstanceKlass* current_class,
|
||||
InstanceKlass* super_class,
|
||||
Symbol* method_name, Symbol* sig, TRAPS) {
|
||||
generic::DescriptorCache cache;
|
||||
generic::Context ctx(&cache);
|
||||
|
||||
// Prime the initial generic context for current -> super_class
|
||||
ctx.apply_type_arguments(current_class, super_class, CHECK_NULL);
|
||||
|
||||
FindMethodsByGenericSig visitor(&cache, method_name, &ctx, CHECK_NULL);
|
||||
visitor.run(super_class);
|
||||
|
||||
GrowableArray<GenericMethodFamily*> families;
|
||||
visitor.get_discovered_families(&families);
|
||||
|
||||
#ifndef PRODUCT
|
||||
if (TraceDefaultMethods) {
|
||||
print_generic_families(&families, sig);
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
|
||||
GenericMethodFamily* selected_family = NULL;
|
||||
|
||||
for (int i = 0; i < families.length(); ++i) {
|
||||
GenericMethodFamily* lm = families.at(i);
|
||||
if (lm->contains_signature(sig)) {
|
||||
lm->determine_target(current_class, CHECK_NULL);
|
||||
selected_family = lm;
|
||||
}
|
||||
}
|
||||
|
||||
if (selected_family->has_target()) {
|
||||
Method* target = selected_family->get_selected_target();
|
||||
InstanceKlass* holder = InstanceKlass::cast(target->method_holder());
|
||||
|
||||
// Verify that the identified method is valid from the context of
|
||||
// the current class
|
||||
GenericShadowChecker checker(&cache, THREAD, target->name(),
|
||||
holder, selected_family->descriptor(), super_class);
|
||||
checker.run(current_class);
|
||||
|
||||
if (checker.found_shadow()) {
|
||||
#ifndef PRODUCT
|
||||
if (TraceDefaultMethods) {
|
||||
tty->print_cr(" Only candidate found was shadowed.");
|
||||
}
|
||||
#endif // ndef PRODUCT
|
||||
THROW_MSG_(vmSymbols::java_lang_AbstractMethodError(),
|
||||
"Accessible default method not found", NULL);
|
||||
} else {
|
||||
return target;
|
||||
}
|
||||
} else {
|
||||
assert(selected_family->throws_exception(), "must have target or throw");
|
||||
THROW_MSG_(vmSymbols::java_lang_AbstractMethodError(),
|
||||
selected_family->get_exception_message()->as_C_string(), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// This is called during linktime when we find an invokespecial call that
|
||||
// refers to a direct superinterface. It indicates that we should find the
|
||||
// default method in the hierarchy of that superinterface, and if that method
|
||||
@ -1296,13 +958,8 @@ Method* DefaultMethods::find_super_default(
|
||||
assert(super_class->is_interface(), "only call for default methods");
|
||||
|
||||
Method* target = NULL;
|
||||
if (ParseGenericDefaults) {
|
||||
target = find_generic_super_default(current_class, super_class,
|
||||
method_name, sig, CHECK_NULL);
|
||||
} else {
|
||||
target = find_erased_super_default(current_class, super_class,
|
||||
method_name, sig, CHECK_NULL);
|
||||
}
|
||||
target = find_erased_super_default(current_class, super_class,
|
||||
method_name, sig, CHECK_NULL);
|
||||
|
||||
#ifndef PRODUCT
|
||||
if (target != NULL) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,467 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_VM_CLASSFILE_GENERICSIGNATURES_HPP
|
||||
#define SHARE_VM_CLASSFILE_GENERICSIGNATURES_HPP
|
||||
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "runtime/signature.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
#include "utilities/resourceHash.hpp"
|
||||
|
||||
class stringStream;
|
||||
|
||||
namespace generic {
|
||||
|
||||
class Identifier;
|
||||
class ClassDescriptor;
|
||||
class MethodDescriptor;
|
||||
|
||||
class TypeParameter; // a formal type parameter declared in generic signatures
|
||||
class TypeArgument; // The "type value" passed to fill parameters in supertypes
|
||||
class TypeVariable; // A usage of a type parameter as a value
|
||||
/**
|
||||
* Example:
|
||||
*
|
||||
* <T, V> class Foo extends Bar<String> { int m(V v) {} }
|
||||
* ^^^^^^ ^^^^^^ ^^
|
||||
* type parameters type argument type variable
|
||||
*
|
||||
* Note that a type variable could be passed as an argument too:
|
||||
* <T, V> class Foo extends Bar<T> { int m(V v) {} }
|
||||
* ^^^
|
||||
* type argument's value is a type variable
|
||||
*/
|
||||
|
||||
|
||||
class Type;
|
||||
class ClassType;
|
||||
class ArrayType;
|
||||
class PrimitiveType;
|
||||
class Context;
|
||||
class DescriptorCache;
|
||||
|
||||
class DescriptorStream;
|
||||
|
||||
class Identifier : public ResourceObj {
|
||||
private:
|
||||
Symbol* _sym;
|
||||
int _begin;
|
||||
int _end;
|
||||
|
||||
public:
|
||||
Identifier(Symbol* sym, int begin, int end) :
|
||||
_sym(sym), _begin(begin), _end(end) {}
|
||||
|
||||
bool equals(Identifier* other);
|
||||
bool equals(Symbol* sym);
|
||||
|
||||
#ifndef PRODUCT
|
||||
void print_on(outputStream* str) const;
|
||||
#endif // ndef PRODUCT
|
||||
};
|
||||
|
||||
class Descriptor : public ResourceObj {
|
||||
protected:
|
||||
GrowableArray<TypeParameter*> _type_parameters;
|
||||
ClassDescriptor* _outer_class;
|
||||
|
||||
Descriptor(GrowableArray<TypeParameter*>& params,
|
||||
ClassDescriptor* outer)
|
||||
: _type_parameters(params), _outer_class(outer) {}
|
||||
|
||||
public:
|
||||
|
||||
ClassDescriptor* outer_class() { return _outer_class; }
|
||||
void set_outer_class(ClassDescriptor* sig) { _outer_class = sig; }
|
||||
|
||||
virtual ClassDescriptor* as_class_signature() { return NULL; }
|
||||
virtual MethodDescriptor* as_method_signature() { return NULL; }
|
||||
|
||||
bool is_class_signature() { return as_class_signature() != NULL; }
|
||||
bool is_method_signature() { return as_method_signature() != NULL; }
|
||||
|
||||
GrowableArray<TypeParameter*>& type_parameters() {
|
||||
return _type_parameters;
|
||||
}
|
||||
|
||||
TypeParameter* find_type_parameter(Identifier* id, int* param_depth);
|
||||
|
||||
virtual void bind_variables_to_parameters() = 0;
|
||||
|
||||
#ifndef PRODUCT
|
||||
virtual void print_on(outputStream* str) const = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
class ClassDescriptor : public Descriptor {
|
||||
private:
|
||||
ClassType* _super;
|
||||
GrowableArray<ClassType*> _interfaces;
|
||||
MethodDescriptor* _outer_method;
|
||||
|
||||
ClassDescriptor(GrowableArray<TypeParameter*>& ftp, ClassType* scs,
|
||||
GrowableArray<ClassType*>& sis, ClassDescriptor* outer_class = NULL,
|
||||
MethodDescriptor* outer_method = NULL)
|
||||
: Descriptor(ftp, outer_class), _super(scs), _interfaces(sis),
|
||||
_outer_method(outer_method) {}
|
||||
|
||||
static u2 get_outer_class_index(InstanceKlass* k, TRAPS);
|
||||
static ClassDescriptor* parse_generic_signature(Klass* k, Symbol* original_name, TRAPS);
|
||||
|
||||
public:
|
||||
|
||||
virtual ClassDescriptor* as_class_signature() { return this; }
|
||||
|
||||
MethodDescriptor* outer_method() { return _outer_method; }
|
||||
void set_outer_method(MethodDescriptor* m) { _outer_method = m; }
|
||||
|
||||
ClassType* super() { return _super; }
|
||||
ClassType* interface_desc(Symbol* sym);
|
||||
|
||||
static ClassDescriptor* parse_generic_signature(Klass* k, TRAPS);
|
||||
static ClassDescriptor* parse_generic_signature(Symbol* sym);
|
||||
|
||||
// For use in superclass chains in positions where this is no generic info
|
||||
static ClassDescriptor* placeholder(InstanceKlass* klass);
|
||||
|
||||
#ifndef PRODUCT
|
||||
void print_on(outputStream* str) const;
|
||||
#endif
|
||||
|
||||
ClassDescriptor* canonicalize(Context* ctx);
|
||||
|
||||
// Linking sets the position index in any contained TypeVariable type
|
||||
// to correspond to the location of that identifier in the formal type
|
||||
// parameters.
|
||||
void bind_variables_to_parameters();
|
||||
};
|
||||
|
||||
class MethodDescriptor : public Descriptor {
|
||||
private:
|
||||
GrowableArray<Type*> _parameters;
|
||||
Type* _return_type;
|
||||
GrowableArray<Type*> _throws;
|
||||
|
||||
MethodDescriptor(GrowableArray<TypeParameter*>& ftp, ClassDescriptor* outer,
|
||||
GrowableArray<Type*>& sigs, Type* rt, GrowableArray<Type*>& throws)
|
||||
: Descriptor(ftp, outer), _parameters(sigs), _return_type(rt),
|
||||
_throws(throws) {}
|
||||
|
||||
public:
|
||||
|
||||
static MethodDescriptor* parse_generic_signature(Method* m, ClassDescriptor* outer);
|
||||
static MethodDescriptor* parse_generic_signature(Symbol* sym, ClassDescriptor* outer);
|
||||
|
||||
MethodDescriptor* as_method_signature() { return this; }
|
||||
|
||||
// Performs generic analysis on the method parameters to determine
|
||||
// if both methods refer to the same argument types.
|
||||
bool covariant_match(MethodDescriptor* other, Context* ctx);
|
||||
|
||||
// Returns a new method descriptor with all generic variables
|
||||
// removed and replaced with whatever is indicated using the Context.
|
||||
MethodDescriptor* canonicalize(Context* ctx);
|
||||
|
||||
void bind_variables_to_parameters();
|
||||
|
||||
#ifndef PRODUCT
|
||||
TempNewSymbol reify_signature(Context* ctx, TRAPS);
|
||||
void print_on(outputStream* str) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
class TypeParameter : public ResourceObj {
|
||||
private:
|
||||
Identifier* _identifier;
|
||||
ClassType* _class_bound;
|
||||
GrowableArray<ClassType*> _interface_bounds;
|
||||
|
||||
// The position is the ordinal location of the parameter within the
|
||||
// formal parameter list (excluding outer classes). It is only set for
|
||||
// formal type parameters that are associated with a class -- method
|
||||
// type parameters are left as -1. When resolving a generic variable to
|
||||
// find the actual type, this index is used to access the generic type
|
||||
// argument in the provided context object.
|
||||
int _position; // Assigned during variable linking
|
||||
|
||||
TypeParameter(Identifier* id, ClassType* class_bound,
|
||||
GrowableArray<ClassType*>& interface_bounds) :
|
||||
_identifier(id), _class_bound(class_bound),
|
||||
_interface_bounds(interface_bounds), _position(-1) {}
|
||||
|
||||
public:
|
||||
static TypeParameter* parse_generic_signature(DescriptorStream* str);
|
||||
|
||||
ClassType* bound();
|
||||
int position() { return _position; }
|
||||
|
||||
void bind_variables_to_parameters(Descriptor* sig, int position);
|
||||
Identifier* identifier() { return _identifier; }
|
||||
|
||||
Type* resolve(Context* ctx, int inner_depth, int ctx_depth);
|
||||
TypeParameter* canonicalize(Context* ctx, int ctx_depth);
|
||||
|
||||
#ifndef PRODUCT
|
||||
void print_on(outputStream* str) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
class Type : public ResourceObj {
|
||||
public:
|
||||
static Type* parse_generic_signature(DescriptorStream* str);
|
||||
|
||||
virtual ClassType* as_class() { return NULL; }
|
||||
virtual TypeVariable* as_variable() { return NULL; }
|
||||
virtual ArrayType* as_array() { return NULL; }
|
||||
virtual PrimitiveType* as_primitive() { return NULL; }
|
||||
|
||||
virtual bool covariant_match(Type* gt, Context* ctx) = 0;
|
||||
virtual Type* canonicalize(Context* ctx, int ctx_depth) = 0;
|
||||
|
||||
virtual void bind_variables_to_parameters(Descriptor* sig) = 0;
|
||||
|
||||
#ifndef PRODUCT
|
||||
virtual void reify_signature(stringStream* ss, Context* ctx) = 0;
|
||||
virtual void print_on(outputStream* str) const = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
class ClassType : public Type {
|
||||
friend class ClassDescriptor;
|
||||
protected:
|
||||
Identifier* _identifier;
|
||||
GrowableArray<TypeArgument*> _type_arguments;
|
||||
ClassType* _outer_class;
|
||||
|
||||
ClassType(Identifier* identifier,
|
||||
GrowableArray<TypeArgument*>& args,
|
||||
ClassType* outer)
|
||||
: _identifier(identifier), _type_arguments(args), _outer_class(outer) {}
|
||||
|
||||
// Returns true if there are inner classes to read
|
||||
static Identifier* parse_generic_signature_simple(
|
||||
GrowableArray<TypeArgument*>* args,
|
||||
bool* has_inner, DescriptorStream* str);
|
||||
|
||||
static ClassType* parse_generic_signature(ClassType* outer,
|
||||
DescriptorStream* str);
|
||||
static ClassType* from_symbol(Symbol* sym);
|
||||
|
||||
public:
|
||||
ClassType* as_class() { return this; }
|
||||
|
||||
static ClassType* parse_generic_signature(DescriptorStream* str);
|
||||
static ClassType* java_lang_Object();
|
||||
|
||||
Identifier* identifier() { return _identifier; }
|
||||
int type_arguments_length() { return _type_arguments.length(); }
|
||||
TypeArgument* type_argument_at(int i);
|
||||
|
||||
virtual ClassType* outer_class() { return _outer_class; }
|
||||
|
||||
bool covariant_match(Type* gt, Context* ctx);
|
||||
ClassType* canonicalize(Context* ctx, int context_depth);
|
||||
|
||||
void bind_variables_to_parameters(Descriptor* sig);
|
||||
|
||||
#ifndef PRODUCT
|
||||
void reify_signature(stringStream* ss, Context* ctx);
|
||||
void print_on(outputStream* str) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
class TypeVariable : public Type {
|
||||
private:
|
||||
Identifier* _id;
|
||||
TypeParameter* _parameter; // assigned during linking
|
||||
|
||||
// how many steps "out" from inner classes, -1 if method
|
||||
int _inner_depth;
|
||||
|
||||
TypeVariable(Identifier* id)
|
||||
: _id(id), _parameter(NULL), _inner_depth(0) {}
|
||||
|
||||
public:
|
||||
TypeVariable* as_variable() { return this; }
|
||||
|
||||
static TypeVariable* parse_generic_signature(DescriptorStream* str);
|
||||
|
||||
Identifier* identifier() { return _id; }
|
||||
TypeParameter* parameter() { return _parameter; }
|
||||
int inner_depth() { return _inner_depth; }
|
||||
|
||||
void bind_variables_to_parameters(Descriptor* sig);
|
||||
|
||||
Type* resolve(Context* ctx, int ctx_depth);
|
||||
bool covariant_match(Type* gt, Context* ctx);
|
||||
Type* canonicalize(Context* ctx, int ctx_depth);
|
||||
|
||||
#ifndef PRODUCT
|
||||
void reify_signature(stringStream* ss, Context* ctx);
|
||||
void print_on(outputStream* str) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
class ArrayType : public Type {
|
||||
private:
|
||||
Type* _base;
|
||||
|
||||
ArrayType(Type* base) : _base(base) {}
|
||||
|
||||
public:
|
||||
ArrayType* as_array() { return this; }
|
||||
|
||||
static ArrayType* parse_generic_signature(DescriptorStream* str);
|
||||
|
||||
bool covariant_match(Type* gt, Context* ctx);
|
||||
ArrayType* canonicalize(Context* ctx, int ctx_depth);
|
||||
|
||||
void bind_variables_to_parameters(Descriptor* sig);
|
||||
|
||||
#ifndef PRODUCT
|
||||
void reify_signature(stringStream* ss, Context* ctx);
|
||||
void print_on(outputStream* str) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
class PrimitiveType : public Type {
|
||||
friend class Type;
|
||||
private:
|
||||
char _type; // includes V for void
|
||||
|
||||
PrimitiveType(char& type) : _type(type) {}
|
||||
|
||||
public:
|
||||
PrimitiveType* as_primitive() { return this; }
|
||||
|
||||
bool covariant_match(Type* gt, Context* ctx);
|
||||
PrimitiveType* canonicalize(Context* ctx, int ctx_depth);
|
||||
|
||||
void bind_variables_to_parameters(Descriptor* sig);
|
||||
|
||||
#ifndef PRODUCT
|
||||
void reify_signature(stringStream* ss, Context* ctx);
|
||||
void print_on(outputStream* str) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
class TypeArgument : public ResourceObj {
|
||||
private:
|
||||
Type* _lower_bound;
|
||||
Type* _upper_bound; // may be null or == _lower_bound
|
||||
|
||||
TypeArgument(Type* lower_bound, Type* upper_bound)
|
||||
: _lower_bound(lower_bound), _upper_bound(upper_bound) {}
|
||||
|
||||
public:
|
||||
|
||||
static TypeArgument* parse_generic_signature(DescriptorStream* str);
|
||||
|
||||
Type* lower_bound() { return _lower_bound; }
|
||||
Type* upper_bound() { return _upper_bound; }
|
||||
|
||||
void bind_variables_to_parameters(Descriptor* sig);
|
||||
TypeArgument* canonicalize(Context* ctx, int ctx_depth);
|
||||
|
||||
bool covariant_match(TypeArgument* a, Context* ctx);
|
||||
|
||||
#ifndef PRODUCT
|
||||
void print_on(outputStream* str) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
class Context : public ResourceObj {
|
||||
private:
|
||||
DescriptorCache* _cache;
|
||||
GrowableArray<ClassType*> _type_arguments;
|
||||
|
||||
void reset_to_mark(int size);
|
||||
|
||||
public:
|
||||
// When this object goes out of scope or 'destroy' is
|
||||
// called, then the application of the type to the
|
||||
// context is wound-back (unless it's been deactivated).
|
||||
class Mark : public StackObj {
|
||||
private:
|
||||
mutable Context* _context;
|
||||
int _marked_size;
|
||||
|
||||
bool is_active() const { return _context != NULL; }
|
||||
void deactivate() const { _context = NULL; }
|
||||
|
||||
public:
|
||||
Mark() : _context(NULL), _marked_size(0) {}
|
||||
Mark(Context* ctx, int sz) : _context(ctx), _marked_size(sz) {}
|
||||
Mark(const Mark& m) : _context(m._context), _marked_size(m._marked_size) {
|
||||
m.deactivate(); // Ownership is transferred
|
||||
}
|
||||
|
||||
Mark& operator=(const Mark& cm) {
|
||||
destroy();
|
||||
_context = cm._context;
|
||||
_marked_size = cm._marked_size;
|
||||
cm.deactivate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void destroy();
|
||||
~Mark() { destroy(); }
|
||||
};
|
||||
|
||||
Context(DescriptorCache* cache) : _cache(cache) {}
|
||||
|
||||
Mark mark() { return Mark(this, _type_arguments.length()); }
|
||||
void apply_type_arguments(InstanceKlass* current, InstanceKlass* super,TRAPS);
|
||||
|
||||
ClassType* at_depth(int i) const;
|
||||
|
||||
#ifndef PRODUCT
|
||||
void print_on(outputStream* str) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Contains a cache of descriptors for classes and methods so they can be
|
||||
* looked-up instead of reparsing each time they are needed.
|
||||
*/
|
||||
class DescriptorCache : public ResourceObj {
|
||||
private:
|
||||
ResourceHashtable<InstanceKlass*, ClassDescriptor*> _class_descriptors;
|
||||
ResourceHashtable<Method*, MethodDescriptor*> _method_descriptors;
|
||||
|
||||
public:
|
||||
ClassDescriptor* descriptor_for(InstanceKlass* ikh, TRAPS);
|
||||
|
||||
MethodDescriptor* descriptor_for(Method* mh, ClassDescriptor* cd, TRAPS);
|
||||
// Class descriptor derived from method holder
|
||||
MethodDescriptor* descriptor_for(Method* mh, TRAPS);
|
||||
};
|
||||
|
||||
} // namespace generic
|
||||
|
||||
#endif // SHARE_VM_CLASSFILE_GENERICSIGNATURES_HPP
|
||||
|
@ -188,6 +188,10 @@ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool shoul
|
||||
bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) {
|
||||
Symbol* name = klass->name();
|
||||
Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass();
|
||||
Klass* lambda_magic_klass = SystemDictionary::lambda_MagicLambdaImpl_klass();
|
||||
|
||||
bool is_reflect = refl_magic_klass != NULL && klass->is_subtype_of(refl_magic_klass);
|
||||
bool is_lambda = lambda_magic_klass != NULL && klass->is_subtype_of(lambda_magic_klass);
|
||||
|
||||
return (should_verify_for(klass->class_loader(), should_verify_class) &&
|
||||
// return if the class is a bootstrapping class
|
||||
@ -210,9 +214,9 @@ bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool shou
|
||||
// sun/reflect/SerializationConstructorAccessor.
|
||||
// NOTE: this is called too early in the bootstrapping process to be
|
||||
// guarded by Universe::is_gte_jdk14x_version()/UseNewReflection.
|
||||
(refl_magic_klass == NULL ||
|
||||
!klass->is_subtype_of(refl_magic_klass) ||
|
||||
VerifyReflectionBytecodes)
|
||||
// Also for lambda generated code, gte jdk8
|
||||
(!is_reflect || VerifyReflectionBytecodes) &&
|
||||
(!is_lambda || VerifyLambdaBytecodes)
|
||||
);
|
||||
}
|
||||
|
||||
@ -2318,9 +2322,6 @@ void ClassVerifier::verify_invoke_instructions(
|
||||
types = 1 << JVM_CONSTANT_InvokeDynamic;
|
||||
break;
|
||||
case Bytecodes::_invokespecial:
|
||||
types = (1 << JVM_CONSTANT_InterfaceMethodref) |
|
||||
(1 << JVM_CONSTANT_Methodref);
|
||||
break;
|
||||
case Bytecodes::_invokestatic:
|
||||
types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ?
|
||||
(1 << JVM_CONSTANT_Methodref) :
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2013, 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
|
||||
@ -245,7 +245,7 @@ BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {
|
||||
}
|
||||
|
||||
|
||||
void* BufferBlob::operator new(size_t s, unsigned size) {
|
||||
void* BufferBlob::operator new(size_t s, unsigned size) throw() {
|
||||
void* p = CodeCache::allocate(size);
|
||||
return p;
|
||||
}
|
||||
@ -347,14 +347,14 @@ RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
|
||||
}
|
||||
|
||||
|
||||
void* RuntimeStub::operator new(size_t s, unsigned size) {
|
||||
void* RuntimeStub::operator new(size_t s, unsigned size) throw() {
|
||||
void* p = CodeCache::allocate(size, true);
|
||||
if (!p) fatal("Initial size of CodeCache is too small");
|
||||
return p;
|
||||
}
|
||||
|
||||
// operator new shared by all singletons:
|
||||
void* SingletonBlob::operator new(size_t s, unsigned size) {
|
||||
void* SingletonBlob::operator new(size_t s, unsigned size) throw() {
|
||||
void* p = CodeCache::allocate(size, true);
|
||||
if (!p) fatal("Initial size of CodeCache is too small");
|
||||
return p;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2013, 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
|
||||
@ -209,7 +209,7 @@ class BufferBlob: public CodeBlob {
|
||||
BufferBlob(const char* name, int size);
|
||||
BufferBlob(const char* name, int size, CodeBuffer* cb);
|
||||
|
||||
void* operator new(size_t s, unsigned size);
|
||||
void* operator new(size_t s, unsigned size) throw();
|
||||
|
||||
public:
|
||||
// Creation
|
||||
@ -283,7 +283,7 @@ class RuntimeStub: public CodeBlob {
|
||||
bool caller_must_gc_arguments
|
||||
);
|
||||
|
||||
void* operator new(size_t s, unsigned size);
|
||||
void* operator new(size_t s, unsigned size) throw();
|
||||
|
||||
public:
|
||||
// Creation
|
||||
@ -321,7 +321,7 @@ class SingletonBlob: public CodeBlob {
|
||||
friend class VMStructs;
|
||||
|
||||
protected:
|
||||
void* operator new(size_t s, unsigned size);
|
||||
void* operator new(size_t s, unsigned size) throw();
|
||||
|
||||
public:
|
||||
SingletonBlob(
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2013, 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
|
||||
@ -38,7 +38,7 @@ class DIR_Chunk {
|
||||
int _length; // number of bytes in the stream
|
||||
int _hash; // hash of stream bytes (for quicker reuse)
|
||||
|
||||
void* operator new(size_t ignore, DebugInformationRecorder* dir) {
|
||||
void* operator new(size_t ignore, DebugInformationRecorder* dir) throw() {
|
||||
assert(ignore == sizeof(DIR_Chunk), "");
|
||||
if (dir->_next_chunk >= dir->_next_chunk_limit) {
|
||||
const int CHUNK = 100;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -93,18 +93,21 @@ HS_DTRACE_PROBE_DECL6(hotspot, compiled__method__unload,
|
||||
#endif
|
||||
|
||||
bool nmethod::is_compiled_by_c1() const {
|
||||
if (compiler() == NULL || method() == NULL) return false; // can happen during debug printing
|
||||
if (is_native_method()) return false;
|
||||
if (compiler() == NULL) {
|
||||
return false;
|
||||
}
|
||||
return compiler()->is_c1();
|
||||
}
|
||||
bool nmethod::is_compiled_by_c2() const {
|
||||
if (compiler() == NULL || method() == NULL) return false; // can happen during debug printing
|
||||
if (is_native_method()) return false;
|
||||
if (compiler() == NULL) {
|
||||
return false;
|
||||
}
|
||||
return compiler()->is_c2();
|
||||
}
|
||||
bool nmethod::is_compiled_by_shark() const {
|
||||
if (is_native_method()) return false;
|
||||
assert(compiler() != NULL, "must be");
|
||||
if (compiler() == NULL) {
|
||||
return false;
|
||||
}
|
||||
return compiler()->is_shark();
|
||||
}
|
||||
|
||||
@ -800,7 +803,7 @@ nmethod::nmethod(
|
||||
}
|
||||
#endif // def HAVE_DTRACE_H
|
||||
|
||||
void* nmethod::operator new(size_t size, int nmethod_size) throw () {
|
||||
void* nmethod::operator new(size_t size, int nmethod_size) throw() {
|
||||
// Not critical, may return null if there is too little continuous memory
|
||||
return CodeCache::allocate(nmethod_size);
|
||||
}
|
||||
@ -1401,6 +1404,9 @@ bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
|
||||
// nmethods aren't scanned for GC.
|
||||
_oops_are_stale = true;
|
||||
#endif
|
||||
// the Method may be reclaimed by class unloading now that the
|
||||
// nmethod is in zombie state
|
||||
set_method(NULL);
|
||||
} else {
|
||||
assert(state == not_entrant, "other cases may need to be handled differently");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -265,7 +265,7 @@ class nmethod : public CodeBlob {
|
||||
int comp_level);
|
||||
|
||||
// helper methods
|
||||
void* operator new(size_t size, int nmethod_size);
|
||||
void* operator new(size_t size, int nmethod_size) throw();
|
||||
|
||||
const char* reloc_string_for(u_char* begin, u_char* end);
|
||||
// Returns true if this thread changed the state of the nmethod or
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -677,7 +677,7 @@ class Relocation VALUE_OBJ_CLASS_SPEC {
|
||||
}
|
||||
|
||||
public:
|
||||
void* operator new(size_t size, const RelocationHolder& holder) {
|
||||
void* operator new(size_t size, const RelocationHolder& holder) throw() {
|
||||
if (size > sizeof(holder._relocbuf)) guarantee_size();
|
||||
assert((void* const *)holder.reloc() == &holder._relocbuf[0], "ptrs must agree");
|
||||
return holder.reloc();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -49,7 +49,7 @@ VMReg VtableStub::_receiver_location = VMRegImpl::Bad();
|
||||
static int num_vtable_chunks = 0;
|
||||
|
||||
|
||||
void* VtableStub::operator new(size_t size, int code_size) {
|
||||
void* VtableStub::operator new(size_t size, int code_size) throw() {
|
||||
assert(size == sizeof(VtableStub), "mismatched size");
|
||||
num_vtable_chunks++;
|
||||
// compute real VtableStub size (rounded to nearest word)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -46,7 +46,7 @@ class VtableStub {
|
||||
bool _is_vtable_stub; // True if vtable stub, false, is itable stub
|
||||
/* code follows here */ // The vtableStub code
|
||||
|
||||
void* operator new(size_t size, int code_size);
|
||||
void* operator new(size_t size, int code_size) throw();
|
||||
|
||||
VtableStub(bool is_vtable_stub, int index)
|
||||
: _next(NULL), _is_vtable_stub(is_vtable_stub),
|
||||
|
@ -1718,7 +1718,7 @@ static void codecache_print(bool detailed)
|
||||
CodeCache::print_summary(&s, detailed);
|
||||
}
|
||||
ttyLocker ttyl;
|
||||
tty->print_cr(s.as_string());
|
||||
tty->print(s.as_string());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@ -3460,7 +3460,9 @@ void ConcurrentMarkSweepGeneration::shrink_by(size_t bytes) {
|
||||
void ConcurrentMarkSweepGeneration::shrink(size_t bytes) {
|
||||
assert_locked_or_safepoint(Heap_lock);
|
||||
size_t size = ReservedSpace::page_align_size_down(bytes);
|
||||
if (size > 0) {
|
||||
// Only shrink if a compaction was done so that all the free space
|
||||
// in the generation is in a contiguous block at the end.
|
||||
if (size > 0 && did_compact()) {
|
||||
shrink_by(size);
|
||||
}
|
||||
}
|
||||
@ -8696,9 +8698,10 @@ void SweepClosure::lookahead_and_flush(FreeChunk* fc, size_t chunk_size) {
|
||||
assert(inFreeRange(), "Should only be called if currently in a free range.");
|
||||
HeapWord* const eob = ((HeapWord*)fc) + chunk_size;
|
||||
assert(_sp->used_region().contains(eob - 1),
|
||||
err_msg("eob = " PTR_FORMAT " out of bounds wrt _sp = [" PTR_FORMAT "," PTR_FORMAT ")"
|
||||
err_msg("eob = " PTR_FORMAT " eob-1 = " PTR_FORMAT " _limit = " PTR_FORMAT
|
||||
" out of bounds wrt _sp = [" PTR_FORMAT "," PTR_FORMAT ")"
|
||||
" when examining fc = " PTR_FORMAT "(" SIZE_FORMAT ")",
|
||||
_limit, _sp->bottom(), _sp->end(), fc, chunk_size));
|
||||
eob, eob-1, _limit, _sp->bottom(), _sp->end(), fc, chunk_size));
|
||||
if (eob >= _limit) {
|
||||
assert(eob == _limit || fc->is_free(), "Only a free chunk should allow us to cross over the limit");
|
||||
if (CMSTraceSweeper) {
|
||||
|
@ -981,7 +981,8 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size,
|
||||
|
||||
if (should_try_gc) {
|
||||
bool succeeded;
|
||||
result = do_collection_pause(word_size, gc_count_before, &succeeded);
|
||||
result = do_collection_pause(word_size, gc_count_before, &succeeded,
|
||||
GCCause::_g1_inc_collection_pause);
|
||||
if (result != NULL) {
|
||||
assert(succeeded, "only way to get back a non-NULL result");
|
||||
return result;
|
||||
@ -1106,7 +1107,8 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size,
|
||||
// enough space for the allocation to succeed after the pause.
|
||||
|
||||
bool succeeded;
|
||||
result = do_collection_pause(word_size, gc_count_before, &succeeded);
|
||||
result = do_collection_pause(word_size, gc_count_before, &succeeded,
|
||||
GCCause::_g1_humongous_allocation);
|
||||
if (result != NULL) {
|
||||
assert(succeeded, "only way to get back a non-NULL result");
|
||||
return result;
|
||||
@ -2006,10 +2008,12 @@ jint G1CollectedHeap::initialize() {
|
||||
|
||||
size_t init_byte_size = collector_policy()->initial_heap_byte_size();
|
||||
size_t max_byte_size = collector_policy()->max_heap_byte_size();
|
||||
size_t heap_alignment = collector_policy()->max_alignment();
|
||||
|
||||
// Ensure that the sizes are properly aligned.
|
||||
Universe::check_alignment(init_byte_size, HeapRegion::GrainBytes, "g1 heap");
|
||||
Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap");
|
||||
Universe::check_alignment(max_byte_size, heap_alignment, "g1 heap");
|
||||
|
||||
_cg1r = new ConcurrentG1Refine(this);
|
||||
|
||||
@ -2026,12 +2030,8 @@ jint G1CollectedHeap::initialize() {
|
||||
// If this happens then we could end up using a non-optimal
|
||||
// compressed oops mode.
|
||||
|
||||
// Since max_byte_size is aligned to the size of a heap region (checked
|
||||
// above).
|
||||
Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap");
|
||||
|
||||
ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size,
|
||||
HeapRegion::GrainBytes);
|
||||
heap_alignment);
|
||||
|
||||
// It is important to do this in a way such that concurrent readers can't
|
||||
// temporarily think something is in the heap. (I've actually seen this
|
||||
@ -2493,11 +2493,11 @@ void G1CollectedHeap::register_concurrent_cycle_start(jlong start_time) {
|
||||
|
||||
void G1CollectedHeap::register_concurrent_cycle_end() {
|
||||
if (_concurrent_cycle_started) {
|
||||
_gc_timer_cm->register_gc_end(os::elapsed_counter());
|
||||
|
||||
if (_cm->has_aborted()) {
|
||||
_gc_tracer_cm->report_concurrent_mode_failure();
|
||||
}
|
||||
|
||||
_gc_timer_cm->register_gc_end(os::elapsed_counter());
|
||||
_gc_tracer_cm->report_gc_end(_gc_timer_cm->gc_end(), _gc_timer_cm->time_partitions());
|
||||
|
||||
_concurrent_cycle_started = false;
|
||||
@ -3700,14 +3700,15 @@ void G1CollectedHeap::gc_epilogue(bool full /* Ignored */) {
|
||||
|
||||
HeapWord* G1CollectedHeap::do_collection_pause(size_t word_size,
|
||||
unsigned int gc_count_before,
|
||||
bool* succeeded) {
|
||||
bool* succeeded,
|
||||
GCCause::Cause gc_cause) {
|
||||
assert_heap_not_locked_and_not_at_safepoint();
|
||||
g1_policy()->record_stop_world_start();
|
||||
VM_G1IncCollectionPause op(gc_count_before,
|
||||
word_size,
|
||||
false, /* should_initiate_conc_mark */
|
||||
g1_policy()->max_pause_time_ms(),
|
||||
GCCause::_g1_inc_collection_pause);
|
||||
gc_cause);
|
||||
VMThread::execute(&op);
|
||||
|
||||
HeapWord* result = op.result();
|
||||
|
@ -776,9 +776,10 @@ protected:
|
||||
// it has to be read while holding the Heap_lock. Currently, both
|
||||
// methods that call do_collection_pause() release the Heap_lock
|
||||
// before the call, so it's easy to read gc_count_before just before.
|
||||
HeapWord* do_collection_pause(size_t word_size,
|
||||
unsigned int gc_count_before,
|
||||
bool* succeeded);
|
||||
HeapWord* do_collection_pause(size_t word_size,
|
||||
unsigned int gc_count_before,
|
||||
bool* succeeded,
|
||||
GCCause::Cause gc_cause);
|
||||
|
||||
// The guts of the incremental collection pause, executed by the vm
|
||||
// thread. It returns false if it is unable to do the collection due
|
||||
|
@ -168,7 +168,15 @@ G1CollectorPolicy::G1CollectorPolicy() :
|
||||
// Set up the region size and associated fields. Given that the
|
||||
// policy is created before the heap, we have to set this up here,
|
||||
// so it's done as soon as possible.
|
||||
HeapRegion::setup_heap_region_size(Arguments::min_heap_size());
|
||||
|
||||
// It would have been natural to pass initial_heap_byte_size() and
|
||||
// max_heap_byte_size() to setup_heap_region_size() but those have
|
||||
// not been set up at this point since they should be aligned with
|
||||
// the region size. So, there is a circular dependency here. We base
|
||||
// the region size on the heap size, but the heap size should be
|
||||
// aligned with the region size. To get around this we use the
|
||||
// unaligned values for the heap.
|
||||
HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize);
|
||||
HeapRegionRemSet::setup_remset_size();
|
||||
|
||||
G1ErgoVerbose::initialize();
|
||||
@ -313,7 +321,8 @@ G1CollectorPolicy::G1CollectorPolicy() :
|
||||
void G1CollectorPolicy::initialize_flags() {
|
||||
set_min_alignment(HeapRegion::GrainBytes);
|
||||
size_t card_table_alignment = GenRemSet::max_alignment_constraint(rem_set_name());
|
||||
set_max_alignment(MAX2(card_table_alignment, min_alignment()));
|
||||
size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size();
|
||||
set_max_alignment(MAX3(card_table_alignment, min_alignment(), page_size));
|
||||
if (SurvivorRatio < 1) {
|
||||
vm_exit_during_initialization("Invalid survivor ratio specified");
|
||||
}
|
||||
|
@ -149,18 +149,11 @@ void HeapRegionDCTOC::walk_mem_region_with_cl(MemRegion mr,
|
||||
// many regions in the heap (based on the min heap size).
|
||||
#define TARGET_REGION_NUMBER 2048
|
||||
|
||||
void HeapRegion::setup_heap_region_size(uintx min_heap_size) {
|
||||
// region_size in bytes
|
||||
void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) {
|
||||
uintx region_size = G1HeapRegionSize;
|
||||
if (FLAG_IS_DEFAULT(G1HeapRegionSize)) {
|
||||
// We base the automatic calculation on the min heap size. This
|
||||
// can be problematic if the spread between min and max is quite
|
||||
// wide, imagine -Xms128m -Xmx32g. But, if we decided it based on
|
||||
// the max size, the region size might be way too large for the
|
||||
// min size. Either way, some users might have to set the region
|
||||
// size manually for some -Xms / -Xmx combos.
|
||||
|
||||
region_size = MAX2(min_heap_size / TARGET_REGION_NUMBER,
|
||||
size_t average_heap_size = (initial_heap_size + max_heap_size) / 2;
|
||||
region_size = MAX2(average_heap_size / TARGET_REGION_NUMBER,
|
||||
(uintx) MIN_REGION_SIZE);
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ class HeapRegion: public G1OffsetTableContigSpace {
|
||||
// CardsPerRegion). All those fields are considered constant
|
||||
// throughout the JVM's execution, therefore they should only be set
|
||||
// up once during initialization time.
|
||||
static void setup_heap_region_size(uintx min_heap_size);
|
||||
static void setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size);
|
||||
|
||||
enum ClaimValues {
|
||||
InitialClaimValue = 0,
|
||||
|
@ -70,9 +70,6 @@ VM_G1IncCollectionPause::VM_G1IncCollectionPause(
|
||||
guarantee(target_pause_time_ms > 0.0,
|
||||
err_msg("target_pause_time_ms = %1.6lf should be positive",
|
||||
target_pause_time_ms));
|
||||
guarantee(word_size == 0 || gc_cause == GCCause::_g1_inc_collection_pause,
|
||||
"we can only request an allocation if the GC cause is for "
|
||||
"an incremental GC pause");
|
||||
_gc_cause = gc_cause;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "gc_implementation/shared/gcTrace.hpp"
|
||||
#include "gc_implementation/shared/gcWhen.hpp"
|
||||
#include "gc_implementation/shared/copyFailedInfo.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "trace/tracing.hpp"
|
||||
#include "trace/traceBackend.hpp"
|
||||
#if INCLUDE_ALL_GCS
|
||||
@ -54,11 +55,12 @@ void GCTracer::send_garbage_collection_event() const {
|
||||
}
|
||||
|
||||
void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const {
|
||||
EventGCReferenceStatistics e;
|
||||
EventGCReferenceStatistics e(UNTIMED);
|
||||
if (e.should_commit()) {
|
||||
e.set_gcId(_shared_gc_info.id());
|
||||
e.set_type((u1)type);
|
||||
e.set_count(count);
|
||||
e.set_endtime(os::elapsed_counter());
|
||||
e.commit();
|
||||
}
|
||||
}
|
||||
@ -105,20 +107,22 @@ static TraceStructCopyFailed to_trace_struct(const CopyFailedInfo& cf_info) {
|
||||
}
|
||||
|
||||
void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
|
||||
EventPromotionFailed e;
|
||||
EventPromotionFailed e(UNTIMED);
|
||||
if (e.should_commit()) {
|
||||
e.set_gcId(_shared_gc_info.id());
|
||||
e.set_data(to_trace_struct(pf_info));
|
||||
e.set_thread(pf_info.thread()->thread_id());
|
||||
e.set_endtime(os::elapsed_counter());
|
||||
e.commit();
|
||||
}
|
||||
}
|
||||
|
||||
// Common to CMS and G1
|
||||
void OldGCTracer::send_concurrent_mode_failure_event() {
|
||||
EventConcurrentModeFailure e;
|
||||
EventConcurrentModeFailure e(UNTIMED);
|
||||
if (e.should_commit()) {
|
||||
e.set_gcId(_shared_gc_info.id());
|
||||
e.set_endtime(os::elapsed_counter());
|
||||
e.commit();
|
||||
}
|
||||
}
|
||||
@ -136,7 +140,7 @@ void G1NewTracer::send_g1_young_gc_event() {
|
||||
}
|
||||
|
||||
void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
|
||||
EventEvacuationInfo e;
|
||||
EventEvacuationInfo e(UNTIMED);
|
||||
if (e.should_commit()) {
|
||||
e.set_gcId(_shared_gc_info.id());
|
||||
e.set_cSetRegions(info->collectionset_regions());
|
||||
@ -147,15 +151,17 @@ void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
|
||||
e.set_allocRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied());
|
||||
e.set_bytesCopied(info->bytes_copied());
|
||||
e.set_regionsFreed(info->regions_freed());
|
||||
e.set_endtime(os::elapsed_counter());
|
||||
e.commit();
|
||||
}
|
||||
}
|
||||
|
||||
void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
|
||||
EventEvacuationFailed e;
|
||||
EventEvacuationFailed e(UNTIMED);
|
||||
if (e.should_commit()) {
|
||||
e.set_gcId(_shared_gc_info.id());
|
||||
e.set_data(to_trace_struct(ef_info));
|
||||
e.set_endtime(os::elapsed_counter());
|
||||
e.commit();
|
||||
}
|
||||
}
|
||||
@ -189,12 +195,13 @@ class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
|
||||
void visit(const GCHeapSummary* heap_summary) const {
|
||||
const VirtualSpaceSummary& heap_space = heap_summary->heap();
|
||||
|
||||
EventGCHeapSummary e;
|
||||
EventGCHeapSummary e(UNTIMED);
|
||||
if (e.should_commit()) {
|
||||
e.set_gcId(_id);
|
||||
e.set_when((u1)_when);
|
||||
e.set_heapSpace(to_trace_struct(heap_space));
|
||||
e.set_heapUsed(heap_summary->used());
|
||||
e.set_endtime(os::elapsed_counter());
|
||||
e.commit();
|
||||
}
|
||||
}
|
||||
@ -209,7 +216,7 @@ class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
|
||||
const SpaceSummary& from_space = ps_heap_summary->from();
|
||||
const SpaceSummary& to_space = ps_heap_summary->to();
|
||||
|
||||
EventPSHeapSummary e;
|
||||
EventPSHeapSummary e(UNTIMED);
|
||||
if (e.should_commit()) {
|
||||
e.set_gcId(_id);
|
||||
e.set_when((u1)_when);
|
||||
@ -220,6 +227,7 @@ class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
|
||||
e.set_edenSpace(to_trace_struct(ps_heap_summary->eden()));
|
||||
e.set_fromSpace(to_trace_struct(ps_heap_summary->from()));
|
||||
e.set_toSpace(to_trace_struct(ps_heap_summary->to()));
|
||||
e.set_endtime(os::elapsed_counter());
|
||||
e.commit();
|
||||
}
|
||||
}
|
||||
@ -241,13 +249,14 @@ static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
|
||||
}
|
||||
|
||||
void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
|
||||
EventMetaspaceSummary e;
|
||||
EventMetaspaceSummary e(UNTIMED);
|
||||
if (e.should_commit()) {
|
||||
e.set_gcId(_shared_gc_info.id());
|
||||
e.set_when((u1) when);
|
||||
e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
|
||||
e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
|
||||
e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));
|
||||
e.set_endtime(os::elapsed_counter());
|
||||
e.commit();
|
||||
}
|
||||
}
|
||||
@ -282,8 +291,6 @@ class PhaseSender : public PhaseVisitor {
|
||||
default: /* Ignore sending this phase */ break;
|
||||
}
|
||||
}
|
||||
|
||||
#undef send_phase
|
||||
};
|
||||
|
||||
void GCTracer::send_phase_events(TimePartitions* time_partitions) const {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, 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
|
||||
@ -144,9 +144,9 @@ class AdaptivePaddedAverage : public AdaptiveWeightedAverage {
|
||||
_padded_avg(0.0), _deviation(0.0), _padding(padding) {}
|
||||
|
||||
// Placement support
|
||||
void* operator new(size_t ignored, void* p) { return p; }
|
||||
void* operator new(size_t ignored, void* p) throw() { return p; }
|
||||
// Allocator
|
||||
void* operator new(size_t size) { return CHeapObj<mtGC>::operator new(size); }
|
||||
void* operator new(size_t size) throw() { return CHeapObj<mtGC>::operator new(size); }
|
||||
|
||||
// Accessor
|
||||
float padded_average() const { return _padded_avg; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, 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
|
||||
@ -163,8 +163,8 @@ extern void safe_free (const char *file, unsigned line, void *ptr);
|
||||
extern void *safe_calloc (const char *file, unsigned line, unsigned nitems, unsigned size);
|
||||
extern void *safe_realloc(const char *file, unsigned line, void *ptr, unsigned size);
|
||||
extern char *safe_strdup (const char *file, unsigned line, const char *src);
|
||||
inline void *operator new( size_t size ) { return malloc(size); }
|
||||
inline void operator delete( void *ptr ) { free(ptr); }
|
||||
inline void *operator new( size_t size ) throw() { return malloc(size); }
|
||||
inline void operator delete( void *ptr ) { free(ptr); }
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -49,19 +49,19 @@
|
||||
# include "os_bsd.inline.hpp"
|
||||
#endif
|
||||
|
||||
void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }
|
||||
void StackObj::operator delete(void* p) { ShouldNotCallThis(); }
|
||||
void* StackObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; }
|
||||
void StackObj::operator delete [](void* p) { ShouldNotCallThis(); }
|
||||
void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; }
|
||||
void StackObj::operator delete(void* p) { ShouldNotCallThis(); }
|
||||
void* StackObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; }
|
||||
void StackObj::operator delete [](void* p) { ShouldNotCallThis(); }
|
||||
|
||||
void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }
|
||||
void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }
|
||||
void* _ValueObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; }
|
||||
void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); }
|
||||
void* _ValueObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; }
|
||||
void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }
|
||||
void* _ValueObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; }
|
||||
void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); }
|
||||
|
||||
void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
|
||||
size_t word_size, bool read_only,
|
||||
MetaspaceObj::Type type, TRAPS) {
|
||||
MetaspaceObj::Type type, TRAPS) throw() {
|
||||
// Klass has it's own operator new
|
||||
return Metaspace::allocate(loader_data, word_size, read_only,
|
||||
type, CHECK_NULL);
|
||||
@ -80,7 +80,7 @@ void MetaspaceObj::print_address_on(outputStream* st) const {
|
||||
st->print(" {"INTPTR_FORMAT"}", this);
|
||||
}
|
||||
|
||||
void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) {
|
||||
void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() {
|
||||
address res;
|
||||
switch (type) {
|
||||
case C_HEAP:
|
||||
@ -97,12 +97,12 @@ void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flag
|
||||
return res;
|
||||
}
|
||||
|
||||
void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) {
|
||||
void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw() {
|
||||
return (address) operator new(size, type, flags);
|
||||
}
|
||||
|
||||
void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_constant,
|
||||
allocation_type type, MEMFLAGS flags) {
|
||||
allocation_type type, MEMFLAGS flags) throw() {
|
||||
//should only call this with std::nothrow, use other operator new() otherwise
|
||||
address res;
|
||||
switch (type) {
|
||||
@ -121,7 +121,7 @@ void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_cons
|
||||
}
|
||||
|
||||
void* ResourceObj::operator new [](size_t size, const std::nothrow_t& nothrow_constant,
|
||||
allocation_type type, MEMFLAGS flags) {
|
||||
allocation_type type, MEMFLAGS flags) throw() {
|
||||
return (address)operator new(size, nothrow_constant, type, flags);
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ class ChunkPoolCleaner : public PeriodicTask {
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Chunk implementation
|
||||
|
||||
void* Chunk::operator new (size_t requested_size, AllocFailType alloc_failmode, size_t length) {
|
||||
void* Chunk::operator new (size_t requested_size, AllocFailType alloc_failmode, size_t length) throw() {
|
||||
// requested_size is equal to sizeof(Chunk) but in order for the arena
|
||||
// allocations to come out aligned as expected the size must be aligned
|
||||
// to expected arena alignment.
|
||||
@ -478,18 +478,18 @@ Arena::~Arena() {
|
||||
NOT_PRODUCT(Atomic::dec(&_instance_count);)
|
||||
}
|
||||
|
||||
void* Arena::operator new(size_t size) {
|
||||
void* Arena::operator new(size_t size) throw() {
|
||||
assert(false, "Use dynamic memory type binding");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* Arena::operator new (size_t size, const std::nothrow_t& nothrow_constant) {
|
||||
void* Arena::operator new (size_t size, const std::nothrow_t& nothrow_constant) throw() {
|
||||
assert(false, "Use dynamic memory type binding");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// dynamic memory type binding
|
||||
void* Arena::operator new(size_t size, MEMFLAGS flags) {
|
||||
void* Arena::operator new(size_t size, MEMFLAGS flags) throw() {
|
||||
#ifdef ASSERT
|
||||
void* p = (void*)AllocateHeap(size, flags|otArena, CALLER_PC);
|
||||
if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p);
|
||||
@ -499,7 +499,7 @@ void* Arena::operator new(size_t size, MEMFLAGS flags) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void* Arena::operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) {
|
||||
void* Arena::operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw() {
|
||||
#ifdef ASSERT
|
||||
void* p = os::malloc(size, flags|otArena, CALLER_PC);
|
||||
if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p);
|
||||
@ -688,22 +688,22 @@ void* Arena::internal_malloc_4(size_t x) {
|
||||
// define ALLOW_OPERATOR_NEW_USAGE for platform on which global operator new allowed.
|
||||
//
|
||||
#ifndef ALLOW_OPERATOR_NEW_USAGE
|
||||
void* operator new(size_t size){
|
||||
void* operator new(size_t size) throw() {
|
||||
assert(false, "Should not call global operator new");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* operator new [](size_t size){
|
||||
void* operator new [](size_t size) throw() {
|
||||
assert(false, "Should not call global operator new[]");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* operator new(size_t size, const std::nothrow_t& nothrow_constant){
|
||||
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
|
||||
assert(false, "Should not call global operator new");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* operator new [](size_t size, std::nothrow_t& nothrow_constant){
|
||||
void* operator new [](size_t size, std::nothrow_t& nothrow_constant) throw() {
|
||||
assert(false, "Should not call global operator new[]");
|
||||
return 0;
|
||||
}
|
||||
|
@ -204,12 +204,12 @@ const bool NMT_track_callsite = false;
|
||||
|
||||
template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||
public:
|
||||
_NOINLINE_ void* operator new(size_t size, address caller_pc = 0);
|
||||
_NOINLINE_ void* operator new(size_t size, address caller_pc = 0) throw();
|
||||
_NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant,
|
||||
address caller_pc = 0);
|
||||
_NOINLINE_ void* operator new [](size_t size, address caller_pc = 0);
|
||||
address caller_pc = 0) throw();
|
||||
_NOINLINE_ void* operator new [](size_t size, address caller_pc = 0) throw();
|
||||
_NOINLINE_ void* operator new [](size_t size, const std::nothrow_t& nothrow_constant,
|
||||
address caller_pc = 0);
|
||||
address caller_pc = 0) throw();
|
||||
void operator delete(void* p);
|
||||
void operator delete [] (void* p);
|
||||
};
|
||||
@ -219,9 +219,9 @@ template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||
|
||||
class StackObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||
private:
|
||||
void* operator new(size_t size);
|
||||
void* operator new(size_t size) throw();
|
||||
void operator delete(void* p);
|
||||
void* operator new [](size_t size);
|
||||
void* operator new [](size_t size) throw();
|
||||
void operator delete [](void* p);
|
||||
};
|
||||
|
||||
@ -245,9 +245,9 @@ class StackObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||
//
|
||||
class _ValueObj {
|
||||
private:
|
||||
void* operator new(size_t size);
|
||||
void* operator new(size_t size) throw();
|
||||
void operator delete(void* p);
|
||||
void* operator new [](size_t size);
|
||||
void* operator new [](size_t size) throw();
|
||||
void operator delete [](void* p);
|
||||
};
|
||||
|
||||
@ -316,7 +316,7 @@ class MetaspaceObj {
|
||||
|
||||
void* operator new(size_t size, ClassLoaderData* loader_data,
|
||||
size_t word_size, bool read_only,
|
||||
Type type, Thread* thread);
|
||||
Type type, Thread* thread) throw();
|
||||
// can't use TRAPS from this header file.
|
||||
void operator delete(void* p) { ShouldNotCallThis(); }
|
||||
};
|
||||
@ -339,7 +339,7 @@ class Chunk: CHeapObj<mtChunk> {
|
||||
Chunk* _next; // Next Chunk in list
|
||||
const size_t _len; // Size of this Chunk
|
||||
public:
|
||||
void* operator new(size_t size, AllocFailType alloc_failmode, size_t length);
|
||||
void* operator new(size_t size, AllocFailType alloc_failmode, size_t length) throw();
|
||||
void operator delete(void* p);
|
||||
Chunk(size_t length);
|
||||
|
||||
@ -422,12 +422,12 @@ protected:
|
||||
char* hwm() const { return _hwm; }
|
||||
|
||||
// new operators
|
||||
void* operator new (size_t size);
|
||||
void* operator new (size_t size, const std::nothrow_t& nothrow_constant);
|
||||
void* operator new (size_t size) throw();
|
||||
void* operator new (size_t size, const std::nothrow_t& nothrow_constant) throw();
|
||||
|
||||
// dynamic memory type tagging
|
||||
void* operator new(size_t size, MEMFLAGS flags);
|
||||
void* operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags);
|
||||
void* operator new(size_t size, MEMFLAGS flags) throw();
|
||||
void* operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw();
|
||||
void operator delete(void* p);
|
||||
|
||||
// Fast allocate in the arena. Common case is: pointer test + increment.
|
||||
@ -583,44 +583,44 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||
#endif // ASSERT
|
||||
|
||||
public:
|
||||
void* operator new(size_t size, allocation_type type, MEMFLAGS flags);
|
||||
void* operator new [](size_t size, allocation_type type, MEMFLAGS flags);
|
||||
void* operator new(size_t size, allocation_type type, MEMFLAGS flags) throw();
|
||||
void* operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw();
|
||||
void* operator new(size_t size, const std::nothrow_t& nothrow_constant,
|
||||
allocation_type type, MEMFLAGS flags);
|
||||
allocation_type type, MEMFLAGS flags) throw();
|
||||
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant,
|
||||
allocation_type type, MEMFLAGS flags);
|
||||
allocation_type type, MEMFLAGS flags) throw();
|
||||
|
||||
void* operator new(size_t size, Arena *arena) {
|
||||
void* operator new(size_t size, Arena *arena) throw() {
|
||||
address res = (address)arena->Amalloc(size);
|
||||
DEBUG_ONLY(set_allocation_type(res, ARENA);)
|
||||
return res;
|
||||
}
|
||||
|
||||
void* operator new [](size_t size, Arena *arena) {
|
||||
void* operator new [](size_t size, Arena *arena) throw() {
|
||||
address res = (address)arena->Amalloc(size);
|
||||
DEBUG_ONLY(set_allocation_type(res, ARENA);)
|
||||
return res;
|
||||
}
|
||||
|
||||
void* operator new(size_t size) {
|
||||
void* operator new(size_t size) throw() {
|
||||
address res = (address)resource_allocate_bytes(size);
|
||||
DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
|
||||
return res;
|
||||
}
|
||||
|
||||
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) {
|
||||
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
|
||||
address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL);
|
||||
DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);)
|
||||
return res;
|
||||
}
|
||||
|
||||
void* operator new [](size_t size) {
|
||||
void* operator new [](size_t size) throw() {
|
||||
address res = (address)resource_allocate_bytes(size);
|
||||
DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
|
||||
return res;
|
||||
}
|
||||
|
||||
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) {
|
||||
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) throw() {
|
||||
address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL);
|
||||
DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);)
|
||||
return res;
|
||||
@ -666,7 +666,7 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||
NEW_RESOURCE_ARRAY_RETURN_NULL(type, 1)
|
||||
|
||||
#define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail)\
|
||||
(type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail)
|
||||
(type*) AllocateHeap((size) * sizeof(type), memflags, pc, allocfail)
|
||||
|
||||
#define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\
|
||||
(type*) (AllocateHeap((size) * sizeof(type), memflags, pc))
|
||||
@ -675,16 +675,16 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||
(type*) (AllocateHeap((size) * sizeof(type), memflags))
|
||||
|
||||
#define NEW_C_HEAP_ARRAY2_RETURN_NULL(type, size, memflags, pc)\
|
||||
NEW_C_HEAP_ARRAY3(type, size, memflags, pc, AllocFailStrategy::RETURN_NULL)
|
||||
NEW_C_HEAP_ARRAY3(type, (size), memflags, pc, AllocFailStrategy::RETURN_NULL)
|
||||
|
||||
#define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, memflags)\
|
||||
NEW_C_HEAP_ARRAY3(type, size, memflags, (address)0, AllocFailStrategy::RETURN_NULL)
|
||||
NEW_C_HEAP_ARRAY3(type, (size), memflags, (address)0, AllocFailStrategy::RETURN_NULL)
|
||||
|
||||
#define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\
|
||||
(type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags))
|
||||
(type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), memflags))
|
||||
|
||||
#define REALLOC_C_HEAP_ARRAY_RETURN_NULL(type, old, size, memflags)\
|
||||
(type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, AllocFailStrategy::RETURN_NULL))
|
||||
(type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), memflags, AllocFailStrategy::RETURN_NULL))
|
||||
|
||||
#define FREE_C_HEAP_ARRAY(type, old, memflags) \
|
||||
FreeHeap((char*)(old), memflags)
|
||||
|
@ -85,7 +85,7 @@ inline void FreeHeap(void* p, MEMFLAGS memflags = mtInternal) {
|
||||
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
|
||||
address caller_pc){
|
||||
address caller_pc) throw() {
|
||||
void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC));
|
||||
#ifdef ASSERT
|
||||
if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
|
||||
@ -94,7 +94,7 @@ template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
|
||||
const std::nothrow_t& nothrow_constant, address caller_pc) {
|
||||
const std::nothrow_t& nothrow_constant, address caller_pc) throw() {
|
||||
void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC),
|
||||
AllocFailStrategy::RETURN_NULL);
|
||||
#ifdef ASSERT
|
||||
@ -104,12 +104,12 @@ template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
|
||||
address caller_pc){
|
||||
address caller_pc) throw() {
|
||||
return CHeapObj<F>::operator new(size, caller_pc);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
|
||||
const std::nothrow_t& nothrow_constant, address caller_pc) {
|
||||
const std::nothrow_t& nothrow_constant, address caller_pc) throw() {
|
||||
return CHeapObj<F>::operator new(size, nothrow_constant, caller_pc);
|
||||
}
|
||||
|
||||
|
@ -193,6 +193,8 @@ size_t GenCollectorPolicy::compute_max_alignment() {
|
||||
alignment = lcm(os::large_page_size(), alignment);
|
||||
}
|
||||
|
||||
assert(alignment >= min_alignment(), "Must be");
|
||||
|
||||
return alignment;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ static void fail(const char *msg, va_list ap) {
|
||||
" shared archive file.\n");
|
||||
jio_vfprintf(defaultStream::error_stream(), msg, ap);
|
||||
jio_fprintf(defaultStream::error_stream(), "\n");
|
||||
// Do not change the text of the below message because some tests check for it.
|
||||
vm_exit_during_initialization("Unable to use shared archive.", NULL);
|
||||
}
|
||||
|
||||
|
@ -95,13 +95,13 @@ jint GenCollectedHeap::initialize() {
|
||||
guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
|
||||
|
||||
// The heap must be at least as aligned as generations.
|
||||
size_t alignment = Generation::GenGrain;
|
||||
size_t gen_alignment = Generation::GenGrain;
|
||||
|
||||
_gen_specs = gen_policy()->generations();
|
||||
|
||||
// Make sure the sizes are all aligned.
|
||||
for (i = 0; i < _n_gens; i++) {
|
||||
_gen_specs[i]->align(alignment);
|
||||
_gen_specs[i]->align(gen_alignment);
|
||||
}
|
||||
|
||||
// Allocate space for the heap.
|
||||
@ -109,9 +109,11 @@ jint GenCollectedHeap::initialize() {
|
||||
char* heap_address;
|
||||
size_t total_reserved = 0;
|
||||
int n_covered_regions = 0;
|
||||
ReservedSpace heap_rs(0);
|
||||
ReservedSpace heap_rs;
|
||||
|
||||
heap_address = allocate(alignment, &total_reserved,
|
||||
size_t heap_alignment = collector_policy()->max_alignment();
|
||||
|
||||
heap_address = allocate(heap_alignment, &total_reserved,
|
||||
&n_covered_regions, &heap_rs);
|
||||
|
||||
if (!heap_rs.is_reserved()) {
|
||||
@ -168,6 +170,8 @@ char* GenCollectedHeap::allocate(size_t alignment,
|
||||
const size_t pageSize = UseLargePages ?
|
||||
os::large_page_size() : os::vm_page_size();
|
||||
|
||||
assert(alignment % pageSize == 0, "Must be");
|
||||
|
||||
for (int i = 0; i < _n_gens; i++) {
|
||||
total_reserved += _gen_specs[i]->max_size();
|
||||
if (total_reserved < _gen_specs[i]->max_size()) {
|
||||
@ -175,24 +179,17 @@ char* GenCollectedHeap::allocate(size_t alignment,
|
||||
}
|
||||
n_covered_regions += _gen_specs[i]->n_covered_regions();
|
||||
}
|
||||
assert(total_reserved % pageSize == 0,
|
||||
err_msg("Gen size; total_reserved=" SIZE_FORMAT ", pageSize="
|
||||
SIZE_FORMAT, total_reserved, pageSize));
|
||||
assert(total_reserved % alignment == 0,
|
||||
err_msg("Gen size; total_reserved=" SIZE_FORMAT ", alignment="
|
||||
SIZE_FORMAT, total_reserved, alignment));
|
||||
|
||||
// Needed until the cardtable is fixed to have the right number
|
||||
// of covered regions.
|
||||
n_covered_regions += 2;
|
||||
|
||||
if (UseLargePages) {
|
||||
assert(total_reserved != 0, "total_reserved cannot be 0");
|
||||
total_reserved = round_to(total_reserved, os::large_page_size());
|
||||
if (total_reserved < os::large_page_size()) {
|
||||
vm_exit_during_initialization(overflow_msg);
|
||||
}
|
||||
}
|
||||
*_total_reserved = total_reserved;
|
||||
*_n_covered_regions = n_covered_regions;
|
||||
|
||||
*_total_reserved = total_reserved;
|
||||
*_n_covered_regions = n_covered_regions;
|
||||
*heap_rs = Universe::reserve_heap(total_reserved, alignment);
|
||||
return heap_rs->base();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2013, 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
|
||||
@ -102,11 +102,11 @@ MemRegion MemRegion::minus(const MemRegion mr2) const {
|
||||
return MemRegion();
|
||||
}
|
||||
|
||||
void* MemRegion::operator new(size_t size) {
|
||||
void* MemRegion::operator new(size_t size) throw() {
|
||||
return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
void* MemRegion::operator new [](size_t size) {
|
||||
void* MemRegion::operator new [](size_t size) throw() {
|
||||
return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
void MemRegion::operator delete(void* p) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2013, 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
|
||||
@ -94,8 +94,8 @@ public:
|
||||
size_t word_size() const { return _word_size; }
|
||||
|
||||
bool is_empty() const { return word_size() == 0; }
|
||||
void* operator new(size_t size);
|
||||
void* operator new [](size_t size);
|
||||
void* operator new(size_t size) throw();
|
||||
void* operator new [](size_t size) throw();
|
||||
void operator delete(void* p);
|
||||
void operator delete [](void* p);
|
||||
};
|
||||
@ -111,13 +111,13 @@ public:
|
||||
|
||||
class MemRegionClosureRO: public MemRegionClosure {
|
||||
public:
|
||||
void* operator new(size_t size, ResourceObj::allocation_type type, MEMFLAGS flags) {
|
||||
void* operator new(size_t size, ResourceObj::allocation_type type, MEMFLAGS flags) throw() {
|
||||
return ResourceObj::operator new(size, type, flags);
|
||||
}
|
||||
void* operator new(size_t size, Arena *arena) {
|
||||
void* operator new(size_t size, Arena *arena) throw() {
|
||||
return ResourceObj::operator new(size, arena);
|
||||
}
|
||||
void* operator new(size_t size) {
|
||||
void* operator new(size_t size) throw() {
|
||||
return ResourceObj::operator new(size);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user