This commit is contained in:
Jesper Wilhelmsson 2014-11-26 18:01:10 +01:00
commit 3c3e60d5be
58 changed files with 705 additions and 903 deletions

@ -442,3 +442,4 @@ af46576a8d7cb4003028b8ee8bf408cfe227315b jdk9-b32
b1c2dd843f247a1db19e1e85eb62ca405f72dc26 jdk9-b37
c363a8b87e477ee45d6d3cb2a36cb365141bc596 jdk9-b38
9cb75e5e394827ccbaf2e15524108a412dc4ddc5 jdk9-b39
6b09b3193d731e3288e2a240c504a20d0a06c766 jdk9-b40

@ -219,7 +219,7 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
if (threadNameField == null) {
SystemDictionary sysDict = VM.getVM().getSystemDictionary();
InstanceKlass k = sysDict.getThreadKlass();
threadNameField = (OopField) k.findField("name", "[C");
threadNameField = (OopField) k.findField("name", "Ljava/lang/String;");
threadGroupField = (OopField) k.findField("group", "Ljava/lang/ThreadGroup;");
threadEETopField = (LongField) k.findField("eetop", "J");
threadTIDField = (LongField) k.findField("tid", "J");
@ -258,7 +258,7 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
public static String threadOopGetName(Oop threadOop) {
initThreadFields();
return charArrayToString((TypeArray) threadNameField.getValue(threadOop));
return stringOopToString(threadNameField.getValue(threadOop));
}
/** May return null if, e.g., thread was not started */

@ -40,6 +40,8 @@ AGENT_DIR = $(GAMMADIR)/agent
include $(GAMMADIR)/make/sa.files
-include $(HS_ALT_MAKE)/bsd/makefiles/sa.make
TOPDIR = $(shell echo `pwd`)
GENERATED = $(TOPDIR)/../generated

@ -1,54 +0,0 @@
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Rules to build add_gnu_debuglink, used by vm.make on Solaris
# Allow $(ADD_GNU_DEBUGLINK) to be called from any directory.
# We don't set or use the GENERATED macro to avoid affecting
# other HotSpot Makefiles.
TOPDIR = $(shell echo `pwd`)
ADD_GNU_DEBUGLINK = $(TOPDIR)/../generated/add_gnu_debuglink
ADD_GNU_DEBUGLINK_DIR = $(GAMMADIR)/src/os/solaris/add_gnu_debuglink
ADD_GNU_DEBUGLINK_SRC = $(ADD_GNU_DEBUGLINK_DIR)/add_gnu_debuglink.c
ADD_GNU_DEBUGLINK_FLAGS =
LIBS_ADD_GNU_DEBUGLINK += -lelf
ifeq ("${Platform_compiler}", "sparcWorks")
# Enable the following ADD_GNU_DEBUGLINK_FLAGS addition if you need to
# compare the built ELF objects.
#
# The -g option makes static data global and the "-W0,-noglobal"
# option tells the compiler to not globalize static data using a unique
# globalization prefix. Instead force the use of a static globalization
# prefix based on the source filepath so the objects from two identical
# compilations are the same.
#
# Note: The blog says to use "-W0,-xglobalstatic", but that doesn't
# seem to work. I got "-W0,-noglobal" from Kelly and that works.
#ADD_GNU_DEBUGLINK_FLAGS += -W0,-noglobal
endif # Platform_compiler == sparcWorks
$(ADD_GNU_DEBUGLINK): $(ADD_GNU_DEBUGLINK_SRC)
$(CC) -g -o $@ $< $(ADD_GNU_DEBUGLINK_FLAGS) $(LIBS_ADD_GNU_DEBUGLINK)

@ -1,5 +1,5 @@
#
# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 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
@ -138,6 +138,55 @@ ifeq ($(JDK6_OR_EARLIER),0)
OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
endif
ifneq ($(OBJCOPY),)
# OBJCOPY version check:
# - version number is last blank separate word on first line
# - version number formats that have been seen:
# - <major>.<minor>
# - <major>.<minor>.<micro>
#
# Full Debug Symbols on Solaris needs version 2.21.1 or newer.
#
OBJCOPY_VERS_CHK := $(shell \
$(OBJCOPY) --version \
| sed -n \
-e 's/.* //' \
-e '/^[01]\./b bad' \
-e '/^2\./{' \
-e ' s/^2\.//' \
-e ' /^[0-9]$$/b bad' \
-e ' /^[0-9]\./b bad' \
-e ' /^1[0-9]$$/b bad' \
-e ' /^1[0-9]\./b bad' \
-e ' /^20\./b bad' \
-e ' /^21\.0$$/b bad' \
-e ' /^21\.0\./b bad' \
-e '}' \
-e ':good' \
-e 's/.*/VALID_VERSION/p' \
-e 'q' \
-e ':bad' \
-e 's/.*/BAD_VERSION/p' \
-e 'q' \
)
ifeq ($(OBJCOPY_VERS_CHK),BAD_VERSION)
_JUNK_ := $(shell \
echo >&2 "WARNING: $(OBJCOPY) --version info:"; \
$(OBJCOPY) --version | sed -n -e 's/^/WARNING: /p' -e 'q' >&2; \
echo >&2 "WARNING: an objcopy version of 2.21.1 or newer" \
"is needed to create valid .debuginfo files."; \
echo >&2 "WARNING: ignoring above objcopy command."; \
echo >&2 "WARNING: patch 149063-01 or newer contains the" \
"correct Solaris 10 SPARC version."; \
echo >&2 "WARNING: patch 149064-01 or newer contains the" \
"correct Solaris 10 X86 version."; \
echo >&2 "WARNING: Solaris 11 Update 1 contains the" \
"correct version."; \
)
OBJCOPY=
endif
endif
ifeq ($(OBJCOPY),)
$(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo files."))
ENABLE_FULL_DEBUG_SYMBOLS=0

@ -101,25 +101,16 @@ XLIBJVM_DB_DIZ = $(XLIBJVM_DIR)/$(LIBJVM_DB_DIZ)
XLIBJVM_DTRACE_DEBUGINFO = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DEBUGINFO)
XLIBJVM_DTRACE_DIZ = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DIZ)
$(XLIBJVM_DB): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
$(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
@echo $(LOG_INFO) Making $@
$(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \
$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. -I$(GENERATED) \
$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
# Clear the SHF_ALLOC flag (if set) from empty section headers.
# An empty section header has sh_addr == 0 and sh_size == 0.
# This problem has only been seen on Solaris X64, but we call this tool
# on all Solaris builds just in case.
$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DB_DEBUGINFO)
# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
# $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) ;
# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not
# in the link name:
( cd $(XLIBJVM_DIR) && $(ADD_GNU_DEBUGLINK) $(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) )
( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) )
ifeq ($(STRIP_POLICY),all_strip)
$(QUIETLY) $(STRIP) $@
else
@ -136,20 +127,16 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
endif
endif
$(XLIBJVM_DTRACE): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
$(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
@echo $(LOG_INFO) Making $@
$(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \
$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. \
$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# Clear the SHF_ALLOC flag (if set) from empty section headers.
$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DTRACE_DEBUGINFO)
# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
# $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) ;
# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not
# in the link name:
( cd $(XLIBJVM_DIR) && $(ADD_GNU_DEBUGLINK) $(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) )
( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) )
ifeq ($(STRIP_POLICY),all_strip)
$(QUIETLY) $(STRIP) $@
else
@ -206,17 +193,13 @@ $(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h
$(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp
$(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
$(LIBJVM_DB): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
$(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
@echo $(LOG_INFO) Making $@
$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# Clear the SHF_ALLOC flag (if set) from empty section headers.
$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DB_DEBUGINFO)
# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
# $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $@
$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBJVM_DB_DEBUGINFO) $@
$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $@
ifeq ($(STRIP_POLICY),all_strip)
$(QUIETLY) $(STRIP) $@
else
@ -231,17 +214,13 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
endif
endif
$(LIBJVM_DTRACE): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
$(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
@echo $(LOG_INFO) Making $@
$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. \
$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# Clear the SHF_ALLOC flag (if set) from empty section headers.
$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DTRACE_DEBUGINFO)
# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
# $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $@
$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBJVM_DTRACE_DEBUGINFO) $@
$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $@
ifeq ($(STRIP_POLICY),all_strip)
$(QUIETLY) $(STRIP) $@
else

@ -1,54 +0,0 @@
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Rules to build fix_empty_sec_hdr_flags, used by vm.make on Solaris
# Allow $(FIX_EMPTY_SEC_HDR_FLAGS) to be called from any directory.
# We don't set or use the GENERATED macro to avoid affecting
# other HotSpot Makefiles.
TOPDIR = $(shell echo `pwd`)
FIX_EMPTY_SEC_HDR_FLAGS = $(TOPDIR)/../generated/fix_empty_sec_hdr_flags
FIX_EMPTY_SEC_HDR_FLAGS_DIR = $(GAMMADIR)/src/os/solaris/fix_empty_sec_hdr_flags
FIX_EMPTY_SEC_HDR_FLAGS_SRC = $(FIX_EMPTY_SEC_HDR_FLAGS_DIR)/fix_empty_sec_hdr_flags.c
FIX_EMPTY_SEC_HDR_FLAGS_FLAGS =
LIBS_FIX_EMPTY_SEC_HDR_FLAGS += -lelf
ifeq ("${Platform_compiler}", "sparcWorks")
# Enable the following FIX_EMPTY_SEC_HDR_FLAGS_FLAGS addition if you need to
# compare the built ELF objects.
#
# The -g option makes static data global and the "-W0,-noglobal"
# option tells the compiler to not globalize static data using a unique
# globalization prefix. Instead force the use of a static globalization
# prefix based on the source filepath so the objects from two identical
# compilations are the same.
#
# Note: The blog says to use "-W0,-xglobalstatic", but that doesn't
# seem to work. I got "-W0,-noglobal" from Kelly and that works.
#FIX_EMPTY_SEC_HDR_FLAGS_FLAGS += -W0,-noglobal
endif # Platform_compiler == sparcWorks
$(FIX_EMPTY_SEC_HDR_FLAGS): $(FIX_EMPTY_SEC_HDR_FLAGS_SRC)
$(CC) -g -o $@ $< $(FIX_EMPTY_SEC_HDR_FLAGS_FLAGS) $(LIBS_FIX_EMPTY_SEC_HDR_FLAGS)

@ -47,22 +47,13 @@ else
LFLAGS_JSIG += -mt -xnolib
endif
$(LIBJSIG): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
@echo $(LOG_INFO) Making signal interposition lib...
$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
$(LFLAGS_JSIG) -o $@ $(JSIGSRCDIR)/jsig.c -ldl
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
# Clear the SHF_ALLOC flag (if set) from empty section headers.
# An empty section header has sh_addr == 0 and sh_size == 0.
# This problem has only been seen on Solaris X64, but we call this tool
# on all Solaris builds just in case.
$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO)
# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
# $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBJSIG_DEBUGINFO) $@
$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
ifeq ($(STRIP_POLICY),all_strip)
$(QUIETLY) $(STRIP) $@
else

