diff --git a/make/hotspot/lib/JvmFeatures.gmk b/make/hotspot/lib/JvmFeatures.gmk index c8a58465d52..a0136870d8c 100644 --- a/make/hotspot/lib/JvmFeatures.gmk +++ b/make/hotspot/lib/JvmFeatures.gmk @@ -84,7 +84,7 @@ ifneq ($(call check-jvm-feature, jvmti), true) jvmtiImpl.cpp jvmtiManageCapabilities.cpp jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp \ jvmtiCodeBlobEvents.cpp jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp jvmtiEnvThreadState.cpp \ jvmtiTagMap.cpp jvmtiEventController.cpp evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \ - jvmtiClassFileReconstituter.cpp jvmtiTagMapTable.cpp jvmtiAgent.cpp jvmtiAgentList.cpp + jvmtiClassFileReconstituter.cpp jvmtiTagMapTable.cpp jvmtiAgent.cpp jvmtiAgentList.cpp jfrJvmtiAgent.cpp endif ifneq ($(call check-jvm-feature, jvmci), true) diff --git a/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.hpp b/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.hpp index bd11cdb54ed..22c1b5c6256 100644 --- a/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.hpp +++ b/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -32,10 +32,10 @@ class JfrJvmtiAgent : public JfrCHeapObj { private: JfrJvmtiAgent(); ~JfrJvmtiAgent(); - static bool create(); - static void destroy(); + static bool create() NOT_JVMTI_RETURN_(true); + static void destroy() NOT_JVMTI_RETURN; public: - static void retransform_classes(JNIEnv* env, jobjectArray classes, TRAPS); + static void retransform_classes(JNIEnv* env, jobjectArray classes, TRAPS) NOT_JVMTI_RETURN; }; #endif // SHARE_JFR_INSTRUMENTATION_JFRJVMTIAGENT_HPP diff --git a/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp b/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp index 65b23e3433a..d9aae89b993 100644 --- a/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp +++ b/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, 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 @@ -280,6 +280,7 @@ TRACE_REQUEST_FUNC(SystemProcess) { } } +#if INCLUDE_JVMTI template static void send_agent_event(AgentEvent& event, const JvmtiAgent* agent) { event.set_name(agent->name()); @@ -316,6 +317,10 @@ TRACE_REQUEST_FUNC(NativeAgent) { const JvmtiAgentList::Iterator xrun_agents_it = JvmtiAgentList::xrun_agents(); send_native_agent_events(xrun_agents_it); } +#else // INCLUDE_JVMTI +TRACE_REQUEST_FUNC(JavaAgent) {} +TRACE_REQUEST_FUNC(NativeAgent) {} +#endif // INCLUDE_JVMTI TRACE_REQUEST_FUNC(ThreadContextSwitchRate) { double rate = 0.0; diff --git a/src/hotspot/share/jfr/recorder/jfrRecorder.cpp b/src/hotspot/share/jfr/recorder/jfrRecorder.cpp index cc460f8c2aa..9aebdcc0afa 100644 --- a/src/hotspot/share/jfr/recorder/jfrRecorder.cpp +++ b/src/hotspot/share/jfr/recorder/jfrRecorder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, 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 @@ -238,7 +238,7 @@ bool JfrRecorder::on_create_vm_2() { } bool JfrRecorder::on_create_vm_3() { - assert(JvmtiEnvBase::get_phase() == JVMTI_PHASE_LIVE, "invalid init sequence"); + JVMTI_ONLY( assert(JvmtiEnvBase::get_phase() == JVMTI_PHASE_LIVE, "invalid init sequence"); ) return CDSConfig::is_dumping_archive() || launch_command_line_recordings(JavaThread::current()); } diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp index 665656d0be4..8fdb96a3038 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp @@ -126,12 +126,14 @@ class CompilerToVM { // Minimum alignment of an offset into CodeBuffer::SECT_CONSTS static int data_section_item_alignment; +#if INCLUDE_JVMTI /* * Pointer to JvmtiExport::_should_notify_object_alloc. * Exposed as an int* instead of an address so the * underlying type is part of the JVMCIVMStructs definition. */ static int* _should_notify_object_alloc; +#endif public: static void initialize(JVMCI_TRAPS); diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp index 02cf6baff78..f1028b4b2bb 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp @@ -144,7 +144,7 @@ address CompilerToVM::Data::symbol_clinit; int CompilerToVM::Data::data_section_item_alignment; -int* CompilerToVM::Data::_should_notify_object_alloc; +JVMTI_ONLY( int* CompilerToVM::Data::_should_notify_object_alloc; ) void CompilerToVM::Data::initialize(JVMCI_TRAPS) { Klass_vtable_start_offset = in_bytes(Klass::vtable_start_offset()); @@ -230,7 +230,7 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) { data_section_item_alignment = relocInfo::addr_unit(); - _should_notify_object_alloc = &JvmtiExport::_should_notify_object_alloc; + JVMTI_ONLY( _should_notify_object_alloc = &JvmtiExport::_should_notify_object_alloc; ) BarrierSet* bs = BarrierSet::barrier_set(); if (bs->is_a(BarrierSet::CardTableBarrierSet)) { diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index f55c7bf91a9..1e2ca0e990e 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -138,7 +138,7 @@ \ static_field(CompilerToVM::Data, data_section_item_alignment, int) \ \ - static_field(CompilerToVM::Data, _should_notify_object_alloc, int*) \ + JVMTI_ONLY(static_field(CompilerToVM::Data, _should_notify_object_alloc, int*)) \ \ static_field(Abstract_VM_Version, _features, uint64_t) \ \ diff --git a/test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java b/test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java index 3bba83ffbe4..9becd4677e1 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestAgentEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -46,7 +46,7 @@ import jdk.test.lib.jfr.TestClassLoader; * @test * @key jfr * @summary Tests Agent Loaded event by starting native and Java agents - * @requires vm.hasJFR + * @requires vm.hasJFR & vm.jvmti * * @library /test/lib * @modules java.instrument