Wed, 11 Jan 2012 17:34:02 -0500
7115199: Add event tracing hooks and Java Flight Recorder infrastructure
Summary: Added a nop tracing infrastructure, JFR makefile changes and other infrastructure used only by JFR.
Reviewed-by: acorn, sspitsyn
Contributed-by: markus.gronlund@oracle.com
1.1 --- a/make/Makefile Mon Jan 09 10:27:24 2012 +0100 1.2 +++ b/make/Makefile Wed Jan 11 17:34:02 2012 -0500 1.3 @@ -367,7 +367,7 @@ 1.4 $(EXPORT_LIB_DIR)/%.jar: $(GEN_DIR)/%.jar 1.5 $(install-file) 1.6 1.7 -# Include files (jvmti.h, jvmticmlr.h, jni.h, $(JDK_INCLUDE_SUBDIR)/jni_md.h, jmm.h) 1.8 +# Include files (jvmti.h, jvmticmlr.h, jni.h, $(JDK_INCLUDE_SUBDIR)/jni_md.h, jmm.h, jfr.h) 1.9 $(EXPORT_INCLUDE_DIR)/%: $(GEN_DIR)/jvmtifiles/% 1.10 $(install-file) 1.11 1.12 @@ -384,6 +384,16 @@ 1.13 $(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/services/% 1.14 $(install-file) 1.15 1.16 +JFR_EXISTS=$(shell if [ -d $(HS_ALT_SRC) ]; then echo 1; else echo 0; fi) 1.17 +# export jfr.h 1.18 +ifeq ($JFR_EXISTS,1) 1.19 +$(EXPORT_INCLUDE_DIR)/%: $(HS_ALT_SRC)/share/vm/jfr/agent/% 1.20 + $(install-file) 1.21 +else 1.22 +$(EXPORT_INCLUDE_DIR)/jfr.h: 1.23 + 1.24 +endif 1.25 + 1.26 # Doc files (jvmti.html) 1.27 $(EXPORT_DOCS_DIR)/platform/jvmti/%: $(DOCS_DIR)/% 1.28 $(install-file)
2.1 --- a/make/bsd/makefiles/vm.make Mon Jan 09 10:27:24 2012 +0100 2.2 +++ b/make/bsd/makefiles/vm.make Wed Jan 11 17:34:02 2012 -0500 2.3 @@ -96,6 +96,10 @@ 2.4 CPPFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\"" 2.5 endif 2.6 2.7 +ifndef JAVASE_EMBEDDED 2.8 +CFLAGS += -DINCLUDE_TRACE 2.9 +endif 2.10 + 2.11 # CFLAGS_WARN holds compiler options to suppress/enable warnings. 2.12 CFLAGS += $(CFLAGS_WARN/BYFILE) 2.13 2.14 @@ -147,6 +151,12 @@ 2.15 SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm 2.16 SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm 2.17 2.18 +ifndef JAVASE_EMBEDDED 2.19 +SOURCE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \ 2.20 + find $(HS_ALT_SRC)/share/vm/jfr -type d; \ 2.21 + fi) 2.22 +endif 2.23 + 2.24 CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path)) 2.25 CORE_PATHS+=$(GENERATED)/jvmtifiles 2.26
3.1 --- a/make/defs.make Mon Jan 09 10:27:24 2012 +0100 3.2 +++ b/make/defs.make Wed Jan 11 17:34:02 2012 -0500 3.3 @@ -294,3 +294,7 @@ 3.4 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jni.h 3.5 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h 3.6 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jmm.h 3.7 + 3.8 +ifndef JAVASE_EMBEDDED 3.9 +EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jfr.h 3.10 +endif
4.1 --- a/make/linux/makefiles/vm.make Mon Jan 09 10:27:24 2012 +0100 4.2 +++ b/make/linux/makefiles/vm.make Wed Jan 11 17:34:02 2012 -0500 4.3 @@ -98,6 +98,10 @@ 4.4 ${JRE_VERSION} \ 4.5 ${VM_DISTRO} 4.6 4.7 +ifndef JAVASE_EMBEDDED 4.8 +CFLAGS += -DINCLUDE_TRACE 4.9 +endif 4.10 + 4.11 # CFLAGS_WARN holds compiler options to suppress/enable warnings. 4.12 CFLAGS += $(CFLAGS_WARN/BYFILE) 4.13 4.14 @@ -143,6 +147,12 @@ 4.15 SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm 4.16 SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm 4.17 4.18 +ifndef JAVASE_EMBEDDED 4.19 +SOURCE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \ 4.20 + find $(HS_ALT_SRC)/share/vm/jfr -type d; \ 4.21 + fi) 4.22 +endif 4.23 + 4.24 CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path)) 4.25 CORE_PATHS+=$(GENERATED)/jvmtifiles 4.26
5.1 --- a/make/solaris/makefiles/vm.make Mon Jan 09 10:27:24 2012 +0100 5.2 +++ b/make/solaris/makefiles/vm.make Wed Jan 11 17:34:02 2012 -0500 5.3 @@ -93,7 +93,7 @@ 5.4 CFLAGS += $(CFLAGS/NOEX) 5.5 5.6 # Extra flags from gnumake's invocation or environment 5.7 -CFLAGS += $(EXTRA_CFLAGS) 5.8 +CFLAGS += $(EXTRA_CFLAGS) -DINCLUDE_TRACE 5.9 5.10 # Math Library (libm.so), do not use -lm. 5.11 # There might be two versions of libm.so on the build system: 5.12 @@ -160,6 +160,10 @@ 5.13 SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm 5.14 SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm 5.15 5.16 +SOURCE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \ 5.17 + find $(HS_ALT_SRC)/share/vm/jfr -type d; \ 5.18 + fi) 5.19 + 5.20 CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path)) 5.21 CORE_PATHS+=$(GENERATED)/jvmtifiles 5.22
6.1 --- a/make/windows/build.bat Mon Jan 09 10:27:24 2012 +0100 6.2 +++ b/make/windows/build.bat Wed Jan 11 17:34:02 2012 -0500 6.3 @@ -35,6 +35,8 @@ 6.4 if %errorlevel% == 0 goto isia64 6.5 cl 2>&1 | grep "AMD64" >NUL 6.6 if %errorlevel% == 0 goto amd64 6.7 +cl 2>&1 | grep "x64" >NUL 6.8 +if %errorlevel% == 0 goto amd64 6.9 set ARCH=x86 6.10 set BUILDARCH=i486 6.11 set Platform_arch=x86
7.1 --- a/make/windows/create_obj_files.sh Mon Jan 09 10:27:24 2012 +0100 7.2 +++ b/make/windows/create_obj_files.sh Wed Jan 11 17:34:02 2012 -0500 7.3 @@ -73,6 +73,13 @@ 7.4 7.5 BASE_PATHS="${BASE_PATHS} ${GENERATED}/jvmtifiles" 7.6 7.7 +if [ -d "${ALTSRC}/share/vm/jfr" ]; then 7.8 + BASE_PATHS="${BASE_PATHS} ${ALTSRC}/share/vm/jfr/agent" 7.9 + BASE_PATHS="${BASE_PATHS} ${ALTSRC}/share/vm/jfr/agent/isolated_deps/util" 7.10 + BASE_PATHS="${BASE_PATHS} ${ALTSRC}/share/vm/jfr/jvm" 7.11 + BASE_PATHS="${BASE_PATHS} ${ALTSRC}/share/vm/jfr" 7.12 +fi 7.13 + 7.14 CORE_PATHS="${BASE_PATHS}" 7.15 # shared is already in BASE_PATHS. Should add vm/memory but that one is also in BASE_PATHS. 7.16 if [ -d "${ALTSRC}/share/vm/gc_implementation" ]; then
8.1 --- a/make/windows/makefiles/projectcreator.make Mon Jan 09 10:27:24 2012 +0100 8.2 +++ b/make/windows/makefiles/projectcreator.make Wed Jan 11 17:34:02 2012 -0500 8.3 @@ -58,7 +58,8 @@ 8.4 -absoluteInclude $(HOTSPOTBUILDSPACE)/%f/generated \ 8.5 -ignorePath $(HOTSPOTBUILDSPACE)/%f/generated \ 8.6 -ignorePath src\share\vm\adlc \ 8.7 - -ignorePath src\share\vm\shark 8.8 + -ignorePath src\share\vm\shark \ 8.9 + -ignorePath posix 8.10 8.11 # This is referenced externally by both the IDE and batch builds 8.12 ProjectCreatorOptions= 8.13 @@ -88,7 +89,7 @@ 8.14 -jdkTargetRoot $(HOTSPOTJDKDIST) \ 8.15 -define ALIGN_STACK_FRAMES \ 8.16 -define VM_LITTLE_ENDIAN \ 8.17 - -prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LINK_VER)" \ 8.18 + -prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) set JAVA_HOME=$(HOTSPOTJDKDIST) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LINK_VER)" \ 8.19 -postbuild "" "Building hotspot.exe..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) nmake -f $(HOTSPOTWORKSPACE)\make\windows\projectfiles\common\Makefile LOCAL_MAKE=$(HOTSPOTBUILDSPACE)\%f\local.make JAVA_HOME=$(HOTSPOTJDKDIST) launcher" \ 8.20 -ignoreFile jsig.c \ 8.21 -ignoreFile jvmtiEnvRecommended.cpp \
9.1 --- a/make/windows/makefiles/vm.make Mon Jan 09 10:27:24 2012 +0100 9.2 +++ b/make/windows/makefiles/vm.make Wed Jan 11 17:34:02 2012 -0500 9.3 @@ -19,7 +19,7 @@ 9.4 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.5 # or visit www.oracle.com if you need additional information or have any 9.6 # questions. 9.7 -# 9.8 +# 9.9 # 9.10 9.11 # Resource file containing VERSIONINFO 9.12 @@ -30,7 +30,7 @@ 9.13 COMMONSRC=$(WorkSpace)\src 9.14 ALTSRC=$(WorkSpace)\src\closed 9.15 9.16 -!ifdef RELEASE 9.17 +!ifdef RELEASE 9.18 !ifdef DEVELOP 9.19 CPP_FLAGS=$(CPP_FLAGS) /D "DEBUG" 9.20 !else 9.21 @@ -74,6 +74,10 @@ 9.22 CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_USER=\"$(BuildUser)\"" 9.23 CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_VM_DISTRO=\"$(HOTSPOT_VM_DISTRO)\"" 9.24 9.25 +!ifndef JAVASE_EMBEDDED 9.26 +CPP_FLAGS=$(CPP_FLAGS) /D "INCLUDE_TRACE" 9.27 +!endif 9.28 + 9.29 CPP_FLAGS=$(CPP_FLAGS) $(CPP_INCLUDE_DIRS) 9.30 9.31 # Define that so jni.h is on correct side 9.32 @@ -97,7 +101,7 @@ 9.33 !endif 9.34 9.35 # If you modify exports below please do the corresponding changes in 9.36 -# src/share/tools/ProjectCreator/WinGammaPlatformVC7.java 9.37 +# src/share/tools/ProjectCreator/WinGammaPlatformVC7.java 9.38 LINK_FLAGS=$(LINK_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 \ 9.39 /export:JNI_GetDefaultJavaVMInitArgs \ 9.40 /export:JNI_CreateJavaVM \ 9.41 @@ -170,6 +174,7 @@ 9.42 VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/prims 9.43 VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/runtime 9.44 VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/services 9.45 +VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/trace 9.46 VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/utilities 9.47 VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/libadt 9.48 VM_PATH=$(VM_PATH);$(WorkSpace)/src/os/windows/vm 9.49 @@ -177,6 +182,13 @@ 9.50 VM_PATH=$(VM_PATH);$(WorkSpace)/src/cpu/$(Platform_arch)/vm 9.51 VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/opto 9.52 9.53 +!if exists($(ALTSRC)\share\vm\jfr) 9.54 +VM_PATH=$(VM_PATH);$(ALTSRC)/share/vm/jfr/agent 9.55 +VM_PATH=$(VM_PATH);$(ALTSRC)/share/vm/jfr/agent/isolated_deps/util 9.56 +VM_PATH=$(VM_PATH);$(ALTSRC)/share/vm/jfr/jvm 9.57 +VM_PATH=$(VM_PATH);$(ALTSRC)/share/vm/jfr 9.58 +!endif 9.59 + 9.60 VM_PATH={$(VM_PATH)} 9.61 9.62 # Special case files not using precompiled header files. 9.63 @@ -263,6 +275,9 @@ 9.64 {$(COMMONSRC)\share\vm\services}.cpp.obj:: 9.65 $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.66 9.67 +{$(COMMONSRC)\share\vm\trace}.cpp.obj:: 9.68 + $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.69 + 9.70 {$(COMMONSRC)\share\vm\utilities}.cpp.obj:: 9.71 $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.72 9.73 @@ -340,6 +355,9 @@ 9.74 {$(ALTSRC)\share\vm\services}.cpp.obj:: 9.75 $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.76 9.77 +{$(ALTSRC)\share\vm\trace}.cpp.obj:: 9.78 + $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.79 + 9.80 {$(ALTSRC)\share\vm\utilities}.cpp.obj:: 9.81 $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.82 9.83 @@ -371,6 +389,18 @@ 9.84 {..\generated\jvmtifiles}.cpp.obj:: 9.85 $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.86 9.87 +{$(ALTSRC)\share\vm\jfr}.cpp.obj:: 9.88 + $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.89 + 9.90 +{$(ALTSRC)\share\vm\jfr\agent}.cpp.obj:: 9.91 + $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.92 + 9.93 +{$(ALTSRC)\share\vm\jfr\agent\isolated_deps\util}.cpp.obj:: 9.94 + $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.95 + 9.96 +{$(ALTSRC)\share\vm\jfr\jvm}.cpp.obj:: 9.97 + $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $< 9.98 + 9.99 default:: 9.100 9.101 _build_pch_file.obj:
10.1 --- a/src/share/vm/classfile/symbolTable.cpp Mon Jan 09 10:27:24 2012 +0100 10.2 +++ b/src/share/vm/classfile/symbolTable.cpp Wed Jan 11 17:34:02 2012 -0500 10.3 @@ -204,6 +204,24 @@ 10.4 return s; 10.5 } 10.6 10.7 +// Look up the address of the literal in the SymbolTable for this Symbol* 10.8 +// Do not create any new symbols 10.9 +// Do not increment the reference count to keep this alive 10.10 +Symbol** SymbolTable::lookup_symbol_addr(Symbol* sym){ 10.11 + unsigned int hash = hash_symbol((char*)sym->bytes(), sym->utf8_length()); 10.12 + int index = the_table()->hash_to_index(hash); 10.13 + 10.14 + for (HashtableEntry<Symbol*>* e = the_table()->bucket(index); e != NULL; e = e->next()) { 10.15 + if (e->hash() == hash) { 10.16 + Symbol* literal_sym = e->literal(); 10.17 + if (sym == literal_sym) { 10.18 + return e->literal_addr(); 10.19 + } 10.20 + } 10.21 + } 10.22 + return NULL; 10.23 +} 10.24 + 10.25 // Suggestion: Push unicode-based lookup all the way into the hashing 10.26 // and probing logic, so there is no need for convert_to_utf8 until 10.27 // an actual new Symbol* is created.
11.1 --- a/src/share/vm/classfile/symbolTable.hpp Mon Jan 09 10:27:24 2012 +0100 11.2 +++ b/src/share/vm/classfile/symbolTable.hpp Wed Jan 11 17:34:02 2012 -0500 11.3 @@ -144,6 +144,9 @@ 11.4 11.5 static void release(Symbol* sym); 11.6 11.7 + // Look up the address of the literal in the SymbolTable for this Symbol* 11.8 + static Symbol** lookup_symbol_addr(Symbol* sym); 11.9 + 11.10 // jchar (utf16) version of lookups 11.11 static Symbol* lookup_unicode(const jchar* name, int len, TRAPS); 11.12 static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash);
12.1 --- a/src/share/vm/classfile/systemDictionary.cpp Mon Jan 09 10:27:24 2012 +0100 12.2 +++ b/src/share/vm/classfile/systemDictionary.cpp Wed Jan 11 17:34:02 2012 -0500 12.3 @@ -2131,6 +2131,12 @@ 12.4 } 12.5 } 12.6 12.7 + // Assign a classid if one has not already been assigned. The 12.8 + // counter does not need to be atomically incremented since this 12.9 + // is only done while holding the SystemDictionary_lock. 12.10 + // All loaded classes get a unique ID. 12.11 + TRACE_INIT_ID(k); 12.12 + 12.13 // Check for a placeholder. If there, remove it and make a 12.14 // new system dictionary entry. 12.15 placeholders()->find_and_remove(p_index, p_hash, name, class_loader, THREAD);
13.1 --- a/src/share/vm/oops/klass.cpp Mon Jan 09 10:27:24 2012 +0100 13.2 +++ b/src/share/vm/oops/klass.cpp Wed Jan 11 17:34:02 2012 -0500 13.3 @@ -158,6 +158,9 @@ 13.4 kl->set_next_sibling(NULL); 13.5 kl->set_alloc_count(0); 13.6 kl->set_alloc_size(0); 13.7 +#ifdef TRACE_SET_KLASS_TRACE_ID 13.8 + TRACE_SET_KLASS_TRACE_ID(kl, 0); 13.9 +#endif 13.10 13.11 kl->set_prototype_header(markOopDesc::prototype()); 13.12 kl->set_biased_lock_revocation_count(0);
14.1 --- a/src/share/vm/oops/klass.hpp Mon Jan 09 10:27:24 2012 +0100 14.2 +++ b/src/share/vm/oops/klass.hpp Wed Jan 11 17:34:02 2012 -0500 14.3 @@ -33,6 +33,7 @@ 14.4 #include "oops/klassPS.hpp" 14.5 #include "oops/oop.hpp" 14.6 #include "runtime/orderAccess.hpp" 14.7 +#include "trace/traceMacros.hpp" 14.8 #include "utilities/accessFlags.hpp" 14.9 #ifndef SERIALGC 14.10 #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp" 14.11 @@ -80,6 +81,7 @@ 14.12 // [last_biased_lock_bulk_revocation_time] (64 bits) 14.13 // [prototype_header] 14.14 // [biased_lock_revocation_count] 14.15 +// [trace_id] 14.16 14.17 14.18 // Forward declarations. 14.19 @@ -263,6 +265,9 @@ 14.20 markOop _prototype_header; // Used when biased locking is both enabled and disabled for this type 14.21 jint _biased_lock_revocation_count; 14.22 14.23 +#ifdef TRACE_DEFINE_KLASS_TRACE_ID 14.24 + TRACE_DEFINE_KLASS_TRACE_ID; 14.25 +#endif 14.26 public: 14.27 14.28 // returns the enclosing klassOop 14.29 @@ -683,6 +688,9 @@ 14.30 jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; } 14.31 void set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; } 14.32 14.33 +#ifdef TRACE_DEFINE_KLASS_METHODS 14.34 + TRACE_DEFINE_KLASS_METHODS; 14.35 +#endif 14.36 14.37 // garbage collection support 14.38 virtual void follow_weak_klass_links(
15.1 --- a/src/share/vm/oops/methodKlass.cpp Mon Jan 09 10:27:24 2012 +0100 15.2 +++ b/src/share/vm/oops/methodKlass.cpp Wed Jan 11 17:34:02 2012 -0500 15.3 @@ -83,6 +83,7 @@ 15.4 m->set_max_stack(0); 15.5 m->set_max_locals(0); 15.6 m->set_intrinsic_id(vmIntrinsics::_none); 15.7 + m->set_jfr_towrite(false); 15.8 m->set_method_data(NULL); 15.9 m->set_interpreter_throwout_count(0); 15.10 m->set_vtable_index(methodOopDesc::garbage_vtable_index);
16.1 --- a/src/share/vm/oops/methodOop.hpp Mon Jan 09 10:27:24 2012 +0100 16.2 +++ b/src/share/vm/oops/methodOop.hpp Wed Jan 11 17:34:02 2012 -0500 16.3 @@ -77,7 +77,7 @@ 16.4 // | method_size | max_stack | 16.5 // | max_locals | size_of_parameters | 16.6 // |------------------------------------------------------| 16.7 -// | intrinsic_id, (unused) | throwout_count | 16.8 +// |intrinsic_id| flags | throwout_count | 16.9 // |------------------------------------------------------| 16.10 // | num_breakpoints | (unused) | 16.11 // |------------------------------------------------------| 16.12 @@ -124,6 +124,8 @@ 16.13 u2 _max_locals; // Number of local variables used by this method 16.14 u2 _size_of_parameters; // size of the parameter block (receiver + arguments) in words 16.15 u1 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none) 16.16 + u1 _jfr_towrite : 1, // Flags 16.17 + : 7; 16.18 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting 16.19 u2 _number_of_breakpoints; // fullspeed debugging support 16.20 InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations 16.21 @@ -225,6 +227,7 @@ 16.22 void clear_number_of_breakpoints() { _number_of_breakpoints = 0; } 16.23 16.24 // index into instanceKlass methods() array 16.25 + // note: also used by jfr 16.26 u2 method_idnum() const { return constMethod()->method_idnum(); } 16.27 void set_method_idnum(u2 idnum) { constMethod()->set_method_idnum(idnum); } 16.28 16.29 @@ -650,6 +653,9 @@ 16.30 void init_intrinsic_id(); // updates from _none if a match 16.31 static vmSymbols::SID klass_id_for_intrinsics(klassOop holder); 16.32 16.33 + bool jfr_towrite() { return _jfr_towrite; } 16.34 + void set_jfr_towrite(bool towrite) { _jfr_towrite = towrite; } 16.35 + 16.36 // On-stack replacement support 16.37 bool has_osr_nmethod(int level, bool match_level) { 16.38 return instanceKlass::cast(method_holder())->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != NULL;
17.1 --- a/src/share/vm/prims/jni.cpp Mon Jan 09 10:27:24 2012 +0100 17.2 +++ b/src/share/vm/prims/jni.cpp Wed Jan 11 17:34:02 2012 -0500 17.3 @@ -48,6 +48,7 @@ 17.4 #include "oops/typeArrayOop.hpp" 17.5 #include "prims/jni.h" 17.6 #include "prims/jniCheck.hpp" 17.7 +#include "prims/jniExport.hpp" 17.8 #include "prims/jniFastGetField.hpp" 17.9 #include "prims/jvm.h" 17.10 #include "prims/jvm_misc.hpp" 17.11 @@ -66,6 +67,8 @@ 17.12 #include "runtime/signature.hpp" 17.13 #include "runtime/vm_operations.hpp" 17.14 #include "services/runtimeService.hpp" 17.15 +#include "trace/tracing.hpp" 17.16 +#include "trace/traceEventTypes.hpp" 17.17 #include "utilities/defaultStream.hpp" 17.18 #include "utilities/dtrace.hpp" 17.19 #include "utilities/events.hpp" 17.20 @@ -5139,6 +5142,11 @@ 17.21 if (JvmtiExport::should_post_thread_life()) { 17.22 JvmtiExport::post_thread_start(thread); 17.23 } 17.24 + 17.25 + EVENT_BEGIN(TraceEventThreadStart, event); 17.26 + EVENT_COMMIT(event, 17.27 + EVENT_SET(event, javalangthread, java_lang_Thread::thread_id(thread->threadObj()))); 17.28 + 17.29 // Check if we should compile all classes on bootclasspath 17.30 NOT_PRODUCT(if (CompileTheWorld) ClassLoader::compile_the_world();) 17.31 // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving. 17.32 @@ -5337,6 +5345,10 @@ 17.33 JvmtiExport::post_thread_start(thread); 17.34 } 17.35 17.36 + EVENT_BEGIN(TraceEventThreadStart, event); 17.37 + EVENT_COMMIT(event, 17.38 + EVENT_SET(event, javalangthread, java_lang_Thread::thread_id(thread->threadObj()))); 17.39 + 17.40 *(JNIEnv**)penv = thread->jni_environment(); 17.41 17.42 // Now leaving the VM, so change thread_state. This is normally automatically taken care 17.43 @@ -5464,8 +5476,7 @@ 17.44 return ret; 17.45 } 17.46 17.47 - if (JvmtiExport::is_jvmti_version(version)) { 17.48 - ret = JvmtiExport::get_jvmti_interface(vm, penv, version); 17.49 + if (JniExportedInterface::GetExportedInterface(vm, penv, version, &ret)) { 17.50 return ret; 17.51 } 17.52
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/src/share/vm/prims/jniExport.hpp Wed Jan 11 17:34:02 2012 -0500 18.3 @@ -0,0 +1,42 @@ 18.4 +/* 18.5 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.7 + * 18.8 + * This code is free software; you can redistribute it and/or modify it 18.9 + * under the terms of the GNU General Public License version 2 only, as 18.10 + * published by the Free Software Foundation. 18.11 + * 18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18.15 + * version 2 for more details (a copy is included in the LICENSE file that 18.16 + * accompanied this code). 18.17 + * 18.18 + * You should have received a copy of the GNU General Public License version 18.19 + * 2 along with this work; if not, write to the Free Software Foundation, 18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18.21 + * 18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 18.23 + * or visit www.oracle.com if you need additional information or have any 18.24 + * questions. 18.25 + * 18.26 + */ 18.27 + 18.28 +#ifndef SHARE_VM_PRIMS_JNI_EXPORT_HPP 18.29 +#define SHARE_VM_PRIMS_JNI_EXPORT_HPP 18.30 + 18.31 +#include "prims/jni.h" 18.32 +#include "prims/jvmtiExport.hpp" 18.33 + 18.34 +class JniExportedInterface { 18.35 + public: 18.36 + static bool GetExportedInterface(JavaVM* vm, void** penv, jint version, jint* iface) { 18.37 + if (JvmtiExport::is_jvmti_version(version)) { 18.38 + *iface = JvmtiExport::get_jvmti_interface(vm, penv, version); 18.39 + return true; 18.40 + } 18.41 + return false; 18.42 + } 18.43 +}; 18.44 + 18.45 +#endif // SHARE_VM_PRIMS_JNI_EXPORT_HPP
19.1 --- a/src/share/vm/runtime/java.cpp Mon Jan 09 10:27:24 2012 +0100 19.2 +++ b/src/share/vm/runtime/java.cpp Wed Jan 11 17:34:02 2012 -0500 19.3 @@ -57,6 +57,8 @@ 19.4 #include "runtime/task.hpp" 19.5 #include "runtime/timer.hpp" 19.6 #include "runtime/vm_operations.hpp" 19.7 +#include "trace/tracing.hpp" 19.8 +#include "trace/traceEventTypes.hpp" 19.9 #include "utilities/dtrace.hpp" 19.10 #include "utilities/globalDefinitions.hpp" 19.11 #include "utilities/histogram.hpp" 19.12 @@ -502,6 +504,11 @@ 19.13 if (JvmtiExport::should_post_thread_life()) { 19.14 JvmtiExport::post_thread_end(thread); 19.15 } 19.16 + 19.17 + EVENT_BEGIN(TraceEventThreadEnd, event); 19.18 + EVENT_COMMIT(event, 19.19 + EVENT_SET(event, javalangthread, java_lang_Thread::thread_id(thread->threadObj()))); 19.20 + 19.21 // Always call even when there are not JVMTI environments yet, since environments 19.22 // may be attached late and JVMTI must track phases of VM execution 19.23 JvmtiExport::post_vm_death();
20.1 --- a/src/share/vm/runtime/mutexLocker.cpp Mon Jan 09 10:27:24 2012 +0100 20.2 +++ b/src/share/vm/runtime/mutexLocker.cpp Wed Jan 11 17:34:02 2012 -0500 20.3 @@ -132,7 +132,13 @@ 20.4 Monitor* GCTaskManager_lock = NULL; 20.5 20.6 Mutex* Management_lock = NULL; 20.7 -Monitor* Service_lock = NULL; 20.8 +Monitor* Service_lock = NULL; 20.9 +Mutex* Stacktrace_lock = NULL; 20.10 + 20.11 +Monitor* JfrQuery_lock = NULL; 20.12 +Monitor* JfrMsg_lock = NULL; 20.13 +Mutex* JfrBuffer_lock = NULL; 20.14 +Mutex* JfrStream_lock = NULL; 20.15 20.16 #define MAX_NUM_MUTEX 128 20.17 static Monitor * _mutex_array[MAX_NUM_MUTEX]; 20.18 @@ -207,6 +213,7 @@ 20.19 def(Patching_lock , Mutex , special, true ); // used for safepointing and code patching. 20.20 def(ObjAllocPost_lock , Monitor, special, false); 20.21 def(Service_lock , Monitor, special, true ); // used for service thread operations 20.22 + def(Stacktrace_lock , Mutex, special, true ); // used for JFR stacktrace database 20.23 def(JmethodIdCreation_lock , Mutex , leaf, true ); // used for creating jmethodIDs. 20.24 20.25 def(SystemDictionary_lock , Monitor, leaf, true ); // lookups done by VM thread 20.26 @@ -271,6 +278,11 @@ 20.27 def(Debug3_lock , Mutex , nonleaf+4, true ); 20.28 def(ProfileVM_lock , Monitor, nonleaf+4, false); // used for profiling of the VMThread 20.29 def(CompileThread_lock , Monitor, nonleaf+5, false ); 20.30 + 20.31 + def(JfrQuery_lock , Monitor, nonleaf, true); // JFR locks, keep these in consecutive order 20.32 + def(JfrMsg_lock , Monitor, nonleaf+2, true); 20.33 + def(JfrBuffer_lock , Mutex, nonleaf+3, true); 20.34 + def(JfrStream_lock , Mutex, nonleaf+4, true); 20.35 } 20.36 20.37 GCMutexLocker::GCMutexLocker(Monitor * mutex) {
21.1 --- a/src/share/vm/runtime/mutexLocker.hpp Mon Jan 09 10:27:24 2012 +0100 21.2 +++ b/src/share/vm/runtime/mutexLocker.hpp Wed Jan 11 17:34:02 2012 -0500 21.3 @@ -135,6 +135,12 @@ 21.4 21.5 extern Mutex* Management_lock; // a lock used to serialize JVM management 21.6 extern Monitor* Service_lock; // a lock used for service thread operation 21.7 +extern Mutex* Stacktrace_lock; // used to guard access to the stacktrace table 21.8 + 21.9 +extern Monitor* JfrQuery_lock; // protects JFR use 21.10 +extern Monitor* JfrMsg_lock; // protects JFR messaging 21.11 +extern Mutex* JfrBuffer_lock; // protects JFR buffer operations 21.12 +extern Mutex* JfrStream_lock; // protects JFR stream access 21.13 21.14 // A MutexLocker provides mutual exclusion with respect to a given mutex 21.15 // for the scope which contains the locker. The lock is an OS lock, not
22.1 --- a/src/share/vm/runtime/os.cpp Mon Jan 09 10:27:24 2012 +0100 22.2 +++ b/src/share/vm/runtime/os.cpp Wed Jan 11 17:34:02 2012 -0500 22.3 @@ -1101,6 +1101,7 @@ 22.4 "%/lib/jsse.jar:" 22.5 "%/lib/jce.jar:" 22.6 "%/lib/charsets.jar:" 22.7 + "%/lib/jfr.jar:" 22.8 #ifdef __APPLE__ 22.9 "%/lib/JObjC.jar:" 22.10 #endif
23.1 --- a/src/share/vm/runtime/thread.cpp Mon Jan 09 10:27:24 2012 +0100 23.2 +++ b/src/share/vm/runtime/thread.cpp Wed Jan 11 17:34:02 2012 -0500 23.3 @@ -73,6 +73,7 @@ 23.4 #include "services/attachListener.hpp" 23.5 #include "services/management.hpp" 23.6 #include "services/threadService.hpp" 23.7 +#include "trace/traceEventTypes.hpp" 23.8 #include "utilities/defaultStream.hpp" 23.9 #include "utilities/dtrace.hpp" 23.10 #include "utilities/events.hpp" 23.11 @@ -232,6 +233,7 @@ 23.12 CHECK_UNHANDLED_OOPS_ONLY(_gc_locked_out_count = 0;) 23.13 _jvmti_env_iteration_count = 0; 23.14 set_allocated_bytes(0); 23.15 + set_trace_buffer(NULL); 23.16 _vm_operation_started_count = 0; 23.17 _vm_operation_completed_count = 0; 23.18 _current_pending_monitor = NULL; 23.19 @@ -1512,6 +1514,10 @@ 23.20 JvmtiExport::post_thread_start(this); 23.21 } 23.22 23.23 + EVENT_BEGIN(TraceEventThreadStart, event); 23.24 + EVENT_COMMIT(event, 23.25 + EVENT_SET(event, javalangthread, java_lang_Thread::thread_id(this->threadObj()))); 23.26 + 23.27 // We call another function to do the rest so we are sure that the stack addresses used 23.28 // from there will be lower than the stack base just computed 23.29 thread_main_inner(); 23.30 @@ -1641,6 +1647,15 @@ 23.31 } 23.32 } 23.33 23.34 + // Called before the java thread exit since we want to read info 23.35 + // from java_lang_Thread object 23.36 + EVENT_BEGIN(TraceEventThreadEnd, event); 23.37 + EVENT_COMMIT(event, 23.38 + EVENT_SET(event, javalangthread, java_lang_Thread::thread_id(this->threadObj()))); 23.39 + 23.40 + // Call after last event on thread 23.41 + EVENT_THREAD_EXIT(this); 23.42 + 23.43 // Call Thread.exit(). We try 3 times in case we got another Thread.stop during 23.44 // the execution of the method. If that is not enough, then we don't really care. Thread.stop 23.45 // is deprecated anyhow. 23.46 @@ -3186,6 +3201,11 @@ 23.47 return status; 23.48 } 23.49 23.50 + // Must be run after init_ft which initializes ft_enabled 23.51 + if (TRACE_INITIALIZE() != JNI_OK) { 23.52 + vm_exit_during_initialization("Failed to initialize tracing backend"); 23.53 + } 23.54 + 23.55 // Should be done after the heap is fully created 23.56 main_thread->cache_global_variables(); 23.57 23.58 @@ -3423,6 +3443,10 @@ 23.59 create_vm_init_libraries(); 23.60 } 23.61 23.62 + if (!TRACE_START()) { 23.63 + vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); 23.64 + } 23.65 + 23.66 // Notify JVMTI agents that VM initialization is complete - nop if no agents. 23.67 JvmtiExport::post_vm_initialized(); 23.68
24.1 --- a/src/share/vm/runtime/thread.hpp Mon Jan 09 10:27:24 2012 +0100 24.2 +++ b/src/share/vm/runtime/thread.hpp Wed Jan 11 17:34:02 2012 -0500 24.3 @@ -41,6 +41,7 @@ 24.4 #include "runtime/stubRoutines.hpp" 24.5 #include "runtime/threadLocalStorage.hpp" 24.6 #include "runtime/unhandledOops.hpp" 24.7 +#include "trace/tracing.hpp" 24.8 #include "utilities/exceptions.hpp" 24.9 #include "utilities/top.hpp" 24.10 #ifndef SERIALGC 24.11 @@ -246,6 +247,8 @@ 24.12 jlong _allocated_bytes; // Cumulative number of bytes allocated on 24.13 // the Java heap 24.14 24.15 + TRACE_BUFFER _trace_buffer; // Thread-local buffer for tracing 24.16 + 24.17 int _vm_operation_started_count; // VM_Operation support 24.18 int _vm_operation_completed_count; // VM_Operation support 24.19 24.20 @@ -414,6 +417,9 @@ 24.21 return allocated_bytes; 24.22 } 24.23 24.24 + TRACE_BUFFER trace_buffer() { return _trace_buffer; } 24.25 + void set_trace_buffer(TRACE_BUFFER buf) { _trace_buffer = buf; } 24.26 + 24.27 // VM operation support 24.28 int vm_operation_ticket() { return ++_vm_operation_started_count; } 24.29 int vm_operation_completed_count() { return _vm_operation_completed_count; }
25.1 --- a/src/share/vm/runtime/vm_operations.hpp Mon Jan 09 10:27:24 2012 +0100 25.2 +++ b/src/share/vm/runtime/vm_operations.hpp Wed Jan 11 17:34:02 2012 -0500 25.3 @@ -93,6 +93,7 @@ 25.4 template(HeapWalkOperation) \ 25.5 template(HeapIterateOperation) \ 25.6 template(ReportJavaOutOfMemory) \ 25.7 + template(JFRCheckpoint) \ 25.8 template(Exit) \ 25.9 25.10 class VM_Operation: public CHeapObj {
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/src/share/vm/trace/traceEventTypes.hpp Wed Jan 11 17:34:02 2012 -0500 26.3 @@ -0,0 +1,30 @@ 26.4 +/* 26.5 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.7 + * 26.8 + * This code is free software; you can redistribute it and/or modify it 26.9 + * under the terms of the GNU General Public License version 2 only, as 26.10 + * published by the Free Software Foundation. 26.11 + * 26.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 26.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 26.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 26.15 + * version 2 for more details (a copy is included in the LICENSE file that 26.16 + * accompanied this code). 26.17 + * 26.18 + * You should have received a copy of the GNU General Public License version 26.19 + * 2 along with this work; if not, write to the Free Software Foundation, 26.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26.21 + * 26.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 26.23 + * or visit www.oracle.com if you need additional information or have any 26.24 + * questions. 26.25 + * 26.26 + */ 26.27 + 26.28 +#ifndef SHARE_VM_TRACE_TRACE_EVENT_TYPES_HPP 26.29 +#define SHARE_VM_TRACE_TRACE_EVENT_TYPES_HPP 26.30 + 26.31 +/* Empty, just a placeholder for tracing events */ 26.32 + 26.33 +#endif
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 27.2 +++ b/src/share/vm/trace/traceMacros.hpp Wed Jan 11 17:34:02 2012 -0500 27.3 @@ -0,0 +1,43 @@ 27.4 +/* 27.5 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 27.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 27.7 + * 27.8 + * This code is free software; you can redistribute it and/or modify it 27.9 + * under the terms of the GNU General Public License version 2 only, as 27.10 + * published by the Free Software Foundation. 27.11 + * 27.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 27.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 27.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 27.15 + * version 2 for more details (a copy is included in the LICENSE file that 27.16 + * accompanied this code). 27.17 + * 27.18 + * You should have received a copy of the GNU General Public License version 27.19 + * 2 along with this work; if not, write to the Free Software Foundation, 27.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 27.21 + * 27.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 27.23 + * or visit www.oracle.com if you need additional information or have any 27.24 + * questions. 27.25 + * 27.26 + */ 27.27 + 27.28 +#ifndef SHARE_VM_TRACE_TRACE_MACRO_HPP 27.29 +#define SHARE_VM_TRACE_TRACE_MACRO_HPP 27.30 + 27.31 +#define EVENT_BEGIN(type, name) 27.32 +#define EVENT_SET(name, field, value) 27.33 +#define EVENT_COMMIT(name, ...) 27.34 +#define EVENT_STARTED(name, time) 27.35 +#define EVENT_ENDED(name, time) 27.36 +#define EVENT_THREAD_EXIT(thread) 27.37 + 27.38 +#define TRACE_ENABLED 0 27.39 + 27.40 +#define TRACE_INIT_ID(k) 27.41 +#define TRACE_BUFFER void* 27.42 + 27.43 +#define TRACE_START() true 27.44 +#define TRACE_INITIALIZE() 0 27.45 + 27.46 +#endif
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/src/share/vm/trace/tracing.hpp Wed Jan 11 17:34:02 2012 -0500 28.3 @@ -0,0 +1,30 @@ 28.4 +/* 28.5 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.7 + * 28.8 + * This code is free software; you can redistribute it and/or modify it 28.9 + * under the terms of the GNU General Public License version 2 only, as 28.10 + * published by the Free Software Foundation. 28.11 + * 28.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 28.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 28.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 28.15 + * version 2 for more details (a copy is included in the LICENSE file that 28.16 + * accompanied this code). 28.17 + * 28.18 + * You should have received a copy of the GNU General Public License version 28.19 + * 2 along with this work; if not, write to the Free Software Foundation, 28.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 28.21 + * 28.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 28.23 + * or visit www.oracle.com if you need additional information or have any 28.24 + * questions. 28.25 + * 28.26 + */ 28.27 + 28.28 +#ifndef SHARE_VM_TRACE_TRACING_HPP 28.29 +#define SHARE_VM_TRACE_TRACING_HPP 28.30 + 28.31 +#include "trace/traceMacros.hpp" 28.32 + 28.33 +#endif
29.1 --- a/src/share/vm/utilities/globalDefinitions.hpp Mon Jan 09 10:27:24 2012 +0100 29.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp Wed Jan 11 17:34:02 2012 -0500 29.3 @@ -298,6 +298,11 @@ 29.4 const juint max_juint = (juint)-1; // 0xFFFFFFFF largest juint 29.5 const julong max_julong = (julong)-1; // 0xFF....FF largest julong 29.6 29.7 +typedef jbyte s1; 29.8 +typedef jshort s2; 29.9 +typedef jint s4; 29.10 +typedef jlong s8; 29.11 + 29.12 //---------------------------------------------------------------------------------------------------- 29.13 // JVM spec restrictions 29.14