src/share/vm/prims/jvmtiTagMap.hpp

Wed, 03 Jul 2019 20:42:37 +0800

author
aoqi
date
Wed, 03 Jul 2019 20:42:37 +0800
changeset 9637
eef07cd490d4
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 // JvmtiTagMap
aoqi@0 26
aoqi@0 27 #ifndef SHARE_VM_PRIMS_JVMTITAGMAP_HPP
aoqi@0 28 #define SHARE_VM_PRIMS_JVMTITAGMAP_HPP
aoqi@0 29
aoqi@0 30 #include "gc_interface/collectedHeap.hpp"
aoqi@0 31 #include "jvmtifiles/jvmti.h"
aoqi@0 32 #include "jvmtifiles/jvmtiEnv.hpp"
aoqi@0 33 #include "memory/allocation.hpp"
aoqi@0 34 #include "memory/genCollectedHeap.hpp"
aoqi@0 35 #include "memory/universe.hpp"
aoqi@0 36
aoqi@0 37 // forward references
aoqi@0 38 class JvmtiTagHashmap;
aoqi@0 39 class JvmtiTagHashmapEntry;
aoqi@0 40 class JvmtiTagHashmapEntryClosure;
aoqi@0 41
aoqi@0 42 class JvmtiTagMap : public CHeapObj<mtInternal> {
aoqi@0 43 private:
aoqi@0 44
aoqi@0 45 enum{
aoqi@0 46 max_free_entries = 4096 // maximum number of free entries per env
aoqi@0 47 };
aoqi@0 48
aoqi@0 49 JvmtiEnv* _env; // the jvmti environment
aoqi@0 50 Mutex _lock; // lock for this tag map
aoqi@0 51 JvmtiTagHashmap* _hashmap; // the hashmap
aoqi@0 52
aoqi@0 53 JvmtiTagHashmapEntry* _free_entries; // free list for this environment
aoqi@0 54 int _free_entries_count; // number of entries on the free list
aoqi@0 55
aoqi@0 56 // create a tag map
aoqi@0 57 JvmtiTagMap(JvmtiEnv* env);
aoqi@0 58
aoqi@0 59 // accessors
aoqi@0 60 inline Mutex* lock() { return &_lock; }
aoqi@0 61 inline JvmtiEnv* env() const { return _env; }
aoqi@0 62
aoqi@0 63 void do_weak_oops(BoolObjectClosure* is_alive, OopClosure* f);
aoqi@0 64
aoqi@0 65 // iterate over all entries in this tag map
aoqi@0 66 void entry_iterate(JvmtiTagHashmapEntryClosure* closure);
aoqi@0 67
aoqi@0 68 public:
aoqi@0 69
aoqi@0 70 // indicates if this tag map is locked
aoqi@0 71 bool is_locked() { return lock()->is_locked(); }
aoqi@0 72
aoqi@0 73 JvmtiTagHashmap* hashmap() { return _hashmap; }
aoqi@0 74
aoqi@0 75 // create/destroy entries
aoqi@0 76 JvmtiTagHashmapEntry* create_entry(oop ref, jlong tag);
aoqi@0 77 void destroy_entry(JvmtiTagHashmapEntry* entry);
aoqi@0 78
aoqi@0 79 // returns true if the hashmaps are empty
aoqi@0 80 bool is_empty();
aoqi@0 81
aoqi@0 82 // return tag for the given environment
aoqi@0 83 static JvmtiTagMap* tag_map_for(JvmtiEnv* env);
aoqi@0 84
aoqi@0 85 // destroy tag map
aoqi@0 86 ~JvmtiTagMap();
aoqi@0 87
aoqi@0 88 // set/get tag
aoqi@0 89 void set_tag(jobject obj, jlong tag);
aoqi@0 90 jlong get_tag(jobject obj);
aoqi@0 91
aoqi@0 92 // deprecated heap iteration functions
aoqi@0 93 void iterate_over_heap(jvmtiHeapObjectFilter object_filter,
aoqi@0 94 KlassHandle klass,
aoqi@0 95 jvmtiHeapObjectCallback heap_object_callback,
aoqi@0 96 const void* user_data);
aoqi@0 97
aoqi@0 98 void iterate_over_reachable_objects(jvmtiHeapRootCallback heap_root_callback,
aoqi@0 99 jvmtiStackReferenceCallback stack_ref_callback,
aoqi@0 100 jvmtiObjectReferenceCallback object_ref_callback,
aoqi@0 101 const void* user_data);
aoqi@0 102
aoqi@0 103 void iterate_over_objects_reachable_from_object(jobject object,
aoqi@0 104 jvmtiObjectReferenceCallback object_reference_callback,
aoqi@0 105 const void* user_data);
aoqi@0 106
aoqi@0 107
aoqi@0 108 // advanced (JVMTI 1.1) heap iteration functions
aoqi@0 109 void iterate_through_heap(jint heap_filter,
aoqi@0 110 KlassHandle klass,
aoqi@0 111 const jvmtiHeapCallbacks* callbacks,
aoqi@0 112 const void* user_data);
aoqi@0 113
aoqi@0 114 void follow_references(jint heap_filter,
aoqi@0 115 KlassHandle klass,
aoqi@0 116 jobject initial_object,
aoqi@0 117 const jvmtiHeapCallbacks* callbacks,
aoqi@0 118 const void* user_data);
aoqi@0 119
aoqi@0 120 // get tagged objects
aoqi@0 121 jvmtiError get_objects_with_tags(const jlong* tags, jint count,
aoqi@0 122 jint* count_ptr, jobject** object_result_ptr,
aoqi@0 123 jlong** tag_result_ptr);
aoqi@0 124
aoqi@0 125 static void weak_oops_do(
aoqi@0 126 BoolObjectClosure* is_alive, OopClosure* f) NOT_JVMTI_RETURN;
aoqi@0 127 };
aoqi@0 128
aoqi@0 129 #endif // SHARE_VM_PRIMS_JVMTITAGMAP_HPP

mercurial