--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp Wed Mar 15 11:44:46 2017 +0100
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp Wed Mar 15 10:25:37 2017 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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
@@ -400,21 +400,20 @@
return JVMTI_ERROR_UNMODIFIABLE_CLASS;
}
- Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
- KlassHandle klass(current_thread, k_oop);
+ Klass* klass = java_lang_Class::as_Klass(k_mirror);
jint status = klass->jvmti_class_status();
if (status & (JVMTI_CLASS_STATUS_ERROR)) {
return JVMTI_ERROR_INVALID_CLASS;
}
- instanceKlassHandle ikh(current_thread, k_oop);
- if (ikh->get_cached_class_file_bytes() == NULL) {
+ InstanceKlass* ik = InstanceKlass::cast(klass);
+ if (ik->get_cached_class_file_bytes() == NULL) {
// Not cached, we need to reconstitute the class file from the
// VM representation. We don't attach the reconstituted class
// bytes to the InstanceKlass here because they have not been
// validated and we're not at a safepoint.
- JvmtiClassFileReconstituter reconstituter(ikh);
+ JvmtiClassFileReconstituter reconstituter(ik);
if (reconstituter.get_error() != JVMTI_ERROR_NONE) {
return reconstituter.get_error();
}
@@ -424,8 +423,8 @@
reconstituter.class_file_bytes();
} else {
// it is cached, get it from the cache
- class_definitions[index].class_byte_count = ikh->get_cached_class_file_len();
- class_definitions[index].class_bytes = ikh->get_cached_class_file_bytes();
+ class_definitions[index].class_byte_count = ik->get_cached_class_file_len();
+ class_definitions[index].class_bytes = ik->get_cached_class_file_bytes();
}
class_definitions[index].klass = jcls;
}
@@ -667,8 +666,6 @@
return JVMTI_ERROR_INTERNAL;
}
- instanceKlassHandle loader_ik(THREAD, loader->klass());
-
// Invoke the appendToClassPathForInstrumentation method - if the method
// is not found it means the loader doesn't support adding to the class path
// in the live phase.
@@ -676,7 +673,7 @@
JavaValue res(T_VOID);
JavaCalls::call_special(&res,
loader,
- loader_ik,
+ loader->klass(),
vmSymbols::appendToClassPathForInstrumentation_name(),
vmSymbols::appendToClassPathForInstrumentation_signature(),
path,
@@ -1781,7 +1778,7 @@
jvmtiError
JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_object, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
// check klass if provided
- Klass* k_oop = NULL;
+ Klass* k = NULL;
if (klass != NULL) {
oop k_mirror = JNIHandles::resolve_external_guard(klass);
if (k_mirror == NULL) {
@@ -1790,18 +1787,17 @@
if (java_lang_Class::is_primitive(k_mirror)) {
return JVMTI_ERROR_NONE;
}
- k_oop = java_lang_Class::as_Klass(k_mirror);
- if (k_oop == NULL) {
+ k = java_lang_Class::as_Klass(k_mirror);
+ if (klass == NULL) {
return JVMTI_ERROR_INVALID_CLASS;
}
}
Thread *thread = Thread::current();
HandleMark hm(thread);
- KlassHandle kh (thread, k_oop);
TraceTime t("FollowReferences", TRACETIME_LOG(Debug, jvmti, objecttagging));
- JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, kh, initial_object, callbacks, user_data);
+ JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, k, initial_object, callbacks, user_data);
return JVMTI_ERROR_NONE;
} /* end FollowReferences */
@@ -1812,7 +1808,7 @@
jvmtiError
JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
// check klass if provided
- Klass* k_oop = NULL;
+ Klass* k = NULL;
if (klass != NULL) {
oop k_mirror = JNIHandles::resolve_external_guard(klass);
if (k_mirror == NULL) {
@@ -1821,18 +1817,14 @@
if (java_lang_Class::is_primitive(k_mirror)) {
return JVMTI_ERROR_NONE;
}
- k_oop = java_lang_Class::as_Klass(k_mirror);
- if (k_oop == NULL) {
+ k = java_lang_Class::as_Klass(k_mirror);
+ if (k == NULL) {
return JVMTI_ERROR_INVALID_CLASS;
}
}
- Thread *thread = Thread::current();
- HandleMark hm(thread);
- KlassHandle kh (thread, k_oop);
-
TraceTime t("IterateThroughHeap", TRACETIME_LOG(Debug, jvmti, objecttagging));
- JvmtiTagMap::tag_map_for(this)->iterate_through_heap(heap_filter, kh, callbacks, user_data);
+ JvmtiTagMap::tag_map_for(this)->iterate_through_heap(heap_filter, k, callbacks, user_data);
return JVMTI_ERROR_NONE;
} /* end IterateThroughHeap */
@@ -1909,7 +1901,7 @@
TraceTime t("IterateOverHeap", TRACETIME_LOG(Debug, jvmti, objecttagging));
Thread *thread = Thread::current();
HandleMark hm(thread);
- JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, KlassHandle(), heap_object_callback, user_data);
+ JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, NULL, heap_object_callback, user_data);
return JVMTI_ERROR_NONE;
} /* end IterateOverHeap */
@@ -1923,13 +1915,10 @@
// DO PRIMITIVE CLASS PROCESSING
return JVMTI_ERROR_NONE;
}
- Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
- if (k_oop == NULL) {
+ Klass* klass = java_lang_Class::as_Klass(k_mirror);
+ if (klass == NULL) {
return JVMTI_ERROR_INVALID_CLASS;
}
- Thread *thread = Thread::current();
- HandleMark hm(thread);
- KlassHandle klass (thread, k_oop);
TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
return JVMTI_ERROR_NONE;
@@ -2408,9 +2397,9 @@
*methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID));
return JVMTI_ERROR_NONE;
}
- instanceKlassHandle instanceK_h(current_thread, k);
+ InstanceKlass* ik = InstanceKlass::cast(k);
// Allocate the result and fill it in
- int result_length = instanceK_h->methods()->length();
+ int result_length = ik->methods()->length();
jmethodID* result_list = (jmethodID*)jvmtiMalloc(result_length * sizeof(jmethodID));
int index;
bool jmethodids_found = true;
@@ -2419,8 +2408,8 @@
// Use the original method ordering indices stored in the class, so we can emit
// jmethodIDs in the order they appeared in the class file
for (index = 0; index < result_length; index++) {
- Method* m = instanceK_h->methods()->at(index);
- int original_index = instanceK_h->method_ordering()->at(index);
+ Method* m = ik->methods()->at(index);
+ int original_index = ik->method_ordering()->at(index);
assert(original_index >= 0 && original_index < result_length, "invalid original method index");
jmethodID id;
if (jmethodids_found) {
@@ -2429,7 +2418,7 @@
// If we find an uninitialized value, make sure there is
// enough space for all the uninitialized values we might
// find.
- instanceK_h->ensure_space_for_methodids(index);
+ ik->ensure_space_for_methodids(index);
jmethodids_found = false;
id = m->jmethod_id();
}
@@ -2441,7 +2430,7 @@
} else {
// otherwise just copy in any order
for (index = 0; index < result_length; index++) {
- Method* m = instanceK_h->methods()->at(index);
+ Method* m = ik->methods()->at(index);
jmethodID id;
if (jmethodids_found) {
id = m->find_jmethod_id_or_null();
@@ -2449,7 +2438,7 @@
// If we find an uninitialized value, make sure there is
// enough space for all the uninitialized values we might
// find.
- instanceK_h->ensure_space_for_methodids(index);
+ ik->ensure_space_for_methodids(index);
jmethodids_found = false;
id = m->jmethod_id();
}
@@ -2494,11 +2483,11 @@
}
- instanceKlassHandle instanceK_h(current_thread, k);
+ InstanceKlass* ik = InstanceKlass::cast(k);
int result_count = 0;
// First, count the fields.
- FilteredFieldStream flds(instanceK_h, true, true);
+ FilteredFieldStream flds(ik, true, true);
result_count = flds.field_count();
// Allocate the result and fill it in
@@ -2507,9 +2496,9 @@
// this is the reverse order of what FieldStream hands out.
int id_index = (result_count - 1);
- for (FilteredFieldStream src_st(instanceK_h, true, true); !src_st.eos(); src_st.next()) {
+ for (FilteredFieldStream src_st(ik, true, true); !src_st.eos(); src_st.next()) {
result_list[id_index--] = jfieldIDWorkaround::to_jfieldID(
- instanceK_h, src_st.offset(),
+ ik, src_st.offset(),
src_st.access_flags().is_static());
}
assert(id_index == -1, "just checking");
@@ -2574,10 +2563,7 @@
if (java_lang_Class::is_primitive(k_mirror)) {
return JVMTI_ERROR_ABSENT_INFORMATION;
}
- Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
- Thread *thread = Thread::current();
- HandleMark hm(thread);
- KlassHandle klass(thread, k_oop);
+ Klass* klass = java_lang_Class::as_Klass(k_mirror);
jint status = klass->jvmti_class_status();
if (status & (JVMTI_CLASS_STATUS_ERROR)) {
@@ -2587,7 +2573,7 @@
return JVMTI_ERROR_ABSENT_INFORMATION;
}
- instanceKlassHandle ik(thread, k_oop);
+ InstanceKlass* ik = InstanceKlass::cast(klass);
*minor_version_ptr = ik->minor_version();
*major_version_ptr = ik->major_version();
@@ -2605,11 +2591,9 @@
return JVMTI_ERROR_ABSENT_INFORMATION;
}
- Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
+ Klass* klass = java_lang_Class::as_Klass(k_mirror);
Thread *thread = Thread::current();
- HandleMark hm(thread);
ResourceMark rm(thread);
- KlassHandle klass(thread, k_oop);
jint status = klass->jvmti_class_status();
if (status & (JVMTI_CLASS_STATUS_ERROR)) {
@@ -2619,8 +2603,8 @@
return JVMTI_ERROR_ABSENT_INFORMATION;
}
- instanceKlassHandle ikh(thread, k_oop);
- JvmtiConstantPoolReconstituter reconstituter(ikh);
+ InstanceKlass* ik = InstanceKlass::cast(klass);
+ JvmtiConstantPoolReconstituter reconstituter(ik);
if (reconstituter.get_error() != JVMTI_ERROR_NONE) {
return reconstituter.get_error();
}
@@ -2639,7 +2623,7 @@
return reconstituter.get_error();
}
- constantPoolHandle constants(thread, ikh->constants());
+ constantPoolHandle constants(thread, ik->constants());
*constant_pool_count_ptr = constants->length();
*constant_pool_byte_count_ptr = cpool_size;
*constant_pool_bytes_ptr = cpool_bytes;