This is a diff between the BSDPort and Mac OS X port HotSpot repositories taken 2 aug 2011:
diff -ru bsd-port/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java macosx-port/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java --- bsd-port/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java 2011-06-03 14:31:00.000000000 -0600 @@ -43,7 +43,7 @@ return "bsd"; } else if (os.equals("OpenBSD")) { return "bsd"; - } else if (os.equals("Darwin")) { + } else if (os.equals("Darwin") || os.startsWith("Mac OS X")) { return "bsd"; } else if (os.startsWith("Windows")) { return "win32"; diff -ru bsd-port/hotspot/make/Makefile macosx-port/hotspot/make/Makefile --- bsd-port/hotspot/make/Makefile 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/Makefile 2011-06-28 14:20:24.000000000 -0600 @@ -457,6 +457,36 @@ ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \ fi +# macosx universal builds + +ifeq ($(MACOSX_UNIVERSAL), true) +$(UNIVERSAL_LIPO_LIST): + lipo -create -output $@ $(EXPORT_JRE_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) + +$(UNIVERSAL_COPY_LIST): + $(CP) $(EXPORT_JRE_LIB_DIR)/i386/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) $@ + +universalize: $(UNIVERSAL_LIPO_LIST) $(UNIVERSAL_COPY_LIST) +endif + +universal_product: + $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 MACOSX_UNIVERSAL=true all_product + $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 MACOSX_UNIVERSAL=true all_product + $(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server} + $(QUIETLY) $(MAKE) MACOSX_UNIVERSAL=true universalize + +universal_fastdebug: + $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 MACOSX_UNIVERSAL=true all_fastdebug + $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 MACOSX_UNIVERSAL=true all_fastdebug + $(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server} + $(QUIETLY) $(MAKE) MACOSX_UNIVERSAL=true universalize + +universal_debug: + $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 MACOSX_UNIVERSAL=true all_debug + $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 MACOSX_UNIVERSAL=true all_debug + $(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server} + $(QUIETLY) $(MAKE) MACOSX_UNIVERSAL=true universalize + # # Check target # @@ -585,5 +615,6 @@ export_product export_fastdebug export_debug export_optimized \ export_jdk_product export_jdk_fastdebug export_jdk_debug \ create_jdk copy_jdk update_jdk test_jdk \ - copy_product_jdk copy_fastdebug_jdk copy_debug_jdk + copy_product_jdk copy_fastdebug_jdk copy_debug_jdk universalize \ + universal_product diff -ru bsd-port/hotspot/make/bsd/makefiles/adlc.make macosx-port/hotspot/make/bsd/makefiles/adlc.make --- bsd-port/hotspot/make/bsd/makefiles/adlc.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/bsd/makefiles/adlc.make 2011-04-14 07:18:10.000000000 -0600 @@ -61,7 +61,9 @@ # CFLAGS_WARN holds compiler options to suppress/enable warnings. # Compiler warnings are treated as errors -CFLAGS_WARN = -Werror +ifneq ($(COMPILER_WARNINGS_FATAL),false) + CFLAGS_WARN = -Werror +endif CFLAGS += $(CFLAGS_WARN) OBJECTNAMES = \ diff -ru bsd-port/hotspot/make/bsd/makefiles/buildtree.make macosx-port/hotspot/make/bsd/makefiles/buildtree.make --- bsd-port/hotspot/make/bsd/makefiles/buildtree.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/bsd/makefiles/buildtree.make 2011-07-14 18:50:44.000000000 -0600 @@ -117,7 +117,8 @@ SIMPLE_DIRS = \ $(PLATFORM_DIR)/generated/dependencies \ $(PLATFORM_DIR)/generated/adfiles \ - $(PLATFORM_DIR)/generated/jvmtifiles + $(PLATFORM_DIR)/generated/jvmtifiles \ + $(PLATFORM_DIR)/generated/dtracefiles TARGETS = debug fastdebug jvmg optimized product profiled SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS)) @@ -125,7 +126,7 @@ # 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 sa.make \ +BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make dtrace.make \ env.sh env.csh jdkpath.sh .dbxrc test_gamma BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \ @@ -155,6 +156,13 @@ endif endif +# MACOSX FIXME: we should be able to run test_gamma (see <radr://8187092>) +ifdef ALWAYS_PASS_TEST_GAMMA +TEST_GAMMA_STATUS= echo 'exit 0'; +else +TEST_GAMMA_STATUS= +endif + BUILDTREE_VARS += HOTSPOT_RELEASE_VERSION=$(HS_BUILD_VER) HOTSPOT_BUILD_VERSION= JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION) BUILDTREE = \ @@ -314,6 +322,16 @@ 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)"; \ + ) > $@ + env.sh: $(BUILDTREE_MAKE) @echo Creating $@ ... $(QUIETLY) ( \ @@ -390,7 +408,6 @@ echo '#!/bin/sh'; \ $(BUILDTREE_COMMENT); \ echo '. ./env.sh'; \ - echo "exit 0;"; \ echo "if [ \"$(CROSS_COMPILE_ARCH)\" != \"\" ]; then { $(CROSS_COMPILING_MSG); exit 0; }; fi"; \ echo "if [ -z \$$JAVA_HOME ]; then { $(NO_JAVA_HOME_MSG); exit 0; }; fi"; \ echo "if ! \$${JAVA_HOME}/bin/java $(JAVA_FLAG) -fullversion 2>&1 > /dev/null"; \ @@ -401,6 +418,7 @@ echo "\$${JAVA_HOME}/bin/javac -d . $(GAMMADIR)/make/test/Queens.java"; \ echo '[ -f gamma_g ] && { gamma=gamma_g; }'; \ echo './$${gamma:-gamma} $(TESTFLAGS) Queens < /dev/null'; \ + $(TEST_GAMMA_STATUS) \ ) > $@ $(QUIETLY) chmod +x $@ diff -ru bsd-port/hotspot/make/bsd/makefiles/defs.make macosx-port/hotspot/make/bsd/makefiles/defs.make --- bsd-port/hotspot/make/bsd/makefiles/defs.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/bsd/makefiles/defs.make 2011-01-27 17:00:04.000000000 -0700 @@ -73,7 +73,7 @@ endif # amd64 -ifeq ($(ARCH), amd64) +ifneq (,$(findstring $(ARCH), amd64 x86_64)) ifeq ($(ARCH_DATA_MODEL), 64) ARCH_DATA_MODEL = 64 MAKE_ARGS += LP64=1 @@ -162,9 +162,19 @@ $(EXPORT_LIB_DIR)/sa-jdi.jar ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \ $(EXPORT_LIB_DIR)/sa-jdi.jar +ADD_SA_BINARIES/universal = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \ + $(EXPORT_LIB_DIR)/sa-jdi.jar ADD_SA_BINARIES/ppc = ADD_SA_BINARIES/ia64 = ADD_SA_BINARIES/arm = ADD_SA_BINARIES/zero = EXPORT_LIST += $(ADD_SA_BINARIES/$(HS_ARCH)) + +UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX) +UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/libsaproc.$(LIBRARY_SUFFIX) +UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX) + +UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/server/Xusage.txt +UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/client/Xusage.txt +UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX) \ No newline at end of file diff -ru bsd-port/hotspot/make/bsd/makefiles/dtrace.make macosx-port/hotspot/make/bsd/makefiles/dtrace.make --- bsd-port/hotspot/make/bsd/makefiles/dtrace.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/bsd/makefiles/dtrace.make 2011-07-22 12:21:59.000000000 -0600 @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,282 @@ # # -# Bsd does not build jvm_db -LIBJVM_DB = +# Rules to build jvm_db/dtrace, used by vm.make +# We build libjvm_dtrace/libjvm_db/dtrace for COMPILER1 and COMPILER2 +# but not for CORE or KERNEL configurations. + +ifneq ("${TYPE}", "CORE") +ifneq ("${TYPE}", "KERNEL") + +ifeq ($(OS_VENDOR), Darwin) +# we build dtrace for macosx using USDT2 probes + +DtraceOutDir = $(GENERATED)/dtracefiles + +# Bsd does not build libjvm_db, does not compile on macosx +# disabled in build: rule in vm.make +JVM_DB = libjvm_db +#LIBJVM_DB = libjvm_db.dylib +LIBJVM_DB = libjvm$(G_SUFFIX)_db.dylib + +JVM_DTRACE = jvm_dtrace +#LIBJVM_DTRACE = libjvm_dtrace.dylib +LIBJVM_DTRACE = libjvm$(G_SUFFIX)_dtrace.dylib + +JVMOFFS = JvmOffsets +JVMOFFS.o = $(JVMOFFS).o +GENOFFS = generate$(JVMOFFS) + +DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace +DTRACE = dtrace +DTRACE.o = $(DTRACE).o + +# to remove '-g' option which causes link problems +# also '-z nodefs' is used as workaround +GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';) + +ifdef LP64 +DTRACE_OPTS = -D_LP64 +endif + +# making libjvm_db + +# 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 + +ISA = $(subst i386,i486,$(BUILDARCH)) + +# Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so +ifneq ("${ISA}","${BUILDARCH}") + +XLIBJVM_DB = 64/$(LIBJVM_DB) +XLIBJVM_DB_G = 64/$(LIBJVM_DB_G) +XLIBJVM_DTRACE = 64/$(LIBJVM_DTRACE) +XLIBJVM_DTRACE_G = 64/$(LIBJVM_DTRACE_G) +XARCH = $(subst sparcv9,v9,$(shell echo $(ISA))) + +$(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE) + @echo Making $@ + $(QUIETLY) mkdir -p 64/ ; \ + $(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. -I$(GENERATED) \ + $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c #-lc +# [ -f $(XLIBJVM_DB_G) ] || { ln -s $(LIBJVM_DB) $(XLIBJVM_DB_G); } + +$(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE) + @echo Making $@ + $(QUIETLY) mkdir -p 64/ ; \ + $(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. \ + $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor +# [ -f $(XLIBJVM_DTRACE_G) ] || { ln -s $(LIBJVM_DTRACE) $(XLIBJVM_DTRACE_G); } + +endif # ifneq ("${ISA}","${BUILDARCH}") + +LFLAGS_GENOFFS += -L. + +lib$(GENOFFS).dylib: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \ + $(LIBJVM.o) + $(QUIETLY) $(CCC) $(CPPFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \ + $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -ljvm + +$(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).dylib + $(QUIETLY) $(LINK.CC) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \ + ./lib$(GENOFFS).dylib + +# $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs. +$(JVMOFFS).h: $(GENOFFS) + $(QUIETLY) DYLD_LIBRARY_PATH=. ./$(GENOFFS) -header > $@.tmp; touch $@; \ + if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \ + then rm -f $@; mv $@.tmp $@; \ + else rm -f $@.tmp; \ + fi + +$(JVMOFFS)Index.h: $(GENOFFS) + $(QUIETLY) DYLD_LIBRARY_PATH=. ./$(GENOFFS) -index > $@.tmp; touch $@; \ + if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \ + then rm -f $@; mv $@.tmp $@; \ + else rm -f $@.tmp; \ + fi + +$(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h + $(QUIETLY) DYLD_LIBRARY_PATH=. ./$(GENOFFS) -table > $@.tmp; touch $@; \ + if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \ + then rm -f $@; mv $@.tmp $@; \ + else rm -f $@.tmp; \ + fi + +$(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp + $(QUIETLY) $(CCC) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp + +$(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE) + @echo Making $@ + $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \ + $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -Wall # -lc +# [ -f $(LIBJVM_DB_G) ] || { ln -s $@ $(LIBJVM_DB_G); } + +$(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE) + @echo Making $@ + $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. \ + $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor +# [ -f $(LIBJVM_DTRACE_G) ] || { ln -s $@ $(LIBJVM_DTRACE_G); } + +#$(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) + +$(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 + +$(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)", "") + +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: + +dtrace_stuff: dtrace_gen_headers + $(QUIETLY) echo "dtrace headers generated" + + +else # manually disabled + +dtraceCheck: + $(QUIETLY) echo "**NOTICE** Dtrace support disabled via environment variable" + +dtrace_stuff: + +endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "") + +else # No dtrace program found + +dtraceCheck: + $(QUIETLY) echo "**NOTICE** Dtrace support disabled: not supported by system" + +dtrace_stuff: + +endif # ifneq ("${dtraceFound}", "") + +endif # ifeq ($(OS_VENDOR), Darwin) + + +else # KERNEL build + +dtraceCheck: + $(QUIETLY) echo "**NOTICE** Dtrace support disabled for KERNEL builds" + +endif # ifneq ("${TYPE}", "KERNEL") + +else # CORE build + +dtraceCheck: + $(QUIETLY) echo "**NOTICE** Dtrace support disabled for CORE builds" + +endif # ifneq ("${TYPE}", "CORE") diff -ru bsd-port/hotspot/make/bsd/makefiles/gcc.make macosx-port/hotspot/make/bsd/makefiles/gcc.make --- bsd-port/hotspot/make/bsd/makefiles/gcc.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/bsd/makefiles/gcc.make 2011-05-20 12:15:39.000000000 -0600 @@ -30,17 +30,49 @@ # When cross-compiling the ALT_COMPILER_PATH points # to the cross-compilation toolset ifdef CROSS_COMPILE_ARCH -CXX = $(ALT_COMPILER_PATH)/g++ -CPP = $(ALT_COMPILER_PATH)/g++ -CC = $(ALT_COMPILER_PATH)/gcc -HOSTCPP = g++ -HOSTCC = gcc -else -CXX ?= g++ -CPP = $(CXX) -CC ?= gcc -HOSTCPP = $(CPP) -HOSTCC = $(CPP) + CPP = $(ALT_COMPILER_PATH)/g++ + CC = $(ALT_COMPILER_PATH)/gcc + HOSTCPP = g++ + HOSTCC = gcc +else ifneq ($(OS_VENDOR), Darwin) + CXX = g++ + CPP = $(CXX) + CC = gcc + HOSTCPP = $(CPP) + HOSTCC = $(CC) +endif + +# i486 hotspot requires -mstackrealign on Darwin. +# llvm-gcc supports this in Xcode 3.2.6 and 4.0. +# gcc-4.0 supports this on earlier versions. +# Prefer llvm-gcc where available. +ifeq ($(OS_VENDOR), Darwin) + ifeq ($(origin CXX), default) + CXX = llvm-g++ + endif + ifeq ($(origin CC), default) + CC = llvm-gcc + endif + CPP = $(CXX) + + ifeq ($(ARCH), i486) + LLVM_SUPPORTS_STACKREALIGN := $(shell \ + [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \ + && echo true || echo false) + + ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true) + CXX32 ?= llvm-g++ + CC32 ?= llvm-gcc + else + CXX32 ?= g++-4.0 + CC32 ?= gcc-4.0 + endif + CPP = $(CXX32) + CC = $(CC32) + endif + + HOSTCPP = $(CPP) + HOSTCC = $(CC) endif AS = $(CC) -c -x assembler-with-cpp @@ -130,7 +162,9 @@ endif # Compiler warnings are treated as errors -WARNINGS_ARE_ERRORS = -Werror +ifneq ($(COMPILER_WARNINGS_FATAL),false) + WARNINGS_ARE_ERRORS = -Werror +endif # Except for a few acceptable ones # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit @@ -152,7 +186,13 @@ # The flags to use for an Optimized g++ build -OPT_CFLAGS += -O3 +ifeq ($(OS_VENDOR), Darwin) + # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy + # <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers> + OPT_CFLAGS += -Os +else + OPT_CFLAGS += -O3 +endif # Hotspot uses very unstrict aliasing turn this optimization off OPT_CFLAGS += -fno-strict-aliasing @@ -212,7 +252,7 @@ SONAMEFLAG = # Build shared library - SHARED_FLAG = -dynamiclib $(VM_PICFLAG) + SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG) # Keep symbols even they are not used #AOUT_FLAGS += -Xlinker -export-dynamic diff -ru bsd-port/hotspot/make/bsd/makefiles/sa.make macosx-port/hotspot/make/bsd/makefiles/sa.make --- bsd-port/hotspot/make/bsd/makefiles/sa.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/bsd/makefiles/sa.make 2011-05-20 12:15:39.000000000 -0600 @@ -38,7 +38,11 @@ GENERATED = $(TOPDIR)/../generated # tools.jar is needed by the JDI - SA binding -SA_CLASSPATH = $(BOOT_JAVA_HOME)/lib/tools.jar +ifeq ($(SA_APPLE_BOOT_JAVA),true) + SA_CLASSPATH = $(BOOT_JAVA_HOME)/bundle/Classes/classes.jar +else + SA_CLASSPATH = $(BOOT_JAVA_HOME)/lib/tools.jar +endif # TODO: if it's a modules image, check if SA module is installed. MODULELIB_PATH= $(BOOT_JAVA_HOME)/lib/modules diff -ru bsd-port/hotspot/make/bsd/makefiles/saproc.make macosx-port/hotspot/make/bsd/makefiles/saproc.make --- bsd-port/hotspot/make/bsd/makefiles/saproc.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/bsd/makefiles/saproc.make 2011-01-27 17:00:04.000000000 -0700 @@ -78,6 +78,15 @@ endif SA_LFLAGS += $(LDFLAGS_HASH_STYLE) +ifeq ($(OS_VENDOR), Darwin) + BOOT_JAVA_INCLUDES = -I$(BOOT_JAVA_HOME)/include \ + -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") \ + -I/System/Library/Frameworks/JavaVM.framework/Headers +else + BOOT_JAVA_INCLUDES = -I$(BOOT_JAVA_HOME)/include \ + -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") +endif + $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE) $(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \ echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \ @@ -88,8 +97,7 @@ $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ -I$(SASRCDIR) \ -I$(GENERATED) \ - -I$(BOOT_JAVA_HOME)/include \ - -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") \ + $(BOOT_JAVA_INCLUDES) \ $(SASRCFILES) \ $(SA_LFLAGS) \ $(SA_DEBUG_CFLAGS) \ diff -ru bsd-port/hotspot/make/bsd/makefiles/top.make macosx-port/hotspot/make/bsd/makefiles/top.make --- bsd-port/hotspot/make/bsd/makefiles/top.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/bsd/makefiles/top.make 2011-07-21 11:51:06.000000000 -0600 @@ -82,7 +82,7 @@ @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 sa_stuff +vm_build_preliminaries: checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stuff sa_stuff dtrace_stuff @# We need a null action here, so implicit rules don't get consulted. $(Cached_plat): $(Plat_File) @@ -96,6 +96,10 @@ jvmti_stuff: $(Cached_plat) $(adjust-mflags) @$(MAKE) -f jvmti.make $(MFLAGS-adjusted) +# generate dtrace header files +dtrace_stuff: $(Cached_plat) $(adjust-mflags) + @$(MAKE) -f dtrace.make dtrace_stuff $(MFLAGS-adjusted) GENERATED=$(GENERATED) + # generate SA jar files and native header sa_stuff: @$(MAKE) -f sa.make $(MFLAGS-adjusted) diff -ru bsd-port/hotspot/make/bsd/makefiles/vm.make macosx-port/hotspot/make/bsd/makefiles/vm.make --- bsd-port/hotspot/make/bsd/makefiles/vm.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/bsd/makefiles/vm.make 2011-07-21 13:11:22.000000000 -0600 @@ -108,6 +108,7 @@ # Don't set excutable bit on stack segment # the same could be done by separate execstack command +# Darwin is non-executable-stack by default ifneq ($(OS_VENDOR), Darwin) LFLAGS += -Xlinker -z -Xlinker noexecstack endif @@ -322,7 +323,13 @@ #---------------------------------------------------------------------- -build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(BUILDLIBSAPROC) +generateDSYM: $(LIBJVM) + dsymutil $(LIBJVM) + +#build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(BUILDLIBSAPROC) +# no launcher or libjvm_db for macosx +build: $(LIBJVM) $(LIBJSIG) $(BUILDLIBSAPROC) dtraceCheck generateDSYM + echo "Doing vm.make build:" install: install_jvm install_jsig install_saproc diff -ru bsd-port/hotspot/make/defs.make macosx-port/hotspot/make/defs.make --- bsd-port/hotspot/make/defs.make 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/make/defs.make 2011-06-28 14:20:24.000000000 -0600 @@ -281,6 +281,13 @@ EXPORT_JRE_LIB_DIR = $(EXPORT_JRE_DIR)/lib EXPORT_JRE_LIB_ARCH_DIR = $(EXPORT_JRE_LIB_DIR)/$(LIBARCH) +# non-universal macosx builds need to appear universal +ifeq ($(OS_VENDOR), Darwin) +ifneq ($(MACOSX_UNIVERSAL), true) +EXPORT_JRE_LIB_ARCH_DIR = $(EXPORT_JRE_LIB_DIR) +endif +endif + # Common export list of files EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmti.h EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmticmlr.h diff -ru bsd-port/hotspot/src/cpu/x86/vm/jni_x86.h macosx-port/hotspot/src/cpu/x86/vm/jni_x86.h --- bsd-port/hotspot/src/cpu/x86/vm/jni_x86.h 2011-07-26 20:21:20.000000000 -0600 +++ macosx-port/hotspot/src/cpu/x86/vm/jni_x86.h 2011-05-20 12:15:39.000000000 -0600 @@ -38,8 +38,7 @@ #define JNICALL typedef int jint; - -#ifdef _LP64 +#if defined(_LP64) && !defined(__APPLE__) typedef long jlong; #else typedef long long jlong; Only in macosx-port/hotspot/src/os/bsd: dtrace diff -ru bsd-port/hotspot/src/os/bsd/vm/dtraceJSDT_bsd.cpp macosx-port/hotspot/src/os/bsd/vm/dtraceJSDT_bsd.cpp --- bsd-port/hotspot/src/os/bsd/vm/dtraceJSDT_bsd.cpp 2011-07-26 20:21:21.000000000 -0600 +++ macosx-port/hotspot/src/os/bsd/vm/dtraceJSDT_bsd.cpp 2011-07-26 12:04:53.000000000 -0600 @@ -33,6 +33,13 @@ #include "runtime/signature.hpp" #include "utilities/globalDefinitions.hpp" +/* + * JSDT java dtrace probes have never been implemented in macosx. It is unknown if the solaris implementation + * is close or if significant implementation work is necessary. The future of the solaris implementation also + * appears to be unclear since compiling code with JSDT probes produces the following warning: + * "warning: ProviderFactory is internal proprietary API and may be removed in a future release" + */ + int DTraceJSDT::pd_activate( void* baseAddress, jstring module, jint providers_count, JVM_DTraceProvider* providers) { diff -ru bsd-port/hotspot/src/os/bsd/vm/os_bsd.cpp macosx-port/hotspot/src/os/bsd/vm/os_bsd.cpp --- bsd-port/hotspot/src/os/bsd/vm/os_bsd.cpp 2011-07-26 20:21:21.000000000 -0600 +++ macosx-port/hotspot/src/os/bsd/vm/os_bsd.cpp 2011-06-03 14:31:01.000000000 -0600 @@ -136,8 +136,9 @@ #endif #ifdef __APPLE__ -#include <mach/mach.h> // semaphore_* API -#include <mach-o/dyld.h> +# include <mach/mach.h> // semaphore_* API +# include <mach-o/dyld.h> +# include <sys/proc_info.h> #endif #ifndef MAP_ANONYMOUS @@ -388,6 +389,20 @@ } #endif +#ifdef __APPLE__ +static const char *get_home() { + const char *home_dir = ::getenv("HOME"); + if ((home_dir == NULL) || (*home_dir == '\0')) { + struct passwd *passwd_info = getpwuid(geteuid()); + if (passwd_info != NULL) { + home_dir = passwd_info->pw_dir; + } + } + + return home_dir; +} +#endif + void os::init_system_properties_values() { // char arch[12]; // sysinfo(SI_ARCHITECTURE, arch, sizeof(arch)); @@ -438,6 +453,16 @@ #define ENDORSED_DIR "/lib/endorsed" #define REG_DIR "/usr/java/packages" +#ifdef __APPLE__ +#define SYS_EXTENSIONS_DIR "/Library/Java/Extensions" +#define SYS_EXTENSIONS_DIRS SYS_EXTENSIONS_DIR ":/Network" SYS_EXTENSIONS_DIR ":/System" SYS_EXTENSIONS_DIR ":/usr/lib/java" + const char *user_home_dir = get_home(); + // the null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir + int system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) + + sizeof(SYS_EXTENSIONS_DIRS); +#else +#endif + { /* sysclasspath, java_home, dll_dir */ { @@ -462,10 +487,12 @@ if (pslash != NULL) { pslash = strrchr(buf, '/'); if (pslash != NULL) { - *pslash = '\0'; /* get rid of /<arch> */ + *pslash = '\0'; /* get rid of /<arch> (/lib on macosx) */ +#ifndef __APPLE__ pslash = strrchr(buf, '/'); if (pslash != NULL) *pslash = '\0'; /* get rid of /lib */ +#endif } } @@ -500,9 +527,14 @@ * nulls included by the sizeof operator (so actually we allocate * a byte more than necessary). */ +#ifdef __APPLE__ + ld_library_path = (char *) malloc(system_ext_size); + sprintf(ld_library_path, "%s" SYS_EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS, user_home_dir); +#else ld_library_path = (char *) malloc(sizeof(REG_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH)); sprintf(ld_library_path, REG_DIR "/lib/%s:" DEFAULT_LIBPATH, cpu_arch); +#endif /* * Get the user setting of LD_LIBRARY_PATH, and prepended it. It @@ -531,10 +563,18 @@ * than necessary is allocated). */ { +#ifdef __APPLE__ + char *buf = malloc(strlen(Arguments::get_java_home()) + + sizeof(EXTENSIONS_DIR) + system_ext_size); + sprintf(buf, "%s" SYS_EXTENSIONS_DIR ":%s" EXTENSIONS_DIR ":" + SYS_EXTENSIONS_DIRS, user_home_dir, Arguments::get_java_home()); +#else char *buf = malloc(strlen(Arguments::get_java_home()) + sizeof(EXTENSIONS_DIR) + sizeof(REG_DIR) + sizeof(EXTENSIONS_DIR)); sprintf(buf, "%s" EXTENSIONS_DIR ":" REG_DIR EXTENSIONS_DIR, Arguments::get_java_home()); +#endif + Arguments::set_ext_dirs(buf); } @@ -547,6 +587,9 @@ } } +#ifdef __APPLE__ +#undef SYS_EXTENSIONS_DIR +#endif #undef malloc #undef getenv #undef EXTENSIONS_DIR @@ -4558,6 +4601,18 @@ #endif } +void os::set_native_thread_name(const char *name) { +#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5 + // This is only supported in Snow Leopard and beyond + if (name != NULL) { + // Add a "Java: " prefix to the name + char buf[MAXTHREADNAMESIZE]; + snprintf(buf, sizeof(buf), "Java: %s", name); + pthread_setname_np(buf); + } +#endif +} + bool os::distribute_processes(uint length, uint* distribution) { // Not yet implemented. return false; @@ -5674,8 +5729,8 @@ struct stat statbuf; char buf[MAXPATHLEN]; char libmawtpath[MAXPATHLEN]; - const char *xawtstr = "/xawt/libmawt.so"; - const char *motifstr = "/motif21/libmawt.so"; + const char *xawtstr = "/xawt/libmawt" JNI_LIB_SUFFIX; + const char *motifstr = "/motif21/libmawt" JNI_LIB_SUFFIX; char *p; // Get path to libjvm.so diff -ru bsd-port/hotspot/src/os/linux/vm/os_linux.cpp macosx-port/hotspot/src/os/linux/vm/os_linux.cpp --- bsd-port/hotspot/src/os/linux/vm/os_linux.cpp 2011-07-26 20:21:21.000000000 -0600 +++ macosx-port/hotspot/src/os/linux/vm/os_linux.cpp 2011-06-03 14:31:01.000000000 -0600 @@ -4258,6 +4258,11 @@ return online_cpus; } +void os::set_native_thread_name(const char *name) { + // Not yet implemented. + return; +} + bool os::distribute_processes(uint length, uint* distribution) { // Not yet implemented. return false; diff -ru bsd-port/hotspot/src/os/solaris/vm/os_solaris.cpp macosx-port/hotspot/src/os/solaris/vm/os_solaris.cpp --- bsd-port/hotspot/src/os/solaris/vm/os_solaris.cpp 2011-07-26 20:21:21.000000000 -0600 +++ macosx-port/hotspot/src/os/solaris/vm/os_solaris.cpp 2011-05-20 12:15:39.000000000 -0600 @@ -669,6 +669,11 @@ return true; } +void os::set_native_thread_name(const char *name) { + // Not yet implemented. + return; +} + bool os::distribute_processes(uint length, uint* distribution) { bool result = false; // Find the processor id's of all the available CPUs. diff -ru bsd-port/hotspot/src/os/windows/vm/os_windows.cpp macosx-port/hotspot/src/os/windows/vm/os_windows.cpp --- bsd-port/hotspot/src/os/windows/vm/os_windows.cpp 2011-07-26 20:21:21.000000000 -0600 +++ macosx-port/hotspot/src/os/windows/vm/os_windows.cpp 2011-06-28 14:20:24.000000000 -0600 @@ -710,6 +710,11 @@ } } +void os::set_native_thread_name(const char *name) { + // Not yet implemented. + return; +} + bool os::distribute_processes(uint length, uint* distribution) { // Not yet implemented. return false; diff -ru bsd-port/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s macosx-port/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s --- bsd-port/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s 2011-07-26 20:21:21.000000000 -0600 +++ macosx-port/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s 2011-03-17 19:04:43.000000000 -0600 @@ -272,7 +272,7 @@ jbe 2f # <= 32 dwords rep; smovl jmp 4f - .=.+8 + .space 8 2: subl %esi,%edi .p2align 4,,15 3: movl (%esi),%edx @@ -409,7 +409,7 @@ rep; smovl jmp 4f # copy aligned dwords - .=.+5 + .space 5 2: subl %esi,%edi .p2align 4,,15 3: movl (%esi),%edx @@ -485,7 +485,7 @@ popl %edi popl %esi ret - .=.+10 + .space 10 2: subl %esi,%edi jmp 4f .p2align 4,,15 @@ -689,8 +689,8 @@ # Support for jlong Atomic::load and Atomic::store. # void _Atomic_move_long(volatile jlong* src, volatile jlong* dst) .p2align 4,,15 - .type _Atomic_move_long,@function -_Atomic_move_long: + ELF_TYPE(_Atomic_move_long,@function) +SYMBOL(_Atomic_move_long): movl 4(%esp), %eax # src fildll (%eax) movl 8(%esp), %eax # dest diff -ru bsd-port/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp macosx-port/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp --- bsd-port/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp 2011-07-26 20:21:21.000000000 -0600 +++ macosx-port/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp 2011-06-28 14:20:24.000000000 -0600 @@ -275,7 +275,11 @@ #endif address os::current_stack_pointer() { -#ifdef SPARC_WORKS +#if defined(__clang__) || defined(__llvm__) + register void *esp; + __asm__("mov %%"SPELL_REG_SP", %0":"=r"(esp)); + return (address) esp; +#elif defined(SPARC_WORKS) register void *esp; __asm__("mov %%"SPELL_REG_SP", %0":"=r"(esp)); return (address) ((char*)esp + sizeof(long)*2); @@ -358,7 +362,7 @@ } intptr_t* _get_previous_fp() { -#ifdef SPARC_WORKS +#if defined(SPARC_WORKS) || defined(__clang__) register intptr_t **ebp; __asm__("mov %%"SPELL_REG_FP", %0":"=r"(ebp)); #else diff -ru bsd-port/hotspot/src/share/vm/code/nmethod.cpp macosx-port/hotspot/src/share/vm/code/nmethod.cpp --- bsd-port/hotspot/src/share/vm/code/nmethod.cpp 2011-07-26 20:21:22.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/code/nmethod.cpp 2011-07-19 11:08:35.000000000 -0600 @@ -49,12 +49,16 @@ // Only bother with this argument setup if dtrace is available +#ifdef USDT1 HS_DTRACE_PROBE_DECL8(hotspot, compiled__method__load, const char*, int, const char*, int, const char*, int, void*, size_t); HS_DTRACE_PROBE_DECL6(hotspot, compiled__method__unload, char*, int, char*, int, char*, int); +#define DTRACE_METHOD_CALL \ + HS_DTRACE_PROBE6(hotspot, compiled__method__unload, \ + #define DTRACE_METHOD_UNLOAD_PROBE(method) \ { \ methodOop m = (method); \ @@ -68,6 +72,22 @@ signature->bytes(), signature->utf8_length()); \ } \ } +#endif /* USDT1 */ +#ifdef USDT2 +#define DTRACE_METHOD_UNLOAD_PROBE(method) \ + { \ + methodOop m = (method); \ + if (m != NULL) { \ + Symbol* klass_name = m->klass_name(); \ + Symbol* name = m->name(); \ + Symbol* signature = m->signature(); \ + HOTSPOT_COMPILED_METHOD_UNLOAD( \ + (char *) klass_name->bytes(), klass_name->utf8_length(), \ + (char *) name->bytes(), name->utf8_length(), \ + (char *) signature->bytes(), signature->utf8_length()); \ + } \ + } +#endif /* USDT2 */ #else // ndef DTRACE_ENABLED @@ -1473,6 +1493,7 @@ void nmethod::post_compiled_method_load_event() { methodOop moop = method(); +#ifdef USDT1 HS_DTRACE_PROBE8(hotspot, compiled__method__load, moop->klass_name()->bytes(), moop->klass_name()->utf8_length(), @@ -1481,6 +1502,17 @@ moop->signature()->bytes(), moop->signature()->utf8_length(), insts_begin(), insts_size()); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_COMPILED_METHOD_LOAD( + (char *) moop->klass_name()->bytes(), + moop->klass_name()->utf8_length(), + (char *) moop->name()->bytes(), + moop->name()->utf8_length(), + (char *) moop->signature()->bytes(), + moop->signature()->utf8_length(), + insts_begin(), insts_size()); +#endif /* USDT2 */ if (JvmtiExport::should_post_compiled_method_load() || JvmtiExport::should_post_compiled_method_unload()) { diff -ru bsd-port/hotspot/src/share/vm/compiler/compileBroker.cpp macosx-port/hotspot/src/share/vm/compiler/compileBroker.cpp --- bsd-port/hotspot/src/share/vm/compiler/compileBroker.cpp 2011-07-26 20:21:22.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/compiler/compileBroker.cpp 2011-07-18 10:03:39.000000000 -0600 @@ -58,6 +58,7 @@ // Only bother with this argument setup if dtrace is available +#ifdef USDT1 HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin, char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t); HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end, @@ -88,6 +89,35 @@ name->bytes(), name->utf8_length(), \ signature->bytes(), signature->utf8_length(), (success)); \ } +#endif /* USDT1 */ + +#ifdef USDT2 +#define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method) \ + { \ + char* comp_name = (char*)(compiler)->name(); \ + Symbol* klass_name = (method)->klass_name(); \ + Symbol* name = (method)->name(); \ + Symbol* signature = (method)->signature(); \ + HOTSPOT_METHOD_COMPILE_BEGIN( \ + 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()); \ + } + +#define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, success) \ + { \ + char* comp_name = (char*)(compiler)->name(); \ + Symbol* klass_name = (method)->klass_name(); \ + Symbol* name = (method)->name(); \ + Symbol* signature = (method)->signature(); \ + HOTSPOT_METHOD_COMPILE_END( \ + 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)); \ + } +#endif /* USDT2 */ #else // ndef DTRACE_ENABLED diff -ru bsd-port/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp macosx-port/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp --- bsd-port/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp 2011-07-26 20:21:22.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp 2011-06-30 11:15:17.000000000 -0600 @@ -30,11 +30,15 @@ #include "memory/gcLocker.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "utilities/dtrace.hpp" + + +#ifdef USDT1 HS_DTRACE_PROBE_DECL(hs_private, cms__initmark__begin); HS_DTRACE_PROBE_DECL(hs_private, cms__initmark__end); HS_DTRACE_PROBE_DECL(hs_private, cms__remark__begin); HS_DTRACE_PROBE_DECL(hs_private, cms__remark__end); +#endif /* USDT1 */ ////////////////////////////////////////////////////////// // Methods in abstract class VM_CMS_Operation @@ -129,8 +133,13 @@ // Nothing to do. return; } +#ifdef USDT1 HS_DTRACE_PROBE(hs_private, cms__initmark__begin); - +#endif /* USDT1 */ +#ifdef USDT2 + HS_PRIVATE_CMS_INITMARK_BEGIN( + ); +#endif /* USDT2 */ GenCollectedHeap* gch = GenCollectedHeap::heap(); GCCauseSetter gccs(gch, GCCause::_cms_initial_mark); @@ -140,7 +149,13 @@ _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsInitial); VM_CMS_Operation::verify_after_gc(); +#ifdef USDT1 HS_DTRACE_PROBE(hs_private, cms__initmark__end); +#endif /* USDT1 */ +#ifdef USDT2 + HS_PRIVATE_CMS_INITMARK_END( + ); +#endif /* USDT2 */ } ////////////////////////////////////////////////////////// @@ -151,7 +166,13 @@ // Nothing to do. return; } +#ifdef USDT1 HS_DTRACE_PROBE(hs_private, cms__remark__begin); +#endif /* USDT1 */ +#ifdef USDT2 + HS_PRIVATE_CMS_REMARK_BEGIN( + ); +#endif /* USDT2 */ GenCollectedHeap* gch = GenCollectedHeap::heap(); GCCauseSetter gccs(gch, GCCause::_cms_final_remark); @@ -162,7 +183,13 @@ _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsFinal); VM_CMS_Operation::verify_after_gc(); +#ifdef USDT1 HS_DTRACE_PROBE(hs_private, cms__remark__end); +#endif /* USDT1 */ +#ifdef USDT2 + HS_PRIVATE_CMS_REMARK_END( + ); +#endif /* USDT2 */ } // VM operation to invoke a concurrent collection of a diff -ru bsd-port/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp macosx-port/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp --- bsd-port/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp 2011-07-19 11:56:04.000000000 -0600 @@ -40,21 +40,36 @@ #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" #endif +#ifdef USDT1 HS_DTRACE_PROBE_DECL1(hotspot, gc__begin, bool); HS_DTRACE_PROBE_DECL(hotspot, gc__end); +#endif /* USDT1 */ // The same dtrace probe can't be inserted in two different files, so we // have to call it here, so it's only in one file. Can't create new probes // for the other file anymore. The dtrace probes have to remain stable. void VM_GC_Operation::notify_gc_begin(bool full) { +#ifdef USDT1 HS_DTRACE_PROBE1(hotspot, gc__begin, full); HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_GC_BEGIN( + full); +#endif /* USDT2 */ } void VM_GC_Operation::notify_gc_end() { +#ifdef USDT1 HS_DTRACE_PROBE(hotspot, gc__end); HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); } +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_GC_END( +); +#endif /* USDT2 */ +} void VM_GC_Operation::acquire_pending_list_lock() { // we may enter this with pending exception set diff -ru bsd-port/hotspot/src/share/vm/oops/instanceKlass.cpp macosx-port/hotspot/src/share/vm/oops/instanceKlass.cpp --- bsd-port/hotspot/src/share/vm/oops/instanceKlass.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/oops/instanceKlass.cpp 2011-07-18 12:39:53.000000000 -0600 @@ -79,6 +79,8 @@ #ifdef DTRACE_ENABLED +#ifdef USDT1 + HS_DTRACE_PROBE_DECL4(hotspot, class__initialization__required, char*, intptr_t, oop, intptr_t); HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__recursive, @@ -121,6 +123,43 @@ HS_DTRACE_PROBE5(hotspot, class__initialization__##type, \ data, len, (clss)->class_loader(), thread_type, wait); \ } +#endif /* USDT1 */ + +#ifdef USDT2 +#define HOTSPOT_CLASS_INITIALIZATION_required HOTSPOT_CLASS_INITIALIZATION_REQUIRED +#define HOTSPOT_CLASS_INITIALIZATION_recursive HOTSPOT_CLASS_INITIALIZATION_RECURSIVE +#define HOTSPOT_CLASS_INITIALIZATION_concurrent HOTSPOT_CLASS_INITIALIZATION_CONCURRENT +#define HOTSPOT_CLASS_INITIALIZATION_erroneous HOTSPOT_CLASS_INITIALIZATION_ERRONEOUS +#define HOTSPOT_CLASS_INITIALIZATION_super__failed HOTSPOT_CLASS_INITIALIZATION_SUPER_FAILED +#define HOTSPOT_CLASS_INITIALIZATION_clinit HOTSPOT_CLASS_INITIALIZATION_CLINIT +#define HOTSPOT_CLASS_INITIALIZATION_error HOTSPOT_CLASS_INITIALIZATION_ERROR +#define HOTSPOT_CLASS_INITIALIZATION_end HOTSPOT_CLASS_INITIALIZATION_END +#define DTRACE_CLASSINIT_PROBE(type, clss, thread_type) \ + { \ + char* data = NULL; \ + int len = 0; \ + Symbol* name = (clss)->name(); \ + if (name != NULL) { \ + data = (char*)name->bytes(); \ + len = name->utf8_length(); \ + } \ + HOTSPOT_CLASS_INITIALIZATION_##type( \ + data, len, (clss)->class_loader(), thread_type); \ + } + +#define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) \ + { \ + char* data = NULL; \ + int len = 0; \ + Symbol* name = (clss)->name(); \ + if (name != NULL) { \ + data = (char*)name->bytes(); \ + len = name->utf8_length(); \ + } \ + HOTSPOT_CLASS_INITIALIZATION_##type( \ + data, len, (clss)->class_loader(), thread_type, wait); \ + } +#endif /* USDT2 */ #else // ndef DTRACE_ENABLED diff -ru bsd-port/hotspot/src/share/vm/prims/jni.cpp macosx-port/hotspot/src/share/vm/prims/jni.cpp --- bsd-port/hotspot/src/share/vm/prims/jni.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/prims/jni.cpp 2011-07-19 10:40:05.000000000 -0600 @@ -119,6 +119,7 @@ // return_value = 5; // return return_value; // JNI_END +#ifdef USDT1 #define DT_RETURN_MARK_DECL(name, type) \ HS_DTRACE_PROBE_DECL1(hotspot_jni, name##__return, type); \ DTRACE_ONLY( \ @@ -143,6 +144,31 @@ } \ ) +#endif /* USDT1 */ +#ifdef USDT2 +#define DT_RETURN_MARK_DECL(name, type, probe) \ + DTRACE_ONLY( \ + class DTraceReturnProbeMark_##name { \ + public: \ + const type& _ret_ref; \ + DTraceReturnProbeMark_##name(const type& v) : _ret_ref(v) {} \ + ~DTraceReturnProbeMark_##name() { \ + probe; \ + } \ + } \ + ) +// Void functions are simpler since there's no return value +#define DT_VOID_RETURN_MARK_DECL(name, probe) \ + DTRACE_ONLY( \ + class DTraceReturnProbeMark_##name { \ + public: \ + ~DTraceReturnProbeMark_##name() { \ + probe; \ + } \ + } \ + ) + +#endif /* USDT2 */ // Place these macros in the function to mark the return. Non-void // functions need the type and address of the return value. @@ -171,14 +197,20 @@ // Choose DT_RETURN_MARK macros based on the type: float/double -> void // (dtrace doesn't do FP yet) +#ifdef USDT1 #define DT_RETURN_MARK_DECL_FOR(TypeName, name, type) \ FP_SELECT(TypeName, \ DT_RETURN_MARK_DECL(name, type), DT_VOID_RETURN_MARK_DECL(name) ) +#endif /* USDT1 */ +#ifdef USDT2 +#define DT_RETURN_MARK_DECL_FOR(TypeName, name, type, probe) \ + FP_SELECT(TypeName, \ + DT_RETURN_MARK_DECL(name, type, probe), DT_VOID_RETURN_MARK_DECL(name, probe) ) +#endif /* USDT2 */ #define DT_RETURN_MARK_FOR(TypeName, name, type, ref) \ FP_SELECT(TypeName, \ DT_RETURN_MARK(name, type, ref), DT_VOID_RETURN_MARK(name) ) - // out-of-line helpers for class jfieldIDWorkaround: bool jfieldIDWorkaround::is_valid_jfieldID(klassOop k, jfieldID id) { @@ -332,14 +364,26 @@ // Implementation of JNI entries +#ifdef USDT1 DT_RETURN_MARK_DECL(DefineClass, jclass); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(DefineClass, jclass + , HOTSPOT_JNI_DEFINECLASS_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderRef, const jbyte *buf, jsize bufLen)) JNIWrapper("DefineClass"); +#ifdef USDT1 DTRACE_PROBE5(hotspot_jni, DefineClass__entry, env, name, loaderRef, buf, bufLen); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DEFINECLASS_ENTRY( + env, (char*) name, loaderRef, (char*) buf, bufLen); +#endif /* USDT2 */ jclass cls = NULL; DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls); @@ -385,12 +429,23 @@ static bool first_time_FindClass = true; +#ifdef USDT1 DT_RETURN_MARK_DECL(FindClass, jclass); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(FindClass, jclass + , HOTSPOT_JNI_FINDCLASS_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) JNIWrapper("FindClass"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, FindClass__entry, env, name); - +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_FINDCLASS_ENTRY( + env, (char *)name); +#endif /* USDT2 */ jclass result = NULL; DT_RETURN_MARK(FindClass, jclass, (const jclass&)result); @@ -453,11 +508,23 @@ return result; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID + , HOTSPOT_JNI_FROMREFLECTEDMETHOD_RETURN((uintptr_t)_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method)) JNIWrapper("FromReflectedMethod"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, FromReflectedMethod__entry, env, method); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_FROMREFLECTEDMETHOD_ENTRY( + env, method); +#endif /* USDT2 */ jmethodID ret = NULL; DT_RETURN_MARK(FromReflectedMethod, jmethodID, (const jmethodID&)ret); @@ -484,11 +551,23 @@ return ret; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(FromReflectedField, jfieldID); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(FromReflectedField, jfieldID + , HOTSPOT_JNI_FROMREFLECTEDFIELD_RETURN((uintptr_t)_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field)) JNIWrapper("FromReflectedField"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, FromReflectedField__entry, env, field); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_FROMREFLECTEDFIELD_ENTRY( + env, field); +#endif /* USDT2 */ jfieldID ret = NULL; DT_RETURN_MARK(FromReflectedField, jfieldID, (const jfieldID&)ret); @@ -523,11 +602,23 @@ return ret; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(ToReflectedMethod, jobject); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(ToReflectedMethod, jobject + , HOTSPOT_JNI_TOREFLECTEDMETHOD_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jobject, jni_ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID method_id, jboolean isStatic)) JNIWrapper("ToReflectedMethod"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, ToReflectedMethod__entry, env, cls, method_id, isStatic); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_TOREFLECTEDMETHOD_ENTRY( + env, cls, (uintptr_t) method_id, isStatic); +#endif /* USDT2 */ jobject ret = NULL; DT_RETURN_MARK(ToReflectedMethod, jobject, (const jobject&)ret); @@ -543,11 +634,23 @@ return ret; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(GetSuperclass, jclass); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(GetSuperclass, jclass + , HOTSPOT_JNI_GETSUPERCLASS_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jclass, jni_GetSuperclass(JNIEnv *env, jclass sub)) JNIWrapper("GetSuperclass"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, GetSuperclass__entry, env, sub); +#endif */ USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSUPERCLASS_ENTRY( + env, sub); +#endif */ USDT2 */ jclass obj = NULL; DT_RETURN_MARK(GetSuperclass, jclass, (const jclass&)obj); @@ -576,13 +679,25 @@ JNI_QUICK_ENTRY(jboolean, jni_IsAssignableFrom(JNIEnv *env, jclass sub, jclass super)) JNIWrapper("IsSubclassOf"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, IsAssignableFrom__entry, env, sub, super); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ISASSIGNABLEFROM_ENTRY( + env, sub, super); +#endif /* USDT2 */ oop sub_mirror = JNIHandles::resolve_non_null(sub); oop super_mirror = JNIHandles::resolve_non_null(super); if (java_lang_Class::is_primitive(sub_mirror) || java_lang_Class::is_primitive(super_mirror)) { jboolean ret = (sub_mirror == super_mirror); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN( + ret); +#endif /* USDT2 */ return ret; } klassOop sub_klass = java_lang_Class::as_klassOop(sub_mirror); @@ -590,15 +705,33 @@ assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom"); jboolean ret = Klass::cast(sub_klass)->is_subtype_of(super_klass) ? JNI_TRUE : JNI_FALSE; +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(Throw, jint); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(Throw, jint + , HOTSPOT_JNI_THROW_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jint, jni_Throw(JNIEnv *env, jthrowable obj)) JNIWrapper("Throw"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, Throw__entry, env, obj); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_THROW_ENTRY( + env, obj); +#endif /* USDT2 */ jint ret = JNI_OK; DT_RETURN_MARK(Throw, jint, (const jint&)ret); @@ -606,11 +739,23 @@ ShouldNotReachHere(); JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(ThrowNew, jint); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(ThrowNew, jint + , HOTSPOT_JNI_THROWNEW_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jint, jni_ThrowNew(JNIEnv *env, jclass clazz, const char *message)) JNIWrapper("ThrowNew"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, ThrowNew__entry, env, clazz, message); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_THROWNEW_ENTRY( + env, clazz, (char *) message); +#endif /* USDT2 */ jint ret = JNI_OK; DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret); @@ -639,18 +784,36 @@ JNI_ENTRY_NO_PRESERVE(jthrowable, jni_ExceptionOccurred(JNIEnv *env)) JNIWrapper("ExceptionOccurred"); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__entry, env); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_EXCEPTIONOCCURRED_ENTRY( + env); +#endif /* USDT2 */ jni_check_async_exceptions(thread); oop exception = thread->pending_exception(); jthrowable ret = (jthrowable) JNIHandles::make_local(env, exception); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_EXCEPTIONOCCURRED_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env)) JNIWrapper("ExceptionDescribe"); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, ExceptionDescribe__entry, env); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_EXCEPTIONDESCRIBE_ENTRY( + env); +#endif /* USDT2 */ if (thread->has_pending_exception()) { Handle ex(thread, thread->pending_exception()); thread->clear_pending_exception(); @@ -686,13 +849,25 @@ } } } +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, ExceptionDescribe__return); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_EXCEPTIONDESCRIBE_RETURN( + ); +#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(void, jni_ExceptionClear(JNIEnv *env)) JNIWrapper("ExceptionClear"); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, ExceptionClear__entry, env); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_EXCEPTIONCLEAR_ENTRY( + env); +#endif /* USDT2 */ // The jni code might be using this API to clear java thrown exception. // So just mark jvmti thread exception state as exception caught. @@ -701,13 +876,25 @@ state->set_exception_caught(); } thread->clear_pending_exception(); +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, ExceptionClear__return); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_EXCEPTIONCLEAR_RETURN( + ); +#endif /* USDT2 */ JNI_END JNI_ENTRY(void, jni_FatalError(JNIEnv *env, const char *msg)) JNIWrapper("FatalError"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, FatalError__entry, env, msg); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_FATALERROR_ENTRY( + env, (char *) msg); +#endif /* USDT2 */ tty->print_cr("FATAL ERROR in native method: %s", msg); thread->print_stack(); os::abort(); // Dump core and abort @@ -716,10 +903,22 @@ JNI_ENTRY(jint, jni_PushLocalFrame(JNIEnv *env, jint capacity)) JNIWrapper("PushLocalFrame"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, PushLocalFrame__entry, env, capacity); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY( + env, capacity); +#endif /* USDT2 */ //%note jni_11 if (capacity < 0 && capacity > MAX_REASONABLE_LOCAL_CAPACITY) { +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, JNI_ERR); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_PUSHLOCALFRAME_RETURN( + (uint32_t)JNI_ERR); +#endif /* USDT2 */ return JNI_ERR; } JNIHandleBlock* old_handles = thread->active_handles(); @@ -728,14 +927,26 @@ new_handles->set_pop_frame_link(old_handles); thread->set_active_handles(new_handles); jint ret = JNI_OK; +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_PUSHLOCALFRAME_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(jobject, jni_PopLocalFrame(JNIEnv *env, jobject result)) JNIWrapper("PopLocalFrame"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, PopLocalFrame__entry, env, result); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_POPLOCALFRAME_ENTRY( + env, result); +#endif /* USDT2 */ //%note jni_11 Handle result_handle(thread, JNIHandles::resolve(result)); JNIHandleBlock* old_handles = thread->active_handles(); @@ -750,71 +961,155 @@ JNIHandleBlock::release_block(old_handles, thread); // may block result = JNIHandles::make_local(thread, result_handle()); } +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, PopLocalFrame__return, result); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_POPLOCALFRAME_RETURN( + result); +#endif /* USDT2 */ return result; JNI_END JNI_ENTRY(jobject, jni_NewGlobalRef(JNIEnv *env, jobject ref)) JNIWrapper("NewGlobalRef"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, NewGlobalRef__entry, env, ref); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWGLOBALREF_ENTRY( + env, ref); +#endif /* USDT2 */ Handle ref_handle(thread, JNIHandles::resolve(ref)); jobject ret = JNIHandles::make_global(ref_handle); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, NewGlobalRef__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWGLOBALREF_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END // Must be JNI_ENTRY (with HandleMark) JNI_ENTRY_NO_PRESERVE(void, jni_DeleteGlobalRef(JNIEnv *env, jobject ref)) JNIWrapper("DeleteGlobalRef"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, DeleteGlobalRef__entry, env, ref); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DELETEGLOBALREF_ENTRY( + env, ref); +#endif /* USDT2 */ JNIHandles::destroy_global(ref); +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, DeleteGlobalRef__return); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DELETEGLOBALREF_RETURN( + ); +#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(void, jni_DeleteLocalRef(JNIEnv *env, jobject obj)) JNIWrapper("DeleteLocalRef"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, DeleteLocalRef__entry, env, obj); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DELETELOCALREF_ENTRY( + env, obj); +#endif /* USDT2 */ JNIHandles::destroy_local(obj); +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, DeleteLocalRef__return); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DELETELOCALREF_RETURN( + ); +#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(jboolean, jni_IsSameObject(JNIEnv *env, jobject r1, jobject r2)) JNIWrapper("IsSameObject"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, IsSameObject__entry, env, r1, r2); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ISSAMEOBJECT_ENTRY( + env, r1, r2); +#endif /* USDT2 */ oop a = JNIHandles::resolve(r1); oop b = JNIHandles::resolve(r2); jboolean ret = (a == b) ? JNI_TRUE : JNI_FALSE; +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, IsSameObject__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ISSAMEOBJECT_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(jobject, jni_NewLocalRef(JNIEnv *env, jobject ref)) JNIWrapper("NewLocalRef"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, NewLocalRef__entry, env, ref); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWLOCALREF_ENTRY( + env, ref); +#endif /* USDT2 */ jobject ret = JNIHandles::make_local(env, JNIHandles::resolve(ref)); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, NewLocalRef__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWLOCALREF_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END JNI_LEAF(jint, jni_EnsureLocalCapacity(JNIEnv *env, jint capacity)) JNIWrapper("EnsureLocalCapacity"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, EnsureLocalCapacity__entry, env, capacity); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY( + env, capacity); +#endif /* USDT2 */ jint ret; if (capacity >= 0 && capacity <= MAX_REASONABLE_LOCAL_CAPACITY) { ret = JNI_OK; } else { ret = JNI_ERR; } +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, EnsureLocalCapacity__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ENSURELOCALCAPACITY_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END // Return the Handle Type JNI_LEAF(jobjectRefType, jni_GetObjectRefType(JNIEnv *env, jobject obj)) JNIWrapper("GetObjectRefType"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, GetObjectRefType__entry, env, obj); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETOBJECTREFTYPE_ENTRY( + env, obj); +#endif /* USDT2 */ jobjectRefType ret; if (JNIHandles::is_local_handle(thread, obj) || JNIHandles::is_frame_handle(thread, obj)) @@ -825,7 +1120,13 @@ ret = JNIWeakGlobalRefType; else ret = JNIInvalidRefType; +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetObjectRefType__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETOBJECTREFTYPE_RETURN( + (void *) ret); +#endif /* USDT2 */ return ret; JNI_END @@ -1176,12 +1477,24 @@ return ih; } +#ifdef USDT1 DT_RETURN_MARK_DECL(AllocObject, jobject); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(AllocObject, jobject + , HOTSPOT_JNI_ALLOCOBJECT_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz)) JNIWrapper("AllocObject"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, AllocObject__entry, env, clazz); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ALLOCOBJECT_ENTRY( + env, clazz); +#endif /* USDT2 */ jobject ret = NULL; DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret); @@ -1190,11 +1503,23 @@ return ret; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(NewObjectA, jobject); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(NewObjectA, jobject + , HOTSPOT_JNI_NEWOBJECTA_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args)) JNIWrapper("NewObjectA"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, NewObjectA__entry, env, clazz, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWOBJECTA_ENTRY( + env, clazz, (uintptr_t) methodID); +#endif /* USDT2 */ jobject obj = NULL; DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj); @@ -1206,11 +1531,23 @@ return obj; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(NewObjectV, jobject); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(NewObjectV, jobject + , HOTSPOT_JNI_NEWOBJECTV_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)) JNIWrapper("NewObjectV"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, NewObjectV__entry, env, clazz, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWOBJECTV_ENTRY( + env, clazz, (uintptr_t) methodID); +#endif /* USDT2 */ jobject obj = NULL; DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj); @@ -1222,11 +1559,23 @@ return obj; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(NewObject, jobject); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(NewObject, jobject + , HOTSPOT_JNI_NEWOBJECT_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)) JNIWrapper("NewObject"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, NewObject__entry, env, clazz, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWOBJECT_ENTRY( + env, clazz, (uintptr_t) methodID); +#endif /* USDT2 */ jobject obj = NULL; DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj); @@ -1244,17 +1593,35 @@ JNI_ENTRY(jclass, jni_GetObjectClass(JNIEnv *env, jobject obj)) JNIWrapper("GetObjectClass"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, GetObjectClass__entry, env, obj); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETOBJECTCLASS_ENTRY( + env, obj); +#endif /* USDT2 */ klassOop k = JNIHandles::resolve_non_null(obj)->klass(); jclass ret = (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETOBJECTCLASS_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END JNI_QUICK_ENTRY(jboolean, jni_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)) JNIWrapper("IsInstanceOf"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, IsInstanceOf__entry, env, obj, clazz); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ISINSTANCEOF_ENTRY( + env, obj, clazz); +#endif /* USDT2 */ jboolean ret = JNI_TRUE; if (obj != NULL) { ret = JNI_FALSE; @@ -1264,7 +1631,13 @@ ret = JNIHandles::resolve_non_null(obj)->is_a(k) ? JNI_TRUE : JNI_FALSE; } } +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, IsInstanceOf__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ISINSTANCEOF_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END @@ -1326,9 +1699,21 @@ JNI_ENTRY(jmethodID, jni_GetMethodID(JNIEnv *env, jclass clazz, const char *name, const char *sig)) JNIWrapper("GetMethodID"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, GetMethodID__entry, env, clazz, name, sig); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETMETHODID_ENTRY( + env, clazz, (char *) name, (char *) sig); +#endif /* USDT2 */ jmethodID ret = get_method_id(env, clazz, name, sig, false, thread); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetMethodID__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETMETHODID_RETURN( + (uintptr_t) ret); +#endif /* USDT2 */ return ret; JNI_END @@ -1336,9 +1721,21 @@ JNI_ENTRY(jmethodID, jni_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, const char *sig)) JNIWrapper("GetStaticMethodID"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, GetStaticMethodID__entry, env, clazz, name, sig); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTATICMETHODID_ENTRY( + env, (char *) clazz, (char *) name, (char *)sig); +#endif /* USDT2 */ jmethodID ret = get_method_id(env, clazz, name, sig, true, thread); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetStaticMethodID__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTATICMETHODID_RETURN( + (uintptr_t) ret); +#endif /* USDT2 */ return ret; JNI_END @@ -1348,7 +1745,7 @@ // Calling Methods // - +#ifdef USDT1 #define DEFINE_CALLMETHOD(ResultType, Result, Tag) \ \ DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType);\ @@ -1359,7 +1756,7 @@ jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \ JNIWrapper("Call" XSTR(Result) "Method"); \ \ - DTRACE_PROBE3(hotspot_jni, Call##Result##Method__entry, env, obj, methodID);\ + DTRACE_PROBE3(hotspot_jni, Call##Result##Method__entry, env, obj, methodID); \ ResultType ret = 0;\ DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \ (const ResultType&)ret);\ @@ -1379,7 +1776,7 @@ jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \ JNIWrapper("Call" XSTR(Result) "MethodV"); \ \ - DTRACE_PROBE3(hotspot_jni, Call##Result##MethodV__entry, env, obj, methodID);\ + DTRACE_PROBE3(hotspot_jni, Call##Result##MethodV__entry, env, obj, methodID); \ ResultType ret = 0;\ DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ (const ResultType&)ret);\ @@ -1395,7 +1792,7 @@ JNI_ENTRY(ResultType, \ jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \ JNIWrapper("Call" XSTR(Result) "MethodA"); \ - DTRACE_PROBE3(hotspot_jni, Call##Result##MethodA__entry, env, obj, methodID);\ + DTRACE_PROBE3(hotspot_jni, Call##Result##MethodA__entry, env, obj, methodID); \ ResultType ret = 0;\ DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ (const ResultType&)ret);\ @@ -1422,10 +1819,184 @@ DT_VOID_RETURN_MARK_DECL(CallVoidMethod); DT_VOID_RETURN_MARK_DECL(CallVoidMethodV); DT_VOID_RETURN_MARK_DECL(CallVoidMethodA); +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_CALLMETHOD(ResultType, Result, Tag \ + , EntryProbe, ReturnProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType \ + , ReturnProbe); \ +\ +JNI_ENTRY(ResultType, \ + jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \ + JNIWrapper("Call" XSTR(Result) "Method"); \ +\ + EntryProbe; \ + ResultType ret = 0;\ + DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \ + (const ResultType&)ret);\ +\ + va_list args; \ + va_start(args, methodID); \ + JavaValue jvalue(Tag); \ + JNI_ArgumentPusherVaArg ap(methodID, args); \ + jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ + va_end(args); \ + ret = jvalue.get_##ResultType(); \ + return ret;\ +JNI_END + +// the runtime type of subword integral basic types is integer +DEFINE_CALLMETHOD(jboolean, Boolean, T_BOOLEAN + , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHOD(jbyte, Byte, T_BYTE + , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHOD(jchar, Char, T_CHAR + , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHOD(jshort, Short, T_SHORT + , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) + +DEFINE_CALLMETHOD(jobject, Object, T_OBJECT + , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHOD(jint, Int, T_INT, + HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHOD(jlong, Long, T_LONG + , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_CALLMETHOD(jfloat, Float, T_FLOAT + , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) +DEFINE_CALLMETHOD(jdouble, Double, T_DOUBLE + , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) + +#define DEFINE_CALLMETHODV(ResultType, Result, Tag \ + , EntryProbe, ReturnProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodV, ResultType \ + , ReturnProbe); \ +\ +JNI_ENTRY(ResultType, \ + jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \ + JNIWrapper("Call" XSTR(Result) "MethodV"); \ +\ + EntryProbe;\ + ResultType ret = 0;\ + DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ + (const ResultType&)ret);\ +\ + JavaValue jvalue(Tag); \ + JNI_ArgumentPusherVaArg ap(methodID, args); \ + jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ + ret = jvalue.get_##ResultType(); \ + return ret;\ +JNI_END + +// the runtime type of subword integral basic types is integer +DEFINE_CALLMETHODV(jboolean, Boolean, T_BOOLEAN + , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODV(jbyte, Byte, T_BYTE + , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODV(jchar, Char, T_CHAR + , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODV(jshort, Short, T_SHORT + , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) + +DEFINE_CALLMETHODV(jobject, Object, T_OBJECT + , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODV(jint, Int, T_INT, + HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODV(jlong, Long, T_LONG + , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_CALLMETHODV(jfloat, Float, T_FLOAT + , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) +DEFINE_CALLMETHODV(jdouble, Double, T_DOUBLE + , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) + +#define DEFINE_CALLMETHODA(ResultType, Result, Tag \ + , EntryProbe, ReturnProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodA, ResultType \ + , ReturnProbe); \ +\ +JNI_ENTRY(ResultType, \ + jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \ + JNIWrapper("Call" XSTR(Result) "MethodA"); \ + EntryProbe; \ + ResultType ret = 0;\ + DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ + (const ResultType&)ret);\ +\ + JavaValue jvalue(Tag); \ + JNI_ArgumentPusherArray ap(methodID, args); \ + jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ + ret = jvalue.get_##ResultType(); \ + return ret;\ +JNI_END + +// the runtime type of subword integral basic types is integer +DEFINE_CALLMETHODA(jboolean, Boolean, T_BOOLEAN + , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODA(jbyte, Byte, T_BYTE + , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODA(jchar, Char, T_CHAR + , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODA(jshort, Short, T_SHORT + , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) + +DEFINE_CALLMETHODA(jobject, Object, T_OBJECT + , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODA(jint, Int, T_INT, + HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) +DEFINE_CALLMETHODA(jlong, Long, T_LONG + , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_CALLMETHODA(jfloat, Float, T_FLOAT + , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) +DEFINE_CALLMETHODA(jdouble, Double, T_DOUBLE + , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) + +DT_VOID_RETURN_MARK_DECL(CallVoidMethod, HOTSPOT_JNI_CALLVOIDMETHOD_RETURN()); +DT_VOID_RETURN_MARK_DECL(CallVoidMethodV, HOTSPOT_JNI_CALLVOIDMETHODV_RETURN()); +DT_VOID_RETURN_MARK_DECL(CallVoidMethodA, HOTSPOT_JNI_CALLVOIDMETHODA_RETURN()); + +#endif /* USDT2 */ JNI_ENTRY(void, jni_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)) JNIWrapper("CallVoidMethod"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, CallVoidMethod__entry, env, obj, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CALLVOIDMETHOD_ENTRY( + env, obj, (uintptr_t) methodID); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallVoidMethod); va_list args; @@ -1439,7 +2010,13 @@ JNI_ENTRY(void, jni_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) JNIWrapper("CallVoidMethodV"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, CallVoidMethodV__entry, env, obj, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CALLVOIDMETHODV_ENTRY( + env, obj, (uintptr_t) methodID); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallVoidMethodV); JavaValue jvalue(T_VOID); @@ -1450,7 +2027,13 @@ JNI_ENTRY(void, jni_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) JNIWrapper("CallVoidMethodA"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, CallVoidMethodA__entry, env, obj, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CALLVOIDMETHODA_ENTRY( + env, obj, (uintptr_t) methodID); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallVoidMethodA); JavaValue jvalue(T_VOID); @@ -1459,6 +2042,7 @@ JNI_END +#ifdef USDT1 #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag) \ \ DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType);\ @@ -1530,12 +2114,189 @@ DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethod); DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV); DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA); +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag \ + , EntryProbe, ReturnProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType \ + , ReturnProbe);\ +\ +JNI_ENTRY(ResultType, \ + jni_CallNonvirtual##Result##Method(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) \ + JNIWrapper("CallNonvitual" XSTR(Result) "Method"); \ +\ + EntryProbe;\ + ResultType ret;\ + DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##Method, ResultType, \ + (const ResultType&)ret);\ +\ + va_list args; \ + va_start(args, methodID); \ + JavaValue jvalue(Tag); \ + JNI_ArgumentPusherVaArg ap(methodID, args); \ + jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ + va_end(args); \ + ret = jvalue.get_##ResultType(); \ + return ret;\ +JNI_END + +// the runtime type of subword integral basic types is integer +DEFINE_CALLNONVIRTUALMETHOD(jboolean, Boolean, T_BOOLEAN + , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHOD(jbyte, Byte, T_BYTE + , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHOD(jchar, Char, T_CHAR + , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHOD(jshort, Short, T_SHORT + , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_RETURN(_ret_ref)) + +DEFINE_CALLNONVIRTUALMETHOD(jobject, Object, T_OBJECT + , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHOD(jint, Int, T_INT + , HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHOD(jlong, Long, T_LONG + , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), +// Float and double probes don't return value because dtrace doesn't currently support it + HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHOD(jfloat, Float, T_FLOAT + , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_RETURN()) +DEFINE_CALLNONVIRTUALMETHOD(jdouble, Double, T_DOUBLE + , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_RETURN()) + +#define DEFINE_CALLNONVIRTUALMETHODV(ResultType, Result, Tag \ + , EntryProbe, ReturnProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodV, ResultType \ + , ReturnProbe);\ +\ +JNI_ENTRY(ResultType, \ + jni_CallNonvirtual##Result##MethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) \ + JNIWrapper("CallNonvitual" XSTR(Result) "MethodV"); \ +\ + EntryProbe;\ + ResultType ret;\ + DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \ + (const ResultType&)ret);\ +\ + JavaValue jvalue(Tag); \ + JNI_ArgumentPusherVaArg ap(methodID, args); \ + jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ + ret = jvalue.get_##ResultType(); \ + return ret;\ +JNI_END + +// the runtime type of subword integral basic types is integer +DEFINE_CALLNONVIRTUALMETHODV(jboolean, Boolean, T_BOOLEAN + , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODV(jbyte, Byte, T_BYTE + , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODV(jchar, Char, T_CHAR + , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODV(jshort, Short, T_SHORT + , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_RETURN(_ret_ref)) + +DEFINE_CALLNONVIRTUALMETHODV(jobject, Object, T_OBJECT + , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODV(jint, Int, T_INT + , HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODV(jlong, Long, T_LONG + , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), +// Float and double probes don't return value because dtrace doesn't currently support it + HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODV(jfloat, Float, T_FLOAT + , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_RETURN()) +DEFINE_CALLNONVIRTUALMETHODV(jdouble, Double, T_DOUBLE + , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_RETURN()) + +#define DEFINE_CALLNONVIRTUALMETHODA(ResultType, Result, Tag \ + , EntryProbe, ReturnProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodA, ResultType \ + , ReturnProbe);\ +\ +JNI_ENTRY(ResultType, \ + jni_CallNonvirtual##Result##MethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) \ + JNIWrapper("CallNonvitual" XSTR(Result) "MethodA"); \ +\ + EntryProbe;\ + ResultType ret;\ + DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \ + (const ResultType&)ret);\ +\ + JavaValue jvalue(Tag); \ + JNI_ArgumentPusherArray ap(methodID, args); \ + jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ + ret = jvalue.get_##ResultType(); \ + return ret;\ +JNI_END + +// the runtime type of subword integral basic types is integer +DEFINE_CALLNONVIRTUALMETHODA(jboolean, Boolean, T_BOOLEAN + , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODA(jbyte, Byte, T_BYTE + , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODA(jchar, Char, T_CHAR + , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODA(jshort, Short, T_SHORT + , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_RETURN(_ret_ref)) + +DEFINE_CALLNONVIRTUALMETHODA(jobject, Object, T_OBJECT + , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODA(jint, Int, T_INT + , HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODA(jlong, Long, T_LONG + , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), +// Float and double probes don't return value because dtrace doesn't currently support it + HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_RETURN(_ret_ref)) +DEFINE_CALLNONVIRTUALMETHODA(jfloat, Float, T_FLOAT + , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_RETURN()) +DEFINE_CALLNONVIRTUALMETHODA(jdouble, Double, T_DOUBLE + , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_RETURN()) + +DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethod + , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_RETURN()); +DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV + , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_RETURN()); +DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA + , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_RETURN()); +#endif /* USDT2 */ JNI_ENTRY(void, jni_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) JNIWrapper("CallNonvirtualVoidMethod"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethod__entry, env, obj, cls, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_ENTRY( + env, obj, cls, (uintptr_t) methodID); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallNonvirtualVoidMethod); va_list args; @@ -1550,8 +2311,14 @@ JNI_ENTRY(void, jni_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) JNIWrapper("CallNonvirtualVoidMethodV"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodV__entry, env, obj, cls, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_ENTRY( + env, obj, cls, (uintptr_t) methodID); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodV); JavaValue jvalue(T_VOID); @@ -1562,8 +2329,14 @@ JNI_ENTRY(void, jni_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) JNIWrapper("CallNonvirtualVoidMethodA"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodA__entry, env, obj, cls, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_ENTRY( + env, obj, cls, (uintptr_t) methodID); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodA); JavaValue jvalue(T_VOID); JNI_ArgumentPusherArray ap(methodID, args); @@ -1571,6 +2344,7 @@ JNI_END +#ifdef USDT1 #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag) \ \ DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType);\ @@ -1642,10 +2416,191 @@ DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethod); DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV); DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA); +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag \ + , EntryProbe, ResultProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType \ + , ResultProbe); \ +\ +JNI_ENTRY(ResultType, \ + jni_CallStatic##Result##Method(JNIEnv *env, jclass cls, jmethodID methodID, ...)) \ + JNIWrapper("CallStatic" XSTR(Result) "Method"); \ +\ + EntryProbe; \ + ResultType ret = 0;\ + DT_RETURN_MARK_FOR(Result, CallStatic##Result##Method, ResultType, \ + (const ResultType&)ret);\ +\ + va_list args; \ + va_start(args, methodID); \ + JavaValue jvalue(Tag); \ + JNI_ArgumentPusherVaArg ap(methodID, args); \ + jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ + va_end(args); \ + ret = jvalue.get_##ResultType(); \ + return ret;\ +JNI_END + +// the runtime type of subword integral basic types is integer +DEFINE_CALLSTATICMETHOD(jboolean, Boolean, T_BOOLEAN + , HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHOD(jbyte, Byte, T_BYTE + , HOTSPOT_JNI_CALLSTATICBYTEMETHOD_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICBYTEMETHOD_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHOD(jchar, Char, T_CHAR + , HOTSPOT_JNI_CALLSTATICCHARMETHOD_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICCHARMETHOD_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHOD(jshort, Short, T_SHORT + , HOTSPOT_JNI_CALLSTATICSHORTMETHOD_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICSHORTMETHOD_RETURN(_ret_ref)); + +DEFINE_CALLSTATICMETHOD(jobject, Object, T_OBJECT + , HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHOD(jint, Int, T_INT + , HOTSPOT_JNI_CALLSTATICINTMETHOD_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICINTMETHOD_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHOD(jlong, Long, T_LONG + , HOTSPOT_JNI_CALLSTATICLONGMETHOD_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICLONGMETHOD_RETURN(_ret_ref)); +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_CALLSTATICMETHOD(jfloat, Float, T_FLOAT + , HOTSPOT_JNI_CALLSTATICFLOATMETHOD_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICFLOATMETHOD_RETURN()); +DEFINE_CALLSTATICMETHOD(jdouble, Double, T_DOUBLE + , HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_RETURN()); + +#define DEFINE_CALLSTATICMETHODV(ResultType, Result, Tag \ + , EntryProbe, ResultProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodV, ResultType \ + , ResultProbe); \ +\ +JNI_ENTRY(ResultType, \ + jni_CallStatic##Result##MethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) \ + JNIWrapper("CallStatic" XSTR(Result) "MethodV"); \ +\ + EntryProbe; \ + ResultType ret = 0;\ + DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \ + (const ResultType&)ret);\ +\ + JavaValue jvalue(Tag); \ + JNI_ArgumentPusherVaArg ap(methodID, args); \ + /* Make sure class is initialized before trying to invoke its method */ \ + KlassHandle k(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls))); \ + Klass::cast(k())->initialize(CHECK_0); \ + jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ + va_end(args); \ + ret = jvalue.get_##ResultType(); \ + return ret;\ +JNI_END + +// the runtime type of subword integral basic types is integer +DEFINE_CALLSTATICMETHODV(jboolean, Boolean, T_BOOLEAN + , HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODV(jbyte, Byte, T_BYTE + , HOTSPOT_JNI_CALLSTATICBYTEMETHODV_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICBYTEMETHODV_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODV(jchar, Char, T_CHAR + , HOTSPOT_JNI_CALLSTATICCHARMETHODV_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICCHARMETHODV_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODV(jshort, Short, T_SHORT + , HOTSPOT_JNI_CALLSTATICSHORTMETHODV_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICSHORTMETHODV_RETURN(_ret_ref)); + +DEFINE_CALLSTATICMETHODV(jobject, Object, T_OBJECT + , HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODV(jint, Int, T_INT + , HOTSPOT_JNI_CALLSTATICINTMETHODV_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICINTMETHODV_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODV(jlong, Long, T_LONG + , HOTSPOT_JNI_CALLSTATICLONGMETHODV_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICLONGMETHODV_RETURN(_ret_ref)); +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_CALLSTATICMETHODV(jfloat, Float, T_FLOAT + , HOTSPOT_JNI_CALLSTATICFLOATMETHODV_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICFLOATMETHODV_RETURN()); +DEFINE_CALLSTATICMETHODV(jdouble, Double, T_DOUBLE + , HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_RETURN()); + +#define DEFINE_CALLSTATICMETHODA(ResultType, Result, Tag \ + , EntryProbe, ResultProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodA, ResultType \ + , ResultProbe); \ +\ +JNI_ENTRY(ResultType, \ + jni_CallStatic##Result##MethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) \ + JNIWrapper("CallStatic" XSTR(Result) "MethodA"); \ +\ + EntryProbe; \ + ResultType ret = 0;\ + DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \ + (const ResultType&)ret);\ +\ + JavaValue jvalue(Tag); \ + JNI_ArgumentPusherArray ap(methodID, args); \ + jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ + ret = jvalue.get_##ResultType(); \ + return ret;\ +JNI_END + +// the runtime type of subword integral basic types is integer +DEFINE_CALLSTATICMETHODA(jboolean, Boolean, T_BOOLEAN + , HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODA(jbyte, Byte, T_BYTE + , HOTSPOT_JNI_CALLSTATICBYTEMETHODA_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICBYTEMETHODA_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODA(jchar, Char, T_CHAR + , HOTSPOT_JNI_CALLSTATICCHARMETHODA_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICCHARMETHODA_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODA(jshort, Short, T_SHORT + , HOTSPOT_JNI_CALLSTATICSHORTMETHODA_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICSHORTMETHODA_RETURN(_ret_ref)); + +DEFINE_CALLSTATICMETHODA(jobject, Object, T_OBJECT + , HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODA(jint, Int, T_INT + , HOTSPOT_JNI_CALLSTATICINTMETHODA_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICINTMETHODA_RETURN(_ret_ref)); +DEFINE_CALLSTATICMETHODA(jlong, Long, T_LONG + , HOTSPOT_JNI_CALLSTATICLONGMETHODA_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICLONGMETHODA_RETURN(_ret_ref)); +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_CALLSTATICMETHODA(jfloat, Float, T_FLOAT + , HOTSPOT_JNI_CALLSTATICFLOATMETHODA_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICFLOATMETHODA_RETURN()); +DEFINE_CALLSTATICMETHODA(jdouble, Double, T_DOUBLE + , HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_ENTRY(env, cls, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_RETURN()); + +DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethod + , HOTSPOT_JNI_CALLSTATICVOIDMETHOD_RETURN()); +DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV + , HOTSPOT_JNI_CALLSTATICVOIDMETHODV_RETURN()); +DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA + , HOTSPOT_JNI_CALLSTATICVOIDMETHODA_RETURN()); +#endif /* USDT2 */ JNI_ENTRY(void, jni_CallStaticVoidMethod(JNIEnv *env, jclass cls, jmethodID methodID, ...)) JNIWrapper("CallStaticVoidMethod"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethod__entry, env, cls, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CALLSTATICVOIDMETHOD_ENTRY( + env, cls, (uintptr_t) methodID); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallStaticVoidMethod); va_list args; @@ -1659,7 +2614,13 @@ JNI_ENTRY(void, jni_CallStaticVoidMethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) JNIWrapper("CallStaticVoidMethodV"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodV__entry, env, cls, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CALLSTATICVOIDMETHODV_ENTRY( + env, cls, (uintptr_t) methodID); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallStaticVoidMethodV); JavaValue jvalue(T_VOID); @@ -1670,7 +2631,13 @@ JNI_ENTRY(void, jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) JNIWrapper("CallStaticVoidMethodA"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodA__entry, env, cls, methodID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CALLSTATICVOIDMETHODA_ENTRY( + env, cls, (uintptr_t) methodID); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallStaticVoidMethodA); JavaValue jvalue(T_VOID); @@ -1684,12 +2651,24 @@ // +#ifdef USDT1 DT_RETURN_MARK_DECL(GetFieldID, jfieldID); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(GetFieldID, jfieldID + , HOTSPOT_JNI_GETFIELDID_RETURN((uintptr_t)_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jfieldID, jni_GetFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig)) JNIWrapper("GetFieldID"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, GetFieldID__entry, env, clazz, name, sig); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETFIELDID_ENTRY( + env, clazz, (char *) name, (char *) sig); +#endif /* USDT2 */ jfieldID ret = 0; DT_RETURN_MARK(GetFieldID, jfieldID, (const jfieldID&)ret); @@ -1721,7 +2700,13 @@ JNI_ENTRY(jobject, jni_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)) JNIWrapper("GetObjectField"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, GetObjectField__entry, env, obj, fieldID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETOBJECTFIELD_ENTRY( + env, obj, (uintptr_t) fieldID); +#endif /* USDT2 */ oop o = JNIHandles::resolve_non_null(obj); klassOop k = o->klass(); int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); @@ -1751,11 +2736,18 @@ } } #endif // SERIALGC +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetObjectField__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 +HOTSPOT_JNI_GETOBJECTFIELD_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END +#ifdef USDT1 #define DEFINE_GETFIELD(Return,Fieldname,Result) \ \ DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return);\ @@ -1788,6 +2780,60 @@ DEFINE_GETFIELD(jlong, long, Long) DEFINE_GETFIELD(jfloat, float, Float) DEFINE_GETFIELD(jdouble, double, Double) +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_GETFIELD(Return,Fieldname,Result \ + , EntryProbe, ReturnProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return \ + , ReturnProbe); \ +\ +JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \ + JNIWrapper("Get" XSTR(Result) "Field"); \ +\ + EntryProbe; \ + Return ret = 0;\ + DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ +\ + oop o = JNIHandles::resolve_non_null(obj); \ + klassOop k = o->klass(); \ + int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ + /* Keep JVMTI addition small and only check enabled flag here. */ \ + /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ + /* and creates a ResetNoHandleMark. */ \ + if (JvmtiExport::should_post_field_access()) { \ + o = JvmtiExport::jni_GetField_probe_nh(thread, obj, o, k, fieldID, false); \ + } \ + ret = o->Fieldname##_field(offset); \ + return ret; \ +JNI_END + +DEFINE_GETFIELD(jboolean, bool, Boolean + , HOTSPOT_JNI_GETBOOLEANFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_GETBOOLEANFIELD_RETURN(_ret_ref)) +DEFINE_GETFIELD(jbyte, byte, Byte + , HOTSPOT_JNI_GETBYTEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_GETBYTEFIELD_RETURN(_ret_ref)) +DEFINE_GETFIELD(jchar, char, Char + , HOTSPOT_JNI_GETCHARFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_GETCHARFIELD_RETURN(_ret_ref)) +DEFINE_GETFIELD(jshort, short, Short + , HOTSPOT_JNI_GETSHORTFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_GETSHORTFIELD_RETURN(_ret_ref)) +DEFINE_GETFIELD(jint, int, Int + , HOTSPOT_JNI_GETINTFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_GETINTFIELD_RETURN(_ret_ref)) +DEFINE_GETFIELD(jlong, long, Long + , HOTSPOT_JNI_GETLONGFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_GETLONGFIELD_RETURN(_ret_ref)) +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_GETFIELD(jfloat, float, Float + , HOTSPOT_JNI_GETFLOATFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_GETFLOATFIELD_RETURN()) +DEFINE_GETFIELD(jdouble, double, Double + , HOTSPOT_JNI_GETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_GETDOUBLEFIELD_RETURN()) +#endif /* USDT2 */ address jni_GetBooleanField_addr() { return (address)jni_GetBooleanField; @@ -1816,7 +2862,13 @@ JNI_QUICK_ENTRY(void, jni_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, jobject value)) JNIWrapper("SetObjectField"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, SetObjectField__entry, env, obj, fieldID, value); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_SETOBJECTFIELD_ENTRY( + env, obj, (uintptr_t) fieldID, value); +#endif /* USDT2 */ oop o = JNIHandles::resolve_non_null(obj); klassOop k = o->klass(); int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); @@ -1829,9 +2881,16 @@ o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, 'L', (jvalue *)&field_value); } o->obj_field_put(offset, JNIHandles::resolve(value)); +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, SetObjectField__return); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_SETOBJECTFIELD_RETURN( +); +#endif /* USDT2 */ JNI_END +#ifdef USDT1 #define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType) \ \ JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \ @@ -1865,13 +2924,76 @@ DEFINE_SETFIELD(jlong, long, Long, 'J', j) DEFINE_SETFIELD(jfloat, float, Float, 'F', f) DEFINE_SETFIELD(jdouble, double, Double, 'D', d) +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType \ + , EntryProbe, ReturnProbe) \ +\ +JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \ + JNIWrapper("Set" XSTR(Result) "Field"); \ +\ + EntryProbe; \ +\ + oop o = JNIHandles::resolve_non_null(obj); \ + klassOop k = o->klass(); \ + int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ + /* Keep JVMTI addition small and only check enabled flag here. */ \ + /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ + /* and creates a ResetNoHandleMark. */ \ + if (JvmtiExport::should_post_field_modification()) { \ + jvalue field_value; \ + field_value.unionType = value; \ + o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \ + } \ + o->Fieldname##_field_put(offset, value); \ + ReturnProbe; \ +JNI_END +DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z + , HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), + HOTSPOT_JNI_SETBOOLEANFIELD_RETURN()) +DEFINE_SETFIELD(jbyte, byte, Byte, 'B', b + , HOTSPOT_JNI_SETBYTEFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), + HOTSPOT_JNI_SETBYTEFIELD_RETURN()) +DEFINE_SETFIELD(jchar, char, Char, 'C', c + , HOTSPOT_JNI_SETCHARFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), + HOTSPOT_JNI_SETCHARFIELD_RETURN()) +DEFINE_SETFIELD(jshort, short, Short, 'S', s + , HOTSPOT_JNI_SETSHORTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), + HOTSPOT_JNI_SETSHORTFIELD_RETURN()) +DEFINE_SETFIELD(jint, int, Int, 'I', i + , HOTSPOT_JNI_SETINTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), + HOTSPOT_JNI_SETINTFIELD_RETURN()) +DEFINE_SETFIELD(jlong, long, Long, 'J', j + , HOTSPOT_JNI_SETLONGFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value), + HOTSPOT_JNI_SETLONGFIELD_RETURN()) +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_SETFIELD(jfloat, float, Float, 'F', f + , HOTSPOT_JNI_SETFLOATFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_SETFLOATFIELD_RETURN()) +DEFINE_SETFIELD(jdouble, double, Double, 'D', d + , HOTSPOT_JNI_SETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), + HOTSPOT_JNI_SETDOUBLEFIELD_RETURN()) +#endif /* USDT2 */ + +#ifdef USDT1 DT_RETURN_MARK_DECL(ToReflectedField, jobject); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(ToReflectedField, jobject + , HOTSPOT_JNI_TOREFLECTEDFIELD_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jobject, jni_ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic)) JNIWrapper("ToReflectedField"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, ToReflectedField__entry, env, cls, fieldID, isStatic); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_TOREFLECTEDFIELD_ENTRY( + env, cls, (uintptr_t) fieldID, isStatic); +#endif /* USDT2 */ jobject ret = NULL; DT_RETURN_MARK(ToReflectedField, jobject, (const jobject&)ret); @@ -1901,12 +3023,24 @@ // // Accessing Static Fields // +#ifdef USDT1 DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID + , HOTSPOT_JNI_GETSTATICFIELDID_RETURN((uintptr_t)_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig)) JNIWrapper("GetStaticFieldID"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, GetStaticFieldID__entry, env, clazz, name, sig); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTATICFIELDID_ENTRY( + env, clazz, (char *) name, (char *) sig); +#endif /* USDT2 */ jfieldID ret = NULL; DT_RETURN_MARK(GetStaticFieldID, jfieldID, (const jfieldID&)ret); @@ -1942,7 +3076,13 @@ JNI_ENTRY(jobject, jni_GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID)) JNIWrapper("GetStaticObjectField"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, GetStaticObjectField__entry, env, clazz, fieldID); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTATICOBJECTFIELD_ENTRY( + env, clazz, (uintptr_t) fieldID); +#endif /* USDT2 */ #ifndef JNICHECK_KERNEL DEBUG_ONLY(klassOop param_k = jniCheck::validate_class(thread, clazz);) #endif // JNICHECK_KERNEL @@ -1954,10 +3094,17 @@ JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); } jobject ret = JNIHandles::make_local(id->holder()->java_mirror()->obj_field(id->offset())); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetStaticObjectField__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTATICOBJECTFIELD_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END +#ifdef USDT1 #define DEFINE_GETSTATICFIELD(Return,Fieldname,Result) \ \ DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return);\ @@ -1987,11 +3134,60 @@ DEFINE_GETSTATICFIELD(jlong, long, Long) DEFINE_GETSTATICFIELD(jfloat, float, Float) DEFINE_GETSTATICFIELD(jdouble, double, Double) +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_GETSTATICFIELD(Return,Fieldname,Result \ + , EntryProbe, ReturnProbe) \ +\ + DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return \ + , ReturnProbe); \ +\ +JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID)) \ + JNIWrapper("GetStatic" XSTR(Result) "Field"); \ + EntryProbe; \ + Return ret = 0;\ + DT_RETURN_MARK_FOR(Result, GetStatic##Result##Field, Return, \ + (const Return&)ret);\ + JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ + assert(id->is_static_field_id(), "invalid static field id"); \ + /* Keep JVMTI addition small and only check enabled flag here. */ \ + /* jni_GetField_probe() assumes that is okay to create handles. */ \ + if (JvmtiExport::should_post_field_access()) { \ + JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \ + } \ + ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \ + return ret;\ +JNI_END + +DEFINE_GETSTATICFIELD(jboolean, bool, Boolean + , HOTSPOT_JNI_GETSTATICBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICBOOLEANFIELD_RETURN(_ret_ref)) +DEFINE_GETSTATICFIELD(jbyte, byte, Byte + , HOTSPOT_JNI_GETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICBYTEFIELD_RETURN(_ret_ref) ) +DEFINE_GETSTATICFIELD(jchar, char, Char + , HOTSPOT_JNI_GETSTATICCHARFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICCHARFIELD_RETURN(_ret_ref) ) +DEFINE_GETSTATICFIELD(jshort, short, Short + , HOTSPOT_JNI_GETSTATICSHORTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICSHORTFIELD_RETURN(_ret_ref) ) +DEFINE_GETSTATICFIELD(jint, int, Int + , HOTSPOT_JNI_GETSTATICINTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICINTFIELD_RETURN(_ret_ref) ) +DEFINE_GETSTATICFIELD(jlong, long, Long + , HOTSPOT_JNI_GETSTATICLONGFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICLONGFIELD_RETURN(_ret_ref) ) +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_GETSTATICFIELD(jfloat, float, Float + , HOTSPOT_JNI_GETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICFLOATFIELD_RETURN() ) +DEFINE_GETSTATICFIELD(jdouble, double, Double + , HOTSPOT_JNI_GETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICDOUBLEFIELD_RETURN() ) +#endif /* USDT2 */ JNI_ENTRY(void, jni_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value)) JNIWrapper("SetStaticObjectField"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, SetStaticObjectField__entry, env, clazz, fieldID, value); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_SETSTATICOBJECTFIELD_ENTRY( + env, clazz, (uintptr_t) fieldID, value); +#endif /* USDT2 */ JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); assert(id->is_static_field_id(), "invalid static field id"); // Keep JVMTI addition small and only check enabled flag here. @@ -2002,10 +3198,17 @@ JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value); } id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value)); +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, SetStaticObjectField__return); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_SETSTATICOBJECTFIELD_RETURN( + ); +#endif /* USDT2 */ JNI_END +#ifdef USDT1 #define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType) \ \ JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \ @@ -2036,6 +3239,54 @@ DEFINE_SETSTATICFIELD(jlong, long, Long, 'J', j) DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f) DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d) +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType \ + , EntryProbe, ReturnProbe) \ +\ +JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \ + JNIWrapper("SetStatic" XSTR(Result) "Field"); \ + EntryProbe; \ +\ + JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ + assert(id->is_static_field_id(), "invalid static field id"); \ + /* Keep JVMTI addition small and only check enabled flag here. */ \ + /* jni_SetField_probe() assumes that is okay to create handles. */ \ + if (JvmtiExport::should_post_field_modification()) { \ + jvalue field_value; \ + field_value.unionType = value; \ + JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ + } \ + id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ + ReturnProbe;\ +JNI_END + +DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z + , HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value), + HOTSPOT_JNI_SETBOOLEANFIELD_RETURN()) +DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b + , HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), + HOTSPOT_JNI_SETSTATICBYTEFIELD_RETURN()) +DEFINE_SETSTATICFIELD(jchar, char, Char, 'C', c + , HOTSPOT_JNI_SETSTATICCHARFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), + HOTSPOT_JNI_SETSTATICCHARFIELD_RETURN()) +DEFINE_SETSTATICFIELD(jshort, short, Short, 'S', s + , HOTSPOT_JNI_SETSTATICSHORTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), + HOTSPOT_JNI_SETSTATICSHORTFIELD_RETURN()) +DEFINE_SETSTATICFIELD(jint, int, Int, 'I', i + , HOTSPOT_JNI_SETSTATICINTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), + HOTSPOT_JNI_SETSTATICINTFIELD_RETURN()) +DEFINE_SETSTATICFIELD(jlong, long, Long, 'J', j + , HOTSPOT_JNI_SETSTATICLONGFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), + HOTSPOT_JNI_SETSTATICLONGFIELD_RETURN()) +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f + , HOTSPOT_JNI_SETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), + HOTSPOT_JNI_SETSTATICFLOATFIELD_RETURN()) +DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d + , HOTSPOT_JNI_SETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), + HOTSPOT_JNI_SETSTATICDOUBLEFIELD_RETURN()) +#endif /* USDT2 */ // @@ -2044,11 +3295,23 @@ // Unicode Interface +#ifdef USDT1 DT_RETURN_MARK_DECL(NewString, jstring); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(NewString, jstring + , HOTSPOT_JNI_NEWSTRING_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jstring, jni_NewString(JNIEnv *env, const jchar *unicodeChars, jsize len)) JNIWrapper("NewString"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, NewString__entry, env, unicodeChars, len); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWSTRING_ENTRY( + env, (uint16_t *) unicodeChars, len); +#endif /* USDT2 */ jstring ret = NULL; DT_RETURN_MARK(NewString, jstring, (const jstring&)ret); oop string=java_lang_String::create_oop_from_unicode((jchar*) unicodeChars, len, CHECK_NULL); @@ -2059,9 +3322,21 @@ JNI_QUICK_ENTRY(jsize, jni_GetStringLength(JNIEnv *env, jstring string)) JNIWrapper("GetStringLength"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, GetStringLength__entry, env, string); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGLENGTH_ENTRY( + env, string); +#endif /* USDT2 */ jsize ret = java_lang_String::length(JNIHandles::resolve_non_null(string)); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetStringLength__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGLENGTH_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END @@ -2069,7 +3344,13 @@ JNI_QUICK_ENTRY(const jchar*, jni_GetStringChars( JNIEnv *env, jstring string, jboolean *isCopy)) JNIWrapper("GetStringChars"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, GetStringChars__entry, env, string, isCopy); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGCHARS_ENTRY( + env, string, (uintptr_t *) isCopy); +#endif /* USDT2 */ //%note jni_5 if (isCopy != NULL) { *isCopy = JNI_TRUE; @@ -2083,31 +3364,61 @@ memcpy(buf, s_value->char_at_addr(s_offset), sizeof(jchar)*s_len); } buf[s_len] = 0; +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetStringChars__return, buf); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGCHARS_RETURN( + buf); +#endif /* USDT2 */ return buf; JNI_END JNI_QUICK_ENTRY(void, jni_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)) JNIWrapper("ReleaseStringChars"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, ReleaseStringChars__entry, env, str, chars); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_RELEASESTRINGCHARS_ENTRY( + env, str, (uint16_t *) chars); +#endif /* USDT2 */ //%note jni_6 if (chars != NULL) { // Since String objects are supposed to be immutable, don't copy any // new data back. A bad user will have to go after the char array. FreeHeap((void*) chars); } +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, ReleaseStringChars__return); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_RELEASESTRINGCHARS_RETURN( +); +#endif /* USDT2 */ JNI_END // UTF Interface +#ifdef USDT1 DT_RETURN_MARK_DECL(NewStringUTF, jstring); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(NewStringUTF, jstring + , HOTSPOT_JNI_NEWSTRINGUTF_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jstring, jni_NewStringUTF(JNIEnv *env, const char *bytes)) JNIWrapper("NewStringUTF"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, NewStringUTF__entry, env, bytes); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWSTRINGUTF_ENTRY( + env, (char *) bytes); +#endif /* USDT2 */ jstring ret; DT_RETURN_MARK(NewStringUTF, jstring, (const jstring&)ret); @@ -2119,43 +3430,91 @@ JNI_ENTRY(jsize, jni_GetStringUTFLength(JNIEnv *env, jstring string)) JNIWrapper("GetStringUTFLength"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, GetStringUTFLength__entry, env, string); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGUTFLENGTH_ENTRY( + env, string); +#endif /* USDT2 */ jsize ret = java_lang_String::utf8_length(JNIHandles::resolve_non_null(string)); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetStringUTFLength__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGUTFLENGTH_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)) JNIWrapper("GetStringUTFChars"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, GetStringUTFChars__entry, env, string, isCopy); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY( + env, string, (uintptr_t *) isCopy); +#endif /* USDT2 */ oop java_string = JNIHandles::resolve_non_null(string); size_t length = java_lang_String::utf8_length(java_string); char* result = AllocateHeap(length + 1, "GetStringUTFChars"); java_lang_String::as_utf8_string(java_string, result, (int) length + 1); if (isCopy != NULL) *isCopy = JNI_TRUE; +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGUTFCHARS_RETURN( + result); +#endif /* USDT2 */ return result; JNI_END JNI_LEAF(void, jni_ReleaseStringUTFChars(JNIEnv *env, jstring str, const char *chars)) JNIWrapper("ReleaseStringUTFChars"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, ReleaseStringUTFChars__entry, env, str, chars); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_RELEASESTRINGUTFCHARS_ENTRY( + env, str, (char *) chars); +#endif /* USDT2 */ if (chars != NULL) { FreeHeap((char*) chars); } +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, ReleaseStringUTFChars__return); +#endif /* USDT1 */ +#ifdef USDT2 +HOTSPOT_JNI_RELEASESTRINGUTFCHARS_RETURN( +); +#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(jsize, jni_GetArrayLength(JNIEnv *env, jarray array)) JNIWrapper("GetArrayLength"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, GetArrayLength__entry, env, array); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETARRAYLENGTH_ENTRY( + env, array); +#endif /* USDT2 */ arrayOop a = arrayOop(JNIHandles::resolve_non_null(array)); assert(a->is_array(), "must be array"); jsize ret = a->length(); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetArrayLength__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETARRAYLENGTH_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END @@ -2164,11 +3523,23 @@ // Object Array Operations // +#ifdef USDT1 DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray + , HOTSPOT_JNI_NEWOBJECTARRAY_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement)) JNIWrapper("NewObjectArray"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, NewObjectArray__entry, env, length, elementClass, initialElement); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY( + env, length, elementClass, initialElement); +#endif /* USDT2 */ jobjectArray ret = NULL; DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); KlassHandle ek(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(elementClass))); @@ -2186,11 +3557,23 @@ return ret; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject + , HOTSPOT_JNI_GETOBJECTARRAYELEMENT_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jobject, jni_GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index)) JNIWrapper("GetObjectArrayElement"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, GetObjectArrayElement__entry, env, array, index); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY( + env, array, index); +#endif /* USDT2 */ jobject ret = NULL; DT_RETURN_MARK(GetObjectArrayElement, jobject, (const jobject&)ret); objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); @@ -2204,11 +3587,23 @@ } JNI_END +#ifdef USDT1 DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement); +#endif /* USDT1 */ +#ifdef USDT2 +DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement + , HOTSPOT_JNI_SETOBJECTARRAYELEMENT_RETURN()); +#endif /* USDT2 */ JNI_ENTRY(void, jni_SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index, jobject value)) JNIWrapper("SetObjectArrayElement"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, SetObjectArrayElement__entry, env, array, index, value); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_SETOBJECTARRAYELEMENT_ENTRY( + env, array, index, value); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(SetObjectArrayElement); objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); @@ -2227,9 +3622,10 @@ JNI_END +#ifdef USDT1 #define DEFINE_NEWSCALARARRAY(Return,Allocator,Result) \ \ - DT_RETURN_MARK_DECL(New##Result##Array, Return);\ + DT_RETURN_MARK_DECL(New##Result##Array, Return); \ \ JNI_ENTRY(Return, \ jni_New##Result##Array(JNIEnv *env, jsize len)) \ @@ -2251,6 +3647,51 @@ DEFINE_NEWSCALARARRAY(jlongArray, new_longArray, Long) DEFINE_NEWSCALARARRAY(jfloatArray, new_singleArray, Float) DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double) +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_NEWSCALARARRAY(Return,Allocator,Result \ + ,EntryProbe,ReturnProbe) \ +\ + DT_RETURN_MARK_DECL(New##Result##Array, Return \ + , ReturnProbe); \ +\ +JNI_ENTRY(Return, \ + jni_New##Result##Array(JNIEnv *env, jsize len)) \ + JNIWrapper("New" XSTR(Result) "Array"); \ + EntryProbe; \ + Return ret = NULL;\ + DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\ +\ + oop obj= oopFactory::Allocator(len, CHECK_0); \ + ret = (Return) JNIHandles::make_local(env, obj); \ + return ret;\ +JNI_END + +DEFINE_NEWSCALARARRAY(jbooleanArray, new_boolArray, Boolean, + HOTSPOT_JNI_NEWBOOLEANARRAY_ENTRY(env, len), + HOTSPOT_JNI_NEWBOOLEANARRAY_RETURN(_ret_ref)) +DEFINE_NEWSCALARARRAY(jbyteArray, new_byteArray, Byte, + HOTSPOT_JNI_NEWBYTEARRAY_ENTRY(env, len), + HOTSPOT_JNI_NEWBYTEARRAY_RETURN(_ret_ref)) +DEFINE_NEWSCALARARRAY(jshortArray, new_shortArray, Short, + HOTSPOT_JNI_NEWSHORTARRAY_ENTRY(env, len), + HOTSPOT_JNI_NEWSHORTARRAY_RETURN(_ret_ref)) +DEFINE_NEWSCALARARRAY(jcharArray, new_charArray, Char, + HOTSPOT_JNI_NEWCHARARRAY_ENTRY(env, len), + HOTSPOT_JNI_NEWCHARARRAY_RETURN(_ret_ref)) +DEFINE_NEWSCALARARRAY(jintArray, new_intArray, Int, + HOTSPOT_JNI_NEWINTARRAY_ENTRY(env, len), + HOTSPOT_JNI_NEWINTARRAY_RETURN(_ret_ref)) +DEFINE_NEWSCALARARRAY(jlongArray, new_longArray, Long, + HOTSPOT_JNI_NEWLONGARRAY_ENTRY(env, len), + HOTSPOT_JNI_NEWLONGARRAY_RETURN(_ret_ref)) +DEFINE_NEWSCALARARRAY(jfloatArray, new_singleArray, Float, + HOTSPOT_JNI_NEWFLOATARRAY_ENTRY(env, len), + HOTSPOT_JNI_NEWFLOATARRAY_RETURN(_ret_ref)) +DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double, + HOTSPOT_JNI_NEWDOUBLEARRAY_ENTRY(env, len), + HOTSPOT_JNI_NEWDOUBLEARRAY_RETURN(_ret_ref)) +#endif /* USDT2 */ // Return an address which will fault if the caller writes to it. @@ -2269,6 +3710,7 @@ } +#ifdef USDT1 #define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag) \ \ JNI_QUICK_ENTRY(ElementType*, \ @@ -2302,8 +3744,63 @@ DEFINE_GETSCALARARRAYELEMENTS(T_LONG, jlong, Long, long) DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag \ + , EntryProbe, ReturnProbe) \ +\ +JNI_QUICK_ENTRY(ElementType*, \ + jni_Get##Result##ArrayElements(JNIEnv *env, ElementType##Array array, jboolean *isCopy)) \ + JNIWrapper("Get" XSTR(Result) "ArrayElements"); \ + EntryProbe; \ + /* allocate an chunk of memory in c land */ \ + typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ + ElementType* result; \ + int len = a->length(); \ + if (len == 0) { \ + /* Empty array: legal but useless, can't return NULL. \ + * Return a pointer to something useless. \ + * Avoid asserts in typeArrayOop. */ \ + result = (ElementType*)get_bad_address(); \ + } else { \ + result = NEW_C_HEAP_ARRAY(ElementType, len); \ + /* copy the array to the c chunk */ \ + memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \ + } \ + if (isCopy) *isCopy = JNI_TRUE; \ + ReturnProbe; \ + return result; \ +JNI_END + +DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool + , HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), + HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_RETURN((uintptr_t*)result)) +DEFINE_GETSCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte + , HOTSPOT_JNI_GETBYTEARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), + HOTSPOT_JNI_GETBYTEARRAYELEMENTS_RETURN((char*)result)) +DEFINE_GETSCALARARRAYELEMENTS(T_SHORT, jshort, Short, short + , HOTSPOT_JNI_GETSHORTARRAYELEMENTS_ENTRY(env, (uint16_t*) array, (uintptr_t *) isCopy), + HOTSPOT_JNI_GETSHORTARRAYELEMENTS_RETURN((uint16_t*)result)) +DEFINE_GETSCALARARRAYELEMENTS(T_CHAR, jchar, Char, char + , HOTSPOT_JNI_GETCHARARRAYELEMENTS_ENTRY(env, (uint16_t*) array, (uintptr_t *) isCopy), + HOTSPOT_JNI_GETCHARARRAYELEMENTS_RETURN(result)) +DEFINE_GETSCALARARRAYELEMENTS(T_INT, jint, Int, int + , HOTSPOT_JNI_GETINTARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), + HOTSPOT_JNI_GETINTARRAYELEMENTS_RETURN((uint32_t*)result)) +DEFINE_GETSCALARARRAYELEMENTS(T_LONG, jlong, Long, long + , HOTSPOT_JNI_GETLONGARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), + HOTSPOT_JNI_GETLONGARRAYELEMENTS_RETURN(((uintptr_t*)result))) +// Float and double probes don't return value because dtrace doesn't currently support it +DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float + , HOTSPOT_JNI_GETFLOATARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), + HOTSPOT_JNI_GETFLOATARRAYELEMENTS_RETURN(result)) +DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double + , HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), + HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_RETURN(result)) +#endif /* USDT2 */ +#ifdef USDT1 #define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag) \ \ JNI_QUICK_ENTRY(void, \ @@ -2332,7 +3829,56 @@ DEFINE_RELEASESCALARARRAYELEMENTS(T_LONG, jlong, Long, long) DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag \ + , EntryProbe, ReturnProbe);\ +\ +JNI_QUICK_ENTRY(void, \ + jni_Release##Result##ArrayElements(JNIEnv *env, ElementType##Array array, \ + ElementType *buf, jint mode)) \ + JNIWrapper("Release" XSTR(Result) "ArrayElements"); \ + EntryProbe; \ + typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ + int len = a->length(); \ + if (len != 0) { /* Empty array: nothing to free or copy. */ \ + if ((mode == 0) || (mode == JNI_COMMIT)) { \ + memcpy(a->Tag##_at_addr(0), buf, sizeof(ElementType)*len); \ + } \ + if ((mode == 0) || (mode == JNI_ABORT)) { \ + FreeHeap(buf); \ + } \ + } \ + ReturnProbe; \ +JNI_END + +DEFINE_RELEASESCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool + , HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) buf, mode), + HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_RETURN()) +DEFINE_RELEASESCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte + , HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_ENTRY(env, array, (char *) buf, mode), + HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_RETURN()) +DEFINE_RELEASESCALARARRAYELEMENTS(T_SHORT, jshort, Short, short + , HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_ENTRY(env, array, (uint16_t *) buf, mode), + HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_RETURN()) +DEFINE_RELEASESCALARARRAYELEMENTS(T_CHAR, jchar, Char, char + , HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_ENTRY(env, array, (uint16_t *) buf, mode), + HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_RETURN()) +DEFINE_RELEASESCALARARRAYELEMENTS(T_INT, jint, Int, int + , HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_ENTRY(env, array, (uint32_t *) buf, mode), + HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_RETURN()) +DEFINE_RELEASESCALARARRAYELEMENTS(T_LONG, jlong, Long, long + , HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) buf, mode), + HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_RETURN()) +DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float + , HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_ENTRY(env, array, (float *) buf, mode), + HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_RETURN()) +DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double + , HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_ENTRY(env, array, (double *) buf, mode), + HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_RETURN()) +#endif /* USDT2 */ +#ifdef USDT1 #define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion);\ \ @@ -2363,7 +3909,59 @@ DEFINE_GETSCALARARRAYREGION(T_LONG, jlong, Long, long) DEFINE_GETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) DEFINE_GETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \ + , EntryProbe, ReturnProbe); \ + DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion \ + , ReturnProbe); \ +\ +JNI_ENTRY(void, \ +jni_Get##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ + jsize len, ElementType *buf)) \ + JNIWrapper("Get" XSTR(Result) "ArrayRegion"); \ + EntryProbe; \ + DT_VOID_RETURN_MARK(Get##Result##ArrayRegion); \ + typeArrayOop src = typeArrayOop(JNIHandles::resolve_non_null(array)); \ + if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)src->length())) { \ + THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ + } else { \ + if (len > 0) { \ + int sc = typeArrayKlass::cast(src->klass())->log2_element_size(); \ + memcpy((u_char*) buf, \ + (u_char*) src->Tag##_at_addr(start), \ + len << sc); \ + } \ + } \ +JNI_END +DEFINE_GETSCALARARRAYREGION(T_BOOLEAN, jboolean,Boolean, bool + , HOTSPOT_JNI_GETBOOLEANARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf), + HOTSPOT_JNI_GETBOOLEANARRAYREGION_RETURN()); +DEFINE_GETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte + , HOTSPOT_JNI_GETBYTEARRAYREGION_ENTRY(env, array, start, len, (char *) buf), + HOTSPOT_JNI_GETBYTEARRAYREGION_RETURN()); +DEFINE_GETSCALARARRAYREGION(T_SHORT, jshort, Short, short + , HOTSPOT_JNI_GETSHORTARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf), + HOTSPOT_JNI_GETSHORTARRAYREGION_RETURN()); +DEFINE_GETSCALARARRAYREGION(T_CHAR, jchar, Char, char + , HOTSPOT_JNI_GETCHARARRAYREGION_ENTRY(env, array, start, len, (uint16_t*) buf), + HOTSPOT_JNI_GETCHARARRAYREGION_RETURN()); +DEFINE_GETSCALARARRAYREGION(T_INT, jint, Int, int + , HOTSPOT_JNI_GETINTARRAYREGION_ENTRY(env, array, start, len, (uint32_t*) buf), + HOTSPOT_JNI_GETINTARRAYREGION_RETURN()); +DEFINE_GETSCALARARRAYREGION(T_LONG, jlong, Long, long + , HOTSPOT_JNI_GETLONGARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf), + HOTSPOT_JNI_GETLONGARRAYREGION_RETURN()); +DEFINE_GETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float + , HOTSPOT_JNI_GETFLOATARRAYREGION_ENTRY(env, array, start, len, (float *) buf), + HOTSPOT_JNI_GETFLOATARRAYREGION_RETURN()); +DEFINE_GETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double + , HOTSPOT_JNI_GETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf), + HOTSPOT_JNI_GETDOUBLEARRAYREGION_RETURN()); +#endif /* USDT2 */ + +#ifdef USDT1 #define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion);\ \ @@ -2394,6 +3992,58 @@ DEFINE_SETSCALARARRAYREGION(T_LONG, jlong, Long, long) DEFINE_SETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) +#endif /* USDT1 */ +#ifdef USDT2 +#define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \ + , EntryProbe, ReturnProbe); \ + DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion \ + ,ReturnProbe); \ +\ +JNI_ENTRY(void, \ +jni_Set##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ + jsize len, const ElementType *buf)) \ + JNIWrapper("Set" XSTR(Result) "ArrayRegion"); \ + EntryProbe; \ + DT_VOID_RETURN_MARK(Set##Result##ArrayRegion); \ + typeArrayOop dst = typeArrayOop(JNIHandles::resolve_non_null(array)); \ + if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)dst->length())) { \ + THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ + } else { \ + if (len > 0) { \ + int sc = typeArrayKlass::cast(dst->klass())->log2_element_size(); \ + memcpy((u_char*) dst->Tag##_at_addr(start), \ + (u_char*) buf, \ + len << sc); \ + } \ + } \ +JNI_END + +DEFINE_SETSCALARARRAYREGION(T_BOOLEAN, jboolean, Boolean, bool + , HOTSPOT_JNI_SETBOOLEANARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *)buf), + HOTSPOT_JNI_SETBOOLEANARRAYREGION_RETURN()) +DEFINE_SETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte + , HOTSPOT_JNI_SETBYTEARRAYREGION_ENTRY(env, array, start, len, (char *) buf), + HOTSPOT_JNI_SETBYTEARRAYREGION_RETURN()) +DEFINE_SETSCALARARRAYREGION(T_SHORT, jshort, Short, short + , HOTSPOT_JNI_SETSHORTARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf), + HOTSPOT_JNI_SETSHORTARRAYREGION_RETURN()) +DEFINE_SETSCALARARRAYREGION(T_CHAR, jchar, Char, char + , HOTSPOT_JNI_SETCHARARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf), + HOTSPOT_JNI_SETCHARARRAYREGION_RETURN()) +DEFINE_SETSCALARARRAYREGION(T_INT, jint, Int, int + , HOTSPOT_JNI_SETINTARRAYREGION_ENTRY(env, array, start, len, (uint32_t *) buf), + HOTSPOT_JNI_SETINTARRAYREGION_RETURN()) +DEFINE_SETSCALARARRAYREGION(T_LONG, jlong, Long, long + , HOTSPOT_JNI_SETLONGARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf), + HOTSPOT_JNI_SETLONGARRAYREGION_RETURN()) +DEFINE_SETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float + , HOTSPOT_JNI_SETFLOATARRAYREGION_ENTRY(env, array, start, len, (float *) buf), + HOTSPOT_JNI_SETFLOATARRAYREGION_RETURN()) +DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double + , HOTSPOT_JNI_SETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf), + HOTSPOT_JNI_SETDOUBLEARRAYREGION_RETURN()) + +#endif /* USDT2 */ // @@ -2476,13 +4126,25 @@ return true; } +#ifdef USDT1 DT_RETURN_MARK_DECL(RegisterNatives, jint); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(RegisterNatives, jint + , HOTSPOT_JNI_REGISTERNATIVES_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz, const JNINativeMethod *methods, jint nMethods)) JNIWrapper("RegisterNatives"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, RegisterNatives__entry, env, clazz, methods, nMethods); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_REGISTERNATIVES_ENTRY( + env, clazz, (void *) methods, nMethods); +#endif /* USDT2 */ jint ret = 0; DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret); @@ -2520,7 +4182,13 @@ JNI_ENTRY(jint, jni_UnregisterNatives(JNIEnv *env, jclass clazz)) JNIWrapper("UnregisterNatives"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, UnregisterNatives__entry, env, clazz); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_UNREGISTERNATIVES_ENTRY( + env, clazz); +#endif /* USDT2 */ klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz)); //%note jni_2 if (Klass::cast(k)->oop_is_instance()) { @@ -2532,7 +4200,13 @@ } } } +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, UnregisterNatives__return, 0); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_UNREGISTERNATIVES_RETURN( + 0); +#endif /* USDT2 */ return 0; JNI_END @@ -2540,10 +4214,22 @@ // Monitor functions // +#ifdef USDT1 DT_RETURN_MARK_DECL(MonitorEnter, jint); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(MonitorEnter, jint + , HOTSPOT_JNI_MONITORENTER_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jint, jni_MonitorEnter(JNIEnv *env, jobject jobj)) +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, MonitorEnter__entry, env, jobj); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_MONITORENTER_ENTRY( + env, jobj); +#endif /* USDT2 */ jint ret = JNI_ERR; DT_RETURN_MARK(MonitorEnter, jint, (const jint&)ret); @@ -2558,10 +4244,22 @@ return ret; JNI_END +#ifdef USDT1 DT_RETURN_MARK_DECL(MonitorExit, jint); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(MonitorExit, jint + , HOTSPOT_JNI_MONITOREXIT_RETURN(_ret_ref)); +#endif /* USDT2 */ JNI_ENTRY(jint, jni_MonitorExit(JNIEnv *env, jobject jobj)) +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, MonitorExit__entry, env, jobj); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_MONITOREXIT_ENTRY( + env, jobj); +#endif /* USDT2 */ jint ret = JNI_ERR; DT_RETURN_MARK(MonitorExit, jint, (const jint&)ret); @@ -2581,11 +4279,23 @@ // Extensions // +#ifdef USDT1 DT_VOID_RETURN_MARK_DECL(GetStringRegion); +#endif /* USDT1 */ +#ifdef USDT2 +DT_VOID_RETURN_MARK_DECL(GetStringRegion + , HOTSPOT_JNI_GETSTRINGREGION_RETURN()); +#endif /* USDT2 */ JNI_ENTRY(void, jni_GetStringRegion(JNIEnv *env, jstring string, jsize start, jsize len, jchar *buf)) JNIWrapper("GetStringRegion"); +#ifdef USDT1 DTRACE_PROBE5(hotspot_jni, GetStringRegion__entry, env, string, start, len, buf); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGREGION_ENTRY( + env, string, start, len, buf); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(GetStringRegion); oop s = JNIHandles::resolve_non_null(string); int s_len = java_lang_String::length(s); @@ -2600,11 +4310,23 @@ } JNI_END +#ifdef USDT1 DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion); +#endif /* USDT1 */ +#ifdef USDT2 +DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion + , HOTSPOT_JNI_GETSTRINGUTFREGION_RETURN()); +#endif /* USDT2 */ JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start, jsize len, char *buf)) JNIWrapper("GetStringUTFRegion"); +#ifdef USDT1 DTRACE_PROBE5(hotspot_jni, GetStringUTFRegion__entry, env, string, start, len, buf); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGUTFREGION_ENTRY( + env, string, start, len, buf); +#endif /* USDT2 */ DT_VOID_RETURN_MARK(GetStringUTFRegion); oop s = JNIHandles::resolve_non_null(string); int s_len = java_lang_String::length(s); @@ -2630,7 +4352,13 @@ JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy)) JNIWrapper("GetPrimitiveArrayCritical"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, GetPrimitiveArrayCritical__entry, env, array, isCopy); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_ENTRY( + env, array, (uintptr_t *) isCopy); +#endif /* USDT2 */ GC_locker::lock_critical(thread); if (isCopy != NULL) { *isCopy = JNI_FALSE; @@ -2644,23 +4372,47 @@ type = typeArrayKlass::cast(a->klass())->element_type(); } void* ret = arrayOop(a)->base(type); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetPrimitiveArrayCritical__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode)) JNIWrapper("ReleasePrimitiveArrayCritical"); +#ifdef USDT1 DTRACE_PROBE4(hotspot_jni, ReleasePrimitiveArrayCritical__entry, env, array, carray, mode); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY( + env, array, carray, mode); +#endif /* USDT2 */ // The array, carray and mode arguments are ignored GC_locker::unlock_critical(thread); +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, ReleasePrimitiveArrayCritical__return); +#endif /* USDT1 */ +#ifdef USDT2 +HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN( +); +#endif /* USDT2 */ JNI_END JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy)) JNIWrapper("GetStringCritical"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, GetStringCritical__entry, env, string, isCopy); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY( + env, string, (uintptr_t *) isCopy); +#endif /* USDT2 */ GC_locker::lock_critical(thread); if (isCopy != NULL) { *isCopy = JNI_FALSE; @@ -2675,44 +4427,98 @@ } else { ret = (jchar*) s_value->base(T_CHAR); } +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetStringCritical__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETSTRINGCRITICAL_RETURN( + (uint16_t *) ret); +#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(void, jni_ReleaseStringCritical(JNIEnv *env, jstring str, const jchar *chars)) JNIWrapper("ReleaseStringCritical"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, ReleaseStringCritical__entry, env, str, chars); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_RELEASESTRINGCRITICAL_ENTRY( + env, str, (uint16_t *) chars); +#endif /* USDT2 */ // The str and chars arguments are ignored GC_locker::unlock_critical(thread); +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, ReleaseStringCritical__return); +#endif /* USDT1 */ +#ifdef USDT2 +HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN( +); +#endif /* USDT2 */ JNI_END JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref)) JNIWrapper("jni_NewWeakGlobalRef"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, NewWeakGlobalRef__entry, env, ref); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY( + env, ref); +#endif /* USDT2 */ Handle ref_handle(thread, JNIHandles::resolve(ref)); jweak ret = JNIHandles::make_weak_global(ref_handle); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, NewWeakGlobalRef__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END // Must be JNI_ENTRY (with HandleMark) JNI_ENTRY(void, jni_DeleteWeakGlobalRef(JNIEnv *env, jweak ref)) JNIWrapper("jni_DeleteWeakGlobalRef"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, DeleteWeakGlobalRef__entry, env, ref); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DELETEWEAKGLOBALREF_ENTRY( + env, ref); +#endif /* USDT2 */ JNIHandles::destroy_weak_global(ref); +#ifdef USDT1 DTRACE_PROBE(hotspot_jni, DeleteWeakGlobalRef__return); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DELETEWEAKGLOBALREF_RETURN( + ); +#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(jboolean, jni_ExceptionCheck(JNIEnv *env)) JNIWrapper("jni_ExceptionCheck"); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, ExceptionCheck__entry, env); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_EXCEPTIONCHECK_ENTRY( + env); +#endif /* USDT2 */ jni_check_async_exceptions(thread); jboolean ret = (thread->has_pending_exception()) ? JNI_TRUE : JNI_FALSE; +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, ExceptionCheck__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_EXCEPTIONCHECK_RETURN( + ret); +#endif /* USDT2 */ return ret; JNI_END @@ -2804,11 +4610,23 @@ JavaThread* thread = JavaThread::thread_from_jni_environment(env); JNIWrapper("jni_NewDirectByteBuffer"); +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, NewDirectByteBuffer__entry, env, address, capacity); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_ENTRY( + env, address, capacity); +#endif /* USDT2 */ if (!directBufferSupportInitializeEnded) { if (!initializeDirectBufferSupport(env, thread)) { +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, NULL); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN( + NULL); +#endif /* USDT2 */ return NULL; } } @@ -2819,11 +4637,23 @@ // takes int capacity jint cap = (jint) capacity; jobject ret = env->NewObject(directByteBufferClass, directByteBufferConstructor, addr, cap); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN( + ret); +#endif /* USDT2 */ return ret; } +#ifdef USDT1 DT_RETURN_MARK_DECL(GetDirectBufferAddress, void*); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(GetDirectBufferAddress, void* + , HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_RETURN((void*) _ret_ref)); +#endif /* USDT2 */ extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) { @@ -2831,7 +4661,13 @@ JavaThread* thread = JavaThread::thread_from_jni_environment(env); JNIWrapper("jni_GetDirectBufferAddress"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, GetDirectBufferAddress__entry, env, buf); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_ENTRY( + env, buf); +#endif /* USDT2 */ void* ret = NULL; DT_RETURN_MARK(GetDirectBufferAddress, void*, (const void*&)ret); @@ -2849,7 +4685,13 @@ return ret; } +#ifdef USDT1 DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong + , HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_RETURN(_ret_ref)); +#endif /* USDT2 */ extern "C" jlong JNICALL jni_GetDirectBufferCapacity(JNIEnv *env, jobject buf) { @@ -2857,7 +4699,13 @@ JavaThread* thread = JavaThread::thread_from_jni_environment(env); JNIWrapper("jni_GetDirectBufferCapacity"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, GetDirectBufferCapacity__entry, env, buf); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_ENTRY( + env, buf); +#endif /* USDT2 */ jlong ret = -1; DT_RETURN_MARK(GetDirectBufferCapacity, jlong, (const jlong&)ret); @@ -2884,8 +4732,20 @@ JNI_LEAF(jint, jni_GetVersion(JNIEnv *env)) JNIWrapper("GetVersion"); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetVersion__entry, env); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETVERSION_ENTRY( + env); +#endif /* USDT2 */ +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetVersion__return, CurrentVersion); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETVERSION_RETURN( + CurrentVersion); +#endif /* USDT2 */ return CurrentVersion; JNI_END @@ -2893,9 +4753,21 @@ JNI_LEAF(jint, jni_GetJavaVM(JNIEnv *env, JavaVM **vm)) JNIWrapper("jni_GetJavaVM"); +#ifdef USDT1 DTRACE_PROBE2(hotspot_jni, GetJavaVM__entry, env, vm); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETJAVAVM_ENTRY( + env, (void **) vm); +#endif /* USDT2 */ *vm = (JavaVM *)(&main_vm); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, GetJavaVM__return, JNI_OK); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETJAVAVM_RETURN( + JNI_OK); +#endif /* USDT2 */ return JNI_OK; JNI_END @@ -3275,11 +5147,23 @@ #define JAVASTACKSIZE (400 * 1024) /* Default size of a thread java stack */ enum { VERIFY_NONE, VERIFY_REMOTE, VERIFY_ALL }; +#ifdef USDT1 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, void*); DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint + , HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_RETURN(_ret_ref)); +#endif /* USDT2 */ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) { +#ifdef USDT1 HS_DTRACE_PROBE1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, args_); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_ENTRY( + args_); +#endif /* USDT2 */ JDK1_1InitArgs *args = (JDK1_1InitArgs *)args_; jint ret = JNI_ERR; DT_RETURN_MARK(GetDefaultJavaVMInitArgs, jint, (const jint&)ret); @@ -3300,12 +5184,23 @@ return ret; } +#ifdef USDT1 HS_DTRACE_PROBE_DECL3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); DT_RETURN_MARK_DECL(CreateJavaVM, jint); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(CreateJavaVM, jint + , HOTSPOT_JNI_CREATEJAVAVM_RETURN(_ret_ref)); +#endif /* USDT2 */ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, void *args) { +#ifdef USDT1 HS_DTRACE_PROBE3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); - +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_CREATEJAVAVM_ENTRY( + (void **) vm, penv, args); +#endif /* USDT2 */ jint result = JNI_ERR; DT_RETURN_MARK(CreateJavaVM, jint, (const jint&)result); @@ -3393,31 +5288,57 @@ return result; } +#ifdef USDT1 HS_DTRACE_PROBE_DECL3(hotspot_jni, GetCreatedJavaVMs__entry, \ JavaVM**, jsize, jsize*); HS_DTRACE_PROBE_DECL1(hotspot_jni, GetCreatedJavaVMs__return, jint); +#endif /* USDT1 */ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **vm_buf, jsize bufLen, jsize *numVMs) { // See bug 4367188, the wrapper can sometimes cause VM crashes // JNIWrapper("GetCreatedJavaVMs"); +#ifdef USDT1 HS_DTRACE_PROBE3(hotspot_jni, GetCreatedJavaVMs__entry, \ vm_buf, bufLen, numVMs); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETCREATEDJAVAVMS_ENTRY( + (void **) vm_buf, bufLen, (uintptr_t *) numVMs); +#endif /* USDT2 */ if (vm_created) { if (numVMs != NULL) *numVMs = 1; if (bufLen > 0) *vm_buf = (JavaVM *)(&main_vm); } else { if (numVMs != NULL) *numVMs = 0; } +#ifdef USDT1 HS_DTRACE_PROBE1(hotspot_jni, GetCreatedJavaVMs__return, JNI_OK); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETCREATEDJAVAVMS_RETURN( + JNI_OK); +#endif /* USDT2 */ return JNI_OK; } extern "C" { +#ifdef USDT1 DT_RETURN_MARK_DECL(DestroyJavaVM, jint); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(DestroyJavaVM, jint + , HOTSPOT_JNI_DESTROYJAVAVM_RETURN(_ret_ref)); +#endif /* USDT2 */ jint JNICALL jni_DestroyJavaVM(JavaVM *vm) { +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, DestroyJavaVM__entry, vm); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DESTROYJAVAVM_ENTRY( + vm); +#endif /* USDT2 */ jint res = JNI_ERR; DT_RETURN_MARK(DestroyJavaVM, jint, (const jint&)res); @@ -3563,34 +5484,70 @@ jint JNICALL jni_AttachCurrentThread(JavaVM *vm, void **penv, void *_args) { +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, AttachCurrentThread__entry, vm, penv, _args); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ATTACHCURRENTTHREAD_ENTRY( + vm, penv, _args); +#endif /* USDT2 */ if (!vm_created) { +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, JNI_ERR); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN( + (uint32_t) JNI_ERR); +#endif /* USDT2 */ return JNI_ERR; } JNIWrapper("AttachCurrentThread"); jint ret = attach_current_thread(vm, penv, _args, false); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN( + ret); +#endif /* USDT2 */ return ret; } jint JNICALL jni_DetachCurrentThread(JavaVM *vm) { +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__entry, vm); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DETACHCURRENTTHREAD_ENTRY( + vm); +#endif /* USDT2 */ VM_Exit::block_if_vm_exited(); JNIWrapper("DetachCurrentThread"); // If the thread has been deattacted the operations is a no-op if (ThreadLocalStorage::thread() == NULL) { +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN( + JNI_OK); +#endif /* USDT2 */ return JNI_OK; } JavaThread* thread = JavaThread::current(); if (thread->has_last_Java_frame()) { +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_ERR); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN( + (uint32_t) JNI_ERR); +#endif /* USDT2 */ // Can't detach a thread that's running java, that can't work. return JNI_ERR; } @@ -3611,14 +5568,32 @@ thread->exit(false, JavaThread::jni_detach); delete thread; +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN( + JNI_OK); +#endif /* USDT2 */ return JNI_OK; } +#ifdef USDT1 DT_RETURN_MARK_DECL(GetEnv, jint); +#endif /* USDT1 */ +#ifdef USDT2 +DT_RETURN_MARK_DECL(GetEnv, jint + , HOTSPOT_JNI_GETENV_RETURN(_ret_ref)); +#endif /* USDT2 */ jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) { +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, GetEnv__entry, vm, penv, version); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_GETENV_ENTRY( + vm, penv, version); +#endif /* USDT2 */ jint ret = JNI_ERR; DT_RETURN_MARK(GetEnv, jint, (const jint&)ret); @@ -3673,15 +5648,33 @@ jint JNICALL jni_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *_args) { +#ifdef USDT1 DTRACE_PROBE3(hotspot_jni, AttachCurrentThreadAsDaemon__entry, vm, penv, _args); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_ENTRY( + vm, penv, _args); +#endif /* USDT2 */ if (!vm_created) { +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, JNI_ERR); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN( + (uint32_t) JNI_ERR); +#endif /* USDT2 */ return JNI_ERR; } JNIWrapper("AttachCurrentThreadAsDaemon"); jint ret = attach_current_thread(vm, penv, _args, true); +#ifdef USDT1 DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, ret); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN( + ret); +#endif /* USDT2 */ return ret; } diff -ru bsd-port/hotspot/src/share/vm/prims/jvm.cpp macosx-port/hotspot/src/share/vm/prims/jvm.cpp --- bsd-port/hotspot/src/share/vm/prims/jvm.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/prims/jvm.cpp 2011-07-19 10:56:41.000000000 -0600 @@ -78,9 +78,11 @@ #include <errno.h> +#ifdef USDT1 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__begin, long long); HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__end, int); HS_DTRACE_PROBE_DECL0(hotspot, thread__yield); +#endif /* USDT1 */ /* NOTE about use of any ctor or function call that can trigger a safepoint/GC: @@ -2824,7 +2826,12 @@ JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) JVMWrapper("JVM_Yield"); if (os::dont_yield()) return; +#ifdef USDT1 HS_DTRACE_PROBE0(hotspot, thread__yield); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_THREAD_YIELD(); +#endif /* USDT2 */ // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. // Critical for similar threading behaviour if (ConvertYieldToSleep) { @@ -2850,7 +2857,13 @@ // And set new thread state to SLEEPING. JavaThreadSleepState jtss(thread); +#ifdef USDT1 HS_DTRACE_PROBE1(hotspot, thread__sleep__begin, millis); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_THREAD_SLEEP_BEGIN( + millis); +#endif /* USDT2 */ if (millis == 0) { // When ConvertSleepToYield is on, this matches the classic VM implementation of @@ -2872,7 +2885,13 @@ // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on // us while we were sleeping. We do not overwrite those. if (!HAS_PENDING_EXCEPTION) { +#ifdef USDT1 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,1); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_THREAD_SLEEP_END( + 1); +#endif /* USDT2 */ // TODO-FIXME: THROW_MSG returns which means we will not call set_state() // to properly restore the thread state. That's likely wrong. THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); @@ -2880,7 +2899,13 @@ } thread->osthread()->set_state(old_state); } +#ifdef USDT1 HS_DTRACE_PROBE1(hotspot, thread__sleep__end,0); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_THREAD_SLEEP_END( + 0); +#endif /* USDT2 */ JVM_END JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) @@ -2998,6 +3023,20 @@ } JVM_END +JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name)) + JVMWrapper("JVM_SetNativeThreadName"); + ResourceMark rm(THREAD); + oop java_thread = JNIHandles::resolve_non_null(jthread); + JavaThread* thr = java_lang_Thread::thread(java_thread); + // Thread naming only supported for the current thread, doesn't work for + // target threads. + if (Thread::current() == thr && !thr->is_attached()) { + // we don't set the name of an attached thread to avoid stepping + // on other programs + const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); + os::set_native_thread_name(thread_name); + } +JVM_END // java.lang.SecurityManager /////////////////////////////////////////////////////////////////////// diff -ru bsd-port/hotspot/src/share/vm/prims/jvm.h macosx-port/hotspot/src/share/vm/prims/jvm.h --- bsd-port/hotspot/src/share/vm/prims/jvm.h 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/prims/jvm.h 2011-05-20 12:15:41.000000000 -0600 @@ -293,6 +293,9 @@ JNIEXPORT jobjectArray JNICALL JVM_GetAllThreads(JNIEnv *env, jclass dummy); +JNIEXPORT void JNICALL +JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name); + /* getStackTrace() and getAllStackTraces() method */ JNIEXPORT jobjectArray JNICALL JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads); diff -ru bsd-port/hotspot/src/share/vm/prims/unsafe.cpp macosx-port/hotspot/src/share/vm/prims/unsafe.cpp --- bsd-port/hotspot/src/share/vm/prims/unsafe.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/prims/unsafe.cpp 2011-07-19 11:52:49.000000000 -0600 @@ -43,9 +43,11 @@ * Implementation of class sun.misc.Unsafe */ +#ifdef USDT1 HS_DTRACE_PROBE_DECL3(hotspot, thread__park__begin, uintptr_t, int, long long); HS_DTRACE_PROBE_DECL1(hotspot, thread__park__end, uintptr_t); HS_DTRACE_PROBE_DECL1(hotspot, thread__unpark, uintptr_t); +#endif /* USDT1 */ #define MAX_OBJECT_SIZE \ ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \ @@ -1175,10 +1177,22 @@ UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time)) UnsafeWrapper("Unsafe_Park"); +#ifdef USDT1 HS_DTRACE_PROBE3(hotspot, thread__park__begin, thread->parker(), (int) isAbsolute, time); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_THREAD_PARK_BEGIN( + (uintptr_t) thread->parker(), (int) isAbsolute, time); +#endif /* USDT2 */ JavaThreadParkedState jtps(thread, time != 0); thread->parker()->park(isAbsolute != 0, time); +#ifdef USDT1 HS_DTRACE_PROBE1(hotspot, thread__park__end, thread->parker()); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_THREAD_PARK_END( + (uintptr_t) thread->parker()); +#endif /* USDT2 */ UNSAFE_END UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread)) @@ -1210,7 +1224,13 @@ } } if (p != NULL) { +#ifdef USDT1 HS_DTRACE_PROBE1(hotspot, thread__unpark, p); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_THREAD_UNPARK( + (uintptr_t) p); +#endif /* USDT2 */ p->unpark(); } UNSAFE_END diff -ru bsd-port/hotspot/src/share/vm/runtime/arguments.cpp macosx-port/hotspot/src/share/vm/runtime/arguments.cpp --- bsd-port/hotspot/src/share/vm/runtime/arguments.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/arguments.cpp 2011-07-22 12:14:35.000000000 -0600 @@ -2578,16 +2578,16 @@ FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false); FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true); } else if (match_option(option, "-XX:+ExtendedDTraceProbes", &tail)) { -#ifdef SOLARIS +#if defined(DTRACE_ENABLED) FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true); FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true); FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true); FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true); -#else // ndef SOLARIS +#else // defined(DTRACE_ENABLED) jio_fprintf(defaultStream::error_stream(), - "ExtendedDTraceProbes flag is only applicable on Solaris\n"); + "ExtendedDTraceProbes flag is not applicable for this configuration\n"); return JNI_EINVAL; -#endif // ndef SOLARIS +#endif // defined(DTRACE_ENABLED) #ifdef ASSERT } else if (match_option(option, "-XX:+FullGCALot", &tail)) { FLAG_SET_CMDLINE(bool, FullGCALot, true); diff -ru bsd-port/hotspot/src/share/vm/runtime/java.cpp macosx-port/hotspot/src/share/vm/runtime/java.cpp --- bsd-port/hotspot/src/share/vm/runtime/java.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/java.cpp 2011-06-28 17:01:48.000000000 -0600 @@ -105,7 +105,9 @@ #include "opto/runtime.hpp" #endif +#ifdef USDT1 HS_DTRACE_PROBE_DECL(hotspot, vm__shutdown); +#endif /* USDT1 */ #ifndef PRODUCT @@ -548,8 +550,13 @@ void notify_vm_shutdown() { // For now, just a dtrace probe. +#ifdef USDT1 HS_DTRACE_PROBE(hotspot, vm__shutdown); HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_VM_SHUTDOWN(); +#endif /* USDT2 */ } void vm_direct_exit(int code) { diff -ru bsd-port/hotspot/src/share/vm/runtime/objectMonitor.cpp macosx-port/hotspot/src/share/vm/runtime/objectMonitor.cpp --- bsd-port/hotspot/src/share/vm/runtime/objectMonitor.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/objectMonitor.cpp 2011-07-19 11:16:59.000000000 -0600 @@ -68,16 +68,6 @@ // Only bother with this argument setup if dtrace is available // TODO-FIXME: probes should not fire when caller is _blocked. assert() accordingly. -HS_DTRACE_PROBE_DECL4(hotspot, monitor__notify, - jlong, uintptr_t, char*, int); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__notifyAll, - jlong, uintptr_t, char*, int); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__enter, - jlong, uintptr_t, char*, int); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__entered, - jlong, uintptr_t, char*, int); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__exit, - jlong, uintptr_t, char*, int); #define DTRACE_MONITOR_PROBE_COMMON(klassOop, thread) \ char* bytes = NULL; \ @@ -89,6 +79,19 @@ len = klassname->utf8_length(); \ } +#ifdef USDT1 + +HS_DTRACE_PROBE_DECL4(hotspot, monitor__notify, + jlong, uintptr_t, char*, int); +HS_DTRACE_PROBE_DECL4(hotspot, monitor__notifyAll, + jlong, uintptr_t, char*, int); +HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__enter, + jlong, uintptr_t, char*, int); +HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__entered, + jlong, uintptr_t, char*, int); +HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__exit, + jlong, uintptr_t, char*, int); + #define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis) \ { \ if (DTraceMonitorProbes) { \ @@ -107,6 +110,35 @@ } \ } +#endif /* USDT1 */ + +#ifdef USDT2 + +#define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis) \ + { \ + if (DTraceMonitorProbes) { \ + DTRACE_MONITOR_PROBE_COMMON(klassOop, thread); \ + HOTSPOT_MONITOR_WAIT(jtid, \ + (monitor), bytes, len, (millis)); \ + } \ + } + +#define HOTSPOT_MONITOR_contended__enter HOTSPOT_MONITOR_CONTENDED_ENTER +#define HOTSPOT_MONITOR_contended__entered HOTSPOT_MONITOR_CONTENDED_ENTERED +#define HOTSPOT_MONITOR_contended__exit HOTSPOT_MONITOR_CONTENDED_EXIT +#define HOTSPOT_MONITOR_notify HOTSPOT_MONITOR_NOTIFY +#define HOTSPOT_MONITOR_notifyAll HOTSPOT_MONITOR_NOTIFYALL + +#define DTRACE_MONITOR_PROBE(probe, monitor, klassOop, thread) \ + { \ + if (DTraceMonitorProbes) { \ + DTRACE_MONITOR_PROBE_COMMON(klassOop, thread); \ + HOTSPOT_MONITOR_##probe(jtid, \ + (uintptr_t)(monitor), bytes, len); \ + } \ + } + +#endif /* USDT2 */ #else // ndef DTRACE_ENABLED #define DTRACE_MONITOR_WAIT_PROBE(klassOop, thread, millis, mon) {;} diff -ru bsd-port/hotspot/src/share/vm/runtime/os.cpp macosx-port/hotspot/src/share/vm/runtime/os.cpp --- bsd-port/hotspot/src/share/vm/runtime/os.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/os.cpp 2011-05-20 12:15:41.000000000 -0600 @@ -1094,6 +1094,12 @@ "%/lib/jsse.jar:" "%/lib/jce.jar:" "%/lib/charsets.jar:" + // ## TEMPORARY hack to keep the legacy launcher working when + // ## only the boot module is installed (cf. j.l.ClassLoader) + "%/lib/modules/jdk.boot.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; diff -ru bsd-port/hotspot/src/share/vm/runtime/os.hpp macosx-port/hotspot/src/share/vm/runtime/os.hpp --- bsd-port/hotspot/src/share/vm/runtime/os.hpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/os.hpp 2011-05-20 12:15:41.000000000 -0600 @@ -187,6 +187,9 @@ // Returns true if it worked, false if it didn't. static bool bind_to_processor(uint processor_id); + // Give a name to the current thread. + static void set_native_thread_name(const char *name); + // Interface for stack banging (predetect possible stack overflow for // exception processing) There are guard pages, and above that shadow // pages for stack overflow checking. diff -ru bsd-port/hotspot/src/share/vm/runtime/sharedRuntime.cpp macosx-port/hotspot/src/share/vm/runtime/sharedRuntime.cpp --- bsd-port/hotspot/src/share/vm/runtime/sharedRuntime.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/sharedRuntime.cpp 2011-07-19 11:21:02.000000000 -0600 @@ -148,11 +148,13 @@ #include <math.h> +#ifdef USDT1 HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t); HS_DTRACE_PROBE_DECL7(hotspot, method__entry, int, char*, int, char*, int, char*, int); HS_DTRACE_PROBE_DECL7(hotspot, method__return, int, char*, int, char*, int, char*, int); +#endif /* USDT1 */ // Implementation of SharedRuntime @@ -954,8 +956,15 @@ Klass* klass = o->blueprint(); int size = o->size(); Symbol* name = klass->name(); +#ifdef USDT1 HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread), name->bytes(), name->utf8_length(), size * HeapWordSize); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_OBJECT_ALLOC( + get_java_tid(thread), + (char *) name->bytes(), name->utf8_length(), size * HeapWordSize); +#endif /* USDT2 */ return 0; } @@ -965,10 +974,19 @@ Symbol* kname = method->klass_name(); Symbol* name = method->name(); Symbol* sig = method->signature(); +#ifdef USDT1 HS_DTRACE_PROBE7(hotspot, method__entry, get_java_tid(thread), kname->bytes(), kname->utf8_length(), name->bytes(), name->utf8_length(), sig->bytes(), sig->utf8_length()); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_METHOD_ENTRY( + get_java_tid(thread), + (char *) kname->bytes(), kname->utf8_length(), + (char *) name->bytes(), name->utf8_length(), + (char *) sig->bytes(), sig->utf8_length()); +#endif /* USDT2 */ return 0; JRT_END @@ -978,10 +996,19 @@ Symbol* kname = method->klass_name(); Symbol* name = method->name(); Symbol* sig = method->signature(); +#ifdef USDT1 HS_DTRACE_PROBE7(hotspot, method__return, get_java_tid(thread), kname->bytes(), kname->utf8_length(), name->bytes(), name->utf8_length(), sig->bytes(), sig->utf8_length()); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_METHOD_RETURN( + get_java_tid(thread), + (char *) kname->bytes(), kname->utf8_length(), + (char *) name->bytes(), name->utf8_length(), + (char *) sig->bytes(), sig->utf8_length()); +#endif /* USDT2 */ return 0; JRT_END diff -ru bsd-port/hotspot/src/share/vm/runtime/synchronizer.cpp macosx-port/hotspot/src/share/vm/runtime/synchronizer.cpp --- bsd-port/hotspot/src/share/vm/runtime/synchronizer.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/synchronizer.cpp 2011-07-19 11:29:48.000000000 -0600 @@ -77,11 +77,6 @@ // Only bother with this argument setup if dtrace is available // TODO-FIXME: probes should not fire when caller is _blocked. assert() accordingly. -HS_DTRACE_PROBE_DECL5(hotspot, monitor__wait, - jlong, uintptr_t, char*, int, long); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__waited, - jlong, uintptr_t, char*, int); - #define DTRACE_MONITOR_PROBE_COMMON(klassOop, thread) \ char* bytes = NULL; \ int len = 0; \ @@ -92,7 +87,13 @@ len = klassname->utf8_length(); \ } -#define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis) \ +#ifdef USDT1 +HS_DTRACE_PROBE_DECL5(hotspot, monitor__wait, + jlong, uintptr_t, char*, int, long); +HS_DTRACE_PROBE_DECL4(hotspot, monitor__waited, + jlong, uintptr_t, char*, int); + +#Define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis) \ { \ if (DTraceMonitorProbes) { \ DTRACE_MONITOR_PROBE_COMMON(klassOop, thread); \ @@ -110,6 +111,30 @@ } \ } +#endif /* USDT1 */ +#ifdef USDT2 + +#define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis) \ + { \ + if (DTraceMonitorProbes) { \ + DTRACE_MONITOR_PROBE_COMMON(klassOop, thread); \ + HOTSPOT_MONITOR_WAIT(jtid, \ + (uintptrt)(monitor), bytes, len, (millis)); \ + } \ + } + +#define HOTSPOT_MONITOR_PROBE_waited HOTSPOT_MONITOR_PROBE_WAITED + +#define DTRACE_MONITOR_PROBE(probe, monitor, klassOop, thread) \ + { \ + if (DTraceMonitorProbes) { \ + DTRACE_MONITOR_PROBE_COMMON(klassOop, thread); \ + HOTSPOT_MONITOR_PROBE_##probe(jtid, /* probe = waited */ \ + (uintptr_t)(monitor), bytes, len); \ + } \ + } + +#endif /* USDT2 */ #else // ndef DTRACE_ENABLED #define DTRACE_MONITOR_WAIT_PROBE(klassOop, thread, millis, mon) {;} @@ -360,7 +385,6 @@ THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative"); } ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj()); - DTRACE_MONITOR_WAIT_PROBE(monitor, obj(), THREAD, millis); monitor->wait(millis, true, THREAD); /* This dummy call is in place to get around dtrace bug 6254741. Once diff -ru bsd-port/hotspot/src/share/vm/runtime/thread.cpp macosx-port/hotspot/src/share/vm/runtime/thread.cpp --- bsd-port/hotspot/src/share/vm/runtime/thread.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/thread.cpp 2011-07-19 11:47:31.000000000 -0600 @@ -110,6 +110,7 @@ // Only bother with this argument setup if dtrace is available +#ifdef USDT1 HS_DTRACE_PROBE_DECL(hotspot, vm__init__begin); HS_DTRACE_PROBE_DECL(hotspot, vm__init__end); HS_DTRACE_PROBE_DECL5(hotspot, thread__start, char*, intptr_t, @@ -130,6 +131,28 @@ java_lang_Thread::is_daemon((javathread)->threadObj())); \ } +#endif /* USDT1 */ + +#ifdef USDT2 + +#define HOTSPOT_THREAD_PROBE_start HOTSPOT_THREAD_PROBE_START +#define HOTSPOT_THREAD_PROBE_stop HOTSPOT_THREAD_PROBE_STOP + +#define DTRACE_THREAD_PROBE(probe, javathread) \ + { \ + ResourceMark rm(this); \ + int len = 0; \ + const char* name = (javathread)->get_thread_name(); \ + len = strlen(name); \ + HOTSPOT_THREAD_PROBE_##probe( /* probe = start, stop */ \ + (char *) name, len, \ + java_lang_Thread::thread_id((javathread)->threadObj()), \ + (uintptr_t) (javathread)->osthread()->thread_id(), \ + java_lang_Thread::is_daemon((javathread)->threadObj())); \ + } + +#endif /* USDT2 */ + #else // ndef DTRACE_ENABLED #define DTRACE_THREAD_PROBE(probe, javathread) @@ -1336,7 +1359,7 @@ #endif // !SERIALGC { initialize(); - _is_attaching = is_attaching; + _is_attached = _is_attaching = is_attaching; assert(_deferred_card_mark.is_empty(), "Default MemRegion ctor"); } @@ -1392,7 +1415,7 @@ tty->print_cr("creating thread %p", this); } initialize(); - _is_attaching = false; + _is_attached = _is_attaching = false; set_entry_point(entry_point); // Create the native thread itself. // %note runtime_23 @@ -1504,6 +1527,10 @@ // Note: Due to JVM_StopThread we can have pending exceptions already! if (!this->has_pending_exception() && !java_lang_Thread::is_stillborn(this->threadObj())) { + { + ResourceMark rm(this); + this->set_native_thread_name(this->get_thread_name()); + } HandleMark hm(this); this->entry_point()(this, this); } @@ -3041,7 +3068,12 @@ os::pause(); } +#ifdef USDT1 HS_DTRACE_PROBE(hotspot, vm__init__begin); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_VM_INIT_BEGIN(); +#endif /* USDT2 */ // Record VM creation timing statistics TraceVmCreationTime create_vm_timer; @@ -3296,7 +3328,12 @@ // debug stuff, that does not work until all basic classes have been initialized. set_init_completed(); +#ifdef USDT1 HS_DTRACE_PROBE(hotspot, vm__init__end); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_VM_INIT_END(); +#endif /* USDT2 */ // record VM initialization completion time Management::record_vm_init_completed(); diff -ru bsd-port/hotspot/src/share/vm/runtime/thread.hpp macosx-port/hotspot/src/share/vm/runtime/thread.hpp --- bsd-port/hotspot/src/share/vm/runtime/thread.hpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/thread.hpp 2011-06-03 14:31:02.000000000 -0600 @@ -308,6 +308,11 @@ static void start(Thread* thread); static void interrupt(Thread* thr); static bool is_interrupted(Thread* thr, bool clear_interrupted); + + void set_native_thread_name(const char *name) { + assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread"); + os::set_native_thread_name(name); + } ObjectMonitor** omInUseList_addr() { return (ObjectMonitor **)&omInUseList; } Monitor* SR_lock() const { return _SR_lock; } @@ -822,6 +827,8 @@ // This flag is never set true other than at construction, and in that case // is shortly thereafter set false volatile bool _is_attaching; + // Remember whether or not we were attached + bool _is_attached; public: // State of the stack guard pages for this thread. @@ -1645,6 +1652,7 @@ // clearing/querying jni attach status bool is_attaching() const { return _is_attaching; } + bool is_attached() const { return _is_attached; } void set_attached() { _is_attaching = false; OrderAccess::fence(); } private: // This field is used to determine if a thread has claimed diff -ru bsd-port/hotspot/src/share/vm/runtime/vmThread.cpp macosx-port/hotspot/src/share/vm/runtime/vmThread.cpp --- bsd-port/hotspot/src/share/vm/runtime/vmThread.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/runtime/vmThread.cpp 2011-07-19 11:58:05.000000000 -0600 @@ -50,9 +50,11 @@ # include "thread_bsd.inline.hpp" #endif +#ifdef USDT1 HS_DTRACE_PROBE_DECL3(hotspot, vmops__request, char *, uintptr_t, int); HS_DTRACE_PROBE_DECL3(hotspot, vmops__begin, char *, uintptr_t, int); HS_DTRACE_PROBE_DECL3(hotspot, vmops__end, char *, uintptr_t, int); +#endif /* USDT1 */ // Dummy VM operation to act as first element in our circular double-linked list class VM_Dummy: public VM_Operation { @@ -162,8 +164,15 @@ // High-level interface bool VMOperationQueue::add(VM_Operation *op) { +#ifdef USDT1 HS_DTRACE_PROBE3(hotspot, vmops__request, op->name(), strlen(op->name()), op->evaluation_mode()); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_VMOPS_REQUEST( + (char *) op->name(), strlen(op->name()), + op->evaluation_mode()); +#endif /* USDT2 */ // Encapsulates VM queue policy. Currently, that // only involves putting them on the right list @@ -360,11 +369,25 @@ { PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time()); +#ifdef USDT1 HS_DTRACE_PROBE3(hotspot, vmops__begin, op->name(), strlen(op->name()), op->evaluation_mode()); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_VMOPS_BEGIN( + (char *) op->name(), strlen(op->name()), + op->evaluation_mode()); +#endif /* USDT2 */ op->evaluate(); +#ifdef USDT1 HS_DTRACE_PROBE3(hotspot, vmops__end, op->name(), strlen(op->name()), op->evaluation_mode()); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_VMOPS_END( + (char *) op->name(), strlen(op->name()), + op->evaluation_mode()); +#endif /* USDT2 */ } // Last access of info in _cur_vm_operation! diff -ru bsd-port/hotspot/src/share/vm/services/classLoadingService.cpp macosx-port/hotspot/src/share/vm/services/classLoadingService.cpp --- bsd-port/hotspot/src/share/vm/services/classLoadingService.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/services/classLoadingService.cpp 2011-07-14 19:34:59.000000000 -0600 @@ -36,6 +36,8 @@ // Only bother with this argument setup if dtrace is available +#ifdef USDT1 + HS_DTRACE_PROBE_DECL4(hotspot, class__loaded, char*, int, oop, bool); HS_DTRACE_PROBE_DECL4(hotspot, class__unloaded, char*, int, oop, bool); @@ -52,6 +54,26 @@ data, len, (clss)->class_loader(), (shared)); \ } +#endif /* USDT1 */ + +#ifdef USDT2 + +#define HOTSPOT_CLASS_unloaded HOTSPOT_CLASS_UNLOADED +#define HOTSPOT_CLASS_loaded HOTSPOT_CLASS_LOADED +#define DTRACE_CLASSLOAD_PROBE(type, clss, shared) \ + { \ + char* data = NULL; \ + int len = 0; \ + Symbol* name = (clss)->name(); \ + if (name != NULL) { \ + data = (char*)name->bytes(); \ + len = name->utf8_length(); \ + } \ + HOTSPOT_CLASS_##type( /* type = unloaded, loaded */ \ + data, len, (clss)->class_loader(), (shared)); \ + } + +#endif /* USDT2 */ #else // ndef DTRACE_ENABLED #define DTRACE_CLASSLOAD_PROBE(type, clss, shared) diff -ru bsd-port/hotspot/src/share/vm/services/memoryManager.cpp macosx-port/hotspot/src/share/vm/services/memoryManager.cpp --- bsd-port/hotspot/src/share/vm/services/memoryManager.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/services/memoryManager.cpp 2011-07-19 11:00:16.000000000 -0600 @@ -36,10 +36,12 @@ #include "services/gcNotifier.hpp" #include "utilities/dtrace.hpp" +#ifdef USDT1 HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__begin, char*, int, char*, int, size_t, size_t, size_t, size_t); HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__end, char*, int, char*, int, size_t, size_t, size_t, size_t); +#endif /* USDT1 */ MemoryManager::MemoryManager() { _num_pools = 0; @@ -238,11 +240,20 @@ MemoryPool* pool = MemoryService::get_memory_pool(i); MemoryUsage usage = pool->get_memory_usage(); _current_gc_stat->set_before_gc_usage(i, usage); +#ifdef USDT1 HS_DTRACE_PROBE8(hotspot, mem__pool__gc__begin, name(), strlen(name()), pool->name(), strlen(pool->name()), usage.init_size(), usage.used(), usage.committed(), usage.max_size()); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_MEM_POOL_GC_BEGIN( + (char *) name(), strlen(name()), + (char *) pool->name(), strlen(pool->name()), + usage.init_size(), usage.used(), + usage.committed(), usage.max_size()); +#endif /* USDT2 */ } } } @@ -268,11 +279,20 @@ MemoryPool* pool = MemoryService::get_memory_pool(i); MemoryUsage usage = pool->get_memory_usage(); +#ifdef USDT1 HS_DTRACE_PROBE8(hotspot, mem__pool__gc__end, name(), strlen(name()), pool->name(), strlen(pool->name()), usage.init_size(), usage.used(), usage.committed(), usage.max_size()); +#endif /* USDT1 */ +#ifdef USDT2 + HOTSPOT_MEM_POOL_GC_END( + (char *) name(), strlen(name()), + (char *) pool->name(), strlen(pool->name()), + usage.init_size(), usage.used(), + usage.committed(), usage.max_size()); +#endif /* USDT2 */ _current_gc_stat->set_after_gc_usage(i, usage); } diff -ru bsd-port/hotspot/src/share/vm/services/runtimeService.cpp macosx-port/hotspot/src/share/vm/services/runtimeService.cpp --- bsd-port/hotspot/src/share/vm/services/runtimeService.cpp 2011-07-26 20:21:23.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/services/runtimeService.cpp 2011-06-28 16:17:47.000000000 -0600 @@ -30,8 +30,10 @@ #include "utilities/dtrace.hpp" #include "utilities/exceptions.hpp" +#ifdef USDT1 HS_DTRACE_PROBE_DECL(hs_private, safepoint__begin); HS_DTRACE_PROBE_DECL(hs_private, safepoint__end); +#endif /* USDT1 */ TimeStamp RuntimeService::_app_timer; TimeStamp RuntimeService::_safepoint_timer; @@ -108,7 +110,12 @@ } void RuntimeService::record_safepoint_begin() { +#ifdef USDT1 HS_DTRACE_PROBE(hs_private, safepoint__begin); +#endif /* USDT1 */ +#ifdef USDT2 + HS_PRIVATE_SAFEPOINT_BEGIN(); +#endif /* USDT2 */ // Print the time interval in which the app was executing if (PrintGCApplicationConcurrentTime) { @@ -133,7 +140,12 @@ } void RuntimeService::record_safepoint_end() { +#ifdef USDT1 HS_DTRACE_PROBE(hs_private, safepoint__end); +#endif /* USDT1 */ +#ifdef USDT2 + HS_PRIVATE_SAFEPOINT_END(); +#endif /* USDT2 */ // Print the time interval for which the app was stopped // during the current safepoint operation. diff -ru bsd-port/hotspot/src/share/vm/utilities/debug.cpp macosx-port/hotspot/src/share/vm/utilities/debug.cpp --- bsd-port/hotspot/src/share/vm/utilities/debug.cpp 2011-07-26 20:21:24.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/utilities/debug.cpp 2011-06-28 14:20:26.000000000 -0600 @@ -309,9 +309,6 @@ } } - -extern "C" void ps(); - static bool error_reported = false; // call this when the VM is dying--it might loosen some asserts @@ -370,7 +367,6 @@ // ------ helper functions for debugging go here ------------ -#ifndef PRODUCT // All debug entries should be wrapped with a stack allocated // Command object. It makes sure a resource mark is set and // flushes the logfile to prevent file sharing problems. @@ -385,17 +381,27 @@ static int level; Command(const char* str) { debug_save = Debugging; +#ifndef PRODUCT Debugging = true; +#endif if (level++ > 0) return; tty->cr(); tty->print_cr("\"Executing %s\"", str); } - ~Command() { tty->flush(); Debugging = debug_save; level--; } + ~Command() { + tty->flush(); +#ifndef PRODUCT + Debugging = debug_save; +#endif + level--; + } }; int Command::level = 0; +#ifndef PRODUCT + extern "C" void blob(CodeBlob* cb) { Command c("blob"); cb->print(); @@ -487,7 +493,10 @@ extern "C" void pa(intptr_t p) { ((AllocatedObj*) p)->print(); } extern "C" void findpc(intptr_t x); +#endif // PRODUCT + extern "C" void ps() { // print stack + if (!Thread::current()) return; Command c("ps"); @@ -500,6 +509,11 @@ if (p->has_last_Java_frame()) { // If the last_Java_fp is set we are in C land and // can call the standard stack_trace function. +#ifdef PRODUCT + p->print_stack(); + } else { + tty->print_cr("Cannot find the last Java frame, printing stack disabled."); +#else p->trace_stack(); } else { frame f = os::current_frame(); @@ -508,6 +522,7 @@ tty->print("(guessing starting frame id=%#p based on current fp)\n", f.id()); p->trace_stack_from(vframe::new_vframe(&f, ®_map, p)); pd_ps(f); +#endif // PRODUCT } } @@ -524,6 +539,8 @@ } } +#ifndef PRODUCT + extern "C" void psf() { // print stack frames { Command c("psf"); @@ -555,12 +572,19 @@ SafepointSynchronize::print_state(); } +#endif // PRODUCT extern "C" void pss() { // print all stacks + if (!Thread::current()) return; Command c("pss"); +#ifdef PRODUCT + Threads::print(true, false); +#else Threads::print(true, true); +#endif } +#ifndef PRODUCT extern "C" void debug() { // to set things up for compiler debugging Command c("debug"); diff -ru bsd-port/hotspot/src/share/vm/utilities/dtrace.hpp macosx-port/hotspot/src/share/vm/utilities/dtrace.hpp --- bsd-port/hotspot/src/share/vm/utilities/dtrace.hpp 2011-07-26 20:21:24.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/utilities/dtrace.hpp 2011-07-14 18:58:14.000000000 -0600 @@ -25,8 +25,7 @@ #ifndef SHARE_VM_UTILITIES_DTRACE_HPP #define SHARE_VM_UTILITIES_DTRACE_HPP -#if defined(SOLARIS) && defined(DTRACE_ENABLED) - +#if defined(DTRACE_ENABLED) #include <sys/sdt.h> #define DTRACE_ONLY(x) x @@ -36,11 +35,27 @@ #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() \ do { volatile size_t dtrace_workaround_tail_call_bug = 1; } while (0) -#else // ndef SOLARIS || ndef DTRACE_ENABLED +#if defined(SOLARIS) +#define USDT1 1 +#elif defined(__APPLE__) +#define USDT2 1 +#include <sys/types.h> +#include "dtracefiles/hotspot.h" +#include "dtracefiles/hotspot_jni.h" +#include "dtracefiles/hs_private.h" +#else +#error "dtrace enabled for unknown os" +#endif /* defined(SOLARIS) */ + +#else /* defined(DTRACE_ENABLED) */ #define DTRACE_ONLY(x) #define NOT_DTRACE(x) x +#define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() + +#ifdef USDT1 + #define DTRACE_PROBE(a,b) {;} #define DTRACE_PROBE1(a,b,c) {;} #define DTRACE_PROBE2(a,b,c,d) {;} @@ -48,9 +63,15 @@ #define DTRACE_PROBE4(a,b,c,d,e,f) {;} #define DTRACE_PROBE5(a,b,c,d,e,f,g) {;} -#define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() +#endif /* USDT1 */ + +#ifdef USDT2 +#include "dtrace_usdt2_disabled.hpp" +#endif /* USDT2 */ -#endif +#endif /* defined(DTRACE_ENABLED) */ + +#ifdef USDT1 #define HS_DTRACE_PROBE_FN(provider,name)\ __dtrace_##provider##___##name @@ -133,4 +154,6 @@ (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\ (uintptr_t)a8,(uintptr_t)a9)) +#endif /* USDT1 */ + #endif // SHARE_VM_UTILITIES_DTRACE_HPP Only in macosx-port/hotspot/src/share/vm/utilities: dtrace.hpp.orig Only in macosx-port/hotspot/src/share/vm/utilities: dtrace_disabled.hpp Only in macosx-port/hotspot/src/share/vm/utilities: dtrace_usdt2_disabled.hpp diff -ru bsd-port/hotspot/src/share/vm/utilities/globalDefinitions.hpp macosx-port/hotspot/src/share/vm/utilities/globalDefinitions.hpp --- bsd-port/hotspot/src/share/vm/utilities/globalDefinitions.hpp 2011-07-26 20:21:24.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/utilities/globalDefinitions.hpp 2011-06-03 14:31:02.000000000 -0600 @@ -1209,12 +1209,11 @@ // Format macros that allow the field width to be specified. The width must be // a string literal (e.g., "8") or a macro that evaluates to one. +#define UINTX_FORMAT_W(width) "%" #width PRIuPTR #ifdef _LP64 -#define UINTX_FORMAT_W(width) UINT64_FORMAT_W(width) #define SSIZE_FORMAT_W(width) INT64_FORMAT_W(width) #define SIZE_FORMAT_W(width) UINT64_FORMAT_W(width) #else -#define UINTX_FORMAT_W(width) UINT32_FORMAT_W(width) #define SSIZE_FORMAT_W(width) INT32_FORMAT_W(width) #define SIZE_FORMAT_W(width) UINT32_FORMAT_W(width) #endif // _LP64 @@ -1228,15 +1227,10 @@ // 4.3.2. So we have to use "%016x" or "%08x" to simulate the printing format. // GCC 4.3.2, however requires the data to be converted to "intptr_t" when // using "%x". -#ifdef _LP64 -#define PTR_FORMAT PTR64_FORMAT -#define SIZE_FORMAT UINT64_FORMAT -#define SSIZE_FORMAT INT64_FORMAT -#else // !_LP64 -#define PTR_FORMAT PTR32_FORMAT -#define SIZE_FORMAT UINT32_FORMAT -#define SSIZE_FORMAT INT32_FORMAT -#endif // _LP64 +#define PTR_FORMAT "%08" PRIxPTR +#define SIZE_FORMAT "%" PRIuPTR +#define SSIZE_FORMAT "%" PRIdPTR + #define UINTX_FORMAT "%" PRIuPTR #define INTX_FORMAT "%" PRIdPTR diff -ru bsd-port/hotspot/src/share/vm/utilities/hashtable.cpp macosx-port/hotspot/src/share/vm/utilities/hashtable.cpp --- bsd-port/hotspot/src/share/vm/utilities/hashtable.cpp 2011-07-26 20:21:24.000000000 -0600 +++ macosx-port/hotspot/src/share/vm/utilities/hashtable.cpp 2011-07-18 12:07:07.000000000 -0600 @@ -31,9 +31,10 @@ #include "utilities/hashtable.hpp" #include "utilities/hashtable.inline.hpp" - +#ifdef USDT1 HS_DTRACE_PROBE_DECL4(hs_private, hashtable__new_entry, void*, unsigned int, void*, void*); +#endif /* USDT1 */ // This is a generic hashtable, designed to be used for the symbol // and string tables. @@ -73,8 +74,14 @@ entry = (HashtableEntry<T>*)BasicHashtable::new_entry(hashValue); entry->set_literal(obj); +#ifdef USDT1 HS_DTRACE_PROBE4(hs_private, hashtable__new_entry, this, hashValue, obj, entry); +#endif /* USDT1 */ +#ifdef USDT2 + HS_PRIVATE_HASHTABLE_NEW_ENTRY( + this, hashValue, (uintptr_t) obj, entry); +#endif /* USDT2 */ return entry; }
Overview
Content Tools
ThemeBuilder