1 /*
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
1604 // callbacks - pre-checked for NULL
1605 // user_data - NULL is a valid value, must be checked
1606 jvmtiError
1607 JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_object, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
1608 // check klass if provided
1609 Klass* k_oop = NULL;
1610 if (klass != NULL) {
1611 oop k_mirror = JNIHandles::resolve_external_guard(klass);
1612 if (k_mirror == NULL) {
1613 return JVMTI_ERROR_INVALID_CLASS;
1614 }
1615 if (java_lang_Class::is_primitive(k_mirror)) {
1616 return JVMTI_ERROR_NONE;
1617 }
1618 k_oop = java_lang_Class::as_Klass(k_mirror);
1619 if (k_oop == NULL) {
1620 return JVMTI_ERROR_INVALID_CLASS;
1621 }
1622 }
1623
1624 Thread *thread = Thread::current();
1625 HandleMark hm(thread);
1626 KlassHandle kh (thread, k_oop);
1627
1628 TraceTime t("FollowReferences", TraceJVMTIObjectTagging);
1629 JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, kh, initial_object, callbacks, user_data);
1630 return JVMTI_ERROR_NONE;
1631 } /* end FollowReferences */
1632
1633
1634 // klass - NULL is a valid value, must be checked
1635 // callbacks - pre-checked for NULL
1636 // user_data - NULL is a valid value, must be checked
1637 jvmtiError
1638 JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
1639 // check klass if provided
1640 Klass* k_oop = NULL;
1641 if (klass != NULL) {
1642 oop k_mirror = JNIHandles::resolve_external_guard(klass);
1643 if (k_mirror == NULL) {
|
1 /*
2 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
1604 // callbacks - pre-checked for NULL
1605 // user_data - NULL is a valid value, must be checked
1606 jvmtiError
1607 JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_object, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
1608 // check klass if provided
1609 Klass* k_oop = NULL;
1610 if (klass != NULL) {
1611 oop k_mirror = JNIHandles::resolve_external_guard(klass);
1612 if (k_mirror == NULL) {
1613 return JVMTI_ERROR_INVALID_CLASS;
1614 }
1615 if (java_lang_Class::is_primitive(k_mirror)) {
1616 return JVMTI_ERROR_NONE;
1617 }
1618 k_oop = java_lang_Class::as_Klass(k_mirror);
1619 if (k_oop == NULL) {
1620 return JVMTI_ERROR_INVALID_CLASS;
1621 }
1622 }
1623
1624 if (initial_object != NULL) {
1625 oop init_obj = JNIHandles::resolve_external_guard(initial_object);
1626 if (init_obj == NULL) {
1627 return JVMTI_ERROR_INVALID_OBJECT;
1628 }
1629 }
1630
1631 Thread *thread = Thread::current();
1632 HandleMark hm(thread);
1633 KlassHandle kh (thread, k_oop);
1634
1635 TraceTime t("FollowReferences", TraceJVMTIObjectTagging);
1636 JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, kh, initial_object, callbacks, user_data);
1637 return JVMTI_ERROR_NONE;
1638 } /* end FollowReferences */
1639
1640
1641 // klass - NULL is a valid value, must be checked
1642 // callbacks - pre-checked for NULL
1643 // user_data - NULL is a valid value, must be checked
1644 jvmtiError
1645 JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
1646 // check klass if provided
1647 Klass* k_oop = NULL;
1648 if (klass != NULL) {
1649 oop k_mirror = JNIHandles::resolve_external_guard(klass);
1650 if (k_mirror == NULL) {
|