src/share/vm/classfile/placeholders.cpp

changeset 4037
da91efe96a93
parent 3900
d2a62e0f25eb
child 4278
070d523b96a7
     1.1 --- a/src/share/vm/classfile/placeholders.cpp	Fri Aug 31 16:39:35 2012 -0700
     1.2 +++ b/src/share/vm/classfile/placeholders.cpp	Sat Sep 01 13:25:18 2012 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -32,12 +32,13 @@
    1.11  // Placeholder methods
    1.12  
    1.13  PlaceholderEntry* PlaceholderTable::new_entry(int hash, Symbol* name,
    1.14 -                                              oop loader, bool havesupername,
    1.15 +                                              ClassLoaderData* loader_data,
    1.16 +                                              bool havesupername,
    1.17                                                Symbol* supername) {
    1.18    PlaceholderEntry* entry = (PlaceholderEntry*)Hashtable<Symbol*, mtClass>::new_entry(hash, name);
    1.19    // Hashtable with Symbol* literal must increment and decrement refcount.
    1.20    name->increment_refcount();
    1.21 -  entry->set_loader(loader);
    1.22 +  entry->set_loader_data(loader_data);
    1.23    entry->set_havesupername(havesupername);
    1.24    entry->set_supername(supername);
    1.25    entry->set_superThreadQ(NULL);
    1.26 @@ -61,14 +62,14 @@
    1.27  // SystemDictionary_lock, so we don't need special precautions
    1.28  // on store ordering here.
    1.29  void PlaceholderTable::add_entry(int index, unsigned int hash,
    1.30 -                                 Symbol* class_name, Handle class_loader,
    1.31 +                                 Symbol* class_name, ClassLoaderData* loader_data,
    1.32                                   bool havesupername, Symbol* supername){
    1.33    assert_locked_or_safepoint(SystemDictionary_lock);
    1.34    assert(class_name != NULL, "adding NULL obj");
    1.35  
    1.36    // Both readers and writers are locked so it's safe to just
    1.37    // create the placeholder and insert it in the list without a membar.
    1.38 -  PlaceholderEntry* entry = new_entry(hash, class_name, class_loader(), havesupername, supername);
    1.39 +  PlaceholderEntry* entry = new_entry(hash, class_name, loader_data, havesupername, supername);
    1.40    add_entry(index, entry);
    1.41  }
    1.42  
    1.43 @@ -76,12 +77,12 @@
    1.44  // Remove a placeholder object.
    1.45  void PlaceholderTable::remove_entry(int index, unsigned int hash,
    1.46                                      Symbol* class_name,
    1.47 -                                    Handle class_loader) {
    1.48 +                                    ClassLoaderData* loader_data) {
    1.49    assert_locked_or_safepoint(SystemDictionary_lock);
    1.50    PlaceholderEntry** p = bucket_addr(index);
    1.51    while (*p) {
    1.52      PlaceholderEntry *probe = *p;
    1.53 -    if (probe->hash() == hash && probe->equals(class_name, class_loader())) {
    1.54 +    if (probe->hash() == hash && probe->equals(class_name, loader_data)) {
    1.55        // Delete entry
    1.56        *p = probe->next();
    1.57        free_entry(probe);
    1.58 @@ -93,16 +94,14 @@
    1.59  
    1.60  PlaceholderEntry* PlaceholderTable::get_entry(int index, unsigned int hash,
    1.61                                         Symbol* class_name,
    1.62 -                                       Handle class_loader) {
    1.63 +                                       ClassLoaderData* loader_data) {
    1.64    assert_locked_or_safepoint(SystemDictionary_lock);
    1.65  
    1.66 -  oop class_loader_ = class_loader();
    1.67 -
    1.68    for (PlaceholderEntry *place_probe = bucket(index);
    1.69                           place_probe != NULL;
    1.70                           place_probe = place_probe->next()) {
    1.71      if (place_probe->hash() == hash &&
    1.72 -        place_probe->equals(class_name, class_loader_)) {
    1.73 +        place_probe->equals(class_name, loader_data)) {
    1.74        return place_probe;
    1.75      }
    1.76    }
    1.77 @@ -111,8 +110,8 @@
    1.78  
    1.79  Symbol* PlaceholderTable::find_entry(int index, unsigned int hash,
    1.80                                         Symbol* class_name,
    1.81 -                                       Handle class_loader) {
    1.82 -  PlaceholderEntry* probe = get_entry(index, hash, class_name, class_loader);
    1.83 +                                       ClassLoaderData* loader_data) {
    1.84 +  PlaceholderEntry* probe = get_entry(index, hash, class_name, loader_data);
    1.85    return (probe? probe->klassname(): (Symbol*)NULL);
    1.86  }
    1.87  
    1.88 @@ -121,12 +120,17 @@
    1.89    // If entry exists, reuse entry
    1.90    // For both, push SeenThread for classloadAction
    1.91    // if havesupername: this is used for circularity for instanceklass loading
    1.92 -PlaceholderEntry* PlaceholderTable::find_and_add(int index, unsigned int hash, Symbol* name, Handle loader, classloadAction action, Symbol* supername, Thread* thread) {
    1.93 -  PlaceholderEntry* probe = get_entry(index, hash, name, loader);
    1.94 +PlaceholderEntry* PlaceholderTable::find_and_add(int index, unsigned int hash,
    1.95 +                                                 Symbol* name,
    1.96 +                                                 ClassLoaderData* loader_data,
    1.97 +                                                 classloadAction action,
    1.98 +                                                 Symbol* supername,
    1.99 +                                                 Thread* thread) {
   1.100 +  PlaceholderEntry* probe = get_entry(index, hash, name, loader_data);
   1.101    if (probe == NULL) {
   1.102      // Nothing found, add place holder
   1.103 -    add_entry(index, hash, name, loader, (action == LOAD_SUPER), supername);
   1.104 -    probe = get_entry(index, hash, name, loader);
   1.105 +    add_entry(index, hash, name, loader_data, (action == LOAD_SUPER), supername);
   1.106 +    probe = get_entry(index, hash, name, loader_data);
   1.107    } else {
   1.108      if (action == LOAD_SUPER) {
   1.109        probe->set_havesupername(true);
   1.110 @@ -153,14 +157,14 @@
   1.111  // Therefore - must always check SD first
   1.112  // Ignores the case where entry is not found
   1.113  void PlaceholderTable::find_and_remove(int index, unsigned int hash,
   1.114 -                       Symbol* name, Handle loader, Thread* thread) {
   1.115 +                       Symbol* name, ClassLoaderData* loader_data, Thread* thread) {
   1.116      assert_locked_or_safepoint(SystemDictionary_lock);
   1.117 -    PlaceholderEntry *probe = get_entry(index, hash, name, loader);
   1.118 +    PlaceholderEntry *probe = get_entry(index, hash, name, loader_data);
   1.119      if (probe != NULL) {
   1.120         // No other threads using this entry
   1.121         if ((probe->superThreadQ() == NULL) && (probe->loadInstanceThreadQ() == NULL)
   1.122            && (probe->defineThreadQ() == NULL) && (probe->definer() == NULL)) {
   1.123 -         remove_entry(index, hash, name, loader);
   1.124 +         remove_entry(index, hash, name, loader_data);
   1.125         }
   1.126      }
   1.127    }
   1.128 @@ -170,34 +174,31 @@
   1.129  }
   1.130  
   1.131  
   1.132 -void PlaceholderTable::oops_do(OopClosure* f) {
   1.133 +void PlaceholderTable::classes_do(KlassClosure* f) {
   1.134    for (int index = 0; index < table_size(); index++) {
   1.135      for (PlaceholderEntry* probe = bucket(index);
   1.136                             probe != NULL;
   1.137                             probe = probe->next()) {
   1.138 -      probe->oops_do(f);
   1.139 +      probe->classes_do(f);
   1.140      }
   1.141    }
   1.142  }
   1.143  
   1.144  
   1.145 -void PlaceholderEntry::oops_do(OopClosure* blk) {
   1.146 +void PlaceholderEntry::classes_do(KlassClosure* closure) {
   1.147    assert(klassname() != NULL, "should have a non-null klass");
   1.148 -  if (_loader != NULL) {
   1.149 -    blk->do_oop(loader_addr());
   1.150 -  }
   1.151    if (_instanceKlass != NULL) {
   1.152 -    blk->do_oop((oop*)instanceKlass_addr());
   1.153 +    closure->do_klass(InstanceKlass());
   1.154    }
   1.155  }
   1.156  
   1.157  // do all entries in the placeholder table
   1.158 -void PlaceholderTable::entries_do(void f(Symbol*, oop)) {
   1.159 +void PlaceholderTable::entries_do(void f(Symbol*)) {
   1.160    for (int index = 0; index < table_size(); index++) {
   1.161      for (PlaceholderEntry* probe = bucket(index);
   1.162                             probe != NULL;
   1.163                             probe = probe->next()) {
   1.164 -      f(probe->klassname(), probe->loader());
   1.165 +      f(probe->klassname());
   1.166      }
   1.167    }
   1.168  }
   1.169 @@ -207,9 +208,9 @@
   1.170  // Note, doesn't append a cr
   1.171  void PlaceholderEntry::print() const {
   1.172    klassname()->print_value();
   1.173 -  if (loader() != NULL) {
   1.174 +  if (loader_data() != NULL) {
   1.175      tty->print(", loader ");
   1.176 -    loader()->print_value();
   1.177 +    loader_data()->print_value();
   1.178    }
   1.179    if (supername() != NULL) {
   1.180      tty->print(", supername ");
   1.181 @@ -219,9 +220,9 @@
   1.182      tty->print(", definer ");
   1.183      definer()->print_value();
   1.184    }
   1.185 -  if (instanceKlass() != NULL) {
   1.186 -    tty->print(", instanceKlass ");
   1.187 -    instanceKlass()->print_value();
   1.188 +  if (InstanceKlass() != NULL) {
   1.189 +    tty->print(", InstanceKlass ");
   1.190 +    InstanceKlass()->print_value();
   1.191    }
   1.192    tty->print("\n");
   1.193    tty->print("loadInstanceThreadQ threads:");
   1.194 @@ -237,11 +238,12 @@
   1.195  #endif
   1.196  
   1.197  void PlaceholderEntry::verify() const {
   1.198 -  guarantee(loader() == NULL || loader()->is_instance(),
   1.199 +  guarantee(loader_data() != NULL, "Must have been setup.");
   1.200 +  guarantee(loader_data()->class_loader() == NULL || loader_data()->class_loader()->is_instance(),
   1.201              "checking type of _loader");
   1.202 -  guarantee(instanceKlass() == NULL
   1.203 -            || Klass::cast(instanceKlass())->oop_is_instance(),
   1.204 -            "checking type of instanceKlass result");
   1.205 +  guarantee(InstanceKlass() == NULL
   1.206 +            || Klass::cast(InstanceKlass())->oop_is_instance(),
   1.207 +            "checking type of InstanceKlass result");
   1.208  }
   1.209  
   1.210  void PlaceholderTable::verify() {

mercurial