Merge

Thu, 12 Apr 2012 18:41:24 -0400

author
dlong
date
Thu, 12 Apr 2012 18:41:24 -0400
changeset 3704
0cea7f13029e
parent 3700
10c12fb36ed2
parent 3703
08f8d00f2ae3
child 3708
c263e0e9f14b

Merge

     1.1 --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/VirtualMachineImpl.java	Thu Apr 05 14:16:23 2012 +0200
     1.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/VirtualMachineImpl.java	Thu Apr 12 18:41:24 2012 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2002, 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 @@ -889,15 +889,9 @@
    1.11          Klass kls = ((ReferenceTypeImpl)type).ref();
    1.12          if (kls instanceof InstanceKlass) {
    1.13              InstanceKlass ik = (InstanceKlass) kls;
    1.14 -            if (ik.isInterface()) {
    1.15 -                if (ik.nofImplementors() == 0L) {
    1.16 -                    return new ArrayList(0);
    1.17 -                }
    1.18 -            } else {
    1.19 -                // if the Klass is final or if there are no subklasses loaded yet
    1.20 -                if (ik.getAccessFlagsObj().isFinal() || ik.getSubklassKlass() == null) {
    1.21 -                    includeSubtypes = false;
    1.22 -                }
    1.23 +            // if the Klass is final or if there are no subklasses loaded yet
    1.24 +            if (ik.getAccessFlagsObj().isFinal() || ik.getSubklassKlass() == null) {
    1.25 +                includeSubtypes = false;
    1.26              }
    1.27          } else {
    1.28              // no subtypes for primitive array types
     2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Thu Apr 05 14:16:23 2012 +0200
     2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Thu Apr 12 18:41:24 2012 -0400
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -52,7 +52,6 @@
    2.11    private static int HIGH_OFFSET;
    2.12    private static int GENERIC_SIGNATURE_INDEX_OFFSET;
    2.13    private static int FIELD_SLOTS;
    2.14 -  public static int IMPLEMENTORS_LIMIT;
    2.15  
    2.16    // ClassState constants
    2.17    private static int CLASS_STATE_UNPARSABLE_BY_GC;
    2.18 @@ -70,13 +69,6 @@
    2.19      methodOrdering       = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize());
    2.20      localInterfaces      = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize());
    2.21      transitiveInterfaces = new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize());
    2.22 -    nofImplementors      = new CIntField(type.getCIntegerField("_nof_implementors"), Oop.getHeaderSize());
    2.23 -    IMPLEMENTORS_LIMIT   = db.lookupIntConstant("instanceKlass::implementors_limit").intValue();
    2.24 -    implementors         = new OopField[IMPLEMENTORS_LIMIT];
    2.25 -    for (int i = 0; i < IMPLEMENTORS_LIMIT; i++) {
    2.26 -      long arrayOffset = Oop.getHeaderSize() + (i * db.getAddressSize());
    2.27 -      implementors[i]    = new OopField(type.getOopField("_implementors[0]"), arrayOffset);
    2.28 -    }
    2.29      fields               = new OopField(type.getOopField("_fields"), Oop.getHeaderSize());
    2.30      javaFieldsCount      = new CIntField(type.getCIntegerField("_java_fields_count"), Oop.getHeaderSize());
    2.31      constants            = new OopField(type.getOopField("_constants"), Oop.getHeaderSize());
    2.32 @@ -136,8 +128,6 @@
    2.33    private static OopField  methodOrdering;
    2.34    private static OopField  localInterfaces;
    2.35    private static OopField  transitiveInterfaces;
    2.36 -  private static CIntField nofImplementors;
    2.37 -  private static OopField[] implementors;
    2.38    private static OopField  fields;
    2.39    private static CIntField javaFieldsCount;
    2.40    private static OopField  constants;
    2.41 @@ -317,9 +307,6 @@
    2.42    public TypeArray getMethodOrdering()      { return (TypeArray)    methodOrdering.getValue(this); }
    2.43    public ObjArray  getLocalInterfaces()     { return (ObjArray)     localInterfaces.getValue(this); }
    2.44    public ObjArray  getTransitiveInterfaces() { return (ObjArray)     transitiveInterfaces.getValue(this); }
    2.45 -  public long      nofImplementors()        { return                nofImplementors.getValue(this); }
    2.46 -  public Klass     getImplementor()         { return (Klass)        implementors[0].getValue(this); }
    2.47 -  public Klass     getImplementor(int i)    { return (Klass)        implementors[i].getValue(this); }
    2.48    public TypeArray getFields()              { return (TypeArray)    fields.getValue(this); }
    2.49    public int       getJavaFieldsCount()     { return                (int) javaFieldsCount.getValue(this); }
    2.50    public int       getAllFieldsCount()      { return                (int)getFields().getLength() / FIELD_SLOTS; }
    2.51 @@ -527,9 +514,6 @@
    2.52        visitor.doOop(methodOrdering, true);
    2.53        visitor.doOop(localInterfaces, true);
    2.54        visitor.doOop(transitiveInterfaces, true);
    2.55 -      visitor.doCInt(nofImplementors, true);
    2.56 -      for (int i = 0; i < IMPLEMENTORS_LIMIT; i++)
    2.57 -        visitor.doOop(implementors[i], true);
    2.58        visitor.doOop(fields, true);
    2.59        visitor.doOop(constants, true);
    2.60        visitor.doOop(classLoader, true);
     3.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Apr 05 14:16:23 2012 +0200
     3.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Apr 12 18:41:24 2012 -0400
     3.3 @@ -1694,7 +1694,9 @@
     3.4        // they are roughly equivalent to Object.
     3.5        ciInstanceKlass* singleton = NULL;
     3.6        if (target->holder()->nof_implementors() == 1) {
     3.7 -        singleton = target->holder()->implementor(0);
     3.8 +        singleton = target->holder()->implementor();
     3.9 +        assert(singleton != NULL && singleton != target->holder(),
    3.10 +               "just checking");
    3.11  
    3.12          assert(holder->is_interface(), "invokeinterface to non interface?");
    3.13          ciInstanceKlass* decl_interface = (ciInstanceKlass*)holder;
     4.1 --- a/src/share/vm/ci/ciInstanceKlass.cpp	Thu Apr 05 14:16:23 2012 +0200
     4.2 +++ b/src/share/vm/ci/ciInstanceKlass.cpp	Thu Apr 12 18:41:24 2012 -0400
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -59,10 +59,7 @@
    4.11    _has_nonstatic_fields = ik->has_nonstatic_fields();
    4.12    _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
    4.13  
    4.14 -  _nof_implementors = ik->nof_implementors();
    4.15 -  for (int i = 0; i < implementors_limit; i++) {
    4.16 -    _implementors[i] = NULL;  // we will fill these lazily
    4.17 -  }
    4.18 +  _implementor = NULL; // we will fill these lazily
    4.19  
    4.20    Thread *thread = Thread::current();
    4.21    if (ciObjectFactory::is_initialized()) {
    4.22 @@ -102,7 +99,6 @@
    4.23    _nonstatic_field_size = -1;
    4.24    _has_nonstatic_fields = false;
    4.25    _nonstatic_fields = NULL;
    4.26 -  _nof_implementors = -1;
    4.27    _loader = loader;
    4.28    _protection_domain = protection_domain;
    4.29    _is_shared = false;
    4.30 @@ -133,17 +129,6 @@
    4.31  }
    4.32  
    4.33  // ------------------------------------------------------------------
    4.34 -// ciInstanceKlass::compute_shared_nof_implementors
    4.35 -int ciInstanceKlass::compute_shared_nof_implementors() {
    4.36 -  // We requery this property, since it is a very old ciObject.
    4.37 -  GUARDED_VM_ENTRY(
    4.38 -    instanceKlass* ik = get_instanceKlass();
    4.39 -    _nof_implementors = ik->nof_implementors();
    4.40 -    return _nof_implementors;
    4.41 -  )
    4.42 -}
    4.43 -
    4.44 -// ------------------------------------------------------------------
    4.45  // ciInstanceKlass::loader
    4.46  oop ciInstanceKlass::loader() {
    4.47    ASSERT_IN_VM;
    4.48 @@ -540,7 +525,7 @@
    4.49    if (is_shared()) {
    4.50      return is_final();  // approximately correct
    4.51    } else {
    4.52 -    return !_has_subklass && (_nof_implementors == 0);
    4.53 +    return !_has_subklass && (nof_implementors() == 0);
    4.54    }
    4.55  }
    4.56  
    4.57 @@ -548,35 +533,31 @@
    4.58  // ciInstanceKlass::implementor
    4.59  //
    4.60  // Report an implementor of this interface.
    4.61 -// Returns NULL if exact information is not available.
    4.62  // Note that there are various races here, since my copy
    4.63  // of _nof_implementors might be out of date with respect
    4.64  // to results returned by instanceKlass::implementor.
    4.65  // This is OK, since any dependencies we decide to assert
    4.66  // will be checked later under the Compile_lock.
    4.67 -ciInstanceKlass* ciInstanceKlass::implementor(int n) {
    4.68 -  if (n >= implementors_limit) {
    4.69 -    return NULL;
    4.70 -  }
    4.71 -  ciInstanceKlass* impl = _implementors[n];
    4.72 +ciInstanceKlass* ciInstanceKlass::implementor() {
    4.73 +  ciInstanceKlass* impl = _implementor;
    4.74    if (impl == NULL) {
    4.75 -    if (_nof_implementors > implementors_limit) {
    4.76 -      return NULL;
    4.77 -    }
    4.78      // Go into the VM to fetch the implementor.
    4.79      {
    4.80        VM_ENTRY_MARK;
    4.81 -      klassOop k = get_instanceKlass()->implementor(n);
    4.82 +      klassOop k = get_instanceKlass()->implementor();
    4.83        if (k != NULL) {
    4.84 -        impl = CURRENT_THREAD_ENV->get_object(k)->as_instance_klass();
    4.85 +        if (k == get_instanceKlass()->as_klassOop()) {
    4.86 +          // More than one implementors. Use 'this' in this case.
    4.87 +          impl = this;
    4.88 +        } else {
    4.89 +          impl = CURRENT_THREAD_ENV->get_object(k)->as_instance_klass();
    4.90 +        }
    4.91        }
    4.92      }
    4.93      // Memoize this result.
    4.94      if (!is_shared()) {
    4.95 -      _implementors[n] = (impl == NULL)? this: impl;
    4.96 +      _implementor = impl;
    4.97      }
    4.98 -  } else if (impl == this) {
    4.99 -    impl = NULL;  // memoized null result from a VM query
   4.100    }
   4.101    return impl;
   4.102  }
     5.1 --- a/src/share/vm/ci/ciInstanceKlass.hpp	Thu Apr 05 14:16:23 2012 +0200
     5.2 +++ b/src/share/vm/ci/ciInstanceKlass.hpp	Thu Apr 12 18:41:24 2012 -0400
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -65,9 +65,11 @@
    5.11    ciConstantPoolCache*   _field_cache;  // cached map index->field
    5.12    GrowableArray<ciField*>* _nonstatic_fields;
    5.13  
    5.14 -  enum { implementors_limit = instanceKlass::implementors_limit };
    5.15 -  ciInstanceKlass*       _implementors[implementors_limit];
    5.16 -  jint                   _nof_implementors;
    5.17 +  // The possible values of the _implementor fall into following three cases:
    5.18 +  //   NULL: no implementor.
    5.19 +  //   A ciInstanceKlass that's not itself: one implementor.
    5.20 +  //   Itsef: more than one implementors.
    5.21 +  ciInstanceKlass*       _implementor;
    5.22  
    5.23    GrowableArray<ciField*>* _non_static_fields;
    5.24  
    5.25 @@ -97,7 +99,6 @@
    5.26  
    5.27    void compute_shared_init_state();
    5.28    bool compute_shared_has_subklass();
    5.29 -  int  compute_shared_nof_implementors();
    5.30    int  compute_nonstatic_fields();
    5.31    GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
    5.32  
    5.33 @@ -158,10 +159,17 @@
    5.34      assert(is_loaded(), "must be loaded");
    5.35      return _nonstatic_oop_map_size; }
    5.36    ciInstanceKlass*       super();
    5.37 -  jint                   nof_implementors()  {
    5.38 +  jint                   nof_implementors() {
    5.39 +    ciInstanceKlass* impl;
    5.40      assert(is_loaded(), "must be loaded");
    5.41 -    if (_is_shared)  return compute_shared_nof_implementors();
    5.42 -    return _nof_implementors;
    5.43 +    impl = implementor();
    5.44 +    if (impl == NULL) {
    5.45 +      return 0;
    5.46 +    } else if (impl != this) {
    5.47 +      return 1;
    5.48 +    } else {
    5.49 +      return 2;
    5.50 +    }
    5.51    }
    5.52  
    5.53    ciInstanceKlass* get_canonical_holder(int offset);
    5.54 @@ -207,7 +215,7 @@
    5.55    // but consider adding to vmSymbols.hpp instead.
    5.56  
    5.57    bool is_leaf_type();
    5.58 -  ciInstanceKlass* implementor(int n);
    5.59 +  ciInstanceKlass* implementor();
    5.60  
    5.61    // Is the defining class loader of this class the default loader?
    5.62    bool uses_default_loader();
     6.1 --- a/src/share/vm/classfile/classFileParser.cpp	Thu Apr 05 14:16:23 2012 +0200
     6.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Thu Apr 12 18:41:24 2012 -0400
     6.3 @@ -3354,6 +3354,7 @@
     6.4      klassOop ik = oopFactory::new_instanceKlass(name, vtable_size, itable_size,
     6.5                                                  static_field_size,
     6.6                                                  total_oop_map_count,
     6.7 +                                                access_flags,
     6.8                                                  rt, CHECK_(nullHandle));
     6.9      instanceKlassHandle this_klass (THREAD, ik);
    6.10  
    6.11 @@ -3362,7 +3363,6 @@
    6.12             "sanity");
    6.13  
    6.14      // Fill in information already parsed
    6.15 -    this_klass->set_access_flags(access_flags);
    6.16      this_klass->set_should_verify_class(verify);
    6.17      jint lh = Klass::instance_layout_helper(instance_size, false);
    6.18      this_klass->set_layout_helper(lh);
     7.1 --- a/src/share/vm/code/dependencies.cpp	Thu Apr 05 14:16:23 2012 +0200
     7.2 +++ b/src/share/vm/code/dependencies.cpp	Thu Apr 12 18:41:24 2012 -0400
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -1033,21 +1033,25 @@
    7.11      // (Old CHA had the same limitation.)
    7.12      return context_type;
    7.13    }
    7.14 -  for (int i = 0; i < nof_impls; i++) {
    7.15 -    klassOop impl = instanceKlass::cast(context_type)->implementor(i);
    7.16 -    if (impl == NULL) {
    7.17 -      // implementors array overflowed => no exact info.
    7.18 +  if (nof_impls > 0) {
    7.19 +    klassOop impl = instanceKlass::cast(context_type)->implementor();
    7.20 +    assert(impl != NULL, "just checking");
    7.21 +    // If impl is the same as the context_type, then more than one
    7.22 +    // implementor has seen. No exact info in this case.
    7.23 +    if (impl == context_type) {
    7.24        return context_type;  // report an inexact witness to this sad affair
    7.25      }
    7.26      if (do_counts)
    7.27        { NOT_PRODUCT(deps_find_witness_steps++); }
    7.28      if (is_participant(impl)) {
    7.29 -      if (participants_hide_witnesses)  continue;
    7.30 -      // else fall through to process this guy's subclasses
    7.31 +      if (!participants_hide_witnesses) {
    7.32 +        ADD_SUBCLASS_CHAIN(impl);
    7.33 +      }
    7.34      } else if (is_witness(impl) && !ignore_witness(impl)) {
    7.35        return impl;
    7.36 +    } else {
    7.37 +      ADD_SUBCLASS_CHAIN(impl);
    7.38      }
    7.39 -    ADD_SUBCLASS_CHAIN(impl);
    7.40    }
    7.41  
    7.42    // Recursively process each non-trivial sibling chain.
    7.43 @@ -1174,8 +1178,9 @@
    7.44    } else if (ctx->nof_implementors() != 0) {
    7.45      // if it is an interface, it must be unimplemented
    7.46      // (if it is not an interface, nof_implementors is always zero)
    7.47 -    klassOop impl = ctx->implementor(0);
    7.48 -    return (impl != NULL)? impl: ctxk;
    7.49 +    klassOop impl = ctx->implementor();
    7.50 +    assert(impl != NULL, "must be set");
    7.51 +    return impl;
    7.52    } else {
    7.53      return NULL;
    7.54    }
     8.1 --- a/src/share/vm/memory/oopFactory.cpp	Thu Apr 05 14:16:23 2012 +0200
     8.2 +++ b/src/share/vm/memory/oopFactory.cpp	Thu Apr 12 18:41:24 2012 -0400
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -127,9 +127,12 @@
    8.11  klassOop oopFactory::new_instanceKlass(Symbol* name, int vtable_len, int itable_len,
    8.12                                         int static_field_size,
    8.13                                         unsigned int nonstatic_oop_map_count,
    8.14 +                                       AccessFlags access_flags,
    8.15                                         ReferenceType rt, TRAPS) {
    8.16    instanceKlassKlass* ikk = instanceKlassKlass::cast(Universe::instanceKlassKlassObj());
    8.17 -  return ikk->allocate_instance_klass(name, vtable_len, itable_len, static_field_size, nonstatic_oop_map_count, rt, CHECK_NULL);
    8.18 +  return ikk->allocate_instance_klass(name, vtable_len, itable_len,
    8.19 +                                      static_field_size, nonstatic_oop_map_count,
    8.20 +                                      access_flags, rt, CHECK_NULL);
    8.21  }
    8.22  
    8.23  
     9.1 --- a/src/share/vm/memory/oopFactory.hpp	Thu Apr 05 14:16:23 2012 +0200
     9.2 +++ b/src/share/vm/memory/oopFactory.hpp	Thu Apr 12 18:41:24 2012 -0400
     9.3 @@ -1,5 +1,5 @@
     9.4  /*
     9.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     9.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     9.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.8   *
     9.9   * This code is free software; you can redistribute it and/or modify it
    9.10 @@ -77,6 +77,7 @@
    9.11                                             int vtable_len, int itable_len,
    9.12                                             int static_field_size,
    9.13                                             unsigned int nonstatic_oop_map_count,
    9.14 +                                           AccessFlags access_flags,
    9.15                                             ReferenceType rt, TRAPS);
    9.16  
    9.17    // Methods
    10.1 --- a/src/share/vm/oops/instanceKlass.cpp	Thu Apr 05 14:16:23 2012 +0200
    10.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Thu Apr 12 18:41:24 2012 -0400
    10.3 @@ -567,8 +567,18 @@
    10.4    ol.notify_all(CHECK);
    10.5  }
    10.6  
    10.7 +// The embedded _implementor field can only record one implementor.
    10.8 +// When there are more than one implementors, the _implementor field
    10.9 +// is set to the interface klassOop itself. Following are the possible
   10.10 +// values for the _implementor field:
   10.11 +//   NULL                  - no implementor
   10.12 +//   implementor klassOop  - one implementor
   10.13 +//   self                  - more than one implementor
   10.14 +//
   10.15 +// The _implementor field only exists for interfaces.
   10.16  void instanceKlass::add_implementor(klassOop k) {
   10.17    assert(Compile_lock->owned_by_self(), "");
   10.18 +  assert(is_interface(), "not interface");
   10.19    // Filter out my subinterfaces.
   10.20    // (Note: Interfaces are never on the subklass list.)
   10.21    if (instanceKlass::cast(k)->is_interface()) return;
   10.22 @@ -583,17 +593,13 @@
   10.23      // Any supers of the super have the same (or fewer) transitive_interfaces.
   10.24      return;
   10.25  
   10.26 -  // Update number of implementors
   10.27 -  int i = _nof_implementors++;
   10.28 -
   10.29 -  // Record this implementor, if there are not too many already
   10.30 -  if (i < implementors_limit) {
   10.31 -    assert(_implementors[i] == NULL, "should be exactly one implementor");
   10.32 -    oop_store_without_check((oop*)&_implementors[i], k);
   10.33 -  } else if (i == implementors_limit) {
   10.34 -    // clear out the list on first overflow
   10.35 -    for (int i2 = 0; i2 < implementors_limit; i2++)
   10.36 -      oop_store_without_check((oop*)&_implementors[i2], NULL);
   10.37 +  klassOop ik = implementor();
   10.38 +  if (ik == NULL) {
   10.39 +    set_implementor(k);
   10.40 +  } else if (ik != this->as_klassOop()) {
   10.41 +    // There is already an implementor. Use itself as an indicator of
   10.42 +    // more than one implementors.
   10.43 +    set_implementor(this->as_klassOop());
   10.44    }
   10.45  
   10.46    // The implementor also implements the transitive_interfaces
   10.47 @@ -603,9 +609,9 @@
   10.48  }
   10.49  
   10.50  void instanceKlass::init_implementor() {
   10.51 -  for (int i = 0; i < implementors_limit; i++)
   10.52 -    oop_store_without_check((oop*)&_implementors[i], NULL);
   10.53 -  _nof_implementors = 0;
   10.54 +  if (is_interface()) {
   10.55 +    set_implementor(NULL);
   10.56 +  }
   10.57  }
   10.58  
   10.59  
   10.60 @@ -1849,24 +1855,22 @@
   10.61  void instanceKlass::follow_weak_klass_links(
   10.62    BoolObjectClosure* is_alive, OopClosure* keep_alive) {
   10.63    assert(is_alive->do_object_b(as_klassOop()), "this oop should be live");
   10.64 -  if (ClassUnloading) {
   10.65 -    for (int i = 0; i < implementors_limit; i++) {
   10.66 -      klassOop impl = _implementors[i];
   10.67 -      if (impl == NULL)  break;  // no more in the list
   10.68 -      if (!is_alive->do_object_b(impl)) {
   10.69 -        // remove this guy from the list by overwriting him with the tail
   10.70 -        int lasti = --_nof_implementors;
   10.71 -        assert(lasti >= i && lasti < implementors_limit, "just checking");
   10.72 -        _implementors[i] = _implementors[lasti];
   10.73 -        _implementors[lasti] = NULL;
   10.74 -        --i; // rerun the loop at this index
   10.75 +
   10.76 +  if (is_interface()) {
   10.77 +    if (ClassUnloading) {
   10.78 +      klassOop impl = implementor();
   10.79 +      if (impl != NULL) {
   10.80 +        if (!is_alive->do_object_b(impl)) {
   10.81 +          // remove this guy
   10.82 +          *start_of_implementor() = NULL;
   10.83 +        }
   10.84        }
   10.85 -    }
   10.86 -  } else {
   10.87 -    for (int i = 0; i < implementors_limit; i++) {
   10.88 -      keep_alive->do_oop(&adr_implementors()[i]);
   10.89 +    } else {
   10.90 +      assert(adr_implementor() != NULL, "just checking");
   10.91 +      keep_alive->do_oop(adr_implementor());
   10.92      }
   10.93    }
   10.94 +
   10.95    Klass::follow_weak_klass_links(is_alive, keep_alive);
   10.96  }
   10.97  
    11.1 --- a/src/share/vm/oops/instanceKlass.hpp	Thu Apr 05 14:16:23 2012 +0200
    11.2 +++ b/src/share/vm/oops/instanceKlass.hpp	Thu Apr 12 18:41:24 2012 -0400
    11.3 @@ -1,5 +1,5 @@
    11.4  /*
    11.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    11.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    11.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.8   *
    11.9   * This code is free software; you can redistribute it and/or modify it
   11.10 @@ -56,8 +56,6 @@
   11.11  //    [methods                    ]
   11.12  //    [local interfaces           ]
   11.13  //    [transitive interfaces      ]
   11.14 -//    [number of implementors     ]
   11.15 -//    [implementors               ] klassOop[2]
   11.16  //    [fields                     ]
   11.17  //    [constants                  ]
   11.18  //    [class loader               ]
   11.19 @@ -77,9 +75,9 @@
   11.20  //    [oop map cache (stack maps) ]
   11.21  //    [EMBEDDED Java vtable             ] size in words = vtable_len
   11.22  //    [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
   11.23 -//
   11.24 -//    The embedded nonstatic oop-map blocks are short pairs (offset, length) indicating
   11.25 -//    where oops are located in instances of this klass.
   11.26 +//      The embedded nonstatic oop-map blocks are short pairs (offset, length)
   11.27 +//      indicating where oops are located in instances of this klass.
   11.28 +//    [EMBEDDED implementor of the interface] only exist for interface
   11.29  
   11.30  
   11.31  // forward declaration for class -- see below for definition
   11.32 @@ -153,10 +151,6 @@
   11.33    oop* oop_block_beg() const { return adr_array_klasses(); }
   11.34    oop* oop_block_end() const { return adr_methods_default_annotations() + 1; }
   11.35  
   11.36 -  enum {
   11.37 -    implementors_limit = 2              // how many implems can we track?
   11.38 -  };
   11.39 -
   11.40   protected:
   11.41    //
   11.42    // The oop block.  See comment in klass.hpp before making changes.
   11.43 @@ -200,8 +194,6 @@
   11.44    // and EnclosingMethod attributes the _inner_classes array length is
   11.45    // number_of_inner_classes * 4 + enclosing_method_attribute_size.
   11.46    typeArrayOop    _inner_classes;
   11.47 -  // Implementors of this interface (not valid if it overflows)
   11.48 -  klassOop        _implementors[implementors_limit];
   11.49    // Annotations for this class, or null if none.
   11.50    typeArrayOop    _class_annotations;
   11.51    // Annotation objects (byte arrays) for fields, or null if no annotations.
   11.52 @@ -257,7 +249,6 @@
   11.53    nmethodBucket*  _dependencies;         // list of dependent nmethods
   11.54    nmethod*        _osr_nmethods_head;    // Head of list of on-stack replacement nmethods for this class
   11.55    BreakpointInfo* _breakpoints;          // bpt lists, managed by methodOop
   11.56 -  int             _nof_implementors;     // No of implementors of this interface (zero if not an interface)
   11.57    // Array of interesting part(s) of the previous version(s) of this
   11.58    // instanceKlass. See PreviousVersionWalker below.
   11.59    GrowableArray<PreviousVersionNode *>* _previous_versions;
   11.60 @@ -278,6 +269,13 @@
   11.61    // embedded Java itables follows here
   11.62    // embedded static fields follows here
   11.63    // embedded nonstatic oop-map blocks follows here
   11.64 +  // embedded implementor of this interface follows here
   11.65 +  //   The embedded implementor only exists if the current klass is an
   11.66 +  //   iterface. The possible values of the implementor fall into following
   11.67 +  //   three cases:
   11.68 +  //     NULL: no implementor.
   11.69 +  //     A klassOop that's not itself: one implementor.
   11.70 +  //     Itsef: more than one implementors.
   11.71  
   11.72    friend class instanceKlassKlass;
   11.73    friend class SystemDictionary;
   11.74 @@ -649,14 +647,34 @@
   11.75    // subclass/subinterface checks
   11.76    bool implements_interface(klassOop k) const;
   11.77  
   11.78 -  // Access to implementors of an interface. We only store the count
   11.79 -  // of implementors, and in case, there are only a few
   11.80 -  // implementors, we store them in a short list.
   11.81 -  // This accessor returns NULL if we walk off the end of the list.
   11.82 -  klassOop implementor(int i) const {
   11.83 -    return (i < implementors_limit)? _implementors[i]: (klassOop) NULL;
   11.84 +  // Access to the implementor of an interface.
   11.85 +  klassOop implementor() const
   11.86 +  {
   11.87 +    klassOop* k = start_of_implementor();
   11.88 +    if (k == NULL) {
   11.89 +      return NULL;
   11.90 +    } else {
   11.91 +      return *k;
   11.92 +    }
   11.93    }
   11.94 -  int  nof_implementors() const       { return _nof_implementors; }
   11.95 +
   11.96 +  void set_implementor(klassOop k) {
   11.97 +    assert(is_interface(), "not interface");
   11.98 +    oop* addr = (oop*)start_of_implementor();
   11.99 +    oop_store_without_check(addr, k);
  11.100 +  }
  11.101 +
  11.102 +  int  nof_implementors() const       {
  11.103 +    klassOop k = implementor();
  11.104 +    if (k == NULL) {
  11.105 +      return 0;
  11.106 +    } else if (k != this->as_klassOop()) {
  11.107 +      return 1;
  11.108 +    } else {
  11.109 +      return 2;
  11.110 +    }
  11.111 +  }
  11.112 +
  11.113    void add_implementor(klassOop k);  // k is a new class that implements this interface
  11.114    void init_implementor();           // initialize
  11.115  
  11.116 @@ -693,7 +711,15 @@
  11.117  
  11.118    // Sizing (in words)
  11.119    static int header_size()            { return align_object_offset(oopDesc::header_size() + sizeof(instanceKlass)/HeapWordSize); }
  11.120 -  int object_size() const             { return object_size(align_object_offset(vtable_length()) + align_object_offset(itable_length()) + nonstatic_oop_map_size()); }
  11.121 +
  11.122 +  int object_size() const
  11.123 +  {
  11.124 +    return object_size(align_object_offset(vtable_length()) +
  11.125 +                       align_object_offset(itable_length()) +
  11.126 +                       (is_interface() ?
  11.127 +                        (align_object_offset(nonstatic_oop_map_size()) + (int)sizeof(klassOop)/HeapWordSize) :
  11.128 +                        nonstatic_oop_map_size()));
  11.129 +  }
  11.130    static int vtable_start_offset()    { return header_size(); }
  11.131    static int vtable_length_offset()   { return oopDesc::header_size() + offset_of(instanceKlass, _vtable_len) / HeapWordSize; }
  11.132    static int object_size(int extra)   { return align_object_size(header_size() + extra); }
  11.133 @@ -710,6 +736,15 @@
  11.134      return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
  11.135    }
  11.136  
  11.137 +  klassOop* start_of_implementor() const {
  11.138 +    if (is_interface()) {
  11.139 +      return (klassOop*)(start_of_nonstatic_oop_maps() +
  11.140 +                         nonstatic_oop_map_count());
  11.141 +    } else {
  11.142 +      return NULL;
  11.143 +    }
  11.144 +  };
  11.145 +
  11.146    // Allocation profiling support
  11.147    juint alloc_size() const            { return _alloc_count * size_helper(); }
  11.148    void set_alloc_size(juint n)        {}
  11.149 @@ -819,7 +854,7 @@
  11.150    oop* adr_host_klass() const        { return (oop*)&this->_host_klass;}
  11.151    oop* adr_signers() const           { return (oop*)&this->_signers;}
  11.152    oop* adr_inner_classes() const     { return (oop*)&this->_inner_classes;}
  11.153 -  oop* adr_implementors() const      { return (oop*)&this->_implementors[0];}
  11.154 +  oop* adr_implementor() const       { return (oop*)start_of_implementor(); }
  11.155    oop* adr_methods_jmethod_ids() const             { return (oop*)&this->_methods_jmethod_ids;}
  11.156    oop* adr_methods_cached_itable_indices() const   { return (oop*)&this->_methods_cached_itable_indices;}
  11.157    oop* adr_class_annotations() const   { return (oop*)&this->_class_annotations;}
    12.1 --- a/src/share/vm/oops/instanceKlassKlass.cpp	Thu Apr 05 14:16:23 2012 +0200
    12.2 +++ b/src/share/vm/oops/instanceKlassKlass.cpp	Thu Apr 12 18:41:24 2012 -0400
    12.3 @@ -1,5 +1,5 @@
    12.4  /*
    12.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    12.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    12.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.8   *
    12.9   * This code is free software; you can redistribute it and/or modify it
   12.10 @@ -111,7 +111,7 @@
   12.11    MarkSweep::mark_and_push(ik->adr_methods_parameter_annotations());
   12.12    MarkSweep::mark_and_push(ik->adr_methods_default_annotations());
   12.13  
   12.14 -  // We do not follow adr_implementors() here. It is followed later
   12.15 +  // We do not follow adr_implementor() here. It is followed later
   12.16    // in instanceKlass::follow_weak_klass_links()
   12.17  
   12.18    klassKlass::oop_follow_contents(obj);
   12.19 @@ -180,8 +180,8 @@
   12.20    blk->do_oop(ik->adr_host_klass());
   12.21    blk->do_oop(ik->adr_signers());
   12.22    blk->do_oop(ik->adr_inner_classes());
   12.23 -  for (int i = 0; i < instanceKlass::implementors_limit; i++) {
   12.24 -    blk->do_oop(&ik->adr_implementors()[i]);
   12.25 +  if (ik->is_interface()) {
   12.26 +    blk->do_oop(ik->adr_implementor());
   12.27    }
   12.28    blk->do_oop(ik->adr_class_annotations());
   12.29    blk->do_oop(ik->adr_fields_annotations());
   12.30 @@ -232,9 +232,9 @@
   12.31    if (mr.contains(adr)) blk->do_oop(adr);
   12.32    adr = ik->adr_inner_classes();
   12.33    if (mr.contains(adr)) blk->do_oop(adr);
   12.34 -  adr = ik->adr_implementors();
   12.35 -  for (int i = 0; i < instanceKlass::implementors_limit; i++) {
   12.36 -    if (mr.contains(&adr[i])) blk->do_oop(&adr[i]);
   12.37 +  if (ik->is_interface()) {
   12.38 +    adr = ik->adr_implementor();
   12.39 +    if (mr.contains(adr)) blk->do_oop(adr);
   12.40    }
   12.41    adr = ik->adr_class_annotations();
   12.42    if (mr.contains(adr)) blk->do_oop(adr);
   12.43 @@ -273,8 +273,8 @@
   12.44    MarkSweep::adjust_pointer(ik->adr_host_klass());
   12.45    MarkSweep::adjust_pointer(ik->adr_signers());
   12.46    MarkSweep::adjust_pointer(ik->adr_inner_classes());
   12.47 -  for (int i = 0; i < instanceKlass::implementors_limit; i++) {
   12.48 -    MarkSweep::adjust_pointer(&ik->adr_implementors()[i]);
   12.49 +  if (ik->is_interface()) {
   12.50 +    MarkSweep::adjust_pointer(ik->adr_implementor());
   12.51    }
   12.52    MarkSweep::adjust_pointer(ik->adr_class_annotations());
   12.53    MarkSweep::adjust_pointer(ik->adr_fields_annotations());
   12.54 @@ -328,6 +328,9 @@
   12.55    for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
   12.56      PSParallelCompact::adjust_pointer(cur_oop);
   12.57    }
   12.58 +  if (ik->is_interface()) {
   12.59 +    PSParallelCompact::adjust_pointer(ik->adr_implementor());
   12.60 +  }
   12.61  
   12.62    OopClosure* closure = PSParallelCompact::adjust_root_pointer_closure();
   12.63    iterate_c_heap_oops(ik, closure);
   12.64 @@ -342,11 +345,18 @@
   12.65  instanceKlassKlass::allocate_instance_klass(Symbol* name, int vtable_len, int itable_len,
   12.66                                              int static_field_size,
   12.67                                              unsigned nonstatic_oop_map_count,
   12.68 +                                            AccessFlags access_flags,
   12.69                                              ReferenceType rt, TRAPS) {
   12.70  
   12.71    const int nonstatic_oop_map_size =
   12.72      instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count);
   12.73 -  int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + nonstatic_oop_map_size);
   12.74 +  int size = align_object_offset(vtable_len) + align_object_offset(itable_len);
   12.75 +  if (access_flags.is_interface()) {
   12.76 +    size += align_object_offset(nonstatic_oop_map_size) + (int)sizeof(klassOop)/HeapWordSize;
   12.77 +  } else {
   12.78 +    size += nonstatic_oop_map_size;
   12.79 +  }
   12.80 +  size = instanceKlass::object_size(size);
   12.81  
   12.82    // Allocation
   12.83    KlassHandle h_this_klass(THREAD, as_klassOop());
   12.84 @@ -378,6 +388,7 @@
   12.85      ik->set_itable_length(itable_len);
   12.86      ik->set_static_field_size(static_field_size);
   12.87      ik->set_nonstatic_oop_map_size(nonstatic_oop_map_size);
   12.88 +    ik->set_access_flags(access_flags);
   12.89      assert(k()->size() == size, "wrong size for object");
   12.90  
   12.91      ik->set_array_klasses(NULL);
   12.92 @@ -470,16 +481,12 @@
   12.93  
   12.94    if (ik->is_interface()) {
   12.95      st->print_cr(BULLET"nof implementors:  %d", ik->nof_implementors());
   12.96 -    int print_impl = 0;
   12.97 -    for (int i = 0; i < instanceKlass::implementors_limit; i++) {
   12.98 -      if (ik->implementor(i) != NULL) {
   12.99 -        if (++print_impl == 1)
  12.100 -          st->print_cr(BULLET"implementor:    ");
  12.101 -        st->print("   ");
  12.102 -        ik->implementor(i)->print_value_on(st);
  12.103 -      }
  12.104 +    if (ik->nof_implementors() == 1) {
  12.105 +      st->print_cr(BULLET"implementor:    ");
  12.106 +      st->print("   ");
  12.107 +      ik->implementor()->print_value_on(st);
  12.108 +      st->cr();
  12.109      }
  12.110 -    if (print_impl > 0)  st->cr();
  12.111    }
  12.112  
  12.113    st->print(BULLET"arrays:            "); ik->array_klasses()->print_value_on(st);     st->cr();
  12.114 @@ -640,16 +647,12 @@
  12.115      }
  12.116  
  12.117      // Verify implementor fields
  12.118 -    bool saw_null_impl = false;
  12.119 -    for (int i = 0; i < instanceKlass::implementors_limit; i++) {
  12.120 -      klassOop im = ik->implementor(i);
  12.121 -      if (im == NULL) { saw_null_impl = true; continue; }
  12.122 -      guarantee(!saw_null_impl, "non-nulls must preceded all nulls");
  12.123 +    klassOop im = ik->implementor();
  12.124 +    if (im != NULL) {
  12.125        guarantee(ik->is_interface(), "only interfaces should have implementor set");
  12.126 -      guarantee(i < ik->nof_implementors(), "should only have one implementor");
  12.127        guarantee(im->is_perm(),  "should be in permspace");
  12.128        guarantee(im->is_klass(), "should be klass");
  12.129 -      guarantee(!Klass::cast(klassOop(im))->is_interface(), "implementors cannot be interfaces");
  12.130 +      guarantee(!Klass::cast(klassOop(im))->is_interface() || im == ik->as_klassOop(), "implementors cannot be interfaces");
  12.131      }
  12.132  
  12.133      // Verify local interfaces
    13.1 --- a/src/share/vm/oops/instanceKlassKlass.hpp	Thu Apr 05 14:16:23 2012 +0200
    13.2 +++ b/src/share/vm/oops/instanceKlassKlass.hpp	Thu Apr 12 18:41:24 2012 -0400
    13.3 @@ -1,5 +1,5 @@
    13.4  /*
    13.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    13.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    13.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.8   *
    13.9   * This code is free software; you can redistribute it and/or modify it
   13.10 @@ -46,6 +46,7 @@
   13.11                                     int itable_len,
   13.12                                     int static_field_size,
   13.13                                     unsigned int nonstatic_oop_map_count,
   13.14 +                                   AccessFlags access_flags,
   13.15                                     ReferenceType rt,
   13.16                                     TRAPS);
   13.17  
    14.1 --- a/src/share/vm/runtime/vmStructs.cpp	Thu Apr 05 14:16:23 2012 +0200
    14.2 +++ b/src/share/vm/runtime/vmStructs.cpp	Thu Apr 12 18:41:24 2012 -0400
    14.3 @@ -292,8 +292,6 @@
    14.4    nonstatic_field(instanceKlass,               _method_ordering,                              typeArrayOop)                          \
    14.5    nonstatic_field(instanceKlass,               _local_interfaces,                             objArrayOop)                           \
    14.6    nonstatic_field(instanceKlass,               _transitive_interfaces,                        objArrayOop)                           \
    14.7 -  nonstatic_field(instanceKlass,               _nof_implementors,                             int)                                   \
    14.8 -  nonstatic_field(instanceKlass,               _implementors[0],                              klassOop)                              \
    14.9    nonstatic_field(instanceKlass,               _fields,                                       typeArrayOop)                          \
   14.10    nonstatic_field(instanceKlass,               _java_fields_count,                            u2)                                    \
   14.11    nonstatic_field(instanceKlass,               _constants,                                    constantPoolOop)                       \
   14.12 @@ -2343,7 +2341,6 @@
   14.13    /* instanceKlass enum                */                                 \
   14.14    /*************************************/                                 \
   14.15                                                                            \
   14.16 -  declare_constant(instanceKlass::implementors_limit)                     \
   14.17                                                                            \
   14.18    /*************************************/                                 \
   14.19    /* FieldInfo FieldOffset enum        */                                 \

mercurial