< prev index next >

src/hotspot/share/prims/jvmtiTagMapTable.hpp

Print this page

  1 /*
  2  * Copyright (c) 2020, 2023, 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  *

 35 
 36 // The oop is needed for lookup rather than creating a WeakHandle during
 37 // lookup because the HeapWalker may walk soon to be dead objects and
 38 // creating a WeakHandle for an otherwise dead object makes G1 unhappy.
 39 //
 40 // This class is the Key type for inserting in ResizeableResourceHashTable
 41 // Its get_hash() and equals() methods are also used for getting the hash
 42 // value of a Key and comparing two Keys, respectively.
 43 class JvmtiTagMapKey : public CHeapObj<mtServiceability> {
 44   WeakHandle _wh;
 45   oop _obj; // temporarily hold obj while searching
 46  public:
 47   JvmtiTagMapKey(oop obj);
 48   JvmtiTagMapKey(const JvmtiTagMapKey& src);
 49   JvmtiTagMapKey& operator=(const JvmtiTagMapKey&) = delete;
 50 
 51   oop object() const;
 52   oop object_no_keepalive() const;
 53   void release_weak_handle();
 54 
 55   static unsigned get_hash(const JvmtiTagMapKey& entry) {
 56     assert(entry._obj != nullptr, "must lookup obj to hash");
 57     return (unsigned)entry._obj->identity_hash();
 58   }
 59 
 60   static bool equals(const JvmtiTagMapKey& lhs, const JvmtiTagMapKey& rhs) {
 61     oop lhs_obj = lhs._obj != nullptr ? lhs._obj : lhs.object_no_keepalive();
 62     oop rhs_obj = rhs._obj != nullptr ? rhs._obj : rhs.object_no_keepalive();
 63     return lhs_obj == rhs_obj;
 64   }
 65 };
 66 
 67 typedef
 68 ResizeableResourceHashtable <JvmtiTagMapKey, jlong,
 69                               AnyObj::C_HEAP, mtServiceability,
 70                               JvmtiTagMapKey::get_hash,
 71                               JvmtiTagMapKey::equals> ResizableResourceHT;
 72 
 73 class JvmtiTagMapTable : public CHeapObj<mtServiceability> {
 74  private:
 75   ResizableResourceHT _table;
 76 
 77  public:
 78   JvmtiTagMapTable();
 79   ~JvmtiTagMapTable();

  1 /*
  2  * Copyright (c) 2020, 2024, 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  *

 35 
 36 // The oop is needed for lookup rather than creating a WeakHandle during
 37 // lookup because the HeapWalker may walk soon to be dead objects and
 38 // creating a WeakHandle for an otherwise dead object makes G1 unhappy.
 39 //
 40 // This class is the Key type for inserting in ResizeableResourceHashTable
 41 // Its get_hash() and equals() methods are also used for getting the hash
 42 // value of a Key and comparing two Keys, respectively.
 43 class JvmtiTagMapKey : public CHeapObj<mtServiceability> {
 44   WeakHandle _wh;
 45   oop _obj; // temporarily hold obj while searching
 46  public:
 47   JvmtiTagMapKey(oop obj);
 48   JvmtiTagMapKey(const JvmtiTagMapKey& src);
 49   JvmtiTagMapKey& operator=(const JvmtiTagMapKey&) = delete;
 50 
 51   oop object() const;
 52   oop object_no_keepalive() const;
 53   void release_weak_handle();
 54 
 55   static unsigned get_hash(const JvmtiTagMapKey& entry);




 56   static bool equals(const JvmtiTagMapKey& lhs, const JvmtiTagMapKey& rhs) {
 57     oop lhs_obj = lhs._obj != nullptr ? lhs._obj : lhs.object_no_keepalive();
 58     oop rhs_obj = rhs._obj != nullptr ? rhs._obj : rhs.object_no_keepalive();
 59     return lhs_obj == rhs_obj;
 60   }
 61 };
 62 
 63 typedef
 64 ResizeableResourceHashtable <JvmtiTagMapKey, jlong,
 65                               AnyObj::C_HEAP, mtServiceability,
 66                               JvmtiTagMapKey::get_hash,
 67                               JvmtiTagMapKey::equals> ResizableResourceHT;
 68 
 69 class JvmtiTagMapTable : public CHeapObj<mtServiceability> {
 70  private:
 71   ResizableResourceHT _table;
 72 
 73  public:
 74   JvmtiTagMapTable();
 75   ~JvmtiTagMapTable();
< prev index next >