@ -90,7 +90,7 @@ $(shell uname -r -v \
#SOLARIS_11_B159_OR_LATER=-DSOLARIS_11_B159_OR_LATER
$(LIBSAPROC): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(SASRCFILES) $(SADISOBJ) $(SAMAPFILE)
$(LIBSAPROC): $(SASRCFILES) $(SADISOBJ) $(SAMAPFILE)
$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \
exit 1; \
@ -121,17 +121,8 @@ $(SADISOBJ): $(SADISSRCFILES)
-c -o $(SADISOBJ)
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
# Clear the SHF_ALLOC flag (if set) from empty section headers.
# An empty section header has sh_addr == 0 and sh_size == 0.
# This problem has only been seen on Solaris X64, but we call this tool
# on all Solaris builds just in case.
$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBSAPROC_DEBUGINFO)
# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
# $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@
$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBSAPROC_DEBUGINFO) $@
$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@
ifeq ($(STRIP_POLICY),all_strip)
$(QUIETLY) $(STRIP) $@
else

@ -154,14 +154,6 @@ JDK_LIBDIR = $(JAVA_HOME)/jre/lib/$(LIBARCH)
# jvm_db & dtrace
include $(MAKEFILES_DIR)/dtrace.make
#----------------------------------------------------------------------
# add_gnu_debuglink tool
include $(MAKEFILES_DIR)/add_gnu_debuglink.make
#----------------------------------------------------------------------
# fix_empty_sec_hdr_flags tool
include $(MAKEFILES_DIR)/fix_empty_sec_hdr_flags.make
#----------------------------------------------------------------------
# JVM
@ -302,7 +294,7 @@ else
LINK_VM = $(LINK_LIB.CXX)
endif
# making the library:
$(LIBJVM): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(LIBJVM.o) $(LIBJVM_MAPFILE)
$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE)
ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),)
@echo $(LOG_INFO) Linking vm...
$(QUIETLY) $(LINK_LIB.CXX/PRE_HOOK)
@ -310,17 +302,8 @@ ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),)
$(QUIETLY) $(LINK_LIB.CXX/POST_HOOK)
$(QUIETLY) rm -f $@.1 && ln -s $@ $@.1
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
# Clear the SHF_ALLOC flag (if set) from empty section headers.
# An empty section header has sh_addr == 0 and sh_size == 0.
# This problem has only been seen on Solaris X64, but we call this tool
# on all Solaris builds just in case.
$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO)
# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
# $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBJVM_DEBUGINFO) $@
$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
ifeq ($(STRIP_POLICY),all_strip)
$(QUIETLY) $(STRIP) $@
else

@ -89,19 +89,24 @@ AGCT_EXPORT=/export:AsyncGetCallTrace
# If you modify exports below please do the corresponding changes in
# src/share/tools/ProjectCreator/WinGammaPlatformVC7.java
LD_FLAGS=$(LD_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 \
/export:JNI_GetDefaultJavaVMInitArgs \
/export:JNI_CreateJavaVM \
/export:JVM_FindClassFromBootLoader \
/export:JNI_GetCreatedJavaVMs \
/export:jio_snprintf \
/export:jio_printf \
/export:jio_fprintf \
/export:jio_vfprintf \
/export:jio_vsnprintf \
$(AGCT_EXPORT) \
/export:JVM_GetVersionInfo \
/export:JVM_InitAgentProperties
!if "$(BUILDARCH)" == "amd64"
EXPORT_LIST=
!else
EXPORT_LIST=/export:JNI_GetDefaultJavaVMInitArgs \
/export:JNI_CreateJavaVM \
/export:JVM_FindClassFromBootLoader \
/export:JNI_GetCreatedJavaVMs \
/export:jio_snprintf \
/export:jio_printf \
/export:jio_fprintf \
/export:jio_vfprintf \
/export:jio_vsnprintf \
$(AGCT_EXPORT) \
/export:JVM_GetVersionInfo \
/export:JVM_InitAgentProperties
!endif
LD_FLAGS=$(LD_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 $(EXPORT_LIST)
CXX_INCLUDE_DIRS=/I "..\generated"

@ -30,7 +30,9 @@
int ZeroStack::suggest_size(Thread *thread) const {
assert(needs_setup(), "already set up");
return align_size_down(abi_stack_available(thread) / 2, wordSize);
int abi_available = abi_stack_available(thread);
assert(abi_available >= 0, "available abi stack must be >= 0");
return align_size_down(abi_available / 2, wordSize);
}
void ZeroStack::handle_overflow(TRAPS) {

@ -48,9 +48,11 @@ inline void ZeroStack::overflow_check(int required_words, TRAPS) {
// to use under normal circumstances. Note that the returned
// value can be negative.
inline int ZeroStack::abi_stack_available(Thread *thread) const {
int stack_used = thread->stack_base() - (address) &stack_used;
guarantee(Thread::current() == thread, "should run in the same thread");
int stack_used = thread->stack_base() - (address) &stack_used
+ (StackYellowPages+StackRedPages+StackShadowPages) * os::vm_page_size();
int stack_free = thread->stack_size() - stack_used;
return stack_free - shadow_pages_size();
return stack_free;
}
#endif // CPU_ZERO_VM_STACK_ZERO_INLINE_HPP

@ -107,6 +107,12 @@
#include <sys/vminfo.h>
#include <sys/wait.h>
// If RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
// getrusage() is prepared to handle the associated failure.
#ifndef RUSAGE_THREAD
#define RUSAGE_THREAD (1) /* only the calling thread */
#endif
// Add missing declarations (should be in procinfo.h but isn't until AIX 6.1).
#if !defined(_AIXVERSION_610)
extern "C" {
@ -1072,15 +1078,19 @@ jlong os::elapsed_frequency() {
return (1000 * 1000);
}
// For now, we say that linux does not support vtime. I have no idea
// whether it can actually be made to (DLD, 9/13/05).
bool os::supports_vtime() { return false; }
bool os::supports_vtime() { return true; }
bool os::enable_vtime() { return false; }
bool os::vtime_enabled() { return false; }
double os::elapsedVTime() {
// better than nothing, but not much
return elapsedTime();
struct rusage usage;
int retval = getrusage(RUSAGE_THREAD, &usage);
if (retval == 0) {
return usage.ru_utime.tv_sec + usage.ru_stime.tv_sec + (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000.0 * 1000);
} else {
// better than nothing, but not much
return elapsedTime();
}
}
jlong os::javaTimeMillis() {

@ -1,285 +0,0 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
* Name: add_gnu_debuglink.c
*
* Description: Add a ".gnu_debuglink" section that refers to the specified
* debug_info_path to the specified ELF object.
*
* This program is adapted from the example program shown on the
* elf(3elf) man page and from code from the Solaris compiler
* driver.
*/
/*
* needed to define SHF_EXCLUDE
*/
#define ELF_TARGET_ALL
#include <fcntl.h>
#include <stdio.h>
#include <libelf.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static void failure(void);
static unsigned int gnu_debuglink_crc32(unsigned int crc, unsigned char *buf,
size_t len);
void
main(int argc, char ** argv) {
/* new ELF section name */
static char SEC_NAME[] = ".gnu_debuglink";
unsigned char buffer[8 * 1024]; /* I/O buffer */
int buffer_len; /* buffer length */
char * debug_info_path; /* debug info path */
void * ehdr; /* ELF header */
Elf * elf; /* ELF descriptor */
char * elf_ident; /* ELF identity string */
char * elf_obj; /* elf_obj file */
int fd; /* descriptor for files */
unsigned int file_crc = 0; /* CRC for debug info file */
int is_elfclass64; /* is an ELFCLASS64 file? */
Elf_Data * link_dat; /* ELF data for new debug info link */
Elf_Data * name_dat; /* ELF data for new section name */
Elf_Scn * new_scn; /* new ELF section descriptor */
void * new_shdr; /* new ELF section header */
Elf_Scn * scn; /* ELF section descriptor */
void * shdr; /* ELF section header */
if (argc != 3) {
(void) fprintf(stderr, "Usage: %s debug_info_path elf_obj\n", argv[0]);
exit(2);
}
debug_info_path = argv[1]; /* save for later */
if ((fd = open(debug_info_path, O_RDONLY)) == -1) {
(void) fprintf(stderr, "%s: cannot open file.\n", debug_info_path);
exit(3);
}
(void) printf("Computing CRC for '%s'\n", debug_info_path);
(void) fflush(stdout);
/* compute CRC for the debug info file */
for (;;) {
int len = read(fd, buffer, sizeof buffer);
if (len <= 0) {
break;
}
file_crc = gnu_debuglink_crc32(file_crc, buffer, len);
}
(void) close(fd);
/* open the elf_obj */
elf_obj = argv[2];
if ((fd = open(elf_obj, O_RDWR)) == -1) {
(void) fprintf(stderr, "%s: cannot open file.\n", elf_obj);
exit(4);
}
(void) printf("Opening '%s' for update\n", elf_obj);
(void) fflush(stdout);
(void) elf_version(EV_CURRENT); /* coordinate ELF versions */
/* obtain the ELF descriptors from the input file */
if ((elf = elf_begin(fd, ELF_C_RDWR, NULL)) == NULL) {
failure();
}
/* determine if ELFCLASS64 or not? */
elf_ident = elf_getident(elf, NULL);
is_elfclass64 = (elf_ident[EI_CLASS] == ELFCLASS64);
/* get the ELF header */
if (is_elfclass64) {
ehdr = elf64_getehdr(elf);
} else {
ehdr = elf32_getehdr(elf);
}
if (ehdr == NULL) {
failure();
}
/* get the ELF section descriptor */
if (is_elfclass64) {
scn = elf_getscn(elf, ((Elf64_Ehdr *) ehdr)->e_shstrndx);
} else {
scn = elf_getscn(elf, ((Elf32_Ehdr *) ehdr)->e_shstrndx);
}
if (scn == NULL) {
failure();
}
/* get the section header */
if (is_elfclass64) {
shdr = elf64_getshdr(scn);
} else {
shdr = elf32_getshdr(scn);
}
if (shdr == NULL) {
failure();
}
(void) printf("Adding ELF data for new section name\n");
(void) fflush(stdout);
name_dat = elf_newdata(scn);
name_dat->d_buf = (void *) SEC_NAME;
if (is_elfclass64) {
name_dat->d_off = ((Elf64_Shdr *) shdr)->sh_size + 1;
} else {
name_dat->d_off = ((Elf32_Shdr *) shdr)->sh_size + 1;
}
name_dat->d_align = 1;
name_dat->d_size = strlen(SEC_NAME) + 1;
new_scn = elf_newscn(elf);
if (is_elfclass64) {
new_shdr = elf64_getshdr(new_scn);
((Elf64_Shdr *) new_shdr)->sh_flags = SHF_EXCLUDE;
((Elf64_Shdr *) new_shdr)->sh_type = SHT_PROGBITS;
((Elf64_Shdr *) new_shdr)->sh_name = ((Elf64_Shdr *) shdr)->sh_size;
((Elf64_Shdr *) new_shdr)->sh_addralign = 1;
((Elf64_Shdr *) shdr)->sh_size += (strlen(SEC_NAME) + 1);
} else {
new_shdr = elf32_getshdr(new_scn);
((Elf32_Shdr *) new_shdr)->sh_flags = SHF_EXCLUDE;
((Elf32_Shdr *) new_shdr)->sh_type = SHT_PROGBITS;
((Elf32_Shdr *) new_shdr)->sh_name = ((Elf32_Shdr *) shdr)->sh_size;
((Elf32_Shdr *) new_shdr)->sh_addralign = 1;
((Elf32_Shdr *) shdr)->sh_size += (strlen(SEC_NAME) + 1);
}
(void) printf("Adding ELF data for debug_info_path value\n");
(void) fflush(stdout);
(void) memset(buffer, 0, sizeof buffer);
buffer_len = strlen(debug_info_path) + 1; /* +1 for NUL */
(void) strncpy((char *) buffer, debug_info_path, buffer_len);
if (buffer_len % 4 != 0) {
/* not on a 4 byte boundary so pad to the next one */
buffer_len += (4 - buffer_len % 4);
}
/* save the CRC */
(void) memcpy(&buffer[buffer_len], &file_crc, sizeof file_crc);
buffer_len += sizeof file_crc;
link_dat = elf_newdata(new_scn);
link_dat->d_type = ELF_T_BYTE;
link_dat->d_size = buffer_len;
link_dat->d_buf = buffer;
link_dat->d_align = 1;
(void) printf("Saving updates to '%s'\n", elf_obj);
(void) fflush(stdout);
(void) elf_update(elf, ELF_C_NULL); /* recalc ELF memory structures */
(void) elf_update(elf, ELF_C_WRITE); /* write out changes to ELF obj */
(void) elf_end(elf); /* done with ELF obj */
(void) close(fd);
(void) printf("Done updating '%s'\n", elf_obj);
(void) fflush(stdout);
exit(0);
} /* end main */
static void
failure() {
(void) fprintf(stderr, "%s\n", elf_errmsg(elf_errno()));
exit(5);
}
/*
* The CRC used in gnu_debuglink, retrieved from
* http://sourceware.org/gdb/current/onlinedocs/gdb/Separate-Debug-Files.html#Separate-Debug-Files.
*/
static unsigned int
gnu_debuglink_crc32(unsigned int crc, unsigned char *buf, size_t len) {
static const unsigned int crc32_table[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
0x2d02ef8d
};
unsigned char *end;
crc = ~crc & 0xffffffff;
for (end = buf + len; buf < end; ++buf) {
crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
}
return ~crc & 0xffffffff;
}

@ -1,181 +0,0 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
* Name: fix_empty_sec_hdr_flags.c
*
* Description: Remove the SHF_ALLOC flag from "empty" section headers.
* An "empty" section header has sh_addr == 0 and sh_size == 0.
*
* This program is adapted from the example program shown on the
* elf(3elf) man page and from code from the Solaris compiler
* driver.
*/
#include <fcntl.h>
#include <stdio.h>
#include <libelf.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static void failure(void);
void
main(int argc, char ** argv) {
void * ehdr; /* ELF header */
unsigned int i; /* section counter */
int fd; /* descriptor for file */
Elf * elf; /* ELF descriptor */
char * elf_ident; /* ELF identity string */
char * elf_obj; /* elf_obj file */
int fix_count; /* number of flags fixed */
int is_elfclass64; /* is an ELFCLASS64 file? */
Elf_Scn * scn; /* ELF section descriptor */
void * shdr; /* ELF section header */
Elf_Data * shstrtab; /* ELF section header string table */
if (argc != 2) {
(void) fprintf(stderr, "Usage: %s elf_obj\n", argv[0]);
exit(2);
}
/* open the elf_obj */
elf_obj = argv[1];
if ((fd = open(elf_obj, O_RDWR)) == -1) {
(void) fprintf(stderr, "%s: cannot open file.\n", elf_obj);
exit(3);
}
(void) printf("Opening '%s' for update\n", elf_obj);
(void) fflush(stdout);
(void) elf_version(EV_CURRENT); /* coordinate ELF versions */
/* obtain the ELF descriptors from the input file */
if ((elf = elf_begin(fd, ELF_C_RDWR, NULL)) == NULL) {
failure();
}
/* determine if ELFCLASS64 or not? */
elf_ident = elf_getident(elf, NULL);
is_elfclass64 = (elf_ident[EI_CLASS] == ELFCLASS64);
/* get the ELF header */
if (is_elfclass64) {
ehdr = elf64_getehdr(elf);
} else {
ehdr = elf32_getehdr(elf);
}
if (ehdr == NULL) {
failure();
}
/* get the ELF section descriptor */
if (is_elfclass64) {
scn = elf_getscn(elf, ((Elf64_Ehdr *) ehdr)->e_shstrndx);
} else {
scn = elf_getscn(elf, ((Elf32_Ehdr *) ehdr)->e_shstrndx);
}
if (scn == NULL) {
failure();
}
/* get the section header string table */
shstrtab = elf_getdata(scn, NULL);
if (shstrtab == NULL) {
failure();
}
fix_count = 0;
/* traverse the sections of the input file */
for (i = 1, scn = NULL; scn = elf_nextscn(elf, scn); i++) {
int has_flag_set; /* is SHF_ALLOC flag set? */
int is_empty; /* is section empty? */
char * name; /* short hand pointer */
/* get the section header */
if (is_elfclass64) {
shdr = elf64_getshdr(scn);
} else {
shdr = elf32_getshdr(scn);
}
if (shdr == NULL) {
failure();
}
if (is_elfclass64) {
name = (char *)shstrtab->d_buf + ((Elf64_Shdr *) shdr)->sh_name;
} else {
name = (char *)shstrtab->d_buf + ((Elf32_Shdr *) shdr)->sh_name;
}
if (is_elfclass64) {
has_flag_set = ((Elf64_Shdr *) shdr)->sh_flags & SHF_ALLOC;
is_empty = ((Elf64_Shdr *) shdr)->sh_addr == 0 &&
((Elf64_Shdr *) shdr)->sh_size == 0;
} else {
has_flag_set = ((Elf32_Shdr *) shdr)->sh_flags & SHF_ALLOC;
is_empty = ((Elf32_Shdr *) shdr)->sh_addr == 0 &&
((Elf32_Shdr *) shdr)->sh_size == 0;
}
if (is_empty && has_flag_set) {
(void) printf("section[%u] '%s' is empty, "
"but SHF_ALLOC flag is set.\n", i, name);
(void) printf("Clearing the SHF_ALLOC flag.\n");
if (is_elfclass64) {
((Elf64_Shdr *) shdr)->sh_flags &= ~SHF_ALLOC;
} else {
((Elf32_Shdr *) shdr)->sh_flags &= ~SHF_ALLOC;
}
fix_count++;
}
} /* end for each ELF section */
if (fix_count > 0) {
(void) printf("Saving %d updates to '%s'\n", fix_count, elf_obj);
(void) fflush(stdout);
(void) elf_update(elf, ELF_C_NULL); /* recalc ELF memory structures */
(void) elf_update(elf, ELF_C_WRITE); /* write out changes to ELF obj */
} else {
(void) printf("No SHF_ALLOC flags needed to be cleared.\n");
}
(void) elf_end(elf); /* done with ELF obj */
(void) close(fd);
(void) printf("Done %s '%s'\n",
(fix_count > 0) ? "updating" : "with", elf_obj);
(void) fflush(stdout);
exit(0);
} /* end main */
static void
failure() {
(void) fprintf(stderr, "%s\n", elf_errmsg(elf_errno()));
exit(6);
}

@ -654,7 +654,11 @@ void os::setup_fpu() {
#ifndef PRODUCT
void os::verify_stack_alignment() {
#ifdef AMD64
assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
// The current_stack_pointer() calls generated get_previous_sp stub routine.
// Only enable the assert after the routine becomes available.
if (StubRoutines::code1() != NULL) {
assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
}
#endif
}
#endif

@ -512,7 +512,9 @@ abstract class GenericDebugConfig extends BuildConfig {
abstract class GenericDebugNonKernelConfig extends GenericDebugConfig {
protected void init(Vector includes, Vector defines) {
super.init(includes, defines);
getCI().getAdditionalNonKernelLinkerFlags(getV("LinkerFlags"));
if (get("PlatformName").equals("Win32")) {
getCI().getAdditionalNonKernelLinkerFlags(getV("LinkerFlags"));
}
}
}

@ -401,16 +401,18 @@ class CompilerInterfaceVC10 extends CompilerInterface {
Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
Vector rv = new Vector();
addAttr(rv, "AdditionalOptions",
"/export:JNI_GetDefaultJavaVMInitArgs " +
"/export:JNI_CreateJavaVM " +
"/export:JVM_FindClassFromBootLoader "+
"/export:JNI_GetCreatedJavaVMs "+
"/export:jio_snprintf /export:jio_printf "+
"/export:jio_fprintf /export:jio_vfprintf "+
"/export:jio_vsnprintf "+
"/export:JVM_GetVersionInfo "+
"/export:JVM_InitAgentProperties");
if(platformName.equals("Win32")) {
addAttr(rv, "AdditionalOptions",
"/export:JNI_GetDefaultJavaVMInitArgs " +
"/export:JNI_CreateJavaVM " +
"/export:JVM_FindClassFromBootLoader "+
"/export:JNI_GetCreatedJavaVMs "+
"/export:jio_snprintf /export:jio_printf "+
"/export:jio_fprintf /export:jio_vfprintf "+
"/export:jio_vsnprintf "+
"/export:JVM_GetVersionInfo "+
"/export:JVM_InitAgentProperties");
}
addAttr(rv, "AdditionalDependencies", "kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;Wsock32.lib;winmm.lib;psapi.lib;version.lib");
addAttr(rv, "OutputFile", outDll);
addAttr(rv, "SuppressStartupBanner", "true");

@ -65,9 +65,8 @@
#include "utilities/growableArray.hpp"
#include "utilities/macros.hpp"
#include "utilities/ostream.hpp"
#if INCLUDE_TRACE
#include "trace/tracing.hpp"
#include "trace/tracing.hpp"
#endif
ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
@ -978,4 +977,4 @@ void ClassLoaderDataGraph::class_unload_event(Klass* const k) {
event.commit();
}
#endif /* INCLUDE_TRACE */
#endif // INCLUDE_TRACE

@ -31,8 +31,9 @@
#include "memory/metaspaceCounters.hpp"
#include "runtime/mutex.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/macros.hpp"
#if INCLUDE_TRACE
# include "utilities/ticks.hpp"
#include "utilities/ticks.hpp"
#endif
//

@ -63,6 +63,9 @@ public:
ClassPathEntry* new_entry) {
ClassLoader::add_to_list(new_entry);
}
static void append_boot_classpath(ClassPathEntry* new_entry) {
ClassLoader::add_to_list(new_entry);
}
static void setup_search_paths() {}
};

@ -41,6 +41,7 @@
#include "oops/method.hpp"
#include "oops/symbol.hpp"
#include "oops/typeArrayOop.hpp"
#include "prims/jvmtiRedefineClassesTrace.hpp"
#include "runtime/fieldDescriptor.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/interfaceSupport.hpp"
@ -944,7 +945,7 @@ void java_lang_Thread::compute_offsets() {
assert(_group_offset == 0, "offsets should be initialized only once");
Klass* k = SystemDictionary::Thread_klass();
compute_offset(_name_offset, k, vmSymbols::name_name(), vmSymbols::char_array_signature());
compute_offset(_name_offset, k, vmSymbols::name_name(), vmSymbols::string_signature());
compute_offset(_group_offset, k, vmSymbols::group_name(), vmSymbols::threadgroup_signature());
compute_offset(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), vmSymbols::classloader_signature());
compute_offset(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), vmSymbols::accesscontrolcontext_signature());
@ -974,15 +975,12 @@ void java_lang_Thread::set_thread(oop java_thread, JavaThread* thread) {
}
typeArrayOop java_lang_Thread::name(oop java_thread) {
oop name = java_thread->obj_field(_name_offset);
assert(name == NULL || (name->is_typeArray() && TypeArrayKlass::cast(name->klass())->element_type() == T_CHAR), "just checking");
return typeArrayOop(name);
oop java_lang_Thread::name(oop java_thread) {
return java_thread->obj_field(_name_offset);
}
void java_lang_Thread::set_name(oop java_thread, typeArrayOop name) {
assert(java_thread->obj_field(_name_offset) == NULL, "name should be NULL");
void java_lang_Thread::set_name(oop java_thread, oop name) {
java_thread->obj_field_put(_name_offset, name);
}
@ -2797,12 +2795,35 @@ Metadata* java_lang_invoke_MemberName::vmtarget(oop mname) {
return (Metadata*)mname->address_field(_vmtarget_offset);
}
bool java_lang_invoke_MemberName::is_method(oop mname) {
assert(is_instance(mname), "must be MemberName");
return (flags(mname) & (MN_IS_METHOD | MN_IS_CONSTRUCTOR)) > 0;
}
#if INCLUDE_JVMTI
// Can be executed on VM thread only
void java_lang_invoke_MemberName::adjust_vmtarget(oop mname, Metadata* ref) {
assert((is_instance(mname) && (flags(mname) & (MN_IS_METHOD | MN_IS_CONSTRUCTOR)) > 0), "wrong type");
void java_lang_invoke_MemberName::adjust_vmtarget(oop mname, Method* old_method,
Method* new_method, bool* trace_name_printed) {
assert(is_method(mname), "wrong type");
assert(Thread::current()->is_VM_thread(), "not VM thread");
mname->address_field_put(_vmtarget_offset, (address)ref);
Method* target = (Method*)mname->address_field(_vmtarget_offset);
if (target == old_method) {
mname->address_field_put(_vmtarget_offset, (address)new_method);
if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
if (!(*trace_name_printed)) {
// RC_TRACE_MESG macro has an embedded ResourceMark
RC_TRACE_MESG(("adjust: name=%s",
old_method->method_holder()->external_name()));
*trace_name_printed = true;
}
// RC_TRACE macro has an embedded ResourceMark
RC_TRACE(0x00400000, ("MemberName method update: %s(%s)",
new_method->name()->as_C_string(),
new_method->signature()->as_C_string()));
}
}
}
#endif // INCLUDE_JVMTI

@ -345,8 +345,8 @@ class java_lang_Thread : AllStatic {
// Set JavaThread for instance
static void set_thread(oop java_thread, JavaThread* thread);
// Name
static typeArrayOop name(oop java_thread);
static void set_name(oop java_thread, typeArrayOop name);
static oop name(oop java_thread);
static void set_name(oop java_thread, oop name);
// Priority
static ThreadPriority priority(oop java_thread);
static void set_priority(oop java_thread, ThreadPriority priority);
@ -1100,7 +1100,8 @@ class java_lang_invoke_MemberName: AllStatic {
static Metadata* vmtarget(oop mname);
static void set_vmtarget(oop mname, Metadata* target);
#if INCLUDE_JVMTI
static void adjust_vmtarget(oop mname, Metadata* target);
static void adjust_vmtarget(oop mname, Method* old_method, Method* new_method,
bool* trace_name_printed);
#endif // INCLUDE_JVMTI
static intptr_t vmindex(oop mname);
@ -1114,6 +1115,8 @@ class java_lang_invoke_MemberName: AllStatic {
return obj != NULL && is_subclass(obj->klass());
}
static bool is_method(oop obj);
// Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
enum {
MN_IS_METHOD = 0x00010000, // method (not constructor)

@ -66,7 +66,7 @@
#include "classfile/systemDictionaryShared.hpp"
#endif
#if INCLUDE_TRACE
#include "trace/tracing.hpp"
#include "trace/tracing.hpp"
#endif
Dictionary* SystemDictionary::_dictionary = NULL;
@ -2659,7 +2659,7 @@ void SystemDictionary::post_class_load_event(const Ticks& start_time,
class_loader->klass() : (Klass*)NULL);
event.commit();
}
#endif /* INCLUDE_TRACE */
#endif // INCLUDE_TRACE
}
#ifndef PRODUCT

@ -29,8 +29,8 @@
#include "memory/heapInspection.hpp"
#include "trace/tracing.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include "utilities/ticks.hpp"
#if INCLUDE_SERVICES
void ObjectCountEventSender::send(const KlassInfoEntry* entry, GCId gc_id, const Ticks& timestamp) {

@ -293,7 +293,6 @@ int ConstMethod::method_parameters_length() const {
MethodParametersElement* ConstMethod::method_parameters_start() const {
u2* addr = method_parameters_length_addr();
u2 length = *addr;
assert(length > 0, "should only be called if table is present");
addr -= length * sizeof(MethodParametersElement) / sizeof(u2);
return (MethodParametersElement*) addr;
}

@ -2931,28 +2931,27 @@ nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_le
return NULL;
}
void InstanceKlass::add_member_name(int index, Handle mem_name) {
bool InstanceKlass::add_member_name(Handle mem_name) {
jweak mem_name_wref = JNIHandles::make_weak_global(mem_name);
MutexLocker ml(MemberNameTable_lock);
assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds");
DEBUG_ONLY(No_Safepoint_Verifier nsv);
// Check if method has been redefined while taking out MemberNameTable_lock, if so
// return false. We cannot cache obsolete methods. They will crash when the function
// is called!
Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name());
if (method->is_obsolete()) {
return false;
} else if (method->is_old()) {
// Replace method with redefined version
java_lang_invoke_MemberName::set_vmtarget(mem_name(), method_with_idnum(method->method_idnum()));
}
if (_member_names == NULL) {
_member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count());
}
_member_names->add_member_name(index, mem_name_wref);
}
oop InstanceKlass::get_member_name(int index) {
MutexLocker ml(MemberNameTable_lock);
assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds");
DEBUG_ONLY(No_Safepoint_Verifier nsv);
if (_member_names == NULL) {
return NULL;
}
oop mem_name =_member_names->get_member_name(index);
return mem_name;
_member_names->add_member_name(mem_name_wref);
return true;
}
// -----------------------------------------------------------------------------------------------------

@ -1072,8 +1072,7 @@ public:
// JSR-292 support
MemberNameTable* member_names() { return _member_names; }
void set_member_names(MemberNameTable* member_names) { _member_names = member_names; }
void add_member_name(int index, Handle member_name);
oop get_member_name(int index);
bool add_member_name(Handle member_name);
public:
// JVMTI support

@ -568,13 +568,14 @@ JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle))
// Make shallow object copy
const int size = obj->size();
oop new_obj = NULL;
oop new_obj_oop = NULL;
if (obj->is_array()) {
const int length = ((arrayOop)obj())->length();
new_obj = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL);
new_obj_oop = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL);
} else {
new_obj = CollectedHeap::obj_allocate(klass, size, CHECK_NULL);
new_obj_oop = CollectedHeap::obj_allocate(klass, size, CHECK_NULL);
}
// 4839641 (4840070): We must do an oop-atomic copy, because if another thread
// is modifying a reference field in the clonee, a non-oop-atomic copy might
// be suspended in the middle of copying the pointer and end up with parts
@ -585,24 +586,41 @@ JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle))
// The same is true of StubRoutines::object_copy and the various oop_copy
// variants, and of the code generated by the inline_native_clone intrinsic.
assert(MinObjAlignmentInBytes >= BytesPerLong, "objects misaligned");
Copy::conjoint_jlongs_atomic((jlong*)obj(), (jlong*)new_obj,
Copy::conjoint_jlongs_atomic((jlong*)obj(), (jlong*)new_obj_oop,
(size_t)align_object_size(size) / HeapWordsPerLong);
// Clear the header
new_obj->init_mark();
new_obj_oop->init_mark();
// Store check (mark entire object and let gc sort it out)
BarrierSet* bs = Universe::heap()->barrier_set();
assert(bs->has_write_region_opt(), "Barrier set does not have write_region");
bs->write_region(MemRegion((HeapWord*)new_obj, size));
bs->write_region(MemRegion((HeapWord*)new_obj_oop, size));
Handle new_obj(THREAD, new_obj_oop);
// Special handling for MemberNames. Since they contain Method* metadata, they
// must be registered so that RedefineClasses can fix metadata contained in them.
if (java_lang_invoke_MemberName::is_instance(new_obj()) &&
java_lang_invoke_MemberName::is_method(new_obj())) {
Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(new_obj());
// MemberName may be unresolved, so doesn't need registration until resolved.
if (method != NULL) {
methodHandle m(THREAD, method);
// This can safepoint and redefine method, so need both new_obj and method
// in a handle, for two different reasons. new_obj can move, method can be
// deleted if nothing is using it on the stack.
m->method_holder()->add_member_name(new_obj());
}
}
// Caution: this involves a java upcall, so the clone should be
// "gc-robust" by this stage.
if (klass->has_finalizer()) {
assert(obj->is_instance(), "should be instanceOop");
new_obj = InstanceKlass::register_finalizer(instanceOop(new_obj), CHECK_NULL);
new_obj_oop = InstanceKlass::register_finalizer(instanceOop(new_obj()), CHECK_NULL);
new_obj = Handle(THREAD, new_obj_oop);
}
return JNIHandles::make_local(env, oop(new_obj));
return JNIHandles::make_local(env, new_obj());
JVM_END
// java.io.File ///////////////////////////////////////////////////////////////
@ -2594,6 +2612,10 @@ int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
if ((intptr_t)count <= 0) return -1;
int result = vsnprintf(str, count, fmt, args);
// Note: on truncation vsnprintf(3) on Unix returns numbers of
// characters which would have been written had the buffer been large
// enough; on Windows, it returns -1. We handle both cases here and
// always return -1, and perform null termination.
if ((result > 0 && (size_t)result >= count) || result == -1) {
str[count - 1] = '\0';
result = -1;

@ -1167,10 +1167,14 @@ JVM_NativePath(char *);
* be renamed to JVM_* in the future?
*/
/*
* BE CAREFUL! The following functions do not implement the
* full feature set of standard C printf formats.
*/
/* jio_snprintf() and jio_vsnprintf() behave like snprintf(3) and vsnprintf(3),
* respectively, with the following differences:
* - The string written to str is always zero-terminated, also in case of
* truncation (count is too small to hold the result string), unless count
* is 0. In case of truncation count-1 characters are written and '\0'
* appendend.
* - If count is too small to hold the whole string, -1 is returned across
* all platforms. */
JNIEXPORT int
jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);

@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
#include "classfile/classLoaderExt.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "interpreter/bytecodeStream.hpp"
@ -472,7 +473,7 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) {
if (TraceClassLoading) {
tty->print_cr("[Opened %s]", zip_entry->name());
}
ClassLoader::add_to_list(zip_entry);
ClassLoaderExt::append_boot_classpath(zip_entry);
return JVMTI_ERROR_NONE;
} else {
return JVMTI_ERROR_WRONG_PHASE;
@ -942,7 +943,7 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) {
return JVMTI_ERROR_INVALID_THREAD;
Handle thread_obj(current_thread, thread_oop);
typeArrayHandle name;
Handle name;
ThreadPriority priority;
Handle thread_group;
Handle context_class_loader;
@ -950,7 +951,7 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) {
{ MutexLocker mu(Threads_lock);
name = typeArrayHandle(current_thread, java_lang_Thread::name(thread_obj()));
name = Handle(current_thread, java_lang_Thread::name(thread_obj()));
priority = java_lang_Thread::priority(thread_obj());
thread_group = Handle(current_thread, java_lang_Thread::threadGroup(thread_obj()));
is_daemon = java_lang_Thread::is_daemon(thread_obj());
@ -961,7 +962,7 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) {
{ const char *n;
if (name() != NULL) {
n = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length());
n = java_lang_String::as_utf8_string(name());
} else {
n = UNICODE::as_utf8(NULL, 0);
}

@ -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
@ -266,11 +266,11 @@ const char *JvmtiTrace::safe_get_thread_name(Thread *thread) {
if (threadObj == NULL) {
return "NULL";
}
typeArrayOop name = java_lang_Thread::name(threadObj);
oop name = java_lang_Thread::name(threadObj);
if (name == NULL) {
return "<NOT FILLED IN>";
}
return UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length());
return java_lang_String::as_utf8_string(name);
}

@ -29,7 +29,6 @@
#include "interpreter/oopMapCache.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/oopFactory.hpp"
#include "prims/jvmtiRedefineClassesTrace.hpp"
#include "prims/methodHandles.hpp"
#include "runtime/compilationPolicy.hpp"
#include "runtime/javaCalls.hpp"
@ -276,9 +275,12 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
// This is done eagerly, since it is readily available without
// constructing any new objects.
// TO DO: maybe intern mname_oop
m->method_holder()->add_member_name(m->method_idnum(), mname);
return mname();
if (m->method_holder()->add_member_name(mname)) {
return mname();
} else {
// Redefinition caused this to fail. Return NULL (and an exception?)
return NULL;
}
}
oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool is_setter) {
@ -951,63 +953,27 @@ MemberNameTable::~MemberNameTable() {
}
}
void MemberNameTable::add_member_name(int index, jweak mem_name_wref) {
void MemberNameTable::add_member_name(jweak mem_name_wref) {
assert_locked_or_safepoint(MemberNameTable_lock);
this->at_put_grow(index, mem_name_wref);
}
// Return a member name oop or NULL.
oop MemberNameTable::get_member_name(int index) {
assert_locked_or_safepoint(MemberNameTable_lock);
jweak ref = this->at(index);
oop mem_name = JNIHandles::resolve(ref);
return mem_name;
this->push(mem_name_wref);
}
#if INCLUDE_JVMTI
oop MemberNameTable::find_member_name_by_method(Method* old_method) {
assert_locked_or_safepoint(MemberNameTable_lock);
oop found = NULL;
int len = this->length();
for (int idx = 0; idx < len; idx++) {
oop mem_name = JNIHandles::resolve(this->at(idx));
if (mem_name == NULL) {
continue;
}
Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name);
if (method == old_method) {
found = mem_name;
break;
}
}
return found;
}
// It is called at safepoint only
// It is called at safepoint only for RedefineClasses
void MemberNameTable::adjust_method_entries(Method** old_methods, Method** new_methods,
int methods_length, bool *trace_name_printed) {
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
// search the MemberNameTable for uses of either obsolete or EMCP methods
// For each redefined method
for (int j = 0; j < methods_length; j++) {
Method* old_method = old_methods[j];
Method* new_method = new_methods[j];
oop mem_name = find_member_name_by_method(old_method);
if (mem_name != NULL) {
java_lang_invoke_MemberName::adjust_vmtarget(mem_name, new_method);
if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
if (!(*trace_name_printed)) {
// RC_TRACE_MESG macro has an embedded ResourceMark
RC_TRACE_MESG(("adjust: name=%s",
old_method->method_holder()->external_name()));
*trace_name_printed = true;
}
// RC_TRACE macro has an embedded ResourceMark
RC_TRACE(0x00400000, ("MemberName method update: %s(%s)",
new_method->name()->as_C_string(),
new_method->signature()->as_C_string()));
// search the MemberNameTable for uses of either obsolete or EMCP methods
for (int idx = 0; idx < length(); idx++) {
oop mem_name = JNIHandles::resolve(this->at(idx));
if (mem_name != NULL) {
java_lang_invoke_MemberName::adjust_vmtarget(mem_name, old_method, new_method,
trace_name_printed);
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@ -236,18 +236,14 @@ class MemberNameTable : public GrowableArray<jweak> {
public:
MemberNameTable(int methods_cnt);
~MemberNameTable();
void add_member_name(int index, jweak mem_name_ref);
oop get_member_name(int index);
void add_member_name(jweak mem_name_ref);
#if INCLUDE_JVMTI
public:
// RedefineClasses() API support:
// If a MemberName refers to old_method then update it
// to refer to new_method.
void adjust_method_entries(Method** old_methods, Method** new_methods,
int methods_length, bool *trace_name_printed);
private:
oop find_member_name_by_method(Method* old_method);
#endif // INCLUDE_JVMTI
};

@ -29,6 +29,7 @@
#include "classfile/classLoaderData.hpp"
#include "classfile/stringTable.hpp"
#include "code/codeCache.hpp"
#include "jvmtifiles/jvmtiEnv.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/universe.hpp"
#include "oops/oop.inline.hpp"
@ -106,6 +107,29 @@ WB_ENTRY(jboolean, WB_IsClassAlive(JNIEnv* env, jobject target, jstring name))
return closure.found();
WB_END
WB_ENTRY(void, WB_AddToBootstrapClassLoaderSearch(JNIEnv* env, jobject o, jstring segment)) {
#if INCLUDE_JVMTI
ResourceMark rm;
const char* seg = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(segment));
JvmtiEnv* jvmti_env = JvmtiEnv::create_a_jvmti(JVMTI_VERSION);
jvmtiError err = jvmti_env->AddToBootstrapClassLoaderSearch(seg);
assert(err == JVMTI_ERROR_NONE, "must not fail");
#endif
}
WB_END
WB_ENTRY(void, WB_AddToSystemClassLoaderSearch(JNIEnv* env, jobject o, jstring segment)) {
#if INCLUDE_JVMTI
ResourceMark rm;
const char* seg = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(segment));
JvmtiEnv* jvmti_env = JvmtiEnv::create_a_jvmti(JVMTI_VERSION);
jvmtiError err = jvmti_env->AddToSystemClassLoaderSearch(seg);
assert(err == JVMTI_ERROR_NONE, "must not fail");
#endif
}
WB_END
WB_ENTRY(jlong, WB_GetCompressedOopsMaxHeapSize(JNIEnv* env, jobject o)) {
return (jlong)Arguments::max_heap_for_compressed_oops();
}
@ -1095,6 +1119,10 @@ static JNINativeMethod methods[] = {
CC"(Ljava/lang/String;[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;",
(void*) &WB_ParseCommandLine
},
{CC"addToBootstrapClassLoaderSearch", CC"(Ljava/lang/String;)V",
(void*)&WB_AddToBootstrapClassLoaderSearch},
{CC"addToSystemClassLoaderSearch", CC"(Ljava/lang/String;)V",
(void*)&WB_AddToSystemClassLoaderSearch},
{CC"getCompressedOopsMaxHeapSize", CC"()J",
(void*)&WB_GetCompressedOopsMaxHeapSize},
{CC"printHeapSizes", CC"()V", (void*)&WB_PrintHeapSizes },

@ -313,6 +313,7 @@ static ObsoleteFlag obsolete_jvm_flags[] = {
{ "UseFastAccessorMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ "UseFastEmptyMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
#endif // ZERO
{ "UseCompilerSafepoints", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ NULL, JDK_Version(0), JDK_Version(0) }
};
@ -327,9 +328,12 @@ bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
const ObsoleteFlag& flag_status = obsolete_jvm_flags[i];
// <flag>=xxx form
// [-|+]<flag> form
if ((strncmp(flag_status.name, s, strlen(flag_status.name)) == 0) ||
size_t len = strlen(flag_status.name);
if (((strncmp(flag_status.name, s, len) == 0) &&
(strlen(s) == len)) ||
((s[0] == '+' || s[0] == '-') &&
(strncmp(flag_status.name, &s[1], strlen(flag_status.name)) == 0))) {
(strncmp(flag_status.name, &s[1], len) == 0) &&
(strlen(&s[1]) == len))) {
if (JDK_Version::current().compare(flag_status.accept_until) == -1) {
*version = flag_status.obsoleted_in;
return true;
@ -934,10 +938,18 @@ bool Arguments::process_argument(const char* arg,
Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
if (fuzzy_matched != NULL) {
jio_fprintf(defaultStream::error_stream(),
"Did you mean '%s%s%s'?\n",
"Did you mean '%s%s%s'? ",
(fuzzy_matched->is_bool()) ? "(+/-)" : "",
fuzzy_matched->_name,
(fuzzy_matched->is_bool()) ? "" : "=<value>");
if (is_newly_obsolete(fuzzy_matched->_name, &since)) {
char version[256];
since.to_string(version, sizeof(version));
jio_fprintf(defaultStream::error_stream(),
"Warning: support for %s was removed in %s\n",
fuzzy_matched->_name,
version);
}
}
}

@ -777,9 +777,6 @@ class CommandLineFlags {
develop(bool, TraceHandleAllocation, false, \
"Print out warnings when suspiciously many handles are allocated")\
\
product(bool, UseCompilerSafepoints, true, \
"Stop at safepoints in compiled code") \
\
product(bool, FailOverToOldVerifier, true, \
"Fail over to old verifier when split verifier fails") \
\
@ -1335,9 +1332,6 @@ class CommandLineFlags {
develop(bool, TraceJNIHandleAllocation, false, \
"Trace allocation/deallocation of JNI handle blocks") \
\
develop(bool, TraceThreadEvents, false, \
"Trace all thread events") \
\
develop(bool, TraceBytecodes, false, \
"Trace bytecode execution") \
\

@ -182,7 +182,7 @@ void SafepointSynchronize::begin() {
// Make interpreter safepoint aware
Interpreter::notice_safepoints();
if (UseCompilerSafepoints && DeferPollingPageLoopCount < 0) {
if (DeferPollingPageLoopCount < 0) {
// Make polling safepoint aware
guarantee (PageArmed == 0, "invariant") ;
PageArmed = 1 ;
@ -288,7 +288,7 @@ void SafepointSynchronize::begin() {
// 9. On windows consider using the return value from SwitchThreadTo()
// to drive subsequent spin/SwitchThreadTo()/Sleep(N) decisions.
if (UseCompilerSafepoints && int(iterations) == DeferPollingPageLoopCount) {
if (int(iterations) == DeferPollingPageLoopCount) {
guarantee (PageArmed == 0, "invariant") ;
PageArmed = 1 ;
os::make_polling_page_unreadable();
@ -1074,7 +1074,7 @@ void SafepointSynchronize::deferred_initialize_stat() {
guarantee(_safepoint_stats != NULL,
"not enough memory for safepoint instrumentation data");
if (UseCompilerSafepoints && DeferPollingPageLoopCount >= 0) {
if (DeferPollingPageLoopCount >= 0) {
need_to_track_page_armed_status = true;
}
init_done = true;
@ -1241,9 +1241,7 @@ void SafepointSynchronize::print_stat_on_exit() {
// Print out polling page sampling status.
if (!need_to_track_page_armed_status) {
if (UseCompilerSafepoints) {
tty->print_cr("Polling page always armed");
}
tty->print_cr("Polling page always armed");
} else {
tty->print_cr("Defer polling page loop count = %d\n",
DeferPollingPageLoopCount);

@ -374,42 +374,7 @@ void check_for_dangling_thread_pointer(Thread *thread) {
}
#endif
#ifndef PRODUCT
// Tracing method for basic thread operations
void Thread::trace(const char* msg, const Thread* const thread) {
if (!TraceThreadEvents) return;
ResourceMark rm;
ThreadCritical tc;
const char *name = "non-Java thread";
int prio = -1;
if (thread->is_Java_thread()
&& !thread->is_Compiler_thread()) {
// The Threads_lock must be held to get information about
// this thread but may not be in some situations when
// tracing thread events.
bool release_Threads_lock = false;
if (!Threads_lock->owned_by_self()) {
Threads_lock->lock();
release_Threads_lock = true;
}
JavaThread* jt = (JavaThread *)thread;
name = (char *)jt->get_thread_name();
oop thread_oop = jt->threadObj();
if (thread_oop != NULL) {
prio = java_lang_Thread::priority(thread_oop);
}
if (release_Threads_lock) {
Threads_lock->unlock();
}
}
tty->print_cr("Thread::%s " INTPTR_FORMAT " [%lx] %s (prio: %d)", msg, thread, thread->osthread()->thread_id(), name, prio);
}
#endif
ThreadPriority Thread::get_priority(const Thread* const thread) {
trace("get priority", thread);
ThreadPriority priority;
// Can return an error!
(void)os::get_priority(thread, priority);
@ -418,7 +383,6 @@ ThreadPriority Thread::get_priority(const Thread* const thread) {
}
void Thread::set_priority(Thread* thread, ThreadPriority priority) {
trace("set priority", thread);
debug_only(check_for_dangling_thread_pointer(thread);)
// Can return an error!
(void)os::set_priority(thread, priority);
@ -426,7 +390,6 @@ void Thread::set_priority(Thread* thread, ThreadPriority priority) {
void Thread::start(Thread* thread) {
trace("start", thread);
// Start is different from resume in that its safety is guaranteed by context or
// being called from a Java method synchronized on the Thread object.
if (!DisableStartThread) {
@ -769,13 +732,11 @@ bool JavaThread::profile_last_Java_frame(frame* _fr) {
}
void Thread::interrupt(Thread* thread) {
trace("interrupt", thread);
debug_only(check_for_dangling_thread_pointer(thread);)
os::interrupt(thread);
}
bool Thread::is_interrupted(Thread* thread, bool clear_interrupted) {
trace("is_interrupted", thread);
debug_only(check_for_dangling_thread_pointer(thread);)
// Note: If clear_interrupted==false, this simply fetches and
// returns the value of the field osthread()->interrupted().
@ -1563,9 +1524,6 @@ JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) :
_dirty_card_queue(&_dirty_card_queue_set)
#endif // INCLUDE_ALL_GCS
{
if (TraceThreadEvents) {
tty->print_cr("creating thread %p", this);
}
initialize();
_jni_attach_state = _not_attaching_via_jni;
set_entry_point(entry_point);
@ -1588,9 +1546,6 @@ JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) :
}
JavaThread::~JavaThread() {
if (TraceThreadEvents) {
tty->print_cr("terminate thread %p", this);
}
// JSR166 -- return the parker to the free list
Parker::Release(_parker);
@ -2872,14 +2827,12 @@ const char* JavaThread::get_thread_name_string(char* buf, int buflen) const {
const char* name_str;
oop thread_obj = threadObj();
if (thread_obj != NULL) {
typeArrayOop name = java_lang_Thread::name(thread_obj);
oop name = java_lang_Thread::name(thread_obj);
if (name != NULL) {
if (buf == NULL) {
name_str = UNICODE::as_utf8((jchar*) name->base(T_CHAR),
name->length());
name_str = java_lang_String::as_utf8_string(name);
} else {
name_str = UNICODE::as_utf8((jchar*) name->base(T_CHAR),
name->length(), buf, buflen);
name_str = java_lang_String::as_utf8_string(name, buf, buflen);
}
} else if (is_attaching_via_jni()) { // workaround for 6412693 - see 6404306
name_str = "<no-name - thread is attaching>";

@ -212,9 +212,6 @@ class Thread: public ThreadShadow {
bool is_inside_signal_handler() const { return _num_nested_signal > 0; }
private:
// Debug tracing
static void trace(const char* msg, const Thread* const thread) PRODUCT_RETURN;
// Active_handles points to a block of handles
JNIHandleBlock* _active_handles;

@ -173,7 +173,7 @@
#endif // INCLUDE_ALL_GCS
#if INCLUDE_TRACE
#include "runtime/vmStructs_trace.hpp"
#include "runtime/vmStructs_trace.hpp"
#endif
#ifdef COMPILER2

@ -41,4 +41,4 @@ public:
typedef NoTraceBackend Tracing;
#endif
#endif // SHARE_VM_TRACE_NOTRACEBACKEND_HPP

@ -25,9 +25,7 @@
#define SHARE_VM_TRACE_TRACEBACKEND_HPP
#include "utilities/macros.hpp"
#if INCLUDE_TRACE
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
#include "trace/traceTime.hpp"
@ -58,9 +56,7 @@ public:
typedef TraceBackend Tracing;
#else /* INCLUDE_TRACE */
#else // !INCLUDE_TRACE
#include "trace/noTraceBackend.hpp"
#endif /* INCLUDE_TRACE */
#endif /* SHARE_VM_TRACE_TRACEBACKEND_HPP */
#endif // INCLUDE_TRACE
#endif // SHARE_VM_TRACE_TRACEBACKEND_HPP

@ -33,7 +33,6 @@ enum EventStartTime {
};
#if INCLUDE_TRACE
#include "trace/traceBackend.hpp"
#include "trace/tracing.hpp"
#include "tracefiles/traceEventIds.hpp"
@ -154,6 +153,5 @@ class TraceEvent : public StackObj {
}
};
#endif /* INCLUDE_TRACE */
#endif /* SHARE_VM_TRACE_TRACEEVENT_HPP */
#endif // INCLUDE_TRACE
#endif // SHARE_VM_TRACE_TRACEEVENT_HPP

@ -41,17 +41,14 @@
#include "trace/traceEvent.hpp"
#include "utilities/macros.hpp"
#include "utilities/ticks.hpp"
#if INCLUDE_TRACE
#include "trace/traceStream.hpp"
#include "utilities/ostream.hpp"
<xsl:apply-templates select="trace/events/struct" mode="trace"/>
<xsl:apply-templates select="trace/events/event" mode="trace"/>
#else
#else // !INCLUDE_TRACE
class TraceEvent {
public:
@ -66,9 +63,8 @@ public:
<xsl:apply-templates select="trace/events/struct" mode="empty"/>
<xsl:apply-templates select="trace/events/event" mode="empty"/>
#endif
#endif
#endif // INCLUDE_TRACE
#endif // TRACEFILES_TRACEEVENTCLASSES_HPP
</xsl:template>
<xsl:template match="struct" mode="trace">

@ -29,13 +29,11 @@
<xsl:template match="/">
<xsl:call-template name="file-header"/>
#ifndef TRACEFILES_JFREVENTIDS_HPP
#define TRACEFILES_JFREVENTIDS_HPP
#ifndef TRACEFILES_TRACEEVENTIDS_HPP
#define TRACEFILES_TRACEEVENTIDS_HPP
#include "utilities/macros.hpp"
#if INCLUDE_TRACE
#include "trace/traceDataTypes.hpp"
/**
@ -67,8 +65,8 @@ enum TraceStructId {
typedef enum TraceEventId TraceEventId;
typedef enum TraceStructId TraceStructId;
#endif
#endif
#endif // INCLUDE_TRACE
#endif // TRACEFILES_TRACEEVENTIDS_HPP
</xsl:template>
</xsl:stylesheet>

@ -22,8 +22,8 @@
*
*/
#ifndef SHARE_VM_TRACE_TRACE_MACRO_HPP
#define SHARE_VM_TRACE_TRACE_MACRO_HPP
#ifndef SHARE_VM_TRACE_TRACEMACROS_HPP
#define SHARE_VM_TRACE_TRACEMACROS_HPP
#define EVENT_THREAD_EXIT(thread)
#define EVENT_THREAD_DESTRUCT(thread)
@ -41,4 +41,4 @@
#define TRACE_TEMPLATES(template)
#define TRACE_INTRINSICS(do_intrinsic, do_class, do_name, do_signature, do_alias)
#endif
#endif // SHARE_VM_TRACE_TRACEMACROS_HPP

@ -26,9 +26,7 @@
#define SHARE_VM_TRACE_TRACESTREAM_HPP
#include "utilities/macros.hpp"
#if INCLUDE_TRACE
#include "oops/klass.hpp"
#include "oops/method.hpp"
#include "oops/symbol.hpp"
@ -117,5 +115,5 @@ class TraceStream : public StackObj {
}
};
#endif /* INCLUDE_TRACE */
#endif /* SHARE_VM_TRACE_TRACESTREAM_HPP */
#endif // INCLUDE_TRACE
#endif // SHARE_VM_TRACE_TRACESTREAM_HPP

@ -29,15 +29,14 @@
<xsl:template match="/">
<xsl:call-template name="file-header"/>
#ifndef TRACEFILES_JFRTYPES_HPP
#define TRACEFILES_JFRTYPES_HPP
#ifndef TRACEFILES_TRACETYPES_HPP
#define TRACEFILES_TRACETYPES_HPP
#include "oops/symbol.hpp"
#include "trace/traceDataTypes.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ticks.hpp"
enum JVMContentType {
_not_a_content_type = (JVM_CONTENT_TYPES_START - 1),
@ -58,7 +57,7 @@ enum JVMEventRelations {
};
/**
* Create typedefs for the JRA types:
* Create typedefs for the TRACE types:
* typedef s8 TYPE_LONG;
* typedef s4 TYPE_INTEGER;
* typedef const char * TYPE_STRING;
@ -68,7 +67,7 @@ enum JVMEventRelations {
typedef <xsl:value-of select="@type"/> TYPE_<xsl:value-of select="@symbol"/>;
</xsl:for-each>
#endif // JFRFILES_JFRTYPES_HPP
#endif // TRACEFILES_TRACETYPES_HPP
</xsl:template>
</xsl:stylesheet>

@ -28,4 +28,4 @@
#include "tracefiles/traceEventClasses.hpp"
#include "tracefiles/traceEventIds.hpp"
#endif
#endif // SHARE_VM_TRACE_TRACING_HPP

@ -0,0 +1,174 @@
/*
* 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 8042235
* @summary redefining method used by multiple MethodHandles crashes VM
* @compile -XDignore.symbol.file RedefineMethodUsedByMultipleMethodHandles.java
* @run main RedefineMethodUsedByMultipleMethodHandles
*/
import java.io.*;
import java.lang.instrument.*;
import java.lang.invoke.*;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.management.*;
import java.lang.reflect.*;
import java.nio.file.*;
import java.security.*;
import java.util.jar.*;
import javax.tools.*;
import jdk.internal.org.objectweb.asm.*;
public class RedefineMethodUsedByMultipleMethodHandles {
static class Foo {
public static Object getName() {
return "foo";
}
}
public static void main(String[] args) throws Throwable {
Lookup lookup = MethodHandles.lookup();
Method fooMethod = Foo.class.getDeclaredMethod("getName");
// fooMH2 displaces fooMH1 from the MemberNamesTable
MethodHandle fooMH1 = lookup.unreflect(fooMethod);
MethodHandle fooMH2 = lookup.unreflect(fooMethod);
System.out.println("fooMH1.invoke = " + fooMH1.invokeExact());
System.out.println("fooMH2.invoke = " + fooMH2.invokeExact());
// Redefining Foo.getName() causes vmtarget to be updated
// in fooMH2 but not fooMH1
redefineFoo();
// Full GC causes fooMH1.vmtarget to be deallocated
System.gc();
// Calling fooMH1.vmtarget crashes the VM
System.out.println("fooMH1.invoke = " + fooMH1.invokeExact());
}
/**
* Adds the class file bytes for {@code c} to {@code jar}.
*/
static void add(JarOutputStream jar, Class<?> c) throws IOException {
String classAsPath = c.getName().replace('.', '/') + ".class";
jar.putNextEntry(new JarEntry(classAsPath));
InputStream stream = c.getClassLoader().getResourceAsStream(classAsPath);
int b;
while ((b = stream.read()) != -1) {
jar.write(b);
}
}
static void redefineFoo() throws Exception {
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
Attributes mainAttrs = manifest.getMainAttributes();
mainAttrs.putValue("Agent-Class", FooAgent.class.getName());
mainAttrs.putValue("Can-Redefine-Classes", "true");
mainAttrs.putValue("Can-Retransform-Classes", "true");
Path jar = Files.createTempFile("myagent", ".jar");
try {
JarOutputStream jarStream = new JarOutputStream(new FileOutputStream(jar.toFile()), manifest);
add(jarStream, FooAgent.class);
add(jarStream, FooTransformer.class);
jarStream.close();
runAgent(jar);
} finally {
Files.deleteIfExists(jar);
}
}
public static void runAgent(Path agent) throws Exception {
String vmName = ManagementFactory.getRuntimeMXBean().getName();
int p = vmName.indexOf('@');
assert p != -1 : "VM name not in <pid>@<host> format: " + vmName;
String pid = vmName.substring(0, p);
ClassLoader cl = ToolProvider.getSystemToolClassLoader();
Class<?> c = Class.forName("com.sun.tools.attach.VirtualMachine", true, cl);
Method attach = c.getDeclaredMethod("attach", String.class);
Method loadAgent = c.getDeclaredMethod("loadAgent", String.class);
Method detach = c.getDeclaredMethod("detach");
Object vm = attach.invoke(null, pid);
loadAgent.invoke(vm, agent.toString());
detach.invoke(vm);
}
public static class FooAgent {
public static void agentmain(@SuppressWarnings("unused") String args, Instrumentation inst) throws Exception {
assert inst.isRedefineClassesSupported();
assert inst.isRetransformClassesSupported();
inst.addTransformer(new FooTransformer(), true);
Class<?>[] classes = inst.getAllLoadedClasses();
for (int i = 0; i < classes.length; i++) {
Class<?> c = classes[i];
if (c == Foo.class) {
inst.retransformClasses(new Class[]{c});
}
}
}
}
static class FooTransformer implements ClassFileTransformer {
@Override
public byte[] transform(ClassLoader cl, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
if (Foo.class.equals(classBeingRedefined)) {
System.out.println("redefining " + classBeingRedefined);
ClassReader cr = new ClassReader(classfileBuffer);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES);
ClassVisitor adapter = new ClassVisitor(Opcodes.ASM5, cw) {
@Override
public MethodVisitor visitMethod(int access, String base, String desc, String signature, String[] exceptions) {
MethodVisitor mv = cv.visitMethod(access, base, desc, signature, exceptions);
if (mv != null) {
mv = new MethodVisitor(Opcodes.ASM5, mv) {
@Override
public void visitLdcInsn(Object cst) {
System.out.println("replacing \"" + cst + "\" with \"bar\"");
mv.visitLdcInsn("bar");
}
};
}
return mv;
}
};
cr.accept(adapter, ClassReader.SKIP_FRAMES);
cw.visitEnd();
return cw.toByteArray();
}
return classfileBuffer;
}
}
}

@ -0,0 +1,146 @@
/*
* 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 TestSoftReferencesBehaviorOnOOME
* @key gc
* @summary Tests that all SoftReferences has been cleared at time of OOM.
* @library /testlibrary
* @build TestSoftReference
* @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 512 2k
* @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 128k 256k
* @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 2k 32k 10
*/
import com.oracle.java.testlibrary.Utils;
import java.lang.ref.SoftReference;
import java.util.LinkedList;
import java.util.Random;
public class TestSoftReferencesBehaviorOnOOME {
private static final Random rndGenerator = Utils.getRandomInstance();
public static void main(String[] args) {
int semiRefAllocFrequency = DEFAULT_FREQUENCY;
long minSize = DEFAULT_MIN_SIZE,
maxSize = DEFAULT_MAX_SIZE;
if ( args.length >= 3 ) {
semiRefAllocFrequency = Integer.parseInt(args[2]);
}
if ( args.length >= 2) {
maxSize = getBytesCount(args[1]);
}
if ( args.length >= 1) {
minSize = getBytesCount(args[0]);
}
new TestSoftReferencesBehaviorOnOOME().softReferencesOom(minSize, maxSize, semiRefAllocFrequency);
}
/**
* Test that all SoftReferences has been cleared at time of OOM.
*/
void softReferencesOom(long minSize, long maxSize, int semiRefAllocFrequency) {
System.out.format( "minSize = %d, maxSize = %d, freq = %d%n", minSize, maxSize, semiRefAllocFrequency );
long counter = 0;
long multiplier = maxSize - minSize;
LinkedList<SoftReference> arrSoftRefs = new LinkedList();
LinkedList arrObjects = new LinkedList();
long numberOfNotNulledObjects = 0;
long oomSoftArraySize = 0;
try {
while (true) {
// Keep every Xth object to make sure we hit OOM pretty fast
if (counter % semiRefAllocFrequency != 0) {
long allocationSize = ((int) (rndGenerator.nextDouble() * multiplier))
+ minSize;
arrObjects.add(new byte[(int)allocationSize]);
} else {
arrSoftRefs.add(new SoftReference(new Object()));
}
counter++;
if (counter == Long.MAX_VALUE) {
counter = 0;
}
}
} catch (OutOfMemoryError oome) {
// Clear allocated ballast, so we don't get another OOM.
arrObjects = null;
// Get the number of soft refs first, so we don't trigger
// another OOM.
oomSoftArraySize = arrSoftRefs.size();
for (SoftReference sr : arrSoftRefs) {
Object o = sr.get();
if (o != null) {
numberOfNotNulledObjects++;
}
}
// Make sure we clear all refs before we return failure
arrSoftRefs = null;
if (numberOfNotNulledObjects > 0) {
throw new RuntimeException(numberOfNotNulledObjects + " out of "
+ oomSoftArraySize + " SoftReferences was not "
+ "null at time of OutOfMemoryError");
}
} finally {
arrSoftRefs = null;
arrObjects = null;
}
}
private static final long getBytesCount(String arg) {
String postfixes = "kMGT";
long mod = 1;
if (arg.trim().length() >= 2) {
mod = postfixes.indexOf(
arg.trim().charAt(arg.length() - 1)
);
if (mod != -1) {
mod = (long) Math.pow(1024, mod+1);
arg = arg.substring(0, arg.length() - 1);
} else {
mod = 1; // 10^0
}
}
return Long.parseLong(arg) * mod;
}
private static final long DEFAULT_MIN_SIZE = 512;
private static final long DEFAULT_MAX_SIZE = 1024;
private static final int DEFAULT_FREQUENCY = 4;
}

@ -25,9 +25,12 @@
* @test TestHumongousShrinkHeap
* @bug 8036025 8056043
* @requires vm.gc=="G1" | vm.gc=="null"
* @summary Verify that heap shrinks after GC in the presence of fragmentation due to humongous objects
* @summary Verify that heap shrinks after GC in the presence of fragmentation
* due to humongous objects
* @library /testlibrary
* @run main/othervm -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=12 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc TestHumongousShrinkHeap
* @run main/othervm -XX:-ExplicitGCInvokesConcurrent -XX:MinHeapFreeRatio=10
* -XX:MaxHeapFreeRatio=12 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc
* TestHumongousShrinkHeap
*/
import java.lang.management.ManagementFactory;

@ -45,6 +45,7 @@ public class TestShrinkAuxiliaryData {
"-XX:MaxHeapFreeRatio=11",
"-XX:+UseG1GC",
"-XX:G1HeapRegionSize=1m",
"-XX:-ExplicitGCInvokesConcurrent",
"-XX:+PrintGCDetails"
};

@ -59,6 +59,7 @@ public class TestShrinkDefragmentedHeap {
"-XX:MaxHeapFreeRatio=11",
"-XX:+UseG1GC",
"-XX:G1HeapRegionSize=" + REGION_SIZE,
"-XX:-ExplicitGCInvokesConcurrent",
"-verbose:gc",
GCTest.class.getName()
);

@ -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 8060449
* @summary Newly obsolete command line options should still give useful error messages when used improperly.
* @library /testlibrary
*/
import com.oracle.java.testlibrary.*;
public class ObsoleteFlagErrorMessage {
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:UseBoundThreadsPlusJunk", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Unrecognized VM option 'UseBoundThreadsPlusJunk'"); // Must identify bad option.
output.shouldContain("UseBoundThreads"); // Should apply fuzzy matching to find correct option.
output.shouldContain("support").shouldContain("removed"); // Should warn user that the option they are trying to use is no longer supported.
output.shouldHaveExitValue(1);
}
}

@ -84,6 +84,10 @@ public class WhiteBox {
}
private native boolean isClassAlive0(String name);
// JVMTI
public native void addToBootstrapClassLoaderSearch(String segment);
public native void addToSystemClassLoaderSearch(String segment);
// G1
public native boolean g1InConcurrentMark();
public native boolean g1IsHumongous(Object o);