This commit is contained in:
Erik Helin 2014-02-03 10:49:49 +01:00
commit d52699c497
65 changed files with 1375 additions and 682 deletions

View File

@ -27,7 +27,9 @@ jar -cvf $SA_NAME/sa.jar -C ../build/classes .
cp ../src/os/solaris/proc/amd64/libsaproc.so $SA_NAME/solaris/amd64
cp ../src/os/solaris/proc/sparc/libsaproc.so $SA_NAME/solaris/sparc
cp ../src/os/solaris/proc/sparc/libsaproc_audit.so $SA_NAME/solaris/sparc
cp ../src/os/solaris/proc/sparcv9/libsaproc.so $SA_NAME/solaris/sparcv9
cp ../src/os/solaris/proc/sparcv9/libsaproc_audit.so $SA_NAME/solaris/sparcv9
cp ../src/os/solaris/proc/i386/libsaproc.so $SA_NAME/solaris/i386
cp ../src/os/linux/i386/libsaproc.so $SA_NAME/linux/i386
cp ../src/os/linux/ia64/libsaproc.so $SA_NAME/linux/ia64

View File

@ -48,16 +48,17 @@ if [ "$OS" = "Linux" ]; then
CPU=i386
fi
else
# configure audit helper library if SA_ALTROOT is set
if [ -n "$SA_ALTROOT" ]; then
# configure audit helper library for solaris
LD_AUDIT_32=$STARTDIR/../src/os/solaris/proc/`uname -p`/libsaproc_audit.so
export LD_AUDIT_32
if [ ! -f $LD_AUDIT_32 ]; then
echo "SA_ALTROOT is set and can't find libsaproc_audit.so."
LD_AUDIT_32=$STARTDIR/solaris/`uname -p`/libsaproc_audit.so
fi
if [ ! -f $LD_AUDIT_32 ]; then
echo "Can't find libsaproc_audit.so."
echo "Make sure to build it with 'make natives'."
exit 1
fi
fi
export LD_AUDIT_32
SA_LIBPATH=$STARTDIR/../src/os/solaris/proc/`uname -p`:$STARTDIR/solaris/`uname -p`
OPTIONS="-Dsa.library.path=$SA_LIBPATH -Dsun.jvm.hotspot.debugger.useProcDebugger"
CPU=sparc

View File

@ -43,16 +43,19 @@ else
fi
fi
# configure audit helper library if SA_ALTROOT is set
if [ -n "$SA_ALTROOT" ]; then
LD_AUDIT_64=$STARTDIR/../src/os/solaris/proc/$CPU/libsaproc_audit.so
export LD_AUDIT_64
if [ ! -f $LD_AUDIT_64 ]; then
echo "SA_ALTROOT is set and can't find libsaproc_audit.so."
# configure audit helper library
LD_AUDIT_64=$STARTDIR/../src/os/solaris/proc/$CPU/libsaproc_audit.so
if [ ! -f $LD_AUDIT_64 ]; then
LD_AUDIT_64=$STARTDIR/solaris/$CPU/libsaproc_audit.so
fi
if [ ! -f $LD_AUDIT_64 ]; then
echo "Can't find libsaproc_audit.so."
echo "Make sure to build it with 'make natives'."
exit 1
fi
fi
export LD_AUDIT_64
SA_LIBPATH=$STARTDIR/../src/os/solaris/proc/$CPU:$STARTDIR/solaris/$CPU
OPTIONS="-Dsa.library.path=$SA_LIBPATH -Dsun.jvm.hotspot.debugger.useProcDebugger"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2014, 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
@ -152,7 +152,7 @@ public class ConstantPool extends Metadata implements ClassConstants {
private long indexOffset(long index) {
if (Assert.ASSERTS_ENABLED) {
Assert.that(index > 0 && index < getLength(), "invalid cp index " + index + " " + getLength());
Assert.that(index >= 0 && index < getLength(), "invalid cp index " + index + " " + getLength());
}
return (index * getElementSize()) + headerSize;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2014, 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
@ -98,11 +98,14 @@ public class ByteCodeRewriter
break;
default: throw new IllegalArgumentException();
}
if (cpCache == null) {
return (short) cpCacheIndex;
} else if (fmt.indexOf("JJJJ") >= 0) {
// change byte-ordering and go via secondary cache entry
throw new InternalError("unimplemented");
// Invokedynamic require special handling
cpCacheIndex = ~cpCacheIndex;
cpCacheIndex = bytes.swapInt(cpCacheIndex);
return (short) cpCache.getEntryAt(cpCacheIndex).getConstantPoolIndex();
} else if (fmt.indexOf("JJ") >= 0) {
// change byte-ordering and go via cache
return (short) cpCache.getEntryAt((int) (0xFFFF & bytes.swapShort((short)cpCacheIndex))).getConstantPoolIndex();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2014, 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
@ -61,8 +61,9 @@ public class Hashtable extends BasicHashtable {
long h = 0;
int s = 0;
int len = buf.length;
// Emulate the unsigned int in java_lang_String::hash_code
while (len-- > 0) {
h = 31*h + (0xFFL & buf[s]);
h = 31*h + (0xFFFFFFFFL & buf[s]);
s++;
}
return h & 0xFFFFFFFFL;

View File

@ -64,7 +64,7 @@ MFLAGS=`
echo "$MFLAGS" \
| sed '
s/^-/ -/
s/ -\([^ ][^ ]*\)j/ -\1 -j/
s/ -\([^ I][^ I]*\)j/ -\1 -j/
s/ -j[0-9][0-9]*/ -j/
s/ -j\([^ ]\)/ -j -\1/
s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/

View File

@ -68,11 +68,9 @@ endif
# Use mapfile with libjvm_db.so
LIBJVM_DB_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_db
#LFLAGS_JVM_DB += $(MAPFLAG:FILENAME=$(LIBJVM_DB_MAPFILE))
# Use mapfile with libjvm_dtrace.so
LIBJVM_DTRACE_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace
#LFLAGS_JVM_DTRACE += $(MAPFLAG:FILENAME=$(LIBJVM_DTRACE_MAPFILE))
LFLAGS_JVM_DB += $(PICFLAG) # -D_REENTRANT
LFLAGS_JVM_DTRACE += $(PICFLAG) # -D_REENTRANT
@ -260,9 +258,6 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
endif
endif
#$(DTRACE).d: $(DTRACE_SRCDIR)/hotspot.d $(DTRACE_SRCDIR)/hotspot_jni.d \
# $(DTRACE_SRCDIR)/hs_private.d $(DTRACE_SRCDIR)/jhelper.d
# $(QUIETLY) cat $^ > $@
$(DtraceOutDir):
mkdir $(DtraceOutDir)
@ -276,100 +271,25 @@ $(DtraceOutDir)/hotspot_jni.h: $(DTRACE_SRCDIR)/hotspot_jni.d | $(DtraceOutDir)
$(DtraceOutDir)/hs_private.h: $(DTRACE_SRCDIR)/hs_private.d | $(DtraceOutDir)
$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hs_private.d
$(DtraceOutDir)/jhelper.h: $(DTRACE_SRCDIR)/jhelper.d $(JVMOFFS).o | $(DtraceOutDir)
$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/jhelper.d
# jhelper currently disabled
dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h
DTraced_Files = ciEnv.o \
classLoadingService.o \
compileBroker.o \
hashtable.o \
instanceKlass.o \
java.o \
jni.o \
jvm.o \
memoryManager.o \
nmethod.o \
objectMonitor.o \
runtimeService.o \
sharedRuntime.o \
synchronizer.o \
thread.o \
unsafe.o \
vmThread.o \
vmCMSOperations.o \
vmPSOperations.o \
vmGCOperations.o \
# Dtrace is available, so we build $(DTRACE.o)
#$(DTRACE.o): $(DTRACE).d $(JVMOFFS).h $(JVMOFFS)Index.h $(DTraced_Files)
# @echo Compiling $(DTRACE).d
# $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -xlazyload -o $@ -s $(DTRACE).d \
# $(DTraced_Files) ||\
# STATUS=$$?;\
# if [ x"$$STATUS" = x"1" -a \
# x`uname -r` = x"5.10" -a \
# x`uname -p` = x"sparc" ]; then\
# echo "*****************************************************************";\
# echo "* If you are building server compiler, and the error message is ";\
# echo "* \"incorrect ELF machine type...\", you have run into solaris bug ";\
# echo "* 6213962, \"dtrace -G doesn't work on sparcv8+ object files\".";\
# echo "* Either patch/upgrade your system (>= S10u1_15), or set the ";\
# echo "* environment variable HOTSPOT_DISABLE_DTRACE_PROBES to disable ";\
# echo "* dtrace probes for this build.";\
# echo "*****************************************************************";\
# fi;\
# exit $$STATUS
# Since some DTraced_Files are in LIBJVM.o and they are touched by this
# command, and libgenerateJvmOffsets.so depends on LIBJVM.o, 'make' will
# think it needs to rebuild libgenerateJvmOffsets.so and thus JvmOffsets*
# files, but it doesn't, so we touch the necessary files to prevent later
# recompilation. Note: we only touch the necessary files if they already
# exist in order to close a race where an empty file can be created
# before the real build rule is executed.
# But, we can't touch the *.h files: This rule depends
# on them, and that would cause an infinite cycle of rebuilding.
# Neither the *.h or *.ccp files need to be touched, since they have
# rules which do not update them when the generator file has not
# changed their contents.
# $(QUIETLY) if [ -f lib$(GENOFFS).so ]; then touch lib$(GENOFFS).so; fi
# $(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi
# $(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi
.PHONY: dtraceCheck
#SYSTEM_DTRACE_H = /usr/include/dtrace.h
SYSTEM_DTRACE_PROG = /usr/sbin/dtrace
#PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace
systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG})
#patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG})
#systemDtraceHdrFound := $(wildcard $(SYSTEM_DTRACE_H))
#ifneq ("$(systemDtraceHdrFound)", "")
#CFLAGS += -DHAVE_DTRACE_H
#endif
#ifneq ("$(patchDtraceFound)", "")
#DTRACE_PROG=$(PATCH_DTRACE_PROG)
#DTRACE_INCL=-I/opt/SUNWdtrd/include
#else
ifneq ("$(systemDtraceFound)", "")
DTRACE_PROG=$(SYSTEM_DTRACE_PROG)
else
endif # ifneq ("$(systemDtraceFound)", "")
#endif # ifneq ("$(patchDtraceFound)", "")
endif
ifneq ("${DTRACE_PROG}", "")
ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
DTRACE_OBJS = $(DTRACE.o) #$(JVMOFFS.o)
CFLAGS += -DDTRACE_ENABLED #$(DTRACE_INCL)
#clangCFLAGS += -DDTRACE_ENABLED -fno-optimize-sibling-calls
#MAPFILE_DTRACE_OPT = $(MAPFILE_DTRACE)
dtraceCheck:

View File

@ -64,7 +64,7 @@ MFLAGS=`
echo "$MFLAGS" \
| sed '
s/^-/ -/
s/ -\([^ ][^ ]*\)j/ -\1 -j/
s/ -\([^ I][^ I]*\)j/ -\1 -j/
s/ -j[0-9][0-9]*/ -j/
s/ -j\([^ ]\)/ -j -\1/
s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/

View File

@ -64,7 +64,7 @@ MFLAGS=`
echo "$MFLAGS" \
| sed '
s/^-/ -/
s/ -\([^ ][^ ]*\)j/ -\1 -j/
s/ -\([^ I][^ I]*\)j/ -\1 -j/
s/ -j[0-9][0-9]*/ -j/
s/ -j\([^ ]\)/ -j -\1/
s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/

View File

@ -117,7 +117,7 @@ SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
# For dependencies and recursive makes.
BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make sa.make
BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make sa.make dtrace.make
BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
@ -349,6 +349,16 @@ sa.make: $(BUILDTREE_MAKE)
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
) > $@
dtrace.make: $(BUILDTREE_MAKE)
@echo Creating $@ ...
$(QUIETLY) ( \
$(BUILDTREE_COMMENT); \
echo; \
echo include flags.make; \
echo; \
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
) > $@
FORCE:
.PHONY: all FORCE

View File

@ -36,6 +36,8 @@ dtraceCheck:
else
DtraceOutDir = $(GENERATED)/dtracefiles
JVM_DB = libjvm_db
LIBJVM_DB = libjvm_db.so
@ -326,6 +328,22 @@ $(DTRACE.o): $(DTRACE).d $(JVMOFFS).h $(JVMOFFS)Index.h $(DTraced_Files)
$(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi
$(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi
$(DtraceOutDir):
mkdir $(DtraceOutDir)
$(DtraceOutDir)/hotspot.h: $(DTRACE_SRCDIR)/hotspot.d | $(DtraceOutDir)
$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot.d
$(DtraceOutDir)/hotspot_jni.h: $(DTRACE_SRCDIR)/hotspot_jni.d | $(DtraceOutDir)
$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot_jni.d
$(DtraceOutDir)/hs_private.h: $(DTRACE_SRCDIR)/hs_private.d | $(DtraceOutDir)
$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hs_private.d
dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h
.PHONY: dtraceCheck
SYSTEM_DTRACE_H = /usr/include/dtrace.h

View File

@ -73,7 +73,7 @@ default: vm_build_preliminaries the_vm
@echo All done.
# This is an explicit dependency for the sake of parallel makes.
vm_build_preliminaries: checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stuff trace_stuff sa_stuff
vm_build_preliminaries: checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stuff trace_stuff sa_stuff dtrace_stuff
@# We need a null action here, so implicit rules don't get consulted.
$(Cached_plat): $(Plat_File)
@ -95,6 +95,9 @@ trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags)
sa_stuff:
@$(MAKE) -f sa.make $(MFLAGS-adjusted)
dtrace_stuff: $(Cached_plat) $(adjust-mflags)
@$(MAKE) -f dtrace.make dtrace_gen_headers $(MFLAGS-adjusted) GENERATED=$(GENERATED)
# and the VM: must use other makefile with dependencies included
# We have to go to great lengths to get control over the -jN argument

View File

@ -3361,8 +3361,8 @@ operand immI16() %{
interface(CONST_INTER);
%}
// Unsigned (positive) Integer Immediate: 13-bit
operand immU13() %{
// Unsigned Integer Immediate: 12-bit (non-negative that fits in simm13)
operand immU12() %{
predicate((0 <= n->get_int()) && Assembler::is_simm13(n->get_int()));
match(ConI);
op_cost(0);
@ -3398,6 +3398,17 @@ operand immI5() %{
interface(CONST_INTER);
%}
// Int Immediate non-negative
operand immU31()
%{
predicate(n->get_int() >= 0);
match(ConI);
op_cost(0);
format %{ %}
interface(CONST_INTER);
%}
// Integer Immediate: 0-bit
operand immI0() %{
predicate(n->get_int() == 0);
@ -5726,7 +5737,6 @@ instruct loadUS2L_immI16(iRegL dst, memory mem, immI16 mask, iRegL tmp) %{
effect(TEMP dst, TEMP tmp);
ins_cost(MEMORY_REF_COST + 2*DEFAULT_COST);
size((3+1)*4); // set may use two instructions.
format %{ "LDUH $mem,$dst\t! ushort/char & 16-bit mask -> long\n\t"
"SET $mask,$tmp\n\t"
"AND $dst,$tmp,$dst" %}
@ -5848,13 +5858,13 @@ instruct loadI2L_immI_65535(iRegL dst, indOffset13m7 mem, immI_65535 mask) %{
ins_pipe(iload_mem);
%}
// Load Integer with a 13-bit mask into a Long Register
instruct loadI2L_immI13(iRegL dst, memory mem, immI13 mask) %{
// Load Integer with a 12-bit mask into a Long Register
instruct loadI2L_immU12(iRegL dst, memory mem, immU12 mask) %{
match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
ins_cost(MEMORY_REF_COST + DEFAULT_COST);
size(2*4);
format %{ "LDUW $mem,$dst\t! int & 13-bit mask -> long\n\t"
format %{ "LDUW $mem,$dst\t! int & 12-bit mask -> long\n\t"
"AND $dst,$mask,$dst" %}
ins_encode %{
Register Rdst = $dst$$Register;
@ -5864,14 +5874,13 @@ instruct loadI2L_immI13(iRegL dst, memory mem, immI13 mask) %{
ins_pipe(iload_mem);
%}
// Load Integer with a 32-bit mask into a Long Register
instruct loadI2L_immI(iRegL dst, memory mem, immI mask, iRegL tmp) %{
// Load Integer with a 31-bit mask into a Long Register
instruct loadI2L_immU31(iRegL dst, memory mem, immU31 mask, iRegL tmp) %{
match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
effect(TEMP dst, TEMP tmp);
ins_cost(MEMORY_REF_COST + 2*DEFAULT_COST);
size((3+1)*4); // set may use two instructions.
format %{ "LDUW $mem,$dst\t! int & 32-bit mask -> long\n\t"
format %{ "LDUW $mem,$dst\t! int & 31-bit mask -> long\n\t"
"SET $mask,$tmp\n\t"
"AND $dst,$tmp,$dst" %}
ins_encode %{
@ -8966,7 +8975,7 @@ instruct testL_reg_con(flagsRegL xcc, iRegL op1, immL13 con, immL0 zero) %{
ins_pipe(ialu_cconly_reg_reg);
%}
instruct compU_iReg_imm13(flagsRegU icc, iRegI op1, immU13 op2 ) %{
instruct compU_iReg_imm13(flagsRegU icc, iRegI op1, immU12 op2 ) %{
match(Set icc (CmpU op1 op2));
size(4);

View File

@ -3889,6 +3889,17 @@ operand immI16() %{
interface(CONST_INTER);
%}
// Int Immediate non-negative
operand immU31()
%{
predicate(n->get_int() >= 0);
match(ConI);
op_cost(0);
format %{ %}
interface(CONST_INTER);
%}
// Constant for long shifts
operand immI_32() %{
predicate( n->get_int() == 32 );
@ -6119,12 +6130,12 @@ instruct loadI2L_immI_65535(eRegL dst, memory mem, immI_65535 mask, eFlagsReg cr
ins_pipe(ialu_reg_mem);
%}
// Load Integer with 32-bit mask into Long Register
instruct loadI2L_immI(eRegL dst, memory mem, immI mask, eFlagsReg cr) %{
// Load Integer with 31-bit mask into Long Register
instruct loadI2L_immU31(eRegL dst, memory mem, immU31 mask, eFlagsReg cr) %{
match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
effect(KILL cr);
format %{ "MOV $dst.lo,$mem\t# int & 32-bit mask -> long\n\t"
format %{ "MOV $dst.lo,$mem\t# int & 31-bit mask -> long\n\t"
"XOR $dst.hi,$dst.hi\n\t"
"AND $dst.lo,$mask" %}
ins_encode %{

View File

@ -3086,6 +3086,17 @@ operand immI16()
interface(CONST_INTER);
%}
// Int Immediate non-negative
operand immU31()
%{
predicate(n->get_int() >= 0);
match(ConI);
op_cost(0);
format %{ %}
interface(CONST_INTER);
%}
// Constant for long shifts
operand immI_32()
%{
@ -5042,12 +5053,12 @@ instruct loadI2L_immI_65535(rRegL dst, memory mem, immI_65535 mask) %{
ins_pipe(ialu_reg_mem);
%}
// Load Integer with a 32-bit mask into Long Register
instruct loadI2L_immI(rRegL dst, memory mem, immI mask, rFlagsReg cr) %{
// Load Integer with a 31-bit mask into Long Register
instruct loadI2L_immU31(rRegL dst, memory mem, immU31 mask, rFlagsReg cr) %{
match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
effect(KILL cr);
format %{ "movl $dst, $mem\t# int & 32-bit mask -> long\n\t"
format %{ "movl $dst, $mem\t# int & 31-bit mask -> long\n\t"
"andl $dst, $mask" %}
ins_encode %{
Register Rdst = $dst$$Register;

View File

@ -56,7 +56,7 @@ provider hotspot {
probe thread__park__end(uintptr_t);
probe thread__unpark(uintptr_t);
probe method__compile__begin(
const char*, uintptr_t, const char*, uintptr_t, const char*, uintptr_t, const char*, uintptr_t);
char*, uintptr_t, char*, uintptr_t, char*, uintptr_t, char*, uintptr_t);
probe method__compile__end(
char*, uintptr_t, char*, uintptr_t, char*, uintptr_t,
char*, uintptr_t, uintptr_t);

View File

@ -1557,6 +1557,17 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
}
#endif /* !__APPLE__ */
void* os::get_default_process_handle() {
#ifdef __APPLE__
// MacOS X needs to use RTLD_FIRST instead of RTLD_LAZY
// to avoid finding unexpected symbols on second (or later)
// loads of a library.
return (void*)::dlopen(NULL, RTLD_FIRST);
#else
return (void*)::dlopen(NULL, RTLD_LAZY);
#endif
}
// XXX: Do we need a lock around this as per Linux?
void* os::dll_lookup(void* handle, const char* name) {
return dlsym(handle, name);
@ -2625,9 +2636,21 @@ int os::sleep(Thread* thread, jlong millis, bool interruptible) {
}
}
int os::naked_sleep() {
// %% make the sleep time an integer flag. for now use 1 millisec.
return os::sleep(Thread::current(), 1, false);
void os::naked_short_sleep(jlong ms) {
struct timespec req;
assert(ms < 1000, "Un-interruptable sleep, short time use only");
req.tv_sec = 0;
if (ms > 0) {
req.tv_nsec = (ms % 1000) * 1000000;
}
else {
req.tv_nsec = 1;
}
nanosleep(&req, NULL);
return;
}
// Sleep forever; naked call to OS-specific sleep; use with CAUTION

View File

@ -2104,6 +2104,9 @@ void* os::dll_lookup(void* handle, const char* name) {
return res;
}
void* os::get_default_process_handle() {
return (void*)::dlopen(NULL, RTLD_LAZY);
}
static bool _print_ascii_file(const char* filename, outputStream* st) {
int fd = ::open(filename, O_RDONLY);
@ -3868,9 +3871,33 @@ int os::sleep(Thread* thread, jlong millis, bool interruptible) {
}
}
int os::naked_sleep() {
// %% make the sleep time an integer flag. for now use 1 millisec.
return os::sleep(Thread::current(), 1, false);
//
// Short sleep, direct OS call.
//
// Note: certain versions of Linux CFS scheduler (since 2.6.23) do not guarantee
// sched_yield(2) will actually give up the CPU:
//
// * Alone on this pariticular CPU, keeps running.
// * Before the introduction of "skip_buddy" with "compat_yield" disabled
// (pre 2.6.39).
//
// So calling this with 0 is an alternative.
//
void os::naked_short_sleep(jlong ms) {
struct timespec req;
assert(ms < 1000, "Un-interruptable sleep, short time use only");
req.tv_sec = 0;
if (ms > 0) {
req.tv_nsec = (ms % 1000) * 1000000;
}
else {
req.tv_nsec = 1;
}
nanosleep(&req, NULL);
return;
}
// Sleep forever; naked call to OS-specific sleep; use with CAUTION

View File

@ -262,10 +262,6 @@ 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:

View File

@ -25,7 +25,7 @@
provider hotspot {
probe class__loaded(char*, uintptr_t, void*, uintptr_t);
probe class__unloaded(char*, uintptr_t, void*, uintptr_t);
probe class__initialization__required(char*, uintptr_t, void*, intptr_t,int);
probe class__initialization__required(char*, uintptr_t, void*, intptr_t);
probe class__initialization__recursive(char*, uintptr_t, void*, intptr_t,int);
probe class__initialization__concurrent(char*, uintptr_t, void*, intptr_t,int);
probe class__initialization__erroneous(char*, uintptr_t, void*, intptr_t, int);

View File

@ -211,7 +211,7 @@ provider hotspot_jni {
probe CallVoidMethodV__return();
probe CreateJavaVM__entry(void**, void**, void*);
probe CreateJavaVM__return(uint32_t);
probe DefineClass__entry(void*, const char*, void*, char, uintptr_t);
probe DefineClass__entry(void*, const char*, void*, char*, uintptr_t);
probe DefineClass__return(void*);
probe DeleteGlobalRef__entry(void*, void*);
probe DeleteGlobalRef__return();

View File

@ -2146,6 +2146,10 @@ void* os::dll_lookup(void* handle, const char* name) {
return dlsym(handle, name);
}
void* os::get_default_process_handle() {
return (void*)::dlopen(NULL, RTLD_LAZY);
}
int os::stat(const char *path, struct stat *sbuf) {
char pathbuf[MAX_PATH];
if (strlen(path) > MAX_PATH - 1) {
@ -3536,9 +3540,14 @@ int os::sleep(Thread* thread, jlong millis, bool interruptible) {
return os_sleep(millis, interruptible);
}
int os::naked_sleep() {
// %% make the sleep time an integer flag. for now use 1 millisec.
return os_sleep(1, false);
void os::naked_short_sleep(jlong ms) {
assert(ms < 1000, "Un-interruptable sleep, short time use only");
// usleep is deprecated and removed from POSIX, in favour of nanosleep, but
// Solaris requires -lrt for this.
usleep((ms * 1000));
return;
}
// Sleep forever; naked call to OS-specific sleep; use with CAUTION

View File

@ -3486,6 +3486,16 @@ int os::sleep(Thread* thread, jlong ms, bool interruptable) {
return result;
}
//
// Short sleep, direct OS call.
//
// ms = 0, means allow others (if any) to run.
//
void os::naked_short_sleep(jlong ms) {
assert(ms < 1000, "Un-interruptable sleep, short time use only");
Sleep(ms);
}
// Sleep forever; naked call to OS-specific sleep; use with CAUTION
void os::infinite_sleep() {
while (true) { // sleep forever ...

View File

@ -49,6 +49,7 @@
#include "runtime/stubRoutines.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/timer.hpp"
#include "services/memTracker.hpp"
#include "utilities/events.hpp"
#include "utilities/vmError.hpp"
@ -906,6 +907,9 @@ void os::workaround_expand_exec_shield_cs_limit() {
if ( (codebuf == NULL) || (!os::commit_memory(codebuf, page_size, true)) ) {
return; // No matter, we tried, best effort.
}
MemTracker::record_virtual_memory_type((address)codebuf, mtInternal);
if (PrintMiscellaneous && (Verbose || WizardMode)) {
tty->print_cr("[CS limit NX emulation work-around, exec code at: %p]", codebuf);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, 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
@ -4504,8 +4504,8 @@ void ClassFileParser::check_final_method_override(instanceKlassHandle this_klass
break; // didn't find any match; get out
}
if (super_m->is_final() &&
// matching method in super is final
if (super_m->is_final() && !super_m->is_static() &&
// matching method in super is final, and not static
(Reflection::verify_field_access(this_klass(),
super_m->method_holder(),
super_m->method_holder(),

View File

@ -1221,11 +1221,9 @@ bool Dependencies::is_concrete_method(Method* m) {
// We could also return false if m does not yet appear to be
// executed, if the VM version supports this distinction also.
// Default methods are considered "concrete" as well.
return !m->is_abstract() &&
!InstanceKlass::cast(m->method_holder())->is_interface();
// TODO: investigate whether default methods should be
// considered as "concrete" in this situation. For now they
// are not.
!m->is_overpass(); // error functions aren't concrete
}

View File

@ -98,7 +98,7 @@ HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end,
Symbol* name = (method)->name(); \
Symbol* signature = (method)->signature(); \
HOTSPOT_METHOD_COMPILE_BEGIN( \
comp_name, strlen(comp_name), \
(char *) comp_name, strlen(comp_name), \
(char *) klass_name->bytes(), klass_name->utf8_length(), \
(char *) name->bytes(), name->utf8_length(), \
(char *) signature->bytes(), signature->utf8_length()); \
@ -110,7 +110,7 @@ HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end,
Symbol* name = (method)->name(); \
Symbol* signature = (method)->signature(); \
HOTSPOT_METHOD_COMPILE_END( \
comp_name, strlen(comp_name), \
(char *) comp_name, strlen(comp_name), \
(char *) klass_name->bytes(), klass_name->utf8_length(), \
(char *) name->bytes(), name->utf8_length(), \
(char *) signature->bytes(), signature->utf8_length(), (success)); \

View File

@ -141,8 +141,7 @@ void VM_CMS_Initial_Mark::doit() {
#ifndef USDT2
HS_DTRACE_PROBE(hs_private, cms__initmark__begin);
#else /* USDT2 */
HS_PRIVATE_CMS_INITMARK_BEGIN(
);
HS_PRIVATE_CMS_INITMARK_BEGIN();
#endif /* USDT2 */
_collector->_gc_timer_cm->register_gc_pause_start("Initial Mark");
@ -162,8 +161,7 @@ void VM_CMS_Initial_Mark::doit() {
#ifndef USDT2
HS_DTRACE_PROBE(hs_private, cms__initmark__end);
#else /* USDT2 */
HS_PRIVATE_CMS_INITMARK_END(
);
HS_PRIVATE_CMS_INITMARK_END();
#endif /* USDT2 */
}
@ -178,8 +176,7 @@ void VM_CMS_Final_Remark::doit() {
#ifndef USDT2
HS_DTRACE_PROBE(hs_private, cms__remark__begin);
#else /* USDT2 */
HS_PRIVATE_CMS_REMARK_BEGIN(
);
HS_PRIVATE_CMS_REMARK_BEGIN();
#endif /* USDT2 */
_collector->_gc_timer_cm->register_gc_pause_start("Final Mark");
@ -200,8 +197,7 @@ void VM_CMS_Final_Remark::doit() {
#ifndef USDT2
HS_DTRACE_PROBE(hs_private, cms__remark__end);
#else /* USDT2 */
HS_PRIVATE_CMS_REMARK_END(
);
HS_PRIVATE_CMS_REMARK_END();
#endif /* USDT2 */
}

View File

@ -56,6 +56,7 @@ void VM_GC_Operation::notify_gc_begin(bool full) {
#else /* USDT2 */
HOTSPOT_GC_BEGIN(
full);
HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
#endif /* USDT2 */
}
@ -64,8 +65,8 @@ void VM_GC_Operation::notify_gc_end() {
HS_DTRACE_PROBE(hotspot, gc__end);
HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
#else /* USDT2 */
HOTSPOT_GC_END(
);
HOTSPOT_GC_END();
HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
#endif /* USDT2 */
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, 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
@ -649,16 +649,6 @@ void LinkResolver::resolve_interface_method(methodHandle& resolved_method,
}
}
if (nostatics && resolved_method->is_static()) {
ResourceMark rm(THREAD);
char buf[200];
jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", Method::name_and_sig_as_C_string(resolved_klass(),
resolved_method->name(),
resolved_method->signature()));
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
}
if (check_access) {
// JDK8 adds non-public interface methods, and accessability check requirement
assert(current_klass.not_null() , "current_klass should not be null");
@ -702,6 +692,15 @@ void LinkResolver::resolve_interface_method(methodHandle& resolved_method,
}
}
if (nostatics && resolved_method->is_static()) {
ResourceMark rm(THREAD);
char buf[200];
jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s",
Method::name_and_sig_as_C_string(resolved_klass(),
resolved_method->name(), resolved_method->signature()));
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
}
if (TraceItables && Verbose) {
ResourceMark rm(THREAD);
tty->print("invokeinterface resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, 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
@ -1874,7 +1874,6 @@ void ConstantPool::preload_and_initialize_all_classes(ConstantPool* obj, TRAPS)
// Printing
void ConstantPool::print_on(outputStream* st) const {
EXCEPTION_MARK;
assert(is_constantPool(), "must be constantPool");
st->print_cr(internal_name());
if (flags() != 0) {

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2014, 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
@ -272,7 +272,7 @@ class VM_GetCurrentLocation : public VM_Operation {
// There can be a race condition between a VM_Operation reaching a safepoint
// and the target thread exiting from Java execution.
// We must recheck the last Java frame still exists.
if (_thread->has_last_Java_frame()) {
if (!_thread->is_exiting() && _thread->has_last_Java_frame()) {
javaVFrame* vf = _thread->last_java_vframe(&rm);
assert(vf != NULL, "must have last java frame");
Method* method = vf->method();

View File

@ -175,8 +175,8 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target) {
oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
assert(info.resolved_appendix().is_null(), "only normal methods here");
KlassHandle receiver_limit = info.resolved_klass();
methodHandle m = info.resolved_method();
KlassHandle m_klass = m->method_holder();
int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS );
int vmindex = Method::invalid_vtable_index;
@ -184,14 +184,13 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
case CallInfo::itable_call:
vmindex = info.itable_index();
// More importantly, the itable index only works with the method holder.
receiver_limit = m->method_holder();
assert(receiver_limit->verify_itable_index(vmindex), "");
assert(m_klass->verify_itable_index(vmindex), "");
flags |= IS_METHOD | (JVM_REF_invokeInterface << REFERENCE_KIND_SHIFT);
if (TraceInvokeDynamic) {
ResourceMark rm;
tty->print_cr("memberName: invokeinterface method_holder::method: %s, receiver: %s, itableindex: %d, access_flags:",
Method::name_and_sig_as_C_string(receiver_limit(), m->name(), m->signature()),
receiver_limit()->internal_name(), vmindex);
tty->print_cr("memberName: invokeinterface method_holder::method: %s, itableindex: %d, access_flags:",
Method::name_and_sig_as_C_string(m->method_holder(), m->name(), m->signature()),
vmindex);
m->access_flags().print_on(tty);
if (!m->is_abstract()) {
tty->print("default");
@ -203,12 +202,35 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
case CallInfo::vtable_call:
vmindex = info.vtable_index();
flags |= IS_METHOD | (JVM_REF_invokeVirtual << REFERENCE_KIND_SHIFT);
assert(receiver_limit->is_subtype_of(m->method_holder()), "virtual call must be type-safe");
assert(info.resolved_klass()->is_subtype_of(m_klass()), "virtual call must be type-safe");
if (m_klass->is_interface()) {
// This is a vtable call to an interface method (abstract "miranda method" or default method).
// The vtable index is meaningless without a class (not interface) receiver type, so get one.
// (LinkResolver should help us figure this out.)
KlassHandle m_klass_non_interface = info.resolved_klass();
if (m_klass_non_interface->is_interface()) {
m_klass_non_interface = SystemDictionary::Object_klass();
#ifdef ASSERT
{ ResourceMark rm;
Method* m2 = m_klass_non_interface->vtable()->method_at(vmindex);
assert(m->name() == m2->name() && m->signature() == m2->signature(),
err_msg("at %d, %s != %s", vmindex,
m->name_and_sig_as_C_string(), m2->name_and_sig_as_C_string()));
}
#endif //ASSERT
}
if (!m->is_public()) {
assert(m->is_public(), "virtual call must be to public interface method");
return NULL; // elicit an error later in product build
}
assert(info.resolved_klass()->is_subtype_of(m_klass_non_interface()), "virtual call must be type-safe");
m_klass = m_klass_non_interface;
}
if (TraceInvokeDynamic) {
ResourceMark rm;
tty->print_cr("memberName: invokevirtual method_holder::method: %s, receiver: %s, vtableindex: %d, access_flags:",
Method::name_and_sig_as_C_string(receiver_limit(), m->name(), m->signature()),
receiver_limit()->internal_name(), vmindex);
Method::name_and_sig_as_C_string(m->method_holder(), m->name(), m->signature()),
m_klass->internal_name(), vmindex);
m->access_flags().print_on(tty);
if (m->is_default_method()) {
tty->print("default");
@ -223,10 +245,8 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT);
} else if (m->is_initializer()) {
flags |= IS_CONSTRUCTOR | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT);
assert(receiver_limit == m->method_holder(), "constructor call must be exactly typed");
} else {
flags |= IS_METHOD | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT);
assert(receiver_limit->is_subtype_of(m->method_holder()), "special call must be type-safe");
}
break;
@ -242,7 +262,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
java_lang_invoke_MemberName::set_flags( mname_oop, flags);
java_lang_invoke_MemberName::set_vmtarget(mname_oop, m());
java_lang_invoke_MemberName::set_vmindex( mname_oop, vmindex); // vtable/itable index
java_lang_invoke_MemberName::set_clazz( mname_oop, receiver_limit->java_mirror());
java_lang_invoke_MemberName::set_clazz( mname_oop, m_klass->java_mirror());
// Note: name and type can be lazily computed by resolve_MemberName,
// if Java code needs them as resolved String and MethodType objects.
// The clazz must be eagerly stored, because it provides a GC
@ -569,7 +589,7 @@ oop MethodHandles::field_signature_type_or_null(Symbol* s) {
// An unresolved member name is a mere symbolic reference.
// Resolving it plants a vmtarget/vmindex in it,
// which refers directly to JVM internals.
Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
Handle MethodHandles::resolve_MemberName(Handle mname, KlassHandle caller, TRAPS) {
Handle empty;
assert(java_lang_invoke_MemberName::is_instance(mname()), "");
@ -646,20 +666,20 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
assert(!HAS_PENDING_EXCEPTION, "");
if (ref_kind == JVM_REF_invokeStatic) {
LinkResolver::resolve_static_call(result,
defc, name, type, KlassHandle(), false, false, THREAD);
defc, name, type, caller, caller.not_null(), false, THREAD);
} else if (ref_kind == JVM_REF_invokeInterface) {
LinkResolver::resolve_interface_call(result, Handle(), defc,
defc, name, type, KlassHandle(), false, false, THREAD);
defc, name, type, caller, caller.not_null(), false, THREAD);
} else if (mh_invoke_id != vmIntrinsics::_none) {
assert(!is_signature_polymorphic_static(mh_invoke_id), "");
LinkResolver::resolve_handle_call(result,
defc, name, type, KlassHandle(), THREAD);
defc, name, type, caller, THREAD);
} else if (ref_kind == JVM_REF_invokeSpecial) {
LinkResolver::resolve_special_call(result,
defc, name, type, KlassHandle(), false, THREAD);
defc, name, type, caller, caller.not_null(), THREAD);
} else if (ref_kind == JVM_REF_invokeVirtual) {
LinkResolver::resolve_virtual_call(result, Handle(), defc,
defc, name, type, KlassHandle(), false, false, THREAD);
defc, name, type, caller, caller.not_null(), false, THREAD);
} else {
assert(false, err_msg("ref_kind=%d", ref_kind));
}
@ -683,7 +703,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
assert(!HAS_PENDING_EXCEPTION, "");
if (name == vmSymbols::object_initializer_name()) {
LinkResolver::resolve_special_call(result,
defc, name, type, KlassHandle(), false, THREAD);
defc, name, type, caller, caller.not_null(), THREAD);
} else {
break; // will throw after end of switch
}
@ -700,7 +720,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
fieldDescriptor result; // find_field initializes fd if found
{
assert(!HAS_PENDING_EXCEPTION, "");
LinkResolver::resolve_field(result, defc, name, type, KlassHandle(), Bytecodes::_nop, false, false, THREAD);
LinkResolver::resolve_field(result, defc, name, type, caller, Bytecodes::_nop, false, false, THREAD);
if (HAS_PENDING_EXCEPTION) {
return empty;
}
@ -1121,7 +1141,11 @@ JVM_ENTRY(jobject, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh,
}
}
Handle resolved = MethodHandles::resolve_MemberName(mname, CHECK_NULL);
KlassHandle caller(THREAD,
caller_jh == NULL ? (Klass*) NULL :
java_lang_Class::as_Klass(JNIHandles::resolve_non_null(caller_jh)));
Handle resolved = MethodHandles::resolve_MemberName(mname, caller, CHECK_NULL);
if (resolved.is_null()) {
int flags = java_lang_invoke_MemberName::flags(mname());
int ref_kind = (flags >> REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK;

View File

@ -55,7 +55,7 @@ class MethodHandles: AllStatic {
public:
// working with member names
static Handle resolve_MemberName(Handle mname, TRAPS); // compute vmtarget/vmindex from name/type
static Handle resolve_MemberName(Handle mname, KlassHandle caller, TRAPS); // compute vmtarget/vmindex from name/type
static void expand_MemberName(Handle mname, int suppress, TRAPS); // expand defc/name/type if missing
static Handle new_MemberName(TRAPS); // must be followed by init_MemberName
static oop init_MemberName(Handle mname_h, Handle target_h); // compute vmtarget/vmindex from target

View File

@ -878,7 +878,7 @@ bool Arguments::process_argument(const char* arg,
arg_len = equal_sign - argname;
}
Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true);
Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true);
if (found_flag != NULL) {
char locked_message_buf[BUFLEN];
found_flag->get_locked_message(locked_message_buf, BUFLEN);

View File

@ -31,6 +31,7 @@
#include "utilities/ostream.hpp"
#include "utilities/macros.hpp"
#include "utilities/top.hpp"
#include "trace/tracing.hpp"
#if INCLUDE_ALL_GCS
#include "gc_implementation/g1/g1_globals.hpp"
#endif // INCLUDE_ALL_GCS
@ -62,6 +63,14 @@ ARCH_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, \
MATERIALIZE_FLAGS_EXT
static bool is_product_build() {
#ifdef PRODUCT
return true;
#else
return false;
#endif
}
void Flag::check_writable() {
if (is_constant_in_binary()) {
fatal(err_msg("flag is constant: %s", _name));
@ -235,6 +244,27 @@ bool Flag::is_unlocked() const {
// Get custom message for this locked flag, or return NULL if
// none is available.
void Flag::get_locked_message(char* buf, int buflen) const {
buf[0] = '\0';
if (is_diagnostic() && !is_unlocked()) {
jio_snprintf(buf, buflen, "Error: VM option '%s' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.\n",
_name);
return;
}
if (is_experimental() && !is_unlocked()) {
jio_snprintf(buf, buflen, "Error: VM option '%s' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.\n",
_name);
return;
}
if (is_develop() && is_product_build()) {
jio_snprintf(buf, buflen, "Error: VM option '%s' is develop and is available only in debug version of VM.\n",
_name);
return;
}
if (is_notproduct() && is_product_build()) {
jio_snprintf(buf, buflen, "Error: VM option '%s' is notproduct and is available only in debug version of VM.\n",
_name);
return;
}
get_locked_message_ext(buf, buflen);
}
@ -464,13 +494,13 @@ inline bool str_equal(const char* s, const char* q, size_t len) {
}
// Search the flag table for a named flag
Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked) {
Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) {
for (Flag* current = &flagTable[0]; current->_name != NULL; current++) {
if (str_equal(current->_name, name, length)) {
// Found a matching entry.
// Don't report notproduct and develop flags in product builds.
if (current->is_constant_in_binary()) {
return NULL;
return (return_flag == true ? current : NULL);
}
// Report locked flags only if allowed.
if (!(current->is_unlocked() || current->is_unlocker())) {
@ -564,6 +594,17 @@ bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
return true;
}
template<class E, class T>
static void trace_flag_changed(const char* name, const T old_value, const T new_value, const Flag::Flags origin)
{
E e;
e.set_name(name);
e.set_old_value(old_value);
e.set_new_value(new_value);
e.set_origin(origin);
e.commit();
}
bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) {
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return false;
@ -577,6 +618,7 @@ bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flag
if (result == NULL) return false;
if (!result->is_bool()) return false;
bool old_value = result->get_bool();
trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
result->set_bool(*value);
*value = old_value;
result->set_origin(origin);
@ -586,6 +628,7 @@ bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flag
void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
trace_flag_changed<EventBooleanFlagChanged, bool>(faddr->_name, faddr->get_bool(), value, origin);
faddr->set_bool(value);
faddr->set_origin(origin);
}
@ -603,6 +646,7 @@ bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flag
if (result == NULL) return false;
if (!result->is_intx()) return false;
intx old_value = result->get_intx();
trace_flag_changed<EventLongFlagChanged, s8>(name, old_value, *value, origin);
result->set_intx(*value);
*value = old_value;
result->set_origin(origin);
@ -612,6 +656,7 @@ bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flag
void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
trace_flag_changed<EventLongFlagChanged, s8>(faddr->_name, faddr->get_intx(), value, origin);
faddr->set_intx(value);
faddr->set_origin(origin);
}
@ -629,6 +674,7 @@ bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Fl
if (result == NULL) return false;
if (!result->is_uintx()) return false;
uintx old_value = result->get_uintx();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
result->set_uintx(*value);
*value = old_value;
result->set_origin(origin);
@ -638,6 +684,7 @@ bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Fl
void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uintx(), value, origin);
faddr->set_uintx(value);
faddr->set_origin(origin);
}
@ -655,6 +702,7 @@ bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Fl
if (result == NULL) return false;
if (!result->is_uint64_t()) return false;
uint64_t old_value = result->get_uint64_t();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
result->set_uint64_t(*value);
*value = old_value;
result->set_origin(origin);
@ -664,6 +712,7 @@ bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Fl
void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uint64_t(), value, origin);
faddr->set_uint64_t(value);
faddr->set_origin(origin);
}
@ -681,6 +730,7 @@ bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::
if (result == NULL) return false;
if (!result->is_double()) return false;
double old_value = result->get_double();
trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
result->set_double(*value);
*value = old_value;
result->set_origin(origin);
@ -690,6 +740,7 @@ bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::
void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin);
faddr->set_double(value);
faddr->set_origin(origin);
}
@ -707,6 +758,7 @@ bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Fl
if (result == NULL) return false;
if (!result->is_ccstr()) return false;
ccstr old_value = result->get_ccstr();
trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin);
char* new_value = NULL;
if (*value != NULL) {
new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal);
@ -728,6 +780,7 @@ void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, F
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
ccstr old_value = faddr->get_ccstr();
trace_flag_changed<EventStringFlagChanged, const char*>(faddr->_name, old_value, value, origin);
char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal);
strcpy(new_value, value);
faddr->set_ccstr(new_value);

View File

@ -241,7 +241,7 @@ struct Flag {
// number of flags
static size_t numFlags;
static Flag* find_flag(const char* name, size_t length, bool allow_locked = false);
static Flag* find_flag(const char* name, size_t length, bool allow_locked = false, bool return_flag = false);
static Flag* fuzzy_match(const char* name, size_t length, bool allow_locked = false);
void check_writable();

View File

@ -608,6 +608,7 @@ void notify_vm_shutdown() {
HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
#else /* USDT2 */
HOTSPOT_VM_SHUTDOWN();
HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
#endif /* USDT2 */
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, 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
@ -195,9 +195,11 @@ private:
int _count;
public:
CountHandleClosure(): _count(0) {}
virtual void do_oop(oop* unused) {
virtual void do_oop(oop* ooph) {
if (*ooph != JNIHandles::deleted_handle()) {
_count++;
}
}
virtual void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
int count() { return _count; }
};

View File

@ -1262,9 +1262,6 @@ bool os::set_boot_path(char fileSep, char pathSep) {
"%/lib/jce.jar:"
"%/lib/charsets.jar:"
"%/lib/jfr.jar:"
#ifdef __APPLE__
"%/lib/JObjC.jar:"
#endif
"%/classes";
char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep);
if (sysclasspath == NULL) return false;

View File

@ -430,7 +430,10 @@ class os: AllStatic {
static intx current_thread_id();
static int current_process_id();
static int sleep(Thread* thread, jlong ms, bool interruptable);
static int naked_sleep();
// Short standalone OS sleep suitable for slow path spin loop.
// Ignores Thread.interrupt() (so keep it short).
// ms = 0, will sleep for the least amount of time allowed by the OS.
static void naked_short_sleep(jlong ms);
static void infinite_sleep(); // never returns, use with CAUTION
static void yield(); // Yields to all threads with same priority
enum YieldResult {

View File

@ -59,58 +59,22 @@ ParkEvent * ParkEvent::Allocate (Thread * t) {
// Start by trying to recycle an existing but unassociated
// ParkEvent from the global free list.
for (;;) {
ev = FreeList ;
if (ev == NULL) break ;
// 1: Detach - sequester or privatize the list
// Tantamount to ev = Swap (&FreeList, NULL)
if (Atomic::cmpxchg_ptr (NULL, &FreeList, ev) != ev) {
continue ;
// Using a spin lock since we are part of the mutex impl.
// 8028280: using concurrent free list without memory management can leak
// pretty badly it turns out.
Thread::SpinAcquire(&ListLock, "ParkEventFreeListAllocate");
{
ev = FreeList;
if (ev != NULL) {
FreeList = ev->FreeNext;
}
// We've detached the list. The list in-hand is now
// local to this thread. This thread can operate on the
// list without risk of interference from other threads.
// 2: Extract -- pop the 1st element from the list.
ParkEvent * List = ev->FreeNext ;
if (List == NULL) break ;
for (;;) {
// 3: Try to reattach the residual list
guarantee (List != NULL, "invariant") ;
ParkEvent * Arv = (ParkEvent *) Atomic::cmpxchg_ptr (List, &FreeList, NULL) ;
if (Arv == NULL) break ;
// New nodes arrived. Try to detach the recent arrivals.
if (Atomic::cmpxchg_ptr (NULL, &FreeList, Arv) != Arv) {
continue ;
}
guarantee (Arv != NULL, "invariant") ;
// 4: Merge Arv into List
ParkEvent * Tail = List ;
while (Tail->FreeNext != NULL) Tail = Tail->FreeNext ;
Tail->FreeNext = Arv ;
}
break ;
}
Thread::SpinRelease(&ListLock);
if (ev != NULL) {
guarantee (ev->AssociatedWith == NULL, "invariant") ;
} else {
// Do this the hard way -- materialize a new ParkEvent.
// In rare cases an allocating thread might detach a long list --
// installing null into FreeList -- and then stall or be obstructed.
// A 2nd thread calling Allocate() would see FreeList == null.
// The list held privately by the 1st thread is unavailable to the 2nd thread.
// In that case the 2nd thread would have to materialize a new ParkEvent,
// even though free ParkEvents existed in the system. In this case we end up
// with more ParkEvents in circulation than we need, but the race is
// rare and the outcome is benign. Ideally, the # of extant ParkEvents
// is equal to the maximum # of threads that existed at any one time.
// Because of the race mentioned above, segments of the freelist
// can be transiently inaccessible. At worst we may end up with the
// # of ParkEvents in circulation slightly above the ideal.
// Note that if we didn't have the TSM/immortal constraint, then
// when reattaching, above, we could trim the list.
ev = new ParkEvent () ;
guarantee ((intptr_t(ev) & 0xFF) == 0, "invariant") ;
}
@ -124,13 +88,14 @@ void ParkEvent::Release (ParkEvent * ev) {
if (ev == NULL) return ;
guarantee (ev->FreeNext == NULL , "invariant") ;
ev->AssociatedWith = NULL ;
for (;;) {
// Push ev onto FreeList
// The mechanism is "half" lock-free.
ParkEvent * List = FreeList ;
ev->FreeNext = List ;
if (Atomic::cmpxchg_ptr (ev, &FreeList, List) == List) break ;
// Note that if we didn't have the TSM/immortal constraint, then
// when reattaching we could trim the list.
Thread::SpinAcquire(&ListLock, "ParkEventFreeListRelease");
{
ev->FreeNext = FreeList;
FreeList = ev;
}
Thread::SpinRelease(&ListLock);
}
// Override operator new and delete so we can ensure that the
@ -164,56 +129,21 @@ Parker * Parker::Allocate (JavaThread * t) {
// Start by trying to recycle an existing but unassociated
// Parker from the global free list.
for (;;) {
p = FreeList ;
if (p == NULL) break ;
// 1: Detach
// Tantamount to p = Swap (&FreeList, NULL)
if (Atomic::cmpxchg_ptr (NULL, &FreeList, p) != p) {
continue ;
// 8028280: using concurrent free list without memory management can leak
// pretty badly it turns out.
Thread::SpinAcquire(&ListLock, "ParkerFreeListAllocate");
{
p = FreeList;
if (p != NULL) {
FreeList = p->FreeNext;
}
// We've detached the list. The list in-hand is now
// local to this thread. This thread can operate on the
// list without risk of interference from other threads.
// 2: Extract -- pop the 1st element from the list.
Parker * List = p->FreeNext ;
if (List == NULL) break ;
for (;;) {
// 3: Try to reattach the residual list
guarantee (List != NULL, "invariant") ;
Parker * Arv = (Parker *) Atomic::cmpxchg_ptr (List, &FreeList, NULL) ;
if (Arv == NULL) break ;
// New nodes arrived. Try to detach the recent arrivals.
if (Atomic::cmpxchg_ptr (NULL, &FreeList, Arv) != Arv) {
continue ;
}
guarantee (Arv != NULL, "invariant") ;
// 4: Merge Arv into List
Parker * Tail = List ;
while (Tail->FreeNext != NULL) Tail = Tail->FreeNext ;
Tail->FreeNext = Arv ;
}
break ;
}
Thread::SpinRelease(&ListLock);
if (p != NULL) {
guarantee (p->AssociatedWith == NULL, "invariant") ;
} else {
// Do this the hard way -- materialize a new Parker..
// In rare cases an allocating thread might detach
// a long list -- installing null into FreeList --and
// then stall. Another thread calling Allocate() would see
// FreeList == null and then invoke the ctor. In this case we
// end up with more Parkers in circulation than we need, but
// the race is rare and the outcome is benign.
// Ideally, the # of extant Parkers is equal to the
// maximum # of threads that existed at any one time.
// Because of the race mentioned above, segments of the
// freelist can be transiently inaccessible. At worst
// we may end up with the # of Parkers in circulation
// slightly above the ideal.
p = new Parker() ;
}
p->AssociatedWith = t ; // Associate p with t
@ -227,11 +157,12 @@ void Parker::Release (Parker * p) {
guarantee (p->AssociatedWith != NULL, "invariant") ;
guarantee (p->FreeNext == NULL , "invariant") ;
p->AssociatedWith = NULL ;
for (;;) {
// Push p onto FreeList
Parker * List = FreeList ;
p->FreeNext = List ;
if (Atomic::cmpxchg_ptr (p, &FreeList, List) == List) break ;
Thread::SpinAcquire(&ListLock, "ParkerFreeListRelease");
{
p->FreeNext = FreeList;
FreeList = p;
}
Thread::SpinRelease(&ListLock);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, 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
@ -3301,6 +3301,58 @@ void Threads::threads_do(ThreadClosure* tc) {
// If CompilerThreads ever become non-JavaThreads, add them here
}
void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
TraceTime timer("Initialize java.lang classes", TraceStartupTime);
if (EagerXrunInit && Arguments::init_libraries_at_startup()) {
create_vm_init_libraries();
}
initialize_class(vmSymbols::java_lang_String(), CHECK);
// Initialize java_lang.System (needed before creating the thread)
initialize_class(vmSymbols::java_lang_System(), CHECK);
initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK);
Handle thread_group = create_initial_thread_group(CHECK);
Universe::set_main_thread_group(thread_group());
initialize_class(vmSymbols::java_lang_Thread(), CHECK);
oop thread_object = create_initial_thread(thread_group, main_thread, CHECK);
main_thread->set_threadObj(thread_object);
// Set thread status to running since main thread has
// been started and running.
java_lang_Thread::set_thread_status(thread_object,
java_lang_Thread::RUNNABLE);
// The VM creates & returns objects of this class. Make sure it's initialized.
initialize_class(vmSymbols::java_lang_Class(), CHECK);
// The VM preresolves methods to these classes. Make sure that they get initialized
initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK);
initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK);
call_initializeSystemClass(CHECK);
// get the Java runtime name after java.lang.System is initialized
JDK_Version::set_runtime_name(get_java_runtime_name(THREAD));
JDK_Version::set_runtime_version(get_java_runtime_version(THREAD));
// an instance of OutOfMemory exception has been allocated earlier
initialize_class(vmSymbols::java_lang_OutOfMemoryError(), CHECK);
initialize_class(vmSymbols::java_lang_NullPointerException(), CHECK);
initialize_class(vmSymbols::java_lang_ClassCastException(), CHECK);
initialize_class(vmSymbols::java_lang_ArrayStoreException(), CHECK);
initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK);
initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK);
initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK);
initialize_class(vmSymbols::java_lang_IllegalArgumentException(), CHECK);
}
void Threads::initialize_jsr292_core_classes(TRAPS) {
initialize_class(vmSymbols::java_lang_invoke_MethodHandle(), CHECK);
initialize_class(vmSymbols::java_lang_invoke_MemberName(), CHECK);
initialize_class(vmSymbols::java_lang_invoke_MethodHandleNatives(), CHECK);
}
jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
extern void JDK_Version_init();
@ -3470,13 +3522,13 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
VMThread::execute(&verify_op);
}
EXCEPTION_MARK;
Thread* THREAD = Thread::current();
// At this point, the Universe is initialized, but we have not executed
// any byte code. Now is a good time (the only time) to dump out the
// internal state of the JVM for sharing.
if (DumpSharedSpaces) {
MetaspaceShared::preload_and_dump(CHECK_0);
MetaspaceShared::preload_and_dump(CHECK_JNI_ERR);
ShouldNotReachHere();
}
@ -3487,74 +3539,12 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// Notify JVMTI agents that VM has started (JNI is up) - nop if no agents.
JvmtiExport::post_vm_start();
{
TraceTime timer("Initialize java.lang classes", TraceStartupTime);
initialize_java_lang_classes(main_thread, CHECK_JNI_ERR);
if (EagerXrunInit && Arguments::init_libraries_at_startup()) {
create_vm_init_libraries();
}
initialize_class(vmSymbols::java_lang_String(), CHECK_0);
// Initialize java_lang.System (needed before creating the thread)
initialize_class(vmSymbols::java_lang_System(), CHECK_0);
initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK_0);
Handle thread_group = create_initial_thread_group(CHECK_0);
Universe::set_main_thread_group(thread_group());
initialize_class(vmSymbols::java_lang_Thread(), CHECK_0);
oop thread_object = create_initial_thread(thread_group, main_thread, CHECK_0);
main_thread->set_threadObj(thread_object);
// Set thread status to running since main thread has
// been started and running.
java_lang_Thread::set_thread_status(thread_object,
java_lang_Thread::RUNNABLE);
// The VM creates & returns objects of this class. Make sure it's initialized.
initialize_class(vmSymbols::java_lang_Class(), CHECK_0);
// The VM preresolves methods to these classes. Make sure that they get initialized
initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK_0);
initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK_0);
call_initializeSystemClass(CHECK_0);
// get the Java runtime name after java.lang.System is initialized
JDK_Version::set_runtime_name(get_java_runtime_name(THREAD));
JDK_Version::set_runtime_version(get_java_runtime_version(THREAD));
// an instance of OutOfMemory exception has been allocated earlier
initialize_class(vmSymbols::java_lang_OutOfMemoryError(), CHECK_0);
initialize_class(vmSymbols::java_lang_NullPointerException(), CHECK_0);
initialize_class(vmSymbols::java_lang_ClassCastException(), CHECK_0);
initialize_class(vmSymbols::java_lang_ArrayStoreException(), CHECK_0);
initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK_0);
initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK_0);
initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK_0);
initialize_class(vmSymbols::java_lang_IllegalArgumentException(), CHECK_0);
}
// See : bugid 4211085.
// Background : the static initializer of java.lang.Compiler tries to read
// property"java.compiler" and read & write property "java.vm.info".
// When a security manager is installed through the command line
// option "-Djava.security.manager", the above properties are not
// readable and the static initializer for java.lang.Compiler fails
// resulting in a NoClassDefFoundError. This can happen in any
// user code which calls methods in java.lang.Compiler.
// Hack : the hack is to pre-load and initialize this class, so that only
// system domains are on the stack when the properties are read.
// Currently even the AWT code has calls to methods in java.lang.Compiler.
// On the classic VM, java.lang.Compiler is loaded very early to load the JIT.
// Future Fix : the best fix is to grant everyone permissions to read "java.compiler" and
// read and write"java.vm.info" in the default policy file. See bugid 4211383
// Once that is done, we should remove this hack.
initialize_class(vmSymbols::java_lang_Compiler(), CHECK_0);
// More hackery - the static initializer of java.lang.Compiler adds the string "nojit" to
// the java.vm.info property if no jit gets loaded through java.lang.Compiler (the hotspot
// compiler does not get loaded through java.lang.Compiler). "java -version" with the
// hotspot vm says "nojit" all the time which is confusing. So, we reset it here.
// This should also be taken out as soon as 4211383 gets fixed.
reset_vm_info_property(CHECK_0);
// We need this for ClassDataSharing - the initial vm.info property is set
// with the default value of CDS "sharing" which may be reset through
// command line options.
reset_vm_info_property(CHECK_JNI_ERR);
quicken_jni_functions();
@ -3583,10 +3573,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and
// set_init_completed has just been called, causing exceptions not to be shortcut
// anymore. We call vm_exit_during_initialization directly instead.
SystemDictionary::compute_java_system_loader(THREAD);
if (HAS_PENDING_EXCEPTION) {
vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
}
SystemDictionary::compute_java_system_loader(CHECK_JNI_ERR);
#if INCLUDE_ALL_GCS
// Support for ConcurrentMarkSweep. This should be cleaned up
@ -3594,12 +3581,9 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// once things are properly refactored. XXX YSR
if (UseConcMarkSweepGC || UseG1GC) {
if (UseConcMarkSweepGC) {
ConcurrentMarkSweepThread::makeSurrogateLockerThread(THREAD);
ConcurrentMarkSweepThread::makeSurrogateLockerThread(CHECK_JNI_ERR);
} else {
ConcurrentMarkThread::makeSurrogateLockerThread(THREAD);
}
if (HAS_PENDING_EXCEPTION) {
vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
ConcurrentMarkThread::makeSurrogateLockerThread(CHECK_JNI_ERR);
}
}
#endif // INCLUDE_ALL_GCS
@ -3642,19 +3626,16 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
CompileBroker::compilation_init();
#endif
if (EnableInvokeDynamic) {
// Pre-initialize some JSR292 core classes to avoid deadlock during class loading.
// It is done after compilers are initialized, because otherwise compilations of
// signature polymorphic MH intrinsics can be missed
// (see SystemDictionary::find_method_handle_intrinsic).
initialize_class(vmSymbols::java_lang_invoke_MethodHandle(), CHECK_0);
initialize_class(vmSymbols::java_lang_invoke_MemberName(), CHECK_0);
initialize_class(vmSymbols::java_lang_invoke_MethodHandleNatives(), CHECK_0);
if (EnableInvokeDynamic) {
initialize_jsr292_core_classes(CHECK_JNI_ERR);
}
#if INCLUDE_MANAGEMENT
Management::initialize(THREAD);
#endif // INCLUDE_MANAGEMENT
if (HAS_PENDING_EXCEPTION) {
// management agent fails to start possibly due to
@ -3662,6 +3643,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// stack trace if appropriate. Simply exit VM.
vm_exit(1);
}
#endif // INCLUDE_MANAGEMENT
if (Arguments::has_profile()) FlatProfiler::engage(main_thread, true);
if (MemProfiling) MemProfiler::engage();
@ -4446,9 +4428,7 @@ void Thread::SpinAcquire (volatile int * adr, const char * LockName) {
++ctr ;
if ((ctr & 0xFFF) == 0 || !os::is_MP()) {
if (Yields > 5) {
// Consider using a simple NakedSleep() instead.
// Then SpinAcquire could be called by non-JVM threads
Thread::current()->_ParkEvent->park(1) ;
os::naked_short_sleep(1);
} else {
os::NakedYield() ;
++Yields ;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, 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
@ -1891,6 +1891,8 @@ class Threads: AllStatic {
static bool _vm_complete;
#endif
static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS);
static void initialize_jsr292_core_classes(TRAPS);
public:
// Thread management
// force_daemon is a concession to JNI, where we may need to add a

View File

@ -122,6 +122,46 @@ Declares a structure type that can be used in other events.
<value type="CLASS" field="definingClassLoader" label="Defining Class Loader"/>
</event>
<event id="LongFlagChanged" path="vm/flag/long_changed" label="Long Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="LONG" field="old_value" label="Old Value" />
<value type="LONG" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="UnsignedLongFlagChanged" path="vm/flag/ulong_changed" label="Unsigned Long Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="ULONG" field="old_value" label="Old Value" />
<value type="ULONG" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="DoubleFlagChanged" path="vm/flag/double_changed" label="Double Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="DOUBLE" field="old_value" label="Old Value" />
<value type="DOUBLE" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="BooleanFlagChanged" path="vm/flag/boolean_changed" label="Boolean Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="BOOLEAN" field="old_value" label="Old Value" />
<value type="BOOLEAN" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="StringFlagChanged" path="vm/flag/string_changed" label="String Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="UTF8" field="old_value" label="Old Value" />
<value type="UTF8" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<struct id="VirtualSpace">
<value type="ADDRESS" field="start" label="Start Address" description="Start address of the virtual space" />
<value type="ADDRESS" field="committedEnd" label="Committed End Address" description="End address of the committed memory for the virtual space" />

View File

@ -150,6 +150,11 @@ Now we can use the content + data type in declaring event fields.
<value type="UTF8" field="phase" label="phase" />
</content_type>
<content_type id="FlagValueOrigin" hr_name="Flag Value Origin"
type="U1" jvm_type="FLAGVALUEORIGIN">
<value type="UTF8" field="origin" label="origin" />
</content_type>
</content_types>
@ -335,5 +340,9 @@ Now we can use the content + data type in declaring event fields.
<primary_type symbol="VMOPERATIONTYPE" datatype="U2" contenttype="VMOPERATIONTYPE"
type="u2" sizeop="sizeof(u2)" />
<!-- FLAGVALUEORIGIN -->
<primary_type symbol="FLAGVALUEORIGIN" datatype="U1"
contenttype="FLAGVALUEORIGIN" type="u1" sizeop="sizeof(u1)" />
</primary_types>
</types>

View File

@ -38,7 +38,10 @@
#define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() \
do { volatile size_t dtrace_workaround_tail_call_bug = 1; } while (0)
#define USDT1 1
#define USDT2 1
#include "dtracefiles/hotspot.h"
#include "dtracefiles/hotspot_jni.h"
#include "dtracefiles/hs_private.h"
#elif defined(LINUX)
#define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG()
#define USDT1 1

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, 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
@ -200,6 +200,7 @@ class Exceptions {
#define CHECK_NH CHECK_(Handle())
#define CHECK_NULL CHECK_(NULL)
#define CHECK_false CHECK_(false)
#define CHECK_JNI_ERR CHECK_(JNI_ERR)
#define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (void)(0
#define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (void)(0

View File

@ -196,6 +196,11 @@ generate_replay() {
then
# enable core dump
ulimit -c unlimited
new_ulimit=`ulimit -c`
if [ $new_ulimit != "unlimited" -a $new_ulimit != "-1" ]
then
test_fail 2 "CHECK :: ULIMIT" "Could not set 'ulimit -c unlimited'. 'ulimit -c' returns : $new_ulimit"
fi
if [ $VM_OS = "solaris" ]
then
@ -228,7 +233,10 @@ generate_replay() {
core_locations=`grep -i core crash.out | grep "location:" | \
sed -e 's/.*location: //'`
echo CRASH OUTPUT:
cat crash.out
rm crash.out
# processing core locations for *nix
if [ $VM_OS != "windows" ]
then

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2014, 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.
*/
/*
* @test
* @bug 8032207
* @summary Invalid node sizing for loadUS2L_immI16 and loadI2L_immI
* @run main/othervm -server -Xbatch -XX:-TieredCompilation -XX:CompileCommand=compileonly,LoadWithMask.foo LoadWithMask
*
*/
public class LoadWithMask {
static int x[] = new int[1];
static long foo() {
return x[0] & 0xfff0ffff;
}
public static void main(String[] args) {
x[0] = -1;
long l = 0;
for (int i = 0; i < 100000; ++i) {
l = foo();
}
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2014, 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.
*/
/*
* @test
* @bug 8031743
* @summary loadI2L_immI broken for negative memory values
* @run main/othervm -server -Xbatch -XX:-TieredCompilation -XX:CompileCommand=compileonly,*.foo* LoadWithMask2
*
*/
public class LoadWithMask2 {
static int x;
static long foo1() {
return x & 0xfffffffe;
}
static long foo2() {
return x & 0xff000000;
}
static long foo3() {
return x & 0x8abcdef1;
}
public static void main(String[] args) {
x = -1;
long l = 0;
for (int i = 0; i < 100000; ++i) {
l = foo1() & foo2() & foo3();
}
if (l > 0) {
System.out.println("FAILED");
System.exit(97);
}
System.out.println("PASSED");
}
}

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2014, 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.
*/
/**
* @test
* @bug 8031695
* @summary CHA ignores default methods during analysis leading to incorrect code generation
*
* @run main/othervm -Xbatch DefaultAndConcreteMethodsCHA
*/
interface I {
default int m() { return 0; }
}
class A implements I {}
class C extends A { }
class D extends A { public int m() { return 1; } }
public class DefaultAndConcreteMethodsCHA {
public static int test(A obj) {
return obj.m();
}
public static void main(String[] args) {
for (int i = 0; i < 10000; i++) {
int idC = test(new C());
if (idC != 0) {
throw new Error("C.m didn't invoke I.m: id "+idC);
}
int idD = test(new D());
if (idD != 1) {
throw new Error("D.m didn't invoke D.m: id "+idD);
}
}
}
}

View File

@ -48,6 +48,11 @@ ${CP} ${TESTSRC}${FS}* ${THIS_DIR}
# A Clean Compile: this line will probably fail within jtreg as have a clean dir:
${RM} -f *.class *.impl many_loader.java
# Make sure that the compilation steps occurs in the future as not to allow fast systems
# to copy and compile bug_21227.java so fast as to make the class and java have the same
# time stamp, which later on would make the compilation step of many_loader.java fail
sleep 2
# Compile all the usual suspects, including the default 'many_loader'
${CP} many_loader1.java.foo many_loader.java
${JAVAC} ${TESTJAVACOPTS} -source 1.4 -target 1.4 -Xlint *.java

View File

@ -1,15 +1,13 @@
#!/bin/sh
##
## @ignore 8028740
## @test Test6929067.sh
## @bug 6929067
## @bug 8021296
## @summary Stack guard pages should be removed when thread is detached
## @compile T.java
## @run shell Test6929067.sh
##
set -x
if [ "${TESTSRC}" = "" ]
then
TESTSRC=${PWD}
@ -114,10 +112,8 @@ fi
LD_LIBRARY_PATH=.:${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE}:/usr/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
cp ${TESTSRC}${FS}invoke.c .
# Copy the result of our @compile action:
cp ${TESTCLASSES}${FS}T.class .
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
${TESTJAVA}${FS}bin${FS}javac *.java
echo "Architecture: ${ARCH}"
echo "Compilation flag: ${COMP_FLAG}"
@ -127,9 +123,9 @@ echo "VM type: ${VMTYPE}"
# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.
$gcc_cmd -DLINUX ${COMP_FLAG} -o invoke \
-I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
-L${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE} \
-ljvm -lpthread invoke.c
-I${TESTJAVA}/include -I${TESTJAVA}/include/linux \
-L${TESTJAVA}/jre/lib/${ARCH}/${VMTYPE} \
${TESTSRC}${FS}invoke.c -ljvm -lpthread
./invoke
exit $?

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2014, 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
@ -33,8 +33,7 @@ import com.oracle.java.testlibrary.*;
public class CompilerConfigFileWarning {
public static void main(String[] args) throws Exception {
String vmVersion = System.getProperty("java.vm.version");
if (vmVersion.toLowerCase().contains("debug") || vmVersion.toLowerCase().contains("jvmg")) {
if (Platform.isDebugBuild()) {
System.out.println("Skip on debug builds since we'll always read the file there");
return;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2014, 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
@ -33,8 +33,7 @@ import com.oracle.java.testlibrary.*;
public class ConfigFileWarning {
public static void main(String[] args) throws Exception {
String vmVersion = System.getProperty("java.vm.version");
if (vmVersion.toLowerCase().contains("debug") || vmVersion.toLowerCase().contains("jvmg")) {
if (Platform.isDebugBuild()) {
System.out.println("Skip on debug builds since we'll always read the file there");
return;
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2014, 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.
*/
/*
* @test
* @bug 8027314
* @summary Warn if diagnostic or experimental vm option is used and -XX:+UnlockDiagnosticVMOptions or -XX:+UnlockExperimentalVMOptions, respectively, isn't specified. Warn if develop or notproduct vm option is used with product version of VM.
* @library /testlibrary
*/
import com.oracle.java.testlibrary.*;
public class VMOptionWarning {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PredictedLoadedClassCount", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Error: VM option 'PredictedLoadedClassCount' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.");
if (Platform.isDebugBuild()) {
System.out.println("Skip the rest of the tests on debug builds since diagnostic, develop, and notproduct options are available on debug builds.");
return;
}
pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintInlining", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");
pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceJNICalls", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Error: VM option 'TraceJNICalls' is develop and is available only in debug version of VM.");
pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceJVMCalls", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Error: VM option 'TraceJVMCalls' is notproduct and is available only in debug version of VM.");
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2014, 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.
*/
/*
* @test ArchiveDoesNotExist
* @summary Test how VM handles "file does not exist" situation while
* attempting to use CDS archive. JVM should exit gracefully
* when sharing mode is ON, and continue w/o sharing if sharing
* mode is AUTO.
* @library /testlibrary
* @run main ArchiveDoesNotExist
*/
import com.oracle.java.testlibrary.*;
import java.io.File;
public class ArchiveDoesNotExist {
public static void main(String[] args) throws Exception {
String fileName = "test.jsa";
File cdsFile = new File(fileName);
if (cdsFile.exists())
throw new RuntimeException("Test error: cds file already exists");
// Sharing: on
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=./" + fileName,
"-Xshare:on",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Specified shared archive not found");
output.shouldHaveExitValue(1);
// Sharing: auto
pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=./" + fileName,
"-Xshare:auto",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("java version");
output.shouldNotContain("sharing");
output.shouldHaveExitValue(0);
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 2014, 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.
*/
/*
* @test CdsWriteError
* @summary Test how VM handles situation when it is impossible to write the
* CDS archive. VM is expected to exit gracefully and display the
* correct reason for the error.
* @library /testlibrary
* @run main CdsWriteError
*/
import com.oracle.java.testlibrary.*;
import java.io.File;
public class CdsWriteError {
public static void main(String[] args) throws Exception {
if (Platform.isWindows()) {
System.out.println("This test is ignored on Windows. This test " +
"manipulates folder writable attribute, which is known to be " +
"often ignored by Windows");
return;
}
String folderName = "tmp";
String fileName = folderName + File.separator + "empty.jsa";
// create an empty archive file and make it read only
File folder = new File(folderName);
if (!folder.mkdir())
throw new RuntimeException("Error when creating a tmp folder");
File cdsFile = new File(fileName);
if (!cdsFile.createNewFile())
throw new RuntimeException("Error when creating an empty CDS file");
if (!cdsFile.setWritable(false))
throw new RuntimeException("Error: could not set writable attribute on cds file");
if (!folder.setWritable(false))
throw new RuntimeException("Error: could not set writable attribute on the cds folder");
try {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + fileName, "-Xshare:dump");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Unable to create shared archive file");
output.shouldHaveExitValue(1);
} finally {
// doing this, just in case, to make sure that files can be deleted by the harness
// on any subsequent run
folder.setWritable(true);
cdsFile.setWritable(true);
}
}
}

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2014, 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.
*/
/*
* @test DefaultUseWithClient
* @summary Test default behavior of sharing with -client
* @library /testlibrary
* @run main DefaultUseWithClient
*/
import com.oracle.java.testlibrary.*;
import java.io.File;
public class DefaultUseWithClient {
public static void main(String[] args) throws Exception {
String fileName = "test.jsa";
// On 32-bit windows CDS should be on by default in "-client" config
// Skip this test on any other platform
boolean is32BitWindows = (Platform.isWindows() && Platform.is32bit());
if (!is32BitWindows) {
System.out.println("Test only applicable on 32-bit Windows. Skipping");
return;
}
// create the archive
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=./" + fileName,
"-Xshare:dump");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=./" + fileName,
"-client",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("sharing");
output.shouldHaveExitValue(0);
}
}

View File

@ -0,0 +1,142 @@
/*
* Copyright (c) 2014, 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.
*/
/*
* @test
* @bug 8028553
* @summary Test that VerifyError is not thrown when 'overriding' a static method.
* @run main FinalStatic
*/
import java.lang.reflect.*;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;
/*
* class A { static final int m() {return FAIL; } }
* class B extends A { int m() { return PASS; } }
* class FinalStatic {
* public static void main () {
* Object b = new B();
* b.m();
* }
* }
*/
public class FinalStatic {
static final String CLASS_NAME_A = "A";
static final String CLASS_NAME_B = "B";
static final int FAILED = 0;
static final int EXPECTED = 1234;
static class TestClassLoader extends ClassLoader implements Opcodes {
@Override
public Class findClass(String name) throws ClassNotFoundException {
byte[] b;
try {
b = loadClassData(name);
} catch (Throwable th) {
// th.printStackTrace();
throw new ClassNotFoundException("Loading error", th);
}
return defineClass(name, b, 0, b.length);
}
private byte[] loadClassData(String name) throws Exception {
ClassWriter cw = new ClassWriter(0);
MethodVisitor mv;
switch (name) {
case CLASS_NAME_A:
cw.visit(52, ACC_SUPER | ACC_PUBLIC, CLASS_NAME_A, null, "java/lang/Object", null);
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
mv = cw.visitMethod(ACC_FINAL | ACC_STATIC, "m", "()I", null, null);
mv.visitCode();
mv.visitLdcInsn(FAILED);
mv.visitInsn(IRETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
break;
case CLASS_NAME_B:
cw.visit(52, ACC_SUPER | ACC_PUBLIC, CLASS_NAME_B, null, CLASS_NAME_A, null);
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, CLASS_NAME_A, "<init>", "()V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null);
mv.visitCode();
mv.visitLdcInsn(EXPECTED);
mv.visitInsn(IRETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
break;
default:
break;
}
cw.visitEnd();
return cw.toByteArray();
}
}
public static void main(String[] args) throws Exception {
TestClassLoader tcl = new TestClassLoader();
Class<?> a = tcl.loadClass(CLASS_NAME_A);
Class<?> b = tcl.loadClass(CLASS_NAME_B);
Object inst = b.newInstance();
Method[] meths = b.getDeclaredMethods();
Method m = meths[0];
int mod = m.getModifiers();
if ((mod & Modifier.FINAL) != 0) {
throw new Exception("FAILED: " + m + " is FINAL");
}
if ((mod & Modifier.STATIC) != 0) {
throw new Exception("FAILED: " + m + " is STATIC");
}
m.setAccessible(true);
if (!m.invoke(inst).equals(EXPECTED)) {
throw new Exception("FAILED: " + EXPECTED + " from " + m);
}
System.out.println("Passed.");
}
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2014, 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.
*
*/
/*
* @test
* @bug 8032024
* @bug 8025937
* @summary [JDK 8] Test invokespecial and invokeinterface with the same JVM_CONSTANT_InterfaceMethodref
* @run main InvokespecialInterface
*/
import java.util.function.*;
import java.util.*;
interface I {
default void imethod() { System.out.println("I::imethod"); }
}
class C implements I {
public void foo() { I.super.imethod(); } // invokespecial InterfaceMethod
public void bar() { I i = this; i.imethod(); } // invokeinterface same
public void doSomeInvokedynamic() {
String str = "world";
Supplier<String> foo = ()->"hello, "+str;
String res = foo.get();
System.out.println(res);
}
}
public class InvokespecialInterface {
public static void main(java.lang.String[] unused) {
// need to create C and call I::foo()
C c = new C();
c.foo();
c.bar();
c.doSomeInvokedynamic();
}
};

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2014, 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.
*/
/*
* @test
* @bug 8028623
* @summary Test hashing of extended characters in Serviceability Agent.
* @library /testlibrary
* @compile -encoding utf8 Test8028623.java
* @run main Test8028623
*/
import com.oracle.java.testlibrary.JDKToolLauncher;
import com.oracle.java.testlibrary.OutputBuffer;
import com.oracle.java.testlibrary.ProcessTools;
import java.io.File;
public class Test8028623 {
public static int à = 1;
public static String dumpFile = "heap.out";
public static void main (String[] args) {
System.out.println(Ã);
try {
int pid = ProcessTools.getProcessId();
JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
.addToolArg("-F")
.addToolArg("-dump:live,format=b,file=" + dumpFile)
.addToolArg(Integer.toString(pid));
ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
OutputBuffer output = ProcessTools.getOutput(pb);
Process p = pb.start();
int e = p.waitFor();
System.out.println("stdout:");
System.out.println(output.getStdout());
System.out.println("stderr:");
System.out.println(output.getStderr());
if (e != 0) {
throw new RuntimeException("jmap returns: " + e);
}
if (! new File(dumpFile).exists()) {
throw new RuntimeException("dump file NOT created: '" + dumpFile + "'");
}
} catch (Throwable t) {
t.printStackTrace();
throw new RuntimeException("Test failed with: " + t);
}
}
}