src/share/vm/classfile/dictionary.hpp

changeset 1145
e5b0439ef4ae
parent 435
a61af66fc99e
child 1862
cd5dbf694d45
     1.1 --- a/src/share/vm/classfile/dictionary.hpp	Wed Apr 08 00:12:59 2009 -0700
     1.2 +++ b/src/share/vm/classfile/dictionary.hpp	Wed Apr 08 10:56:49 2009 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * Copyright 2003-2009 Sun Microsystems, Inc.  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 @@ -217,3 +217,112 @@
    1.11      tty->print_cr("pd set = #%d", count);
    1.12    }
    1.13  };
    1.14 +
    1.15 +// Entry in a SymbolPropertyTable, mapping a single symbolOop
    1.16 +// to a managed and an unmanaged pointer.
    1.17 +class SymbolPropertyEntry : public HashtableEntry {
    1.18 +  friend class VMStructs;
    1.19 + private:
    1.20 +  oop     _property_oop;
    1.21 +  address _property_data;
    1.22 +
    1.23 + public:
    1.24 +  symbolOop symbol() const          { return (symbolOop) literal(); }
    1.25 +
    1.26 +  oop      property_oop() const     { return _property_oop; }
    1.27 +  void set_property_oop(oop p)      { _property_oop = p; }
    1.28 +
    1.29 +  address  property_data() const    { return _property_data; }
    1.30 +  void set_property_data(address p) { _property_data = p; }
    1.31 +
    1.32 +  SymbolPropertyEntry* next() const {
    1.33 +    return (SymbolPropertyEntry*)HashtableEntry::next();
    1.34 +  }
    1.35 +
    1.36 +  SymbolPropertyEntry** next_addr() {
    1.37 +    return (SymbolPropertyEntry**)HashtableEntry::next_addr();
    1.38 +  }
    1.39 +
    1.40 +  oop* symbol_addr()                { return literal_addr(); }
    1.41 +  oop* property_oop_addr()          { return &_property_oop; }
    1.42 +
    1.43 +  void print_on(outputStream* st) const {
    1.44 +    symbol()->print_value_on(st);
    1.45 +    st->print(" -> ");
    1.46 +    bool printed = false;
    1.47 +    if (property_oop() != NULL) {
    1.48 +      property_oop()->print_value_on(st);
    1.49 +      printed = true;
    1.50 +    }
    1.51 +    if (property_data() != NULL) {
    1.52 +      if (printed)  st->print(" and ");
    1.53 +      st->print(INTPTR_FORMAT, property_data());
    1.54 +      printed = true;
    1.55 +    }
    1.56 +    st->print_cr(printed ? "" : "(empty)");
    1.57 +  }
    1.58 +};
    1.59 +
    1.60 +// A system-internal mapping of symbols to pointers, both managed
    1.61 +// and unmanaged.  Used to record the auto-generation of each method
    1.62 +// MethodHandle.invoke(S)T, for all signatures (S)T.
    1.63 +class SymbolPropertyTable : public Hashtable {
    1.64 +  friend class VMStructs;
    1.65 +private:
    1.66 +  SymbolPropertyEntry* bucket(int i) {
    1.67 +    return (SymbolPropertyEntry*) Hashtable::bucket(i);
    1.68 +  }
    1.69 +
    1.70 +  // The following method is not MT-safe and must be done under lock.
    1.71 +  SymbolPropertyEntry** bucket_addr(int i) {
    1.72 +    return (SymbolPropertyEntry**) Hashtable::bucket_addr(i);
    1.73 +  }
    1.74 +
    1.75 +  void add_entry(int index, SymbolPropertyEntry* new_entry) {
    1.76 +    ShouldNotReachHere();
    1.77 +  }
    1.78 +  void set_entry(int index, SymbolPropertyEntry* new_entry) {
    1.79 +    ShouldNotReachHere();
    1.80 +  }
    1.81 +
    1.82 +  SymbolPropertyEntry* new_entry(unsigned int hash, symbolOop symbol) {
    1.83 +    SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable::new_entry(hash, symbol);
    1.84 +    entry->set_property_oop(NULL);
    1.85 +    entry->set_property_data(NULL);
    1.86 +    return entry;
    1.87 +  }
    1.88 +
    1.89 +public:
    1.90 +  SymbolPropertyTable(int table_size);
    1.91 +  SymbolPropertyTable(int table_size, HashtableBucket* t, int number_of_entries);
    1.92 +
    1.93 +  void free_entry(SymbolPropertyEntry* entry) {
    1.94 +    Hashtable::free_entry(entry);
    1.95 +  }
    1.96 +
    1.97 +  unsigned int compute_hash(symbolHandle sym) {
    1.98 +    // Use the regular identity_hash.
    1.99 +    return Hashtable::compute_hash(sym);
   1.100 +  }
   1.101 +
   1.102 +  // need not be locked; no state change
   1.103 +  SymbolPropertyEntry* find_entry(int index, unsigned int hash, symbolHandle name);
   1.104 +
   1.105 +  // must be done under SystemDictionary_lock
   1.106 +  SymbolPropertyEntry* add_entry(int index, unsigned int hash, symbolHandle name);
   1.107 +
   1.108 +  // GC support
   1.109 +  void oops_do(OopClosure* f);
   1.110 +  void methods_do(void f(methodOop));
   1.111 +
   1.112 +  // Sharing support
   1.113 +  void dump(SerializeOopClosure* soc);
   1.114 +  void restore(SerializeOopClosure* soc);
   1.115 +  void reorder_dictionary();
   1.116 +
   1.117 +#ifndef PRODUCT
   1.118 +  void print();
   1.119 +#endif
   1.120 +  void verify();
   1.121 +};
   1.122 +

mercurial