src/share/vm/classfile/dictionary.hpp
Print this page
rev 5310 : imported patch ioi_original_patch
*** 1,7 ****
/*
! * Copyright (c) 2003, 2012, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2003, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 25,39 ****
#ifndef SHARE_VM_CLASSFILE_DICTIONARY_HPP
#define SHARE_VM_CLASSFILE_DICTIONARY_HPP
#include "classfile/systemDictionary.hpp"
#include "oops/instanceKlass.hpp"
! #include "oops/oop.hpp"
#include "utilities/hashtable.hpp"
class DictionaryEntry;
class PSPromotionManager;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// The data structure for the system dictionary (and the shared system
// dictionary).
--- 25,41 ----
#ifndef SHARE_VM_CLASSFILE_DICTIONARY_HPP
#define SHARE_VM_CLASSFILE_DICTIONARY_HPP
#include "classfile/systemDictionary.hpp"
#include "oops/instanceKlass.hpp"
! #include "oops/oop.inline.hpp"
#include "utilities/hashtable.hpp"
class DictionaryEntry;
class PSPromotionManager;
+ class ProtectionDomainCacheTable;
+ class ProtectionDomainCacheEntry;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// The data structure for the system dictionary (and the shared system
// dictionary).
*** 43,52 ****
--- 45,56 ----
// current iteration index.
static int _current_class_index;
// pointer to the current hash table entry.
static DictionaryEntry* _current_class_entry;
+ ProtectionDomainCacheTable* _pd_cache_table;
+
DictionaryEntry* get_entry(int index, unsigned int hash,
Symbol* name, ClassLoaderData* loader_data);
DictionaryEntry* bucket(int i) {
return (DictionaryEntry*)Hashtable<Klass*, mtClass>::bucket(i);
*** 116,148 ****
Handle protection_domain, TRAPS);
// Sharing support
void reorder_dictionary();
#ifndef PRODUCT
void print();
#endif
void verify();
};
// The following classes can be in dictionary.cpp, but we need these
! // to be in header file so that SA's vmStructs can access.
class ProtectionDomainEntry :public CHeapObj<mtClass> {
friend class VMStructs;
public:
ProtectionDomainEntry* _next;
! oop _protection_domain;
! ProtectionDomainEntry(oop protection_domain, ProtectionDomainEntry* next) {
! _protection_domain = protection_domain;
_next = next;
}
ProtectionDomainEntry* next() { return _next; }
! oop protection_domain() { return _protection_domain; }
};
// An entry in the system dictionary, this describes a class as
// { Klass*, loader, protection_domain }.
--- 120,249 ----
Handle protection_domain, TRAPS);
// Sharing support
void reorder_dictionary();
+ ProtectionDomainCacheEntry* cache_get(oop protection_domain);
#ifndef PRODUCT
void print();
#endif
void verify();
};
// The following classes can be in dictionary.cpp, but we need these
! // to be in header file so that SA's vmStructs can access them.
! class ProtectionDomainCacheEntry : public HashtableEntry<oop, mtClass> {
! friend class VMStructs;
! private:
! int _refcount;
! int _scan_generation;
! public:
! oop protection_domain() { return literal(); }
!
! void increment_refcount() {
! assert(_refcount >= 0, "sanity");
! _refcount++;
! }
!
! int refcount() { return _refcount; }
! int decrement_refcount() {
! assert(_refcount > 0, "sanity");
! _refcount--;
! return _refcount;
! }
!
! void init() {
! _refcount = 0;
! _scan_generation = 0;
! }
!
! ProtectionDomainCacheEntry* next() {
! return (ProtectionDomainCacheEntry*)HashtableEntry<oop, mtClass>::next();
! }
!
! ProtectionDomainCacheEntry** next_addr() {
! return (ProtectionDomainCacheEntry**)HashtableEntry<oop, mtClass>::next_addr();
! }
!
! void oops_do(OopClosure* f) {
! f->do_oop(literal_addr());
! }
!
! void set_strongly_reachable(int gen) { _scan_generation = gen; }
!
! bool is_strongly_reachable(int gen) { return _scan_generation == gen; }
! };
!
! class ProtectionDomainCacheTable : public Hashtable<oop, mtClass> {
! friend class VMStructs;
! private:
! ProtectionDomainCacheEntry* bucket(int i) {
! return (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::bucket(i);
! }
!
! // The following method is not MT-safe and must be done under lock.
! ProtectionDomainCacheEntry** bucket_addr(int i) {
! return (ProtectionDomainCacheEntry**) Hashtable<oop, mtClass>::bucket_addr(i);
! }
!
! ProtectionDomainCacheEntry* new_entry(unsigned int hash, oop protection_domain) {
! ProtectionDomainCacheEntry* entry = (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::new_entry(hash, protection_domain);
! entry->init();
! return entry;
! }
!
! unsigned int compute_hash(oop protection_domain) {
! return (unsigned int)(protection_domain->identity_hash());
! }
!
! int index_for(oop protection_domain) {
! return hash_to_index(compute_hash(protection_domain));
! }
!
! ProtectionDomainCacheEntry* add_entry(int index, unsigned int hash, oop protection_domain);
! ProtectionDomainCacheEntry* find_entry(int index, oop protection_domain);
!
! public:
!
! ProtectionDomainCacheTable(int table_size);
!
! ProtectionDomainCacheEntry* get(oop protection_domain);
! void free(ProtectionDomainCacheEntry* entry);
!
! // GC support
! void oops_do(OopClosure* f);
! void always_strong_oops_do(OopClosure* f, int gen);
!
! #ifndef PRODUCT
! void print();
! #endif
! void verify();
! };
!
class ProtectionDomainEntry :public CHeapObj<mtClass> {
friend class VMStructs;
public:
ProtectionDomainEntry* _next;
! ProtectionDomainCacheEntry* _pd_cache;
! ProtectionDomainEntry(ProtectionDomainCacheEntry* pd_cache, ProtectionDomainEntry* next) {
! _pd_cache = pd_cache;
_next = next;
+ _pd_cache->increment_refcount();
}
ProtectionDomainEntry* next() { return _next; }
! oop protection_domain() { return _pd_cache->protection_domain(); }
! ProtectionDomainCacheEntry * release_pd_cache() {
! if (_pd_cache->decrement_refcount() == 0) {
! return _pd_cache;
! } else {
! return NULL;
! }
! }
};
// An entry in the system dictionary, this describes a class as
// { Klass*, loader, protection_domain }.
*** 156,166 ****
public:
// Tells whether a protection is in the approved set.
bool contains_protection_domain(oop protection_domain) const;
// Adds a protection domain to the approved set.
! void add_protection_domain(oop protection_domain);
Klass* klass() const { return (Klass*)literal(); }
Klass** klass_addr() { return (Klass**)literal_addr(); }
DictionaryEntry* next() const {
--- 257,267 ----
public:
// Tells whether a protection is in the approved set.
bool contains_protection_domain(oop protection_domain) const;
// Adds a protection domain to the approved set.
! void add_protection_domain(Dictionary* dict, oop protection_domain);
Klass* klass() const { return (Klass*)literal(); }
Klass** klass_addr() { return (Klass**)literal_addr(); }
DictionaryEntry* next() const {
*** 187,210 ****
return protection_domain() == NULL
? true
: contains_protection_domain(protection_domain());
}
!
! void protection_domain_set_oops_do(OopClosure* f) {
for (ProtectionDomainEntry* current = _pd_set;
current != NULL;
current = current->_next) {
! f->do_oop(&(current->_protection_domain));
}
}
void verify_protection_domain_set() {
for (ProtectionDomainEntry* current = _pd_set;
current != NULL;
current = current->_next) {
! current->_protection_domain->verify();
}
}
bool equals(Symbol* class_name, ClassLoaderData* loader_data) const {
Klass* klass = (Klass*)literal();
--- 288,310 ----
return protection_domain() == NULL
? true
: contains_protection_domain(protection_domain());
}
! void set_strongly_reachable(int gen) {
for (ProtectionDomainEntry* current = _pd_set;
current != NULL;
current = current->_next) {
! current->_pd_cache->set_strongly_reachable(gen);
}
}
void verify_protection_domain_set() {
for (ProtectionDomainEntry* current = _pd_set;
current != NULL;
current = current->_next) {
! current->_pd_cache->protection_domain()->verify();
}
}
bool equals(Symbol* class_name, ClassLoaderData* loader_data) const {
Klass* klass = (Klass*)literal();