Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare JEP331 with an empty implementation #4461

Merged
merged 1 commit into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions runtime/include/jvmti.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2018 IBM Corp. and others
* Copyright (c) 1991, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -44,10 +44,10 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM* vm, char *options, void *reserved)
#define JVMTI_VERSION_1_1 0x30010100
#define JVMTI_VERSION_1_2 0x30010200
#define JVMTI_VERSION_1 (JVMTI_VERSION_1_0)
#define JVMTI_VERSION_9_0 0x30090000
#define JVMTI_VERSION_9 0x30090000
#define JVMTI_VERSION_11 0x300b0000

/* Required as of Java 9 b14x */
#define JVMTI_VERSION JVMTI_VERSION_9_0
#define JVMTI_VERSION JVMTI_VERSION_11

#define JVMTI_1_0_SPEC_VERSION (JVMTI_VERSION_1_0 + 37) /* Spec version is 1.0.37 */
#define JVMTI_1_1_SPEC_VERSION (JVMTI_VERSION_1_1 + 102) /* Spec version is 1.1.102 */
Expand Down Expand Up @@ -483,7 +483,8 @@ typedef struct {
unsigned int can_generate_resource_exhaustion_threads_events : 1;
unsigned int can_generate_early_vmstart : 1;
unsigned int can_generate_early_class_hook_events : 1;
unsigned int : 5;
unsigned int can_generate_sampled_object_alloc_events : 1;
unsigned int : 4;
unsigned int : 16;
unsigned int : 16;
unsigned int : 16;
Expand Down Expand Up @@ -733,8 +734,9 @@ typedef enum jvmtiEvent {
JVMTI_EVENT_GARBAGE_COLLECTION_FINISH = 82,
JVMTI_EVENT_OBJECT_FREE = 83,
JVMTI_EVENT_VM_OBJECT_ALLOC = 84,
JVMTI_EVENT_SAMPLED_OBJECT_ALLOC = 86,

JVMTI_MAX_EVENT_TYPE_VAL = 84,
JVMTI_MAX_EVENT_TYPE_VAL = 86,
jvmtiEventEnsureWideEnum = 0x1000000 /* ensure 4-byte enum */
} jvmtiEvent;

Expand Down Expand Up @@ -948,6 +950,14 @@ typedef void (JNICALL *jvmtiEventResourceExhausted) (
const void* reserved,
const char* description);

typedef void (JNICALL *jvmtiEventSampledObjectAlloc) (
jvmtiEnv *jvmti_env,
JNIEnv *jni_env,
jthread thread,
jobject object,
jclass object_klass,
jlong size);

typedef void * jvmtiEventReserved;

typedef struct {
Expand Down Expand Up @@ -986,6 +996,8 @@ typedef struct {
jvmtiEventGarbageCollectionFinish GarbageCollectionFinish;
jvmtiEventObjectFree ObjectFree;
jvmtiEventVMObjectAlloc VMObjectAlloc;
jvmtiEventReserved reserved85;
jvmtiEventSampledObjectAlloc SampledObjectAlloc;
} jvmtiEventCallbacks;

/*
Expand Down Expand Up @@ -1150,6 +1162,7 @@ typedef struct JVMTINativeInterface_ {
jvmtiError (JNICALL * GetOwnedMonitorStackDepthInfo)(jvmtiEnv* env, jthread thread, jint* monitor_info_count_ptr, jvmtiMonitorStackDepthInfo** monitor_info_ptr);
jvmtiError (JNICALL * GetObjectSize)(jvmtiEnv* env, jobject object, jlong* size_ptr);
jvmtiError (JNICALL * GetLocalInstance)(jvmtiEnv* env, jthread thread, jint depth, jobject* value_ptr);
jvmtiError (JNICALL * SetHeapSamplingInterval)(jvmtiEnv* env, jint sampling_interval);
} jvmtiNativeInterface;

struct _jvmtiEnv {
Expand Down Expand Up @@ -1302,6 +1315,7 @@ struct _jvmtiEnv {
jvmtiError GetOwnedMonitorStackDepthInfo (jthread thread, jint* monitor_info_count_ptr, jvmtiMonitorStackDepthInfo** monitor_info_ptr) { return functions->GetOwnedMonitorStackDepthInfo(this, thread, monitor_info_count_ptr, monitor_info_ptr); }
jvmtiError GetObjectSize (jobject object, jlong* size_ptr) { return functions->GetObjectSize(this, object, size_ptr); }
jvmtiError GetLocalInstance (jthread thread, jint depth, jobject* value_ptr) { return functions->GetLocalInstance(this, thread, depth, value_ptr); }
jvmtiError SetHeapSamplingInterval (jint sampling_interval) { return functions->SetHeapSamplingInterval(this, sampling_interval); }
#endif
};

Expand Down
7 changes: 6 additions & 1 deletion runtime/jvmti/j9jvmti.tdf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2006, 2017 IBM Corp. and others
//Copyright (c) 2006, 2019 IBM Corp. and others
//
//This program and the accompanying materials are made available under
//the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -617,3 +617,8 @@ TraceEvent=Trc_JVMTI_jvmtiAddCapabilities_turnOfRomMethodSorting Overhead=1 Leve

TraceEntry=Trc_JVMTI_jvmtiHookModuleSystemStarted_Entry Overhead=1 Level=1 Noenv Template="ModuleSystemStarted"
TraceExit=Trc_JVMTI_jvmtiHookModuleSystemStarted_Exit Overhead=1 Level=1 Noenv Template="ModuleSystemStarted"

TraceEntry=Trc_JVMTI_jvmtiSetHeapSamplingInterval_Entry Overhead=1 Level=5 Noenv Template="SetHeapSamplingInterval env=%p samplingInterval=%d"
TraceExit=Trc_JVMTI_jvmtiSetHeapSamplingInterval_Exit Overhead=1 Level=5 Noenv Template="SetHeapSamplingInterval: returning %d"
TraceEntry=Trc_JVMTI_jvmtiHookSampledObjectAlloc_Entry Overhead=1 Level=5 Noenv Template="HookSampledObjectAlloc starts"
TraceExit=Trc_JVMTI_jvmtiHookSampledObjectAlloc_Exit Overhead=1 Level=5 Noenv Template="HookSampledObjectAlloc"
13 changes: 12 additions & 1 deletion runtime/jvmti/jvmtiCapability.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2018 IBM Corp. and others
* Copyright (c) 1991, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -92,6 +92,8 @@ dumpCapabilities(J9JavaVM * vm, const jvmtiCapabilities *capabilities, const cha
PRINT_CAPABILITY(can_generate_early_vmstart);
PRINT_CAPABILITY(can_generate_early_class_hook_events);

/* JVMTI 11 */
PRINT_CAPABILITY(can_generate_sampled_object_alloc_events);
#undef PRINT_CAPABILITY
}

Expand Down Expand Up @@ -166,6 +168,11 @@ jvmtiGetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr
if (isEventHookable(j9env, JVMTI_EVENT_VM_OBJECT_ALLOC)) {
rv_capabilities.can_generate_vm_object_alloc_events = 1;
}

if (isEventHookable(j9env, JVMTI_EVENT_SAMPLED_OBJECT_ALLOC)) {
/* hardcode to 0 (not enabled) for empty JEP331 implementation */
rv_capabilities.can_generate_sampled_object_alloc_events = 0;
}

if (isEventHookable(j9env, JVMTI_EVENT_NATIVE_METHOD_BIND)) {
rv_capabilities.can_generate_native_method_bind_events = 1;
Expand Down Expand Up @@ -541,6 +548,10 @@ mapCapabilitiesToEvents(J9JVMTIEnv * j9env, jvmtiCapabilities * capabilities, J9
rc |= eventHookFunction(j9env, JVMTI_EVENT_VM_OBJECT_ALLOC);
}

if (capabilities->can_generate_sampled_object_alloc_events) {
rc |= eventHookFunction(j9env, JVMTI_EVENT_SAMPLED_OBJECT_ALLOC);
}

if (capabilities->can_generate_object_free_events) {
rc |= eventHookFunction(j9env, JVMTI_EVENT_OBJECT_FREE);
}
Expand Down
8 changes: 6 additions & 2 deletions runtime/jvmti/jvmtiEventManagement.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2018 IBM Corp. and others
* Copyright (c) 1991, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -149,7 +149,11 @@ jvmtiSetEventNotificationMode(jvmtiEnv* env,
case JVMTI_EVENT_VM_OBJECT_ALLOC:
ENSURE_CAPABILITY(env, can_generate_vm_object_alloc_events);
break;


case JVMTI_EVENT_SAMPLED_OBJECT_ALLOC:
ENSURE_CAPABILITY(env, can_generate_sampled_object_alloc_events);
break;

case JVMTI_EVENT_NATIVE_METHOD_BIND:
ENSURE_CAPABILITY(env, can_generate_native_method_bind_events);
break;
Expand Down
3 changes: 2 additions & 1 deletion runtime/jvmti/jvmtiFunctionTable.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2016 IBM Corp. and others
* Copyright (c) 1991, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -179,6 +179,7 @@ jvmtiNativeInterface jvmtiFunctionTable = {
jvmtiGetOwnedMonitorStackDepthInfo,
jvmtiGetObjectSize,
jvmtiGetLocalInstance,
jvmtiSetHeapSamplingInterval,
};


2 changes: 1 addition & 1 deletion runtime/jvmti/jvmtiGeneral.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jvmtiGetVersionNumber(jvmtiEnv* env,
ENSURE_NON_NULL(version_ptr);

if (J2SE_VERSION(vm) >= J2SE_V11) {
rv_version = JVMTI_VERSION_9_0;
rv_version = JVMTI_VERSION_11;
}

rc = JVMTI_ERROR_NONE;
Expand Down
137 changes: 2 additions & 135 deletions runtime/jvmti/jvmtiHelpers.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2018 IBM Corp. and others
* Copyright (c) 1991, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -26,132 +26,6 @@

extern jvmtiNativeInterface jvmtiFunctionTable;

static jvmtiCapabilities capabilitiesMask10 = {
1, /* can_tag_objects */
1, /* can_generate_field_modification_events */
1, /* can_generate_field_access_events */
1, /* can_get_bytecodes */
1, /* can_get_synthetic_attribute */
1, /* can_get_owned_monitor_info */
1, /* can_get_current_contended_monitor */
1, /* can_get_monitor_info */
1, /* can_pop_frame */
1, /* can_redefine_classes */
1, /* can_signal_thread */
1, /* can_get_source_file_name */
1, /* can_get_line_numbers */
1, /* can_get_source_debug_extension */
1, /* can_access_local_variables */
1, /* can_maintain_original_method_order */
1, /* can_generate_single_step_events */
1, /* can_generate_exception_events */
1, /* can_generate_frame_pop_events */
1, /* can_generate_breakpoint_events */
1, /* can_suspend */
1, /* can_redefine_any_class */
1, /* can_get_current_thread_cpu_time */
1, /* can_get_thread_cpu_time */
1, /* can_generate_method_entry_events */
1, /* can_generate_method_exit_events */
1, /* can_generate_all_class_hook_events */
1, /* can_generate_compiled_method_load_events */
1, /* can_generate_monitor_events */
1, /* can_generate_vm_object_alloc_events */
1, /* can_generate_native_method_bind_events */
1, /* can_generate_garbage_collection_events */
1, /* can_generate_object_free_events */
};

static jvmtiCapabilities capabilitiesMask11 = {
1, /* can_tag_objects */
1, /* can_generate_field_modification_events */
1, /* can_generate_field_access_events */
1, /* can_get_bytecodes */
1, /* can_get_synthetic_attribute */
1, /* can_get_owned_monitor_info */
1, /* can_get_current_contended_monitor */
1, /* can_get_monitor_info */
1, /* can_pop_frame */
1, /* can_redefine_classes */
1, /* can_signal_thread */
1, /* can_get_source_file_name */
1, /* can_get_line_numbers */
1, /* can_get_source_debug_extension */
1, /* can_access_local_variables */
1, /* can_maintain_original_method_order */
1, /* can_generate_single_step_events */
1, /* can_generate_exception_events */
1, /* can_generate_frame_pop_events */
1, /* can_generate_breakpoint_events */
1, /* can_suspend */
1, /* can_redefine_any_class */
1, /* can_get_current_thread_cpu_time */
1, /* can_get_thread_cpu_time */
1, /* can_generate_method_entry_events */
1, /* can_generate_method_exit_events */
1, /* can_generate_all_class_hook_events */
1, /* can_generate_compiled_method_load_events */
1, /* can_generate_monitor_events */
1, /* can_generate_vm_object_alloc_events */
1, /* can_generate_native_method_bind_events */
1, /* can_generate_garbage_collection_events */
1, /* can_generate_object_free_events */
1, /* can_force_early_return */
1, /* can_get_owned_monitor_stack_depth_info */
1, /* can_get_constant_pool */
1, /* can_set_native_method_prefix */
1, /* can_retransform_classes */
1, /* can_retransform_any_class */
1, /* can_generate_resource_exhaustion_heap_events */
1, /* can_generate_resource_exhaustion_threads_events */
};

static jvmtiCapabilities capabilitiesMask90 = {
1, /* can_tag_objects */
1, /* can_generate_field_modification_events */
1, /* can_generate_field_access_events */
1, /* can_get_bytecodes */
1, /* can_get_synthetic_attribute */
1, /* can_get_owned_monitor_info */
1, /* can_get_current_contended_monitor */
1, /* can_get_monitor_info */
1, /* can_pop_frame */
1, /* can_redefine_classes */
1, /* can_signal_thread */
1, /* can_get_source_file_name */
1, /* can_get_line_numbers */
1, /* can_get_source_debug_extension */
1, /* can_access_local_variables */
1, /* can_maintain_original_method_order */
1, /* can_generate_single_step_events */
1, /* can_generate_exception_events */
1, /* can_generate_frame_pop_events */
1, /* can_generate_breakpoint_events */
1, /* can_suspend */
1, /* can_redefine_any_class */
1, /* can_get_current_thread_cpu_time */
1, /* can_get_thread_cpu_time */
1, /* can_generate_method_entry_events */
1, /* can_generate_method_exit_events */
1, /* can_generate_all_class_hook_events */
1, /* can_generate_compiled_method_load_events */
1, /* can_generate_monitor_events */
1, /* can_generate_vm_object_alloc_events */
1, /* can_generate_native_method_bind_events */
1, /* can_generate_garbage_collection_events */
1, /* can_generate_object_free_events */
1, /* can_force_early_return */
1, /* can_get_owned_monitor_stack_depth_info */
1, /* can_get_constant_pool */
1, /* can_set_native_method_prefix */
1, /* can_retransform_classes */
1, /* can_retransform_any_class */
1, /* can_generate_resource_exhaustion_heap_events */
1, /* can_generate_resource_exhaustion_threads_events */
1, /* can_generate_early_vmstart */
1, /* can_generate_early_class_hook_events */
};

/* Jazz 99339: Map JVMTI event number to the reason code for zAAP switching on zOS.
* Note: refer to jvmtiEventCallbacks (/runtime/include/jvmti.h) for reserved JVMTI events.
*/
Expand Down Expand Up @@ -199,6 +73,7 @@ static const UDATA reasonCodeFromJVMTIEvent[] = {
J9_JNI_OFFLOAD_SWITCH_J9JVMTI_VM_DUMP_END, /* J9JVMTI_EVENT_COM_IBM_VM_DUMP_END */
J9_JNI_OFFLOAD_SWITCH_J9JVMTI_GC_CYCLE_START, /* J9JVMTI_EVENT_COM_IBM_GARBAGE_COLLECTION_CYCLE_START */
J9_JNI_OFFLOAD_SWITCH_J9JVMTI_GC_CYCLE_FINISH, /* J9JVMTI_EVENT_COM_IBM_GARBAGE_COLLECTION_CYCLE_FINISH */
J9_JNI_OFFLOAD_SWITCH_JVMTI_SAMPLED_OBJECT_ALLOC, /* JVMTI_EVENT_VM_OBJECT_ALLOC */
};
#endif /* J9VM_OPT_JAVA_OFFLOAD_SUPPORT */

Expand Down Expand Up @@ -423,14 +298,6 @@ allocateEnvironment(J9InvocationJavaVM * invocationJavaVM, jint version, void **
#if defined (J9VM_INTERP_NATIVE_SUPPORT)
j9env->jitHook.hookInterface = jitHook;
#endif
j9env->capabilitiesMask = capabilitiesMask10;
if (version >= JVMTI_VERSION_1_1) {
j9env->capabilitiesMask = capabilitiesMask11;
}
if (version >= JVMTI_VERSION_9_0) {
j9env->capabilitiesMask = capabilitiesMask90;
}

if ((j9env->vmHook.agentID = (*vmHook)->J9HookAllocateAgentID(vmHook)) == 0) {
goto fail;
}
Expand Down
Loading