7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.

Mon, 08 Oct 2012 09:18:54 -0400

author
coleenp
date
Mon, 08 Oct 2012 09:18:54 -0400
changeset 4148
75982791ddb6
parent 4147
f2eb2d4488db
child 4150
0e8ca886e4e1

7170638: Use DTRACE_PROBE[N] in JNI Set and SetStatic Field.
Summary: Don't use HS_DTRACE_PROBE_CDECL_N and HS_DTRACE_PROBE_N directly.
Reviewed-by: coleenp, kamg, dholmes, sspitsyn
Contributed-by: Mark Wielaard <mjw@redhat.com>

make/bsd/makefiles/buildtree.make file | annotate | diff | comparison | revisions
make/linux/makefiles/buildtree.make file | annotate | diff | comparison | revisions
make/linux/makefiles/dtrace.make file | annotate | diff | comparison | revisions
make/linux/makefiles/vm.make file | annotate | diff | comparison | revisions
make/solaris/makefiles/buildtree.make file | annotate | diff | comparison | revisions
src/share/vm/prims/jni.cpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/dtrace.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/make/bsd/makefiles/buildtree.make	Thu Oct 04 20:09:46 2012 -0400
     1.2 +++ b/make/bsd/makefiles/buildtree.make	Mon Oct 08 09:18:54 2012 -0400
     1.3 @@ -163,6 +163,13 @@
     1.4    endif
     1.5  endif
     1.6  
     1.7 +# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
     1.8 +ifndef OPENJDK
     1.9 +  ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
    1.10 +    OPENJDK=true
    1.11 +  endif
    1.12 +endif
    1.13 +
    1.14  BUILDTREE_VARS += HOTSPOT_RELEASE_VERSION=$(HS_BUILD_VER) HOTSPOT_BUILD_VERSION=  JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
    1.15  
    1.16  BUILDTREE	= \
    1.17 @@ -205,6 +212,7 @@
    1.18  	echo "SA_BUILD_VERSION = $(HS_BUILD_VER)"; \
    1.19  	echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
    1.20  	echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
    1.21 +	echo "OPENJDK = $(OPENJDK)"; \
    1.22  	echo; \
    1.23  	echo "# Used for platform dispatching"; \
    1.24  	echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
     2.1 --- a/make/linux/makefiles/buildtree.make	Thu Oct 04 20:09:46 2012 -0400
     2.2 +++ b/make/linux/makefiles/buildtree.make	Mon Oct 08 09:18:54 2012 -0400
     2.3 @@ -156,6 +156,13 @@
     2.4    endif
     2.5  endif
     2.6  
     2.7 +# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
     2.8 +ifndef OPENJDK
     2.9 +  ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
    2.10 +    OPENJDK=true
    2.11 +  endif
    2.12 +endif
    2.13 +
    2.14  BUILDTREE_VARS += HOTSPOT_RELEASE_VERSION=$(HS_BUILD_VER) HOTSPOT_BUILD_VERSION=  JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
    2.15  
    2.16  BUILDTREE	= \
    2.17 @@ -198,6 +205,7 @@
    2.18  	echo "SA_BUILD_VERSION = $(HS_BUILD_VER)"; \
    2.19  	echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
    2.20  	echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
    2.21 +	echo "OPENJDK = $(OPENJDK)"; \
    2.22  	echo; \
    2.23  	echo "# Used for platform dispatching"; \
    2.24  	echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
     3.1 --- a/make/linux/makefiles/dtrace.make	Thu Oct 04 20:09:46 2012 -0400
     3.2 +++ b/make/linux/makefiles/dtrace.make	Mon Oct 08 09:18:54 2012 -0400
     3.3 @@ -1,5 +1,6 @@
     3.4  #
     3.5 -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
     3.6 +# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     3.7 +# Copyright (c) 2012 Red Hat, Inc.
     3.8  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.9  #
    3.10  # This code is free software; you can redistribute it and/or modify it
    3.11 @@ -25,3 +26,40 @@
    3.12  # Linux does not build jvm_db
    3.13  LIBJVM_DB =
    3.14  
    3.15 +# Only OPENJDK builds test and support SDT probes currently.
    3.16 +ifndef OPENJDK
    3.17 +REASON = "This JDK does not support SDT probes"
    3.18 +else
    3.19 +
    3.20 +# We need a recent GCC for the default
    3.21 +ifeq "$(shell expr \( $(CC_VER_MAJOR) \>= 4 \) \& \( $(CC_VER_MINOR) \>= 4 \) )" "0"
    3.22 +REASON = "gcc version is too old"
    3.23 +else
    3.24 +
    3.25 +# But it does have a SystemTap dtrace compatible sys/sdt.h
    3.26 +ifneq ($(ALT_SDT_H),)
    3.27 +  SDT_H_FILE = $(ALT_SDT_H)
    3.28 +else
    3.29 +  SDT_H_FILE = /usr/include/sys/sdt.h
    3.30 +endif
    3.31 +DTRACE_ENABLED = $(shell test -f $(SDT_H_FILE) && echo $(SDT_H_FILE))
    3.32 +REASON = "$(SDT_H_FILE) not found"
    3.33 +
    3.34 +ifneq ($(DTRACE_ENABLED),)
    3.35 +  CFLAGS += -DDTRACE_ENABLED
    3.36 +endif
    3.37 +
    3.38 +endif
    3.39 +endif
    3.40 +
    3.41 +# Phony target used in vm.make build target to check whether enabled.
    3.42 +.PHONY: dtraceCheck
    3.43 +ifeq ($(DTRACE_ENABLED),)
    3.44 +dtraceCheck:
    3.45 +	$(QUIETLY) echo "**NOTICE** Dtrace support disabled: $(REASON)"
    3.46 +else
    3.47 +dtraceCheck:
    3.48 +endif
    3.49 +
    3.50 +# It doesn't support HAVE_DTRACE_H though.
    3.51 +
     4.1 --- a/make/linux/makefiles/vm.make	Thu Oct 04 20:09:46 2012 -0400
     4.2 +++ b/make/linux/makefiles/vm.make	Mon Oct 08 09:18:54 2012 -0400
     4.3 @@ -387,7 +387,7 @@
     4.4  
     4.5  #----------------------------------------------------------------------
     4.6  
     4.7 -build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(BUILDLIBSAPROC) $(WB_JAR)
     4.8 +build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(BUILDLIBSAPROC) dtraceCheck $(WB_JAR)
     4.9  
    4.10  install: install_jvm install_jsig install_saproc
    4.11  
     5.1 --- a/make/solaris/makefiles/buildtree.make	Thu Oct 04 20:09:46 2012 -0400
     5.2 +++ b/make/solaris/makefiles/buildtree.make	Mon Oct 08 09:18:54 2012 -0400
     5.3 @@ -148,6 +148,13 @@
     5.4    endif
     5.5  endif
     5.6  
     5.7 +# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK
     5.8 +ifndef OPENJDK
     5.9 +  ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
    5.10 +    OPENJDK=true
    5.11 +  endif
    5.12 +endif
    5.13 +
    5.14  BUILDTREE_VARS += HOTSPOT_RELEASE_VERSION=$(HS_BUILD_VER) HOTSPOT_BUILD_VERSION= JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION) 
    5.15  
    5.16  BUILDTREE	= \
    5.17 @@ -190,6 +197,7 @@
    5.18  	echo "SA_BUILD_VERSION = $(HS_BUILD_VER)"; \
    5.19  	echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
    5.20  	echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
    5.21 +	echo "OPENJDK = $(OPENJDK)"; \
    5.22  	echo "$(LP64_SETTING/$(DATA_MODE))"; \
    5.23  	echo; \
    5.24  	echo "# Used for platform dispatching"; \
     6.1 --- a/src/share/vm/prims/jni.cpp	Thu Oct 04 20:09:46 2012 -0400
     6.2 +++ b/src/share/vm/prims/jni.cpp	Mon Oct 08 09:18:54 2012 -0400
     6.3 @@ -1,5 +1,6 @@
     6.4  /*
     6.5   * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2012 Red Hat, Inc.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -2820,10 +2821,9 @@
    6.11  JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \
    6.12    JNIWrapper("Set" XSTR(Result) "Field"); \
    6.13  \
    6.14 -  HS_DTRACE_PROBE_CDECL_N(hotspot_jni, Set##Result##Field__entry, \
    6.15 -    ( JNIEnv*, jobject, jfieldID FP_SELECT_##Result(COMMA Argument,/*empty*/) ) ); \
    6.16 -  HS_DTRACE_PROBE_N(hotspot_jni, Set##Result##Field__entry, \
    6.17 -    ( env, obj, fieldID FP_SELECT_##Result(COMMA value,/*empty*/) ) ); \
    6.18 +  FP_SELECT_##Result( \
    6.19 +    DTRACE_PROBE4(hotspot_jni, Set##Result##Field__entry, env, obj, fieldID, value), \
    6.20 +    DTRACE_PROBE3(hotspot_jni, Set##Result##Field__entry, env, obj, fieldID)); \
    6.21  \
    6.22    oop o = JNIHandles::resolve_non_null(obj); \
    6.23    Klass* k = o->klass(); \
    6.24 @@ -3130,10 +3130,9 @@
    6.25  \
    6.26  JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \
    6.27    JNIWrapper("SetStatic" XSTR(Result) "Field"); \
    6.28 -  HS_DTRACE_PROBE_CDECL_N(hotspot_jni, SetStatic##Result##Field__entry,\
    6.29 -    ( JNIEnv*, jclass, jfieldID FP_SELECT_##Result(COMMA Argument,/*empty*/) ) ); \
    6.30 -  HS_DTRACE_PROBE_N(hotspot_jni, SetStatic##Result##Field__entry, \
    6.31 -    ( env, clazz, fieldID FP_SELECT_##Result(COMMA value,/*empty*/) ) ); \
    6.32 +  FP_SELECT_##Result( \
    6.33 +     DTRACE_PROBE4(hotspot_jni, SetStatic##Result##Field__entry, env, clazz, fieldID, value), \
    6.34 +     DTRACE_PROBE3(hotspot_jni, SetStatic##Result##Field__entry, env, clazz, fieldID)); \
    6.35  \
    6.36    JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \
    6.37    assert(id->is_static_field_id(), "invalid static field id"); \
     7.1 --- a/src/share/vm/utilities/dtrace.hpp	Thu Oct 04 20:09:46 2012 -0400
     7.2 +++ b/src/share/vm/utilities/dtrace.hpp	Mon Oct 08 09:18:54 2012 -0400
     7.3 @@ -1,5 +1,6 @@
     7.4  /*
     7.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     7.7 + * Copyright (c) 2009, 2012 Red Hat, Inc.
     7.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.9   *
    7.10   * This code is free software; you can redistribute it and/or modify it
    7.11 @@ -32,13 +33,17 @@
    7.12  #define DTRACE_ONLY(x) x
    7.13  #define NOT_DTRACE(x)
    7.14  
    7.15 +#if defined(SOLARIS)
    7.16  // Work around dtrace tail call bug 6672627 until it is fixed in solaris 10.
    7.17  #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() \
    7.18    do { volatile size_t dtrace_workaround_tail_call_bug = 1; } while (0)
    7.19  
    7.20 -#if defined(SOLARIS)
    7.21 +#define USDT1 1
    7.22 +#elif defined(LINUX)
    7.23 +#define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG()
    7.24  #define USDT1 1
    7.25  #elif defined(__APPLE__)
    7.26 +#define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG()
    7.27  #define USDT2 1
    7.28  #include <sys/types.h>
    7.29  #include "dtracefiles/hotspot.h"
    7.30 @@ -63,6 +68,11 @@
    7.31  #define DTRACE_PROBE3(a,b,c,d,e) {;}
    7.32  #define DTRACE_PROBE4(a,b,c,d,e,f) {;}
    7.33  #define DTRACE_PROBE5(a,b,c,d,e,f,g) {;}
    7.34 +#define DTRACE_PROBE6(a,b,c,d,e,f,g,h) {;}
    7.35 +#define DTRACE_PROBE7(a,b,c,d,e,f,g,h,i) {;}
    7.36 +#define DTRACE_PROBE8(a,b,c,d,e,f,g,h,i,j) {;}
    7.37 +#define DTRACE_PROBE9(a,b,c,d,e,f,g,h,i,j,k) {;}
    7.38 +#define DTRACE_PROBE10(a,b,c,d,e,f,g,h,i,j,k,l) {;}
    7.39  
    7.40  #else /* USDT2 */
    7.41  
    7.42 @@ -76,10 +86,18 @@
    7.43  #define HS_DTRACE_PROBE_FN(provider,name)\
    7.44    __dtrace_##provider##___##name
    7.45  
    7.46 +#ifdef SOLARIS
    7.47 +// Solaris dtrace needs actual extern function decls.
    7.48  #define HS_DTRACE_PROBE_DECL_N(provider,name,args) \
    7.49    DTRACE_ONLY(extern "C" void HS_DTRACE_PROBE_FN(provider,name) args)
    7.50  #define HS_DTRACE_PROBE_CDECL_N(provider,name,args) \
    7.51    DTRACE_ONLY(extern void HS_DTRACE_PROBE_FN(provider,name) args)
    7.52 +#else
    7.53 +// Systemtap dtrace compatible probes on GNU/Linux don't.
    7.54 +// If dtrace is disabled this macro becomes NULL
    7.55 +#define HS_DTRACE_PROBE_DECL_N(provider,name,args)
    7.56 +#define HS_DTRACE_PROBE_CDECL_N(provider,name,args)
    7.57 +#endif
    7.58  
    7.59  /* Dtrace probe declarations */
    7.60  #define HS_DTRACE_PROBE_DECL(provider,name) \
    7.61 @@ -118,6 +136,8 @@
    7.62      uintptr_t,uintptr_t,uintptr_t))
    7.63  
    7.64  /* Dtrace probe definitions */
    7.65 +#if defined(SOLARIS)
    7.66 +// Solaris dtrace uses actual function calls.
    7.67  #define HS_DTRACE_PROBE_N(provider,name, args) \
    7.68    DTRACE_ONLY(HS_DTRACE_PROBE_FN(provider,name) args)
    7.69  
    7.70 @@ -153,6 +173,33 @@
    7.71    HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\
    7.72      (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\
    7.73      (uintptr_t)a8,(uintptr_t)a9))
    7.74 +#else
    7.75 +// Systemtap dtrace compatible probes on GNU/Linux use direct macros.
    7.76 +// If dtrace is disabled this macro becomes NULL
    7.77 +#define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name)
    7.78 +#define HS_DTRACE_PROBE0(provider,name)\
    7.79 +  DTRACE_PROBE(provider,name)
    7.80 +#define HS_DTRACE_PROBE1(provider,name,a0)\
    7.81 +  DTRACE_PROBE1(provider,name,a0)
    7.82 +#define HS_DTRACE_PROBE2(provider,name,a0,a1)\
    7.83 +  DTRACE_PROBE2(provider,name,a0,a1)
    7.84 +#define HS_DTRACE_PROBE3(provider,name,a0,a1,a2)\
    7.85 +  DTRACE_PROBE3(provider,name,a0,a1,a2)
    7.86 +#define HS_DTRACE_PROBE4(provider,name,a0,a1,a2,a3)\
    7.87 +  DTRACE_PROBE4(provider,name,a0,a1,a2,a3)
    7.88 +#define HS_DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)\
    7.89 +  DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)
    7.90 +#define HS_DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)\
    7.91 +  DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)
    7.92 +#define HS_DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)\
    7.93 +  DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)
    7.94 +#define HS_DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)\
    7.95 +  DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)
    7.96 +#define HS_DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)\
    7.97 +  DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)
    7.98 +#define HS_DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
    7.99 +  DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)
   7.100 +#endif
   7.101  
   7.102  #endif /* !USDT2 */
   7.103  

mercurial