changeset 48781:6ebef5cd0c8d

8194736: Refactor weak oops in ProtectionDomain table to use the Access API Reviewed-by: coleenp, pliden
author eosterlund
date Wed, 10 Jan 2018 22:40:47 +0100
parents b96f03796580
children c823eca266c3
files src/hotspot/share/classfile/dictionary.cpp src/hotspot/share/classfile/dictionary.hpp src/hotspot/share/classfile/protectionDomainCache.cpp src/hotspot/share/classfile/protectionDomainCache.hpp
diffstat 4 files changed, 35 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/dictionary.cpp	Thu Jan 11 21:49:51 2018 -0500
+++ b/src/hotspot/share/classfile/dictionary.cpp	Wed Jan 10 22:40:47 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -167,7 +167,7 @@
     for (ProtectionDomainEntry* current = pd_set_acquire();
                                 current != NULL;
                                 current = current->next()) {
-      if (current->protection_domain() == protection_domain) {
+      if (current->object_no_keepalive() == protection_domain) {
         in_pd_set = true;
         break;
       }
@@ -187,7 +187,7 @@
   for (ProtectionDomainEntry* current = pd_set_acquire();
                               current != NULL;
                               current = current->next()) {
-    if (current->protection_domain() == protection_domain) return true;
+    if (current->object_no_keepalive() == protection_domain) return true;
   }
   return false;
 }
--- a/src/hotspot/share/classfile/dictionary.hpp	Thu Jan 11 21:49:51 2018 -0500
+++ b/src/hotspot/share/classfile/dictionary.hpp	Wed Jan 10 22:40:47 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -189,7 +189,7 @@
     for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
                                 current != NULL;
                                 current = current->_next) {
-      current->_pd_cache->protection_domain()->verify();
+      current->_pd_cache->object_no_keepalive()->verify();
     }
   }
 
--- a/src/hotspot/share/classfile/protectionDomainCache.cpp	Thu Jan 11 21:49:51 2018 -0500
+++ b/src/hotspot/share/classfile/protectionDomainCache.cpp	Wed Jan 10 22:40:47 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, 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
@@ -52,14 +52,14 @@
     ProtectionDomainCacheEntry** p = bucket_addr(i);
     ProtectionDomainCacheEntry* entry = bucket(i);
     while (entry != NULL) {
-      if (is_alive->do_object_b(entry->literal())) {
+      if (is_alive->do_object_b(entry->object_no_keepalive())) {
         p = entry->next_addr();
       } else {
         LogTarget(Debug, protectiondomain) lt;
         if (lt.is_enabled()) {
           LogStream ls(lt);
           ls.print("protection domain unlinked: ");
-          entry->literal()->print_value_on(&ls);
+          entry->object_no_keepalive()->print_value_on(&ls);
           ls.cr();
         }
         *p = entry->next();
@@ -87,7 +87,7 @@
     for (ProtectionDomainCacheEntry* probe = bucket(index);
                                      probe != NULL;
                                      probe = probe->next()) {
-      st->print_cr("%4d: protection_domain: " PTR_FORMAT, index, p2i(probe->literal()));
+      st->print_cr("%4d: protection_domain: " PTR_FORMAT, index, p2i(probe->object_no_keepalive()));
     }
   }
 }
@@ -96,8 +96,27 @@
   verify_table<ProtectionDomainCacheEntry>("Protection Domain Table");
 }
 
+oop ProtectionDomainCacheEntry::object() {
+  return RootAccess<ON_PHANTOM_OOP_REF>::oop_load(literal_addr());
+}
+
+oop ProtectionDomainEntry::object() {
+  return _pd_cache->object();
+}
+
+// The object_no_keepalive() call peeks at the phantomly reachable oop without
+// keeping it alive. This is okay to do in the VM thread state if it is not
+// leaked out to become strongly reachable.
+oop ProtectionDomainCacheEntry::object_no_keepalive() {
+  return RootAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(literal_addr());
+}
+
+oop ProtectionDomainEntry::object_no_keepalive() {
+  return _pd_cache->object_no_keepalive();
+}
+
 void ProtectionDomainCacheEntry::verify() {
-  guarantee(oopDesc::is_oop(literal()), "must be an oop");
+  guarantee(oopDesc::is_oop(object_no_keepalive()), "must be an oop");
 }
 
 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::get(Handle protection_domain) {
@@ -113,7 +132,7 @@
 
 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::find_entry(int index, Handle protection_domain) {
   for (ProtectionDomainCacheEntry* e = bucket(index); e != NULL; e = e->next()) {
-    if (e->protection_domain() == protection_domain()) {
+    if (e->object_no_keepalive() == protection_domain()) {
       return e;
     }
   }
--- a/src/hotspot/share/classfile/protectionDomainCache.hpp	Thu Jan 11 21:49:51 2018 -0500
+++ b/src/hotspot/share/classfile/protectionDomainCache.hpp	Wed Jan 10 22:40:47 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, 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
@@ -37,7 +37,8 @@
 class ProtectionDomainCacheEntry : public HashtableEntry<oop, mtClass> {
   friend class VMStructs;
  public:
-  oop protection_domain() { return literal(); }
+  oop object();
+  oop object_no_keepalive();
 
   ProtectionDomainCacheEntry* next() {
     return (ProtectionDomainCacheEntry*)HashtableEntry<oop, mtClass>::next();
@@ -112,6 +113,7 @@
   }
 
   ProtectionDomainEntry* next() { return _next; }
-  oop protection_domain() { return _pd_cache->protection_domain(); }
+  oop object();
+  oop object_no_keepalive();
 };
 #endif // SHARE_VM_CLASSFILE_PROTECTIONDOMAINCACHE_HPP