mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 20:44:41 +02:00
8035946: Use ResourceHashtable for dependency checking
Use ResourceHashtable for dependency checking and delete GenericHashtable Reviewed-by: kvn, coleenp
This commit is contained in:
parent
ad8d066a4a
commit
7722b3d097
6 changed files with 26 additions and 208 deletions
|
@ -725,13 +725,13 @@ Klass* Dependencies::DepStream::context_type() {
|
|||
}
|
||||
|
||||
// ----------------- DependencySignature --------------------------------------
|
||||
bool DependencySignature::equals(DependencySignature* sig) const {
|
||||
if ((type() != sig->type()) || (args_count() != sig->args_count())) {
|
||||
bool DependencySignature::equals(DependencySignature const& s1, DependencySignature const& s2) {
|
||||
if ((s1.type() != s2.type()) || (s1.args_count() != s2.args_count())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < sig->args_count(); i++) {
|
||||
if (arg(i) != sig->arg(i)) {
|
||||
for (int i = 0; i < s1.args_count(); i++) {
|
||||
if (s1.arg(i) != s2.arg(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -527,7 +527,7 @@ class Dependencies: public ResourceObj {
|
|||
};
|
||||
|
||||
|
||||
class DependencySignature : public GenericHashtableEntry<DependencySignature, ResourceObj> {
|
||||
class DependencySignature : public ResourceObj {
|
||||
private:
|
||||
int _args_count;
|
||||
uintptr_t _argument_hash[Dependencies::max_arg_count];
|
||||
|
@ -542,12 +542,13 @@ class DependencySignature : public GenericHashtableEntry<DependencySignature, Re
|
|||
}
|
||||
}
|
||||
|
||||
bool equals(DependencySignature* sig) const;
|
||||
uintptr_t key() const { return _argument_hash[0] >> 2; }
|
||||
static bool equals(DependencySignature const& s1, DependencySignature const& s2);
|
||||
static unsigned hash (DependencySignature const& s1) { return s1.arg(0) >> 2; }
|
||||
|
||||
int args_count() const { return _args_count; }
|
||||
uintptr_t arg(int idx) const { return _argument_hash[idx]; }
|
||||
Dependencies::DepType type() const { return _type; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "prims/jvmtiImpl.hpp"
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "runtime/sweeper.hpp"
|
||||
#include "utilities/resourceHash.hpp"
|
||||
#include "utilities/dtrace.hpp"
|
||||
#include "utilities/events.hpp"
|
||||
#include "utilities/xmlstream.hpp"
|
||||
|
@ -2135,7 +2136,11 @@ void nmethod::check_all_dependencies(DepChange& changes) {
|
|||
// Turn off dependency tracing while actually testing dependencies.
|
||||
NOT_PRODUCT( FlagSetting fs(TraceDependencies, false) );
|
||||
|
||||
GenericHashtable<DependencySignature, ResourceObj>* table = new GenericHashtable<DependencySignature, ResourceObj>(11027);
|
||||
typedef ResourceHashtable<DependencySignature, int, &DependencySignature::hash,
|
||||
&DependencySignature::equals, 11027> DepTable;
|
||||
|
||||
DepTable* table = new DepTable();
|
||||
|
||||
// Iterate over live nmethods and check dependencies of all nmethods that are not
|
||||
// marked for deoptimization. A particular dependency is only checked once.
|
||||
for(nmethod* nm = CodeCache::alive_nmethod(CodeCache::first()); nm != NULL; nm = CodeCache::alive_nmethod(CodeCache::next(nm))) {
|
||||
|
@ -2143,9 +2148,10 @@ void nmethod::check_all_dependencies(DepChange& changes) {
|
|||
for (Dependencies::DepStream deps(nm); deps.next(); ) {
|
||||
// Construct abstraction of a dependency.
|
||||
DependencySignature* current_sig = new DependencySignature(deps);
|
||||
// Determine if 'deps' is already checked. table->add() returns
|
||||
// 'true' if the dependency was added (i.e., was not in the hashtable).
|
||||
if (table->add(current_sig)) {
|
||||
|
||||
// Determine if dependency is already checked. table->put(...) returns
|
||||
// 'true' if the dependency is added (i.e., was not in the hashtable).
|
||||
if (table->put(*current_sig, 1)) {
|
||||
if (deps.check_dependency() != NULL) {
|
||||
// Dependency checking failed. Print out information about the failed
|
||||
// dependency and finally fail with an assert. We can fail here, since
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue