Merge

Thu, 24 Mar 2011 23:00:27 -0700

author
jcoomes
date
Thu, 24 Mar 2011 23:00:27 -0700
changeset 2663
f195ebb181b8
parent 2654
b898f0fc3ced
parent 2662
32f7097f9d8f
child 2667
0e3ed5a14f73

Merge

     1.1 --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java	Fri Mar 18 13:28:33 2011 -0700
     1.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java	Thu Mar 24 23:00:27 2011 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2002, 2011, 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 @@ -62,7 +62,7 @@
    1.11  
    1.12      // get the value of static field
    1.13      ValueImpl getValue() {
    1.14 -        return getValue(saField.getFieldHolder());
    1.15 +        return getValue(saField.getFieldHolder().getJavaMirror());
    1.16      }
    1.17  
    1.18      // get the value of this Field from a specific Oop
     2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java	Fri Mar 18 13:28:33 2011 -0700
     2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java	Thu Mar 24 23:00:27 2011 -0700
     2.3 @@ -44,12 +44,10 @@
     2.4    private static synchronized void initialize(TypeDataBase db) {
     2.5      Type type = db.lookupType("StringTable");
     2.6      theTableField  = type.getAddressField("_the_table");
     2.7 -    stringTableSize = db.lookupIntConstant("StringTable::string_table_size").intValue();
     2.8    }
     2.9  
    2.10    // Fields
    2.11    private static AddressField theTableField;
    2.12 -  private static int stringTableSize;
    2.13  
    2.14    // Accessors
    2.15    public static StringTable getTheTable() {
    2.16 @@ -57,10 +55,6 @@
    2.17      return (StringTable) VMObjectFactory.newObject(StringTable.class, tmp);
    2.18    }
    2.19  
    2.20 -  public static int getStringTableSize() {
    2.21 -    return stringTableSize;
    2.22 -  }
    2.23 -
    2.24    public StringTable(Address addr) {
    2.25      super(addr);
    2.26    }
     3.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Fri Mar 18 13:28:33 2011 -0700
     3.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Thu Mar 24 23:00:27 2011 -0700
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -87,7 +87,7 @@
    3.11      innerClasses         = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize());
    3.12      nonstaticFieldSize   = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize());
    3.13      staticFieldSize      = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize());
    3.14 -    staticOopFieldSize   = new CIntField(type.getCIntegerField("_static_oop_field_size"), Oop.getHeaderSize());
    3.15 +    staticOopFieldCount   = new CIntField(type.getCIntegerField("_static_oop_field_count"), Oop.getHeaderSize());
    3.16      nonstaticOopMapSize  = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize());
    3.17      isMarkedDependent    = new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize());
    3.18      initState            = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize());
    3.19 @@ -140,7 +140,7 @@
    3.20    private static OopField  innerClasses;
    3.21    private static CIntField nonstaticFieldSize;
    3.22    private static CIntField staticFieldSize;
    3.23 -  private static CIntField staticOopFieldSize;
    3.24 +  private static CIntField staticOopFieldCount;
    3.25    private static CIntField nonstaticOopMapSize;
    3.26    private static CIntField isMarkedDependent;
    3.27    private static CIntField initState;
    3.28 @@ -261,8 +261,7 @@
    3.29    public Symbol    getSourceDebugExtension(){ return getSymbol(sourceDebugExtension); }
    3.30    public TypeArray getInnerClasses()        { return (TypeArray)    innerClasses.getValue(this); }
    3.31    public long      getNonstaticFieldSize()  { return                nonstaticFieldSize.getValue(this); }
    3.32 -  public long      getStaticFieldSize()     { return                staticFieldSize.getValue(this); }
    3.33 -  public long      getStaticOopFieldSize()  { return                staticOopFieldSize.getValue(this); }
    3.34 +  public long      getStaticOopFieldCount() { return                staticOopFieldCount.getValue(this); }
    3.35    public long      getNonstaticOopMapSize() { return                nonstaticOopMapSize.getValue(this); }
    3.36    public boolean   getIsMarkedDependent()   { return                isMarkedDependent.getValue(this) != 0; }
    3.37    public long      getVtableLen()           { return                vtableLen.getValue(this); }
    3.38 @@ -453,7 +452,7 @@
    3.39        visitor.doOop(innerClasses, true);
    3.40        visitor.doCInt(nonstaticFieldSize, true);
    3.41        visitor.doCInt(staticFieldSize, true);
    3.42 -      visitor.doCInt(staticOopFieldSize, true);
    3.43 +      visitor.doCInt(staticOopFieldCount, true);
    3.44        visitor.doCInt(nonstaticOopMapSize, true);
    3.45        visitor.doCInt(isMarkedDependent, true);
    3.46        visitor.doCInt(initState, true);
    3.47 @@ -692,7 +691,7 @@
    3.48    public long getObjectSize() {
    3.49      long bodySize =    alignObjectOffset(getVtableLen() * getHeap().getOopSize())
    3.50                       + alignObjectOffset(getItableLen() * getHeap().getOopSize())
    3.51 -                     + (getStaticFieldSize() + getNonstaticOopMapSize()) * getHeap().getOopSize();
    3.52 +                     + (getNonstaticOopMapSize()) * getHeap().getOopSize();
    3.53      return alignObjectSize(headerSize + bodySize);
    3.54    }
    3.55  
     4.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java	Fri Mar 18 13:28:33 2011 -0700
     4.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java	Thu Mar 24 23:00:27 2011 -0700
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2000, 2011, 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 @@ -40,7 +40,12 @@
    4.11      super(holder, fieldArrayIndex);
    4.12    }
    4.13  
    4.14 -  public int getValue(Oop obj) { return obj.getHandle().getJIntAt(getOffset()); }
    4.15 +  public int getValue(Oop obj) {
    4.16 +    if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
    4.17 +      throw new InternalError(obj.toString());
    4.18 +    }
    4.19 +    return obj.getHandle().getJIntAt(getOffset());
    4.20 +  }
    4.21    public void setValue(Oop obj, int value) throws MutationException {
    4.22      // Fix this: setJIntAt is missing in Address
    4.23    }
     5.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java	Fri Mar 18 13:28:33 2011 -0700
     5.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java	Thu Mar 24 23:00:27 2011 -0700
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2000, 2011, 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 @@ -41,11 +41,17 @@
    5.11    }
    5.12  
    5.13    public Oop getValue(Oop obj) {
    5.14 +    if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
    5.15 +      throw new InternalError();
    5.16 +    }
    5.17      return obj.getHeap().newOop(getValueAsOopHandle(obj));
    5.18    }
    5.19  
    5.20    /** Debugging support */
    5.21    public OopHandle getValueAsOopHandle(Oop obj) {
    5.22 +    if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
    5.23 +      throw new InternalError(obj.toString());
    5.24 +    }
    5.25      return obj.getHandle().getOopHandleAt(getOffset());
    5.26    }
    5.27  
     6.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Fri Mar 18 13:28:33 2011 -0700
     6.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Thu Mar 24 23:00:27 2011 -0700
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -274,13 +274,7 @@
    6.11         // hc_klass is a HotSpot magic field and hence we can't
    6.12         // find it from InstanceKlass for java.lang.Class.
    6.13         TypeDataBase db = VM.getVM().getTypeDataBase();
    6.14 -       int hcKlassOffset = (int) Instance.getHeaderSize();
    6.15 -       try {
    6.16 -          hcKlassOffset += (db.lookupIntConstant("java_lang_Class::hc_klass_offset").intValue() *
    6.17 -                           VM.getVM().getHeapOopSize());
    6.18 -       } catch (RuntimeException re) {
    6.19 -          // ignore, currently java_lang_Class::hc_klass_offset is zero
    6.20 -       }
    6.21 +       int hcKlassOffset = (int) db.lookupType("java_lang_Class").getCIntegerField("klass_offset").getValue();
    6.22         if (VM.getVM().isCompressedOopsEnabled()) {
    6.23           hcKlassField = new NarrowOopField(new NamedFieldIdentifier("hc_klass"), hcKlassOffset, true);
    6.24         } else {
     7.1 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Fri Mar 18 13:28:33 2011 -0700
     7.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Thu Mar 24 23:00:27 2011 -0700
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2000, 2011, 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 @@ -839,13 +839,13 @@
    7.11    }
    7.12  
    7.13    private void readSystemProperties() {
    7.14 -     InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
    7.15 +     final InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
    7.16       systemKls.iterate(new DefaultOopVisitor() {
    7.17                                 ObjectReader objReader = new ObjectReader();
    7.18                                 public void doOop(sun.jvm.hotspot.oops.OopField field, boolean isVMField) {
    7.19                                    if (field.getID().getName().equals("props")) {
    7.20                                       try {
    7.21 -                                        sysProps = (Properties) objReader.readObject(field.getValue(getObj()));
    7.22 +                                        sysProps = (Properties) objReader.readObject(field.getValue(systemKls.getJavaMirror()));
    7.23                                       } catch (Exception e) {
    7.24                                          if (Assert.ASSERTS_ENABLED) {
    7.25                                             e.printStackTrace();
     8.1 --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java	Fri Mar 18 13:28:33 2011 -0700
     8.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java	Thu Mar 24 23:00:27 2011 -0700
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 2004, 2011, 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 @@ -746,7 +746,7 @@
    8.11              out.writeByte((byte)kind);
    8.12              if (ik != null) {
    8.13                  // static field
    8.14 -                writeField(field, ik);
    8.15 +                writeField(field, ik.getJavaMirror());
    8.16              }
    8.17          }
    8.18      }
     9.1 --- a/agent/test/jdi/sasanity.sh	Fri Mar 18 13:28:33 2011 -0700
     9.2 +++ b/agent/test/jdi/sasanity.sh	Thu Mar 24 23:00:27 2011 -0700
     9.3 @@ -43,6 +43,7 @@
     9.4  fi
     9.5  
     9.6  jdk=$1
     9.7 +shift
     9.8  OS=`uname`
     9.9  
    9.10  if [ "$OS" != "Linux" ]; then
    9.11 @@ -68,7 +69,7 @@
    9.12  
    9.13  tmp=/tmp/sagsetup
    9.14  rm -f $tmp
    9.15 -$jdk/bin/java sagtarg > $tmp &
    9.16 +$jdk/bin/java $* sagtarg > $tmp &
    9.17  pid=$!
    9.18  while [ ! -s $tmp ] ; do
    9.19    # Kludge alert!
    10.1 --- a/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Fri Mar 18 13:28:33 2011 -0700
    10.2 +++ b/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Thu Mar 24 23:00:27 2011 -0700
    10.3 @@ -301,7 +301,8 @@
    10.4      // thread.
    10.5      assert(_obj != noreg, "must be a valid register");
    10.6      assert(_oop_index >= 0, "must have oop index");
    10.7 -    __ ld_ptr(_obj, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc), G3);
    10.8 +    __ load_heap_oop(_obj, java_lang_Class::klass_offset_in_bytes(), G3);
    10.9 +    __ ld_ptr(G3, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc), G3);
   10.10      __ cmp(G2_thread, G3);
   10.11      __ br(Assembler::notEqual, false, Assembler::pn, call_patch);
   10.12      __ delayed()->nop();
    11.1 --- a/src/cpu/sparc/vm/dump_sparc.cpp	Fri Mar 18 13:28:33 2011 -0700
    11.2 +++ b/src/cpu/sparc/vm/dump_sparc.cpp	Thu Mar 24 23:00:27 2011 -0700
    11.3 @@ -80,13 +80,19 @@
    11.4      for (int j = 0; j < num_virtuals; ++j) {
    11.5        dummy_vtable[num_virtuals * i + j] = (void*)masm->pc();
    11.6        __ save(SP, -256, SP);
    11.7 +      int offset = (i << 8) + j;
    11.8 +      Register src = G0;
    11.9 +      if (!Assembler::is_simm13(offset)) {
   11.10 +        __ sethi(offset, L0);
   11.11 +        src = L0;
   11.12 +        offset = offset & ((1 << 10) - 1);
   11.13 +      }
   11.14        __ brx(Assembler::always, false, Assembler::pt, common_code);
   11.15  
   11.16        // Load L0 with a value indicating vtable/offset pair.
   11.17        // -- bits[ 7..0]  (8 bits) which virtual method in table?
   11.18 -      // -- bits[12..8]  (5 bits) which virtual method table?
   11.19 -      // -- must fit in 13-bit instruction immediate field.
   11.20 -      __ delayed()->set((i << 8) + j, L0);
   11.21 +      // -- bits[13..8]  (6 bits) which virtual method table?
   11.22 +      __ delayed()->or3(src, offset, L0);
   11.23      }
   11.24    }
   11.25  
    12.1 --- a/src/cpu/sparc/vm/nativeInst_sparc.cpp	Fri Mar 18 13:28:33 2011 -0700
    12.2 +++ b/src/cpu/sparc/vm/nativeInst_sparc.cpp	Thu Mar 24 23:00:27 2011 -0700
    12.3 @@ -52,6 +52,22 @@
    12.4    ICache::invalidate_range(instaddr, 7 * BytesPerInstWord);
    12.5  }
    12.6  
    12.7 +void NativeInstruction::verify_data64_sethi(address instaddr, intptr_t x) {
    12.8 +  ResourceMark rm;
    12.9 +  unsigned char buffer[10 * BytesPerInstWord];
   12.10 +  CodeBuffer buf(buffer, 10 * BytesPerInstWord);
   12.11 +  MacroAssembler masm(&buf);
   12.12 +
   12.13 +  Register destreg = inv_rd(*(unsigned int *)instaddr);
   12.14 +  // Generate the proper sequence into a temporary buffer and compare
   12.15 +  // it with the original sequence.
   12.16 +  masm.patchable_sethi(x, destreg);
   12.17 +  int len = buffer - masm.pc();
   12.18 +  for (int i = 0; i < len; i++) {
   12.19 +    assert(instaddr[i] == buffer[i], "instructions must match");
   12.20 +  }
   12.21 +}
   12.22 +
   12.23  void NativeInstruction::verify() {
   12.24    // make sure code pattern is actually an instruction address
   12.25    address addr = addr_at(0);
    13.1 --- a/src/cpu/sparc/vm/nativeInst_sparc.hpp	Fri Mar 18 13:28:33 2011 -0700
    13.2 +++ b/src/cpu/sparc/vm/nativeInst_sparc.hpp	Thu Mar 24 23:00:27 2011 -0700
    13.3 @@ -254,6 +254,7 @@
    13.4    // sethi.  This only does the sethi.  The disp field (bottom 10 bits)
    13.5    // must be handled separately.
    13.6    static void set_data64_sethi(address instaddr, intptr_t x);
    13.7 +  static void verify_data64_sethi(address instaddr, intptr_t x);
    13.8  
    13.9    // combine the fields of a sethi/simm13 pair (simm13 = or, add, jmpl, ld/st)
   13.10    static int data32(int sethi_insn, int arith_insn) {
    14.1 --- a/src/cpu/sparc/vm/relocInfo_sparc.cpp	Fri Mar 18 13:28:33 2011 -0700
    14.2 +++ b/src/cpu/sparc/vm/relocInfo_sparc.cpp	Thu Mar 24 23:00:27 2011 -0700
    14.3 @@ -30,7 +30,7 @@
    14.4  #include "oops/oop.inline.hpp"
    14.5  #include "runtime/safepoint.hpp"
    14.6  
    14.7 -void Relocation::pd_set_data_value(address x, intptr_t o) {
    14.8 +void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
    14.9    NativeInstruction* ip = nativeInstruction_at(addr());
   14.10    jint inst = ip->long_at(0);
   14.11    assert(inst != NativeInstruction::illegal_instruction(), "no breakpoint");
   14.12 @@ -83,7 +83,11 @@
   14.13      guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13");
   14.14      inst &= ~Assembler::simm(    -1, 13);
   14.15      inst |=  Assembler::simm(simm13, 13);
   14.16 -    ip->set_long_at(0, inst);
   14.17 +    if (verify_only) {
   14.18 +      assert(ip->long_at(0) == inst, "instructions must match");
   14.19 +    } else {
   14.20 +      ip->set_long_at(0, inst);
   14.21 +    }
   14.22      }
   14.23      break;
   14.24  
   14.25 @@ -97,19 +101,36 @@
   14.26        jint np = oopDesc::encode_heap_oop((oop)x);
   14.27        inst &= ~Assembler::hi22(-1);
   14.28        inst |=  Assembler::hi22((intptr_t)np);
   14.29 -      ip->set_long_at(0, inst);
   14.30 +      if (verify_only) {
   14.31 +        assert(ip->long_at(0) == inst, "instructions must match");
   14.32 +      } else {
   14.33 +        ip->set_long_at(0, inst);
   14.34 +      }
   14.35        inst2 = ip->long_at( NativeInstruction::nop_instruction_size );
   14.36        guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op");
   14.37 -      ip->set_long_at(NativeInstruction::nop_instruction_size, ip->set_data32_simm13( inst2, (intptr_t)np));
   14.38 +      if (verify_only) {
   14.39 +        assert(ip->long_at(NativeInstruction::nop_instruction_size) == NativeInstruction::set_data32_simm13( inst2, (intptr_t)np),
   14.40 +               "instructions must match");
   14.41 +      } else {
   14.42 +        ip->set_long_at(NativeInstruction::nop_instruction_size, NativeInstruction::set_data32_simm13( inst2, (intptr_t)np));
   14.43 +      }
   14.44        break;
   14.45      }
   14.46 -    ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x );
   14.47 +    if (verify_only) {
   14.48 +      ip->verify_data64_sethi( ip->addr_at(0), (intptr_t)x );
   14.49 +    } else {
   14.50 +      ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x );
   14.51 +    }
   14.52  #else
   14.53      guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
   14.54      inst &= ~Assembler::hi22(     -1);
   14.55      inst |=  Assembler::hi22((intptr_t)x);
   14.56      // (ignore offset; it doesn't play into the sethi)
   14.57 -    ip->set_long_at(0, inst);
   14.58 +    if (verify_only) {
   14.59 +      assert(ip->long_at(0) == inst, "instructions must match");
   14.60 +    } else {
   14.61 +      ip->set_long_at(0, inst);
   14.62 +    }
   14.63  #endif
   14.64      }
   14.65      break;
    15.1 --- a/src/cpu/x86/vm/c1_CodeStubs_x86.cpp	Fri Mar 18 13:28:33 2011 -0700
    15.2 +++ b/src/cpu/x86/vm/c1_CodeStubs_x86.cpp	Thu Mar 24 23:00:27 2011 -0700
    15.3 @@ -313,10 +313,13 @@
    15.4      }
    15.5      assert(_obj != noreg, "must be a valid register");
    15.6      Register tmp = rax;
    15.7 -    if (_obj == tmp) tmp = rbx;
    15.8 +    Register tmp2 = rbx;
    15.9      __ push(tmp);
   15.10 +    __ push(tmp2);
   15.11 +    __ load_heap_oop(tmp2, Address(_obj, java_lang_Class::klass_offset_in_bytes()));
   15.12      __ get_thread(tmp);
   15.13 -    __ cmpptr(tmp, Address(_obj, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc)));
   15.14 +    __ cmpptr(tmp, Address(tmp2, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc)));
   15.15 +    __ pop(tmp2);
   15.16      __ pop(tmp);
   15.17      __ jcc(Assembler::notEqual, call_patch);
   15.18  
    16.1 --- a/src/cpu/x86/vm/relocInfo_x86.cpp	Fri Mar 18 13:28:33 2011 -0700
    16.2 +++ b/src/cpu/x86/vm/relocInfo_x86.cpp	Thu Mar 24 23:00:27 2011 -0700
    16.3 @@ -31,7 +31,7 @@
    16.4  #include "runtime/safepoint.hpp"
    16.5  
    16.6  
    16.7 -void Relocation::pd_set_data_value(address x, intptr_t o) {
    16.8 +void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
    16.9  #ifdef AMD64
   16.10    x += o;
   16.11    typedef Assembler::WhichOperand WhichOperand;
   16.12 @@ -40,19 +40,35 @@
   16.13           which == Assembler::narrow_oop_operand ||
   16.14           which == Assembler::imm_operand, "format unpacks ok");
   16.15    if (which == Assembler::imm_operand) {
   16.16 -    *pd_address_in_code() = x;
   16.17 +    if (verify_only) {
   16.18 +      assert(*pd_address_in_code() == x, "instructions must match");
   16.19 +    } else {
   16.20 +      *pd_address_in_code() = x;
   16.21 +    }
   16.22    } else if (which == Assembler::narrow_oop_operand) {
   16.23      address disp = Assembler::locate_operand(addr(), which);
   16.24 -    *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
   16.25 +    if (verify_only) {
   16.26 +      assert(*(uint32_t*) disp == oopDesc::encode_heap_oop((oop)x), "instructions must match");
   16.27 +    } else {
   16.28 +      *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
   16.29 +    }
   16.30    } else {
   16.31      // Note:  Use runtime_call_type relocations for call32_operand.
   16.32      address ip = addr();
   16.33      address disp = Assembler::locate_operand(ip, which);
   16.34      address next_ip = Assembler::locate_next_instruction(ip);
   16.35 -    *(int32_t*) disp = x - next_ip;
   16.36 +    if (verify_only) {
   16.37 +      assert(*(int32_t*) disp == (x - next_ip), "instructions must match");
   16.38 +    } else {
   16.39 +      *(int32_t*) disp = x - next_ip;
   16.40 +    }
   16.41    }
   16.42  #else
   16.43 -  *pd_address_in_code() = x + o;
   16.44 +  if (verify_only) {
   16.45 +    assert(*pd_address_in_code() == (x + o), "instructions must match");
   16.46 +  } else {
   16.47 +    *pd_address_in_code() = x + o;
   16.48 +  }
   16.49  #endif // AMD64
   16.50  }
   16.51  
    17.1 --- a/src/cpu/zero/vm/cppInterpreter_zero.cpp	Fri Mar 18 13:28:33 2011 -0700
    17.2 +++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp	Thu Mar 24 23:00:27 2011 -0700
    17.3 @@ -1,5 +1,5 @@
    17.4  /*
    17.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    17.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    17.7   * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
    17.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.9   *
   17.10 @@ -281,7 +281,7 @@
   17.11  
   17.12      if (method->is_static()) {
   17.13        istate->set_oop_temp(
   17.14 -        method->constants()->pool_holder()->klass_part()->java_mirror());
   17.15 +        method->constants()->pool_holder()->java_mirror());
   17.16        mirror = istate->oop_temp_addr();
   17.17        *(dst++) = &mirror;
   17.18      }
   17.19 @@ -667,7 +667,7 @@
   17.20        (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
   17.21      oop object;
   17.22      if (method->is_static())
   17.23 -      object = method->constants()->pool_holder()->klass_part()->java_mirror();
   17.24 +      object = method->constants()->pool_holder()->java_mirror();
   17.25      else
   17.26        object = (oop) locals[0];
   17.27      monitor->set_obj(object);
    18.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Fri Mar 18 13:28:33 2011 -0700
    18.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Mar 24 23:00:27 2011 -0700
    18.3 @@ -1471,9 +1471,9 @@
    18.4    if (code == Bytecodes::_getstatic || code == Bytecodes::_putstatic) {
    18.5      if (state_before != NULL) {
    18.6        // build a patching constant
    18.7 -      obj = new Constant(new ClassConstant(holder), state_before);
    18.8 +      obj = new Constant(new InstanceConstant(holder->java_mirror()), state_before);
    18.9      } else {
   18.10 -      obj = new Constant(new ClassConstant(holder));
   18.11 +      obj = new Constant(new InstanceConstant(holder->java_mirror()));
   18.12      }
   18.13    }
   18.14  
    19.1 --- a/src/share/vm/c1/c1_Runtime1.cpp	Fri Mar 18 13:28:33 2011 -0700
    19.2 +++ b/src/share/vm/c1/c1_Runtime1.cpp	Thu Mar 24 23:00:27 2011 -0700
    19.3 @@ -808,7 +808,7 @@
    19.4          { klassOop klass = resolve_field_return_klass(caller_method, bci, CHECK);
    19.5            // Save a reference to the class that has to be checked for initialization
    19.6            init_klass = KlassHandle(THREAD, klass);
    19.7 -          k = klass;
    19.8 +          k = klass->java_mirror();
    19.9          }
   19.10          break;
   19.11        case Bytecodes::_new:
    20.1 --- a/src/share/vm/ci/ciCPCache.cpp	Fri Mar 18 13:28:33 2011 -0700
    20.2 +++ b/src/share/vm/ci/ciCPCache.cpp	Thu Mar 24 23:00:27 2011 -0700
    20.3 @@ -1,5 +1,5 @@
    20.4  /*
    20.5 - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
    20.6 + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
    20.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.8   *
    20.9   * This code is free software; you can redistribute it and/or modify it
   20.10 @@ -46,8 +46,7 @@
   20.11  // ciCPCache::is_f1_null_at
   20.12  bool ciCPCache::is_f1_null_at(int index) {
   20.13    VM_ENTRY_MARK;
   20.14 -  oop f1 = entry_at(index)->f1();
   20.15 -  return (f1 == NULL);
   20.16 +  return entry_at(index)->is_f1_null();
   20.17  }
   20.18  
   20.19  
    21.1 --- a/src/share/vm/ci/ciField.cpp	Fri Mar 18 13:28:33 2011 -0700
    21.2 +++ b/src/share/vm/ci/ciField.cpp	Thu Mar 24 23:00:27 2011 -0700
    21.3 @@ -213,7 +213,7 @@
    21.4      //    may change.  The three examples are java.lang.System.in,
    21.5      //    java.lang.System.out, and java.lang.System.err.
    21.6  
    21.7 -    Handle k = _holder->get_klassOop();
    21.8 +    KlassHandle k = _holder->get_klassOop();
    21.9      assert( SystemDictionary::System_klass() != NULL, "Check once per vm");
   21.10      if( k() == SystemDictionary::System_klass() ) {
   21.11        // Check offsets for case 2: System.in, System.out, or System.err
   21.12 @@ -225,36 +225,38 @@
   21.13        }
   21.14      }
   21.15  
   21.16 +    Handle mirror = k->java_mirror();
   21.17 +
   21.18      _is_constant = true;
   21.19      switch(type()->basic_type()) {
   21.20      case T_BYTE:
   21.21 -      _constant_value = ciConstant(type()->basic_type(), k->byte_field(_offset));
   21.22 +      _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset));
   21.23        break;
   21.24      case T_CHAR:
   21.25 -      _constant_value = ciConstant(type()->basic_type(), k->char_field(_offset));
   21.26 +      _constant_value = ciConstant(type()->basic_type(), mirror->char_field(_offset));
   21.27        break;
   21.28      case T_SHORT:
   21.29 -      _constant_value = ciConstant(type()->basic_type(), k->short_field(_offset));
   21.30 +      _constant_value = ciConstant(type()->basic_type(), mirror->short_field(_offset));
   21.31        break;
   21.32      case T_BOOLEAN:
   21.33 -      _constant_value = ciConstant(type()->basic_type(), k->bool_field(_offset));
   21.34 +      _constant_value = ciConstant(type()->basic_type(), mirror->bool_field(_offset));
   21.35        break;
   21.36      case T_INT:
   21.37 -      _constant_value = ciConstant(type()->basic_type(), k->int_field(_offset));
   21.38 +      _constant_value = ciConstant(type()->basic_type(), mirror->int_field(_offset));
   21.39        break;
   21.40      case T_FLOAT:
   21.41 -      _constant_value = ciConstant(k->float_field(_offset));
   21.42 +      _constant_value = ciConstant(mirror->float_field(_offset));
   21.43        break;
   21.44      case T_DOUBLE:
   21.45 -      _constant_value = ciConstant(k->double_field(_offset));
   21.46 +      _constant_value = ciConstant(mirror->double_field(_offset));
   21.47        break;
   21.48      case T_LONG:
   21.49 -      _constant_value = ciConstant(k->long_field(_offset));
   21.50 +      _constant_value = ciConstant(mirror->long_field(_offset));
   21.51        break;
   21.52      case T_OBJECT:
   21.53      case T_ARRAY:
   21.54        {
   21.55 -        oop o = k->obj_field(_offset);
   21.56 +        oop o = mirror->obj_field(_offset);
   21.57  
   21.58          // A field will be "constant" if it is known always to be
   21.59          // a non-null reference to an instance of a particular class,
    22.1 --- a/src/share/vm/ci/ciInstance.cpp	Fri Mar 18 13:28:33 2011 -0700
    22.2 +++ b/src/share/vm/ci/ciInstance.cpp	Thu Mar 24 23:00:27 2011 -0700
    22.3 @@ -1,5 +1,5 @@
    22.4  /*
    22.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    22.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    22.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.8   *
    22.9   * This code is free software; you can redistribute it and/or modify it
   22.10 @@ -138,3 +138,9 @@
   22.11    st->print(" type=");
   22.12    klass()->print(st);
   22.13  }
   22.14 +
   22.15 +
   22.16 +ciKlass* ciInstance::java_lang_Class_klass() {
   22.17 +  VM_ENTRY_MARK;
   22.18 +  return CURRENT_ENV->get_object(java_lang_Class::as_klassOop(get_oop()))->as_klass();
   22.19 +}
    23.1 --- a/src/share/vm/ci/ciInstance.hpp	Fri Mar 18 13:28:33 2011 -0700
    23.2 +++ b/src/share/vm/ci/ciInstance.hpp	Thu Mar 24 23:00:27 2011 -0700
    23.3 @@ -1,5 +1,5 @@
    23.4  /*
    23.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    23.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    23.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.8   *
    23.9   * This code is free software; you can redistribute it and/or modify it
   23.10 @@ -64,6 +64,8 @@
   23.11  
   23.12    // Constant value of a field at the specified offset.
   23.13    ciConstant field_value_by_offset(int field_offset);
   23.14 +
   23.15 +  ciKlass* java_lang_Class_klass();
   23.16  };
   23.17  
   23.18  #endif // SHARE_VM_CI_CIINSTANCE_HPP
    24.1 --- a/src/share/vm/ci/ciInstanceKlass.cpp	Fri Mar 18 13:28:33 2011 -0700
    24.2 +++ b/src/share/vm/ci/ciInstanceKlass.cpp	Thu Mar 24 23:00:27 2011 -0700
    24.3 @@ -1,5 +1,5 @@
    24.4  /*
    24.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    24.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
    24.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.8   *
    24.9   * This code is free software; you can redistribute it and/or modify it
   24.10 @@ -85,7 +85,6 @@
   24.11      if (h_k() != SystemDictionary::Object_klass()) {
   24.12        super();
   24.13      }
   24.14 -    java_mirror();
   24.15      //compute_nonstatic_fields();  // done outside of constructor
   24.16    }
   24.17  
   24.18 @@ -320,6 +319,9 @@
   24.19  // Get the instance of java.lang.Class corresponding to this klass.
   24.20  // Cache it on this->_java_mirror.
   24.21  ciInstance* ciInstanceKlass::java_mirror() {
   24.22 +  if (is_shared()) {
   24.23 +    return ciKlass::java_mirror();
   24.24 +  }
   24.25    if (_java_mirror == NULL) {
   24.26      _java_mirror = ciKlass::java_mirror();
   24.27    }
    25.1 --- a/src/share/vm/ci/ciObjectFactory.cpp	Fri Mar 18 13:28:33 2011 -0700
    25.2 +++ b/src/share/vm/ci/ciObjectFactory.cpp	Thu Mar 24 23:00:27 2011 -0700
    25.3 @@ -663,7 +663,7 @@
    25.4    if (key->is_perm() && _non_perm_count == 0) {
    25.5      return emptyBucket;
    25.6    } else if (key->is_instance()) {
    25.7 -    if (key->klass() == SystemDictionary::Class_klass()) {
    25.8 +    if (key->klass() == SystemDictionary::Class_klass() && JavaObjectsInPerm) {
    25.9        // class mirror instances are always perm
   25.10        return emptyBucket;
   25.11      }
    26.1 --- a/src/share/vm/classfile/classFileParser.cpp	Fri Mar 18 13:28:33 2011 -0700
    26.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Thu Mar 24 23:00:27 2011 -0700
    26.3 @@ -37,6 +37,7 @@
    26.4  #include "memory/universe.inline.hpp"
    26.5  #include "oops/constantPoolOop.hpp"
    26.6  #include "oops/instanceKlass.hpp"
    26.7 +#include "oops/instanceMirrorKlass.hpp"
    26.8  #include "oops/klass.inline.hpp"
    26.9  #include "oops/klassOop.hpp"
   26.10  #include "oops/klassVtable.hpp"
   26.11 @@ -2606,54 +2607,6 @@
   26.12  }
   26.13  
   26.14  
   26.15 -static void initialize_static_field(fieldDescriptor* fd, TRAPS) {
   26.16 -  KlassHandle h_k (THREAD, fd->field_holder());
   26.17 -  assert(h_k.not_null() && fd->is_static(), "just checking");
   26.18 -  if (fd->has_initial_value()) {
   26.19 -    BasicType t = fd->field_type();
   26.20 -    switch (t) {
   26.21 -      case T_BYTE:
   26.22 -        h_k()->byte_field_put(fd->offset(), fd->int_initial_value());
   26.23 -              break;
   26.24 -      case T_BOOLEAN:
   26.25 -        h_k()->bool_field_put(fd->offset(), fd->int_initial_value());
   26.26 -              break;
   26.27 -      case T_CHAR:
   26.28 -        h_k()->char_field_put(fd->offset(), fd->int_initial_value());
   26.29 -              break;
   26.30 -      case T_SHORT:
   26.31 -        h_k()->short_field_put(fd->offset(), fd->int_initial_value());
   26.32 -              break;
   26.33 -      case T_INT:
   26.34 -        h_k()->int_field_put(fd->offset(), fd->int_initial_value());
   26.35 -        break;
   26.36 -      case T_FLOAT:
   26.37 -        h_k()->float_field_put(fd->offset(), fd->float_initial_value());
   26.38 -        break;
   26.39 -      case T_DOUBLE:
   26.40 -        h_k()->double_field_put(fd->offset(), fd->double_initial_value());
   26.41 -        break;
   26.42 -      case T_LONG:
   26.43 -        h_k()->long_field_put(fd->offset(), fd->long_initial_value());
   26.44 -        break;
   26.45 -      case T_OBJECT:
   26.46 -        {
   26.47 -          #ifdef ASSERT
   26.48 -          TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
   26.49 -          assert(fd->signature() == sym, "just checking");
   26.50 -          #endif
   26.51 -          oop string = fd->string_initial_value(CHECK);
   26.52 -          h_k()->obj_field_put(fd->offset(), string);
   26.53 -        }
   26.54 -        break;
   26.55 -      default:
   26.56 -        THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
   26.57 -                  "Illegal ConstantValue attribute in class file");
   26.58 -    }
   26.59 -  }
   26.60 -}
   26.61 -
   26.62 -
   26.63  void ClassFileParser::java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
   26.64    constantPoolHandle cp, FieldAllocationCount *fac_ptr, TRAPS) {
   26.65    // This code is for compatibility with earlier jdk's that do not
   26.66 @@ -2769,8 +2722,8 @@
   26.67  }
   26.68  
   26.69  
   26.70 -void ClassFileParser::java_lang_Class_fix_pre(objArrayHandle* methods_ptr,
   26.71 -  FieldAllocationCount *fac_ptr, TRAPS) {
   26.72 +void ClassFileParser::java_lang_Class_fix_pre(int* nonstatic_field_size,
   26.73 +                                              FieldAllocationCount *fac_ptr) {
   26.74    // Add fake fields for java.lang.Class instances
   26.75    //
   26.76    // This is not particularly nice. We should consider adding a
   26.77 @@ -2787,10 +2740,13 @@
   26.78    // versions because when the offsets are computed at bootstrap
   26.79    // time we don't know yet which version of the JDK we're running in.
   26.80  
   26.81 -  // The values below are fake but will force two non-static oop fields and
   26.82 +  // The values below are fake but will force three non-static oop fields and
   26.83    // a corresponding non-static oop map block to be allocated.
   26.84    const int extra = java_lang_Class::number_of_fake_oop_fields;
   26.85    fac_ptr->nonstatic_oop_count += extra;
   26.86 +
   26.87 +  // Reserve some leading space for fake ints
   26.88 +  *nonstatic_field_size += align_size_up(java_lang_Class::hc_number_of_fake_int_fields * BytesPerInt, heapOopSize) / heapOopSize;
   26.89  }
   26.90  
   26.91  
   26.92 @@ -3205,9 +3161,7 @@
   26.93      int next_nonstatic_field_offset;
   26.94  
   26.95      // Calculate the starting byte offsets
   26.96 -    next_static_oop_offset      = (instanceKlass::header_size() +
   26.97 -                                  align_object_offset(vtable_size) +
   26.98 -                                  align_object_offset(itable_size)) * wordSize;
   26.99 +    next_static_oop_offset      = instanceMirrorKlass::offset_of_static_fields();
  26.100      next_static_double_offset   = next_static_oop_offset +
  26.101                                    (fac.static_oop_count * heapOopSize);
  26.102      if ( fac.static_double_count &&
  26.103 @@ -3226,15 +3180,16 @@
  26.104                                    fac.static_byte_count ), wordSize );
  26.105      static_field_size           = (next_static_type_offset -
  26.106                                    next_static_oop_offset) / wordSize;
  26.107 +
  26.108 +    // Add fake fields for java.lang.Class instances (also see below)
  26.109 +    if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
  26.110 +      java_lang_Class_fix_pre(&nonstatic_field_size, &fac);
  26.111 +    }
  26.112 +
  26.113      first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
  26.114                                     nonstatic_field_size * heapOopSize;
  26.115      next_nonstatic_field_offset = first_nonstatic_field_offset;
  26.116  
  26.117 -    // Add fake fields for java.lang.Class instances (also see below)
  26.118 -    if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
  26.119 -      java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle));
  26.120 -    }
  26.121 -
  26.122      // adjust the vmentry field declaration in java.lang.invoke.MethodHandle
  26.123      if (EnableMethodHandles && class_name == vmSymbols::java_lang_invoke_MethodHandle() && class_loader.is_null()) {
  26.124        java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
  26.125 @@ -3566,7 +3521,7 @@
  26.126      }
  26.127  
  26.128      // We can now create the basic klassOop for this klass
  26.129 -    klassOop ik = oopFactory::new_instanceKlass(vtable_size, itable_size,
  26.130 +    klassOop ik = oopFactory::new_instanceKlass(name, vtable_size, itable_size,
  26.131                                                  static_field_size,
  26.132                                                  total_oop_map_count,
  26.133                                                  rt, CHECK_(nullHandle));
  26.134 @@ -3588,7 +3543,7 @@
  26.135      this_klass->set_class_loader(class_loader());
  26.136      this_klass->set_nonstatic_field_size(nonstatic_field_size);
  26.137      this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
  26.138 -    this_klass->set_static_oop_field_size(fac.static_oop_count);
  26.139 +    this_klass->set_static_oop_field_count(fac.static_oop_count);
  26.140      cp->set_pool_holder(this_klass());
  26.141      error_handler.set_in_error(false);   // turn off error handler for cp
  26.142      this_klass->set_constants(cp());
  26.143 @@ -3649,9 +3604,6 @@
  26.144      // Make sure this is the end of class file stream
  26.145      guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
  26.146  
  26.147 -    // Initialize static fields
  26.148 -    this_klass->do_local_static_fields(&initialize_static_field, CHECK_(nullHandle));
  26.149 -
  26.150      // VerifyOops believes that once this has been set, the object is completely loaded.
  26.151      // Compute transitive closure of interfaces this class implements
  26.152      this_klass->set_transitive_interfaces(transitive_interfaces());
  26.153 @@ -3685,6 +3637,9 @@
  26.154        check_illegal_static_method(this_klass, CHECK_(nullHandle));
  26.155      }
  26.156  
  26.157 +    // Allocate mirror and initialize static fields
  26.158 +    java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle));
  26.159 +
  26.160      ClassLoadingService::notify_class_loaded(instanceKlass::cast(this_klass()),
  26.161                                               false /* not shared class */);
  26.162  
    27.1 --- a/src/share/vm/classfile/classFileParser.hpp	Fri Mar 18 13:28:33 2011 -0700
    27.2 +++ b/src/share/vm/classfile/classFileParser.hpp	Thu Mar 24 23:00:27 2011 -0700
    27.3 @@ -154,11 +154,12 @@
    27.4    // Add the "discovered" field to java.lang.ref.Reference if
    27.5    // it does not exist.
    27.6    void java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
    27.7 -    constantPoolHandle cp, FieldAllocationCount *fac_ptr, TRAPS);
    27.8 +                                       constantPoolHandle cp,
    27.9 +                                       FieldAllocationCount *fac_ptr, TRAPS);
   27.10    // Adjust the field allocation counts for java.lang.Class to add
   27.11    // fake fields.
   27.12 -  void java_lang_Class_fix_pre(objArrayHandle* methods_ptr,
   27.13 -    FieldAllocationCount *fac_ptr, TRAPS);
   27.14 +  void java_lang_Class_fix_pre(int* nonstatic_field_size,
   27.15 +                               FieldAllocationCount *fac_ptr);
   27.16    // Adjust the next_nonstatic_oop_offset to place the fake fields
   27.17    // before any Java fields.
   27.18    void java_lang_Class_fix_post(int* next_nonstatic_oop_offset);
    28.1 --- a/src/share/vm/classfile/javaClasses.cpp	Fri Mar 18 13:28:33 2011 -0700
    28.2 +++ b/src/share/vm/classfile/javaClasses.cpp	Thu Mar 24 23:00:27 2011 -0700
    28.3 @@ -33,6 +33,7 @@
    28.4  #include "memory/resourceArea.hpp"
    28.5  #include "memory/universe.inline.hpp"
    28.6  #include "oops/instanceKlass.hpp"
    28.7 +#include "oops/instanceMirrorKlass.hpp"
    28.8  #include "oops/klass.hpp"
    28.9  #include "oops/klassOop.hpp"
   28.10  #include "oops/methodOop.hpp"
   28.11 @@ -161,7 +162,7 @@
   28.12  }
   28.13  
   28.14  Handle java_lang_String::create_tenured_from_unicode(jchar* unicode, int length, TRAPS) {
   28.15 -  return basic_create_from_unicode(unicode, length, true, CHECK_NH);
   28.16 +  return basic_create_from_unicode(unicode, length, JavaObjectsInPerm, CHECK_NH);
   28.17  }
   28.18  
   28.19  oop java_lang_String::create_oop_from_unicode(jchar* unicode, int length, TRAPS) {
   28.20 @@ -391,6 +392,75 @@
   28.21    }
   28.22  }
   28.23  
   28.24 +static void initialize_static_field(fieldDescriptor* fd, TRAPS) {
   28.25 +  Handle mirror (THREAD, fd->field_holder()->java_mirror());
   28.26 +  assert(mirror.not_null() && fd->is_static(), "just checking");
   28.27 +  if (fd->has_initial_value()) {
   28.28 +    BasicType t = fd->field_type();
   28.29 +    switch (t) {
   28.30 +      case T_BYTE:
   28.31 +        mirror()->byte_field_put(fd->offset(), fd->int_initial_value());
   28.32 +              break;
   28.33 +      case T_BOOLEAN:
   28.34 +        mirror()->bool_field_put(fd->offset(), fd->int_initial_value());
   28.35 +              break;
   28.36 +      case T_CHAR:
   28.37 +        mirror()->char_field_put(fd->offset(), fd->int_initial_value());
   28.38 +              break;
   28.39 +      case T_SHORT:
   28.40 +        mirror()->short_field_put(fd->offset(), fd->int_initial_value());
   28.41 +              break;
   28.42 +      case T_INT:
   28.43 +        mirror()->int_field_put(fd->offset(), fd->int_initial_value());
   28.44 +        break;
   28.45 +      case T_FLOAT:
   28.46 +        mirror()->float_field_put(fd->offset(), fd->float_initial_value());
   28.47 +        break;
   28.48 +      case T_DOUBLE:
   28.49 +        mirror()->double_field_put(fd->offset(), fd->double_initial_value());
   28.50 +        break;
   28.51 +      case T_LONG:
   28.52 +        mirror()->long_field_put(fd->offset(), fd->long_initial_value());
   28.53 +        break;
   28.54 +      case T_OBJECT:
   28.55 +        {
   28.56 +          #ifdef ASSERT
   28.57 +          TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
   28.58 +          assert(fd->signature() == sym, "just checking");
   28.59 +          #endif
   28.60 +          oop string = fd->string_initial_value(CHECK);
   28.61 +          mirror()->obj_field_put(fd->offset(), string);
   28.62 +        }
   28.63 +        break;
   28.64 +      default:
   28.65 +        THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
   28.66 +                  "Illegal ConstantValue attribute in class file");
   28.67 +    }
   28.68 +  }
   28.69 +}
   28.70 +
   28.71 +
   28.72 +// During bootstrap, java.lang.Class wasn't loaded so static field
   28.73 +// offsets were computed without the size added it.  Go back and
   28.74 +// update all the static field offsets to included the size.
   28.75 +static void fixup_static_field(fieldDescriptor* fd, TRAPS) {
   28.76 +  if (fd->is_static()) {
   28.77 +    int real_offset = fd->offset() + instanceMirrorKlass::offset_of_static_fields();
   28.78 +    typeArrayOop fields = instanceKlass::cast(fd->field_holder())->fields();
   28.79 +    fields->short_at_put(fd->index() + instanceKlass::low_offset,  extract_low_short_from_int(real_offset));
   28.80 +    fields->short_at_put(fd->index() + instanceKlass::high_offset, extract_high_short_from_int(real_offset));
   28.81 +  }
   28.82 +}
   28.83 +
   28.84 +void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
   28.85 +  assert(instanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
   28.86 +
   28.87 +  if (k->oop_is_instance()) {
   28.88 +    // Fixup the offsets
   28.89 +    instanceKlass::cast(k())->do_local_static_fields(&fixup_static_field, CHECK);
   28.90 +  }
   28.91 +  create_mirror(k, CHECK);
   28.92 +}
   28.93  
   28.94  oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) {
   28.95    assert(k->java_mirror() == NULL, "should only assign mirror once");
   28.96 @@ -400,12 +470,17 @@
   28.97    // class is put into the system dictionary.
   28.98    int computed_modifiers = k->compute_modifier_flags(CHECK_0);
   28.99    k->set_modifier_flags(computed_modifiers);
  28.100 -  if (SystemDictionary::Class_klass_loaded()) {
  28.101 +  if (SystemDictionary::Class_klass_loaded() && (k->oop_is_instance() || k->oop_is_javaArray())) {
  28.102      // Allocate mirror (java.lang.Class instance)
  28.103 -    Handle mirror = instanceKlass::cast(SystemDictionary::Class_klass())->allocate_permanent_instance(CHECK_0);
  28.104 +    Handle mirror = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0);
  28.105      // Setup indirections
  28.106      mirror->obj_field_put(klass_offset,  k());
  28.107      k->set_java_mirror(mirror());
  28.108 +
  28.109 +    instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass());
  28.110 +    java_lang_Class::set_oop_size(mirror(), mk->instance_size(k));
  28.111 +    java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
  28.112 +
  28.113      // It might also have a component mirror.  This mirror must already exist.
  28.114      if (k->oop_is_javaArray()) {
  28.115        Handle comp_mirror;
  28.116 @@ -428,6 +503,9 @@
  28.117          arrayKlass::cast(k->as_klassOop())->set_component_mirror(comp_mirror());
  28.118          set_array_klass(comp_mirror(), k->as_klassOop());
  28.119        }
  28.120 +    } else if (k->oop_is_instance()) {
  28.121 +      // Initialize static fields
  28.122 +      instanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, CHECK_NULL);
  28.123      }
  28.124      return mirror();
  28.125    } else {
  28.126 @@ -436,21 +514,46 @@
  28.127  }
  28.128  
  28.129  
  28.130 +
  28.131 +int  java_lang_Class::oop_size(oop java_class) {
  28.132 +  assert(oop_size_offset != 0, "must be set");
  28.133 +  return java_class->int_field(oop_size_offset);
  28.134 +}
  28.135 +void java_lang_Class::set_oop_size(oop java_class, int size) {
  28.136 +  assert(oop_size_offset != 0, "must be set");
  28.137 +  java_class->int_field_put(oop_size_offset, size);
  28.138 +}
  28.139 +int  java_lang_Class::static_oop_field_count(oop java_class) {
  28.140 +  assert(static_oop_field_count_offset != 0, "must be set");
  28.141 +  return java_class->int_field(static_oop_field_count_offset);
  28.142 +}
  28.143 +void java_lang_Class::set_static_oop_field_count(oop java_class, int size) {
  28.144 +  assert(static_oop_field_count_offset != 0, "must be set");
  28.145 +  java_class->int_field_put(static_oop_field_count_offset, size);
  28.146 +}
  28.147 +
  28.148 +
  28.149 +
  28.150 +
  28.151  oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
  28.152    // This should be improved by adding a field at the Java level or by
  28.153    // introducing a new VM klass (see comment in ClassFileParser)
  28.154 -  oop java_class = instanceKlass::cast(SystemDictionary::Class_klass())->allocate_permanent_instance(CHECK_0);
  28.155 +  oop java_class = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance((oop)NULL, CHECK_0);
  28.156    if (type != T_VOID) {
  28.157      klassOop aklass = Universe::typeArrayKlassObj(type);
  28.158      assert(aklass != NULL, "correct bootstrap");
  28.159      set_array_klass(java_class, aklass);
  28.160    }
  28.161 +  instanceMirrorKlass* mk = instanceMirrorKlass::cast(SystemDictionary::Class_klass());
  28.162 +  java_lang_Class::set_oop_size(java_class, mk->instance_size(oop(NULL)));
  28.163 +  java_lang_Class::set_static_oop_field_count(java_class, 0);
  28.164    return java_class;
  28.165  }
  28.166  
  28.167  
  28.168  klassOop java_lang_Class::as_klassOop(oop java_class) {
  28.169    //%note memory_2
  28.170 +  assert(java_lang_Class::is_instance(java_class), "must be a Class object");
  28.171    klassOop k = klassOop(java_class->obj_field(klass_offset));
  28.172    assert(k == NULL || k->is_klass(), "type check");
  28.173    return k;
  28.174 @@ -2152,7 +2255,7 @@
  28.175  // Support for java_lang_ref_Reference
  28.176  oop java_lang_ref_Reference::pending_list_lock() {
  28.177    instanceKlass* ik = instanceKlass::cast(SystemDictionary::Reference_klass());
  28.178 -  char *addr = (((char *)ik->start_of_static_fields()) + static_lock_offset);
  28.179 +  address addr = ik->static_field_addr(static_lock_offset);
  28.180    if (UseCompressedOops) {
  28.181      return oopDesc::load_decode_heap_oop((narrowOop *)addr);
  28.182    } else {
  28.183 @@ -2162,7 +2265,7 @@
  28.184  
  28.185  HeapWord *java_lang_ref_Reference::pending_list_addr() {
  28.186    instanceKlass* ik = instanceKlass::cast(SystemDictionary::Reference_klass());
  28.187 -  char *addr = (((char *)ik->start_of_static_fields()) + static_pending_offset);
  28.188 +  address addr = ik->static_field_addr(static_pending_offset);
  28.189    // XXX This might not be HeapWord aligned, almost rather be char *.
  28.190    return (HeapWord*)addr;
  28.191  }
  28.192 @@ -2185,16 +2288,14 @@
  28.193  
  28.194  jlong java_lang_ref_SoftReference::clock() {
  28.195    instanceKlass* ik = instanceKlass::cast(SystemDictionary::SoftReference_klass());
  28.196 -  int offset = ik->offset_of_static_fields() + static_clock_offset;
  28.197 -
  28.198 -  return SystemDictionary::SoftReference_klass()->long_field(offset);
  28.199 +  jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
  28.200 +  return *offset;
  28.201  }
  28.202  
  28.203  void java_lang_ref_SoftReference::set_clock(jlong value) {
  28.204    instanceKlass* ik = instanceKlass::cast(SystemDictionary::SoftReference_klass());
  28.205 -  int offset = ik->offset_of_static_fields() + static_clock_offset;
  28.206 -
  28.207 -  SystemDictionary::SoftReference_klass()->long_field_put(offset, value);
  28.208 +  jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
  28.209 +  *offset = value;
  28.210  }
  28.211  
  28.212  
  28.213 @@ -2625,26 +2726,18 @@
  28.214  
  28.215  
  28.216  // Support for java_lang_System
  28.217 -
  28.218 -void java_lang_System::compute_offsets() {
  28.219 -  assert(offset_of_static_fields == 0, "offsets should be initialized only once");
  28.220 -
  28.221 -  instanceKlass* ik = instanceKlass::cast(SystemDictionary::System_klass());
  28.222 -  offset_of_static_fields = ik->offset_of_static_fields();
  28.223 +int java_lang_System::in_offset_in_bytes() {
  28.224 +  return (instanceMirrorKlass::offset_of_static_fields() + static_in_offset);
  28.225  }
  28.226  
  28.227 -int java_lang_System::in_offset_in_bytes() {
  28.228 -  return (offset_of_static_fields + static_in_offset);
  28.229 +
  28.230 +int java_lang_System::out_offset_in_bytes() {
  28.231 +  return (instanceMirrorKlass::offset_of_static_fields() + static_out_offset);
  28.232  }
  28.233  
  28.234  
  28.235 -int java_lang_System::out_offset_in_bytes() {
  28.236 -  return (offset_of_static_fields + static_out_offset);
  28.237 -}
  28.238 -
  28.239 -
  28.240  int java_lang_System::err_offset_in_bytes() {
  28.241 -  return (offset_of_static_fields + static_err_offset);
  28.242 +  return (instanceMirrorKlass::offset_of_static_fields() + static_err_offset);
  28.243  }
  28.244  
  28.245  
  28.246 @@ -2657,6 +2750,8 @@
  28.247  int java_lang_Class::array_klass_offset;
  28.248  int java_lang_Class::resolved_constructor_offset;
  28.249  int java_lang_Class::number_of_fake_oop_fields;
  28.250 +int java_lang_Class::oop_size_offset;
  28.251 +int java_lang_Class::static_oop_field_count_offset;
  28.252  int java_lang_Throwable::backtrace_offset;
  28.253  int java_lang_Throwable::detailMessage_offset;
  28.254  int java_lang_Throwable::cause_offset;
  28.255 @@ -2700,7 +2795,6 @@
  28.256  int java_lang_ref_SoftReference::timestamp_offset;
  28.257  int java_lang_ref_SoftReference::static_clock_offset;
  28.258  int java_lang_ClassLoader::parent_offset;
  28.259 -int java_lang_System::offset_of_static_fields;
  28.260  int java_lang_System::static_in_offset;
  28.261  int java_lang_System::static_out_offset;
  28.262  int java_lang_System::static_err_offset;
  28.263 @@ -2817,10 +2911,19 @@
  28.264    java_lang_String::count_offset  = java_lang_String::offset_offset + sizeof (jint);
  28.265    java_lang_String::hash_offset   = java_lang_String::count_offset + sizeof (jint);
  28.266  
  28.267 -  // Do the Class Class
  28.268 -  java_lang_Class::klass_offset = java_lang_Class::hc_klass_offset * x + header;
  28.269 -  java_lang_Class::array_klass_offset = java_lang_Class::hc_array_klass_offset * x + header;
  28.270 -  java_lang_Class::resolved_constructor_offset = java_lang_Class::hc_resolved_constructor_offset * x + header;
  28.271 +  {
  28.272 +    // Do the Class Class
  28.273 +    int offset = header;
  28.274 +    java_lang_Class::oop_size_offset = header;
  28.275 +    offset += BytesPerInt;
  28.276 +    java_lang_Class::static_oop_field_count_offset = offset;
  28.277 +    offset = align_size_up(offset + BytesPerInt, x);
  28.278 +    java_lang_Class::klass_offset = offset;
  28.279 +    offset += x;
  28.280 +    java_lang_Class::array_klass_offset = offset;
  28.281 +    offset += x;
  28.282 +    java_lang_Class::resolved_constructor_offset = offset;
  28.283 +  }
  28.284  
  28.285    // This is NOT an offset
  28.286    java_lang_Class::number_of_fake_oop_fields = java_lang_Class::hc_number_of_fake_oop_fields;
  28.287 @@ -2877,7 +2980,6 @@
  28.288  void JavaClasses::compute_offsets() {
  28.289  
  28.290    java_lang_Class::compute_offsets();
  28.291 -  java_lang_System::compute_offsets();
  28.292    java_lang_Thread::compute_offsets();
  28.293    java_lang_ThreadGroup::compute_offsets();
  28.294    if (EnableMethodHandles) {
  28.295 @@ -2961,10 +3063,10 @@
  28.296      tty->print_cr("Static field %s.%s appears to be nonstatic", klass_name, field_name);
  28.297      return false;
  28.298    }
  28.299 -  if (fd.offset() == hardcoded_offset + h_klass->offset_of_static_fields()) {
  28.300 +  if (fd.offset() == hardcoded_offset + instanceMirrorKlass::offset_of_static_fields()) {
  28.301      return true;
  28.302    } else {
  28.303 -    tty->print_cr("Offset of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_offset, fd.offset() - h_klass->offset_of_static_fields());
  28.304 +    tty->print_cr("Offset of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_offset, fd.offset() - instanceMirrorKlass::offset_of_static_fields());
  28.305      return false;
  28.306    }
  28.307  }
    29.1 --- a/src/share/vm/classfile/javaClasses.hpp	Fri Mar 18 13:28:33 2011 -0700
    29.2 +++ b/src/share/vm/classfile/javaClasses.hpp	Thu Mar 24 23:00:27 2011 -0700
    29.3 @@ -138,10 +138,8 @@
    29.4    // The fake offsets are added by the class loader when java.lang.Class is loaded
    29.5  
    29.6    enum {
    29.7 -    hc_klass_offset                = 0,
    29.8 -    hc_array_klass_offset          = 1,
    29.9 -    hc_resolved_constructor_offset = 2,
   29.10 -    hc_number_of_fake_oop_fields   = 3
   29.11 +    hc_number_of_fake_oop_fields   = 3,
   29.12 +    hc_number_of_fake_int_fields   = 2
   29.13    };
   29.14  
   29.15    static int klass_offset;
   29.16 @@ -149,6 +147,9 @@
   29.17    static int array_klass_offset;
   29.18    static int number_of_fake_oop_fields;
   29.19  
   29.20 +  static int oop_size_offset;
   29.21 +  static int static_oop_field_count_offset;
   29.22 +
   29.23    static void compute_offsets();
   29.24    static bool offsets_computed;
   29.25    static int classRedefinedCount_offset;
   29.26 @@ -157,6 +158,7 @@
   29.27   public:
   29.28    // Instance creation
   29.29    static oop  create_mirror(KlassHandle k, TRAPS);
   29.30 +  static void fixup_mirror(KlassHandle k, TRAPS);
   29.31    static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
   29.32    // Conversion
   29.33    static klassOop as_klassOop(oop java_class);
   29.34 @@ -191,6 +193,12 @@
   29.35    static void set_classRedefinedCount(oop the_class_mirror, int value);
   29.36    // Support for parallelCapable field
   29.37    static bool parallelCapable(oop the_class_mirror);
   29.38 +
   29.39 +  static int oop_size(oop java_class);
   29.40 +  static void set_oop_size(oop java_class, int size);
   29.41 +  static int static_oop_field_count(oop java_class);
   29.42 +  static void set_static_oop_field_count(oop java_class, int size);
   29.43 +
   29.44    // Debugging
   29.45    friend class JavaClasses;
   29.46    friend class instanceKlass;   // verification code accesses offsets
   29.47 @@ -1165,13 +1173,10 @@
   29.48     hc_static_err_offset = 2
   29.49    };
   29.50  
   29.51 -  static int offset_of_static_fields;
   29.52    static int  static_in_offset;
   29.53    static int static_out_offset;
   29.54    static int static_err_offset;
   29.55  
   29.56 -  static void compute_offsets();
   29.57 -
   29.58   public:
   29.59    static int  in_offset_in_bytes();
   29.60    static int out_offset_in_bytes();
    30.1 --- a/src/share/vm/classfile/symbolTable.cpp	Fri Mar 18 13:28:33 2011 -0700
    30.2 +++ b/src/share/vm/classfile/symbolTable.cpp	Thu Mar 24 23:00:27 2011 -0700
    30.3 @@ -530,7 +530,7 @@
    30.4  
    30.5    Handle string;
    30.6    // try to reuse the string if possible
    30.7 -  if (!string_or_null.is_null() && string_or_null()->is_perm()) {
    30.8 +  if (!string_or_null.is_null() && (!JavaObjectsInPerm || string_or_null()->is_perm())) {
    30.9      string = string_or_null;
   30.10    } else {
   30.11      string = java_lang_String::create_tenured_from_unicode(name, len, CHECK_NULL);
   30.12 @@ -662,7 +662,7 @@
   30.13      for ( ; p != NULL; p = p->next()) {
   30.14        oop s = p->literal();
   30.15        guarantee(s != NULL, "interned string is NULL");
   30.16 -      guarantee(s->is_perm(), "interned string not in permspace");
   30.17 +      guarantee(s->is_perm() || !JavaObjectsInPerm, "interned string not in permspace");
   30.18  
   30.19        int length;
   30.20        jchar* chars = java_lang_String::as_unicode_string(s, length);
    31.1 --- a/src/share/vm/classfile/symbolTable.hpp	Fri Mar 18 13:28:33 2011 -0700
    31.2 +++ b/src/share/vm/classfile/symbolTable.hpp	Thu Mar 24 23:00:27 2011 -0700
    31.3 @@ -216,18 +216,14 @@
    31.4    oop basic_add(int index, Handle string_or_null, jchar* name, int len,
    31.5                  unsigned int hashValue, TRAPS);
    31.6  
    31.7 -  // Table size
    31.8 -  enum {
    31.9 -    string_table_size = 1009
   31.10 -  };
   31.11 -
   31.12    oop lookup(int index, jchar* chars, int length, unsigned int hashValue);
   31.13  
   31.14 -  StringTable() : Hashtable<oop>(string_table_size, sizeof (HashtableEntry<oop>)) {}
   31.15 +  StringTable() : Hashtable<oop>((int)StringTableSize,
   31.16 +                                 sizeof (HashtableEntry<oop>)) {}
   31.17  
   31.18    StringTable(HashtableBucket* t, int number_of_entries)
   31.19 -    : Hashtable<oop>(string_table_size, sizeof (HashtableEntry<oop>), t,
   31.20 -                number_of_entries) {}
   31.21 +    : Hashtable<oop>((int)StringTableSize, sizeof (HashtableEntry<oop>), t,
   31.22 +                     number_of_entries) {}
   31.23  
   31.24  public:
   31.25    // The string table
   31.26 @@ -241,7 +237,7 @@
   31.27    static void create_table(HashtableBucket* t, int length,
   31.28                             int number_of_entries) {
   31.29      assert(_the_table == NULL, "One string table allowed.");
   31.30 -    assert(length == string_table_size * sizeof(HashtableBucket),
   31.31 +    assert((size_t)length == StringTableSize * sizeof(HashtableBucket),
   31.32             "bad shared string size.");
   31.33      _the_table = new StringTable(t, number_of_entries);
   31.34    }
    32.1 --- a/src/share/vm/code/codeCache.cpp	Fri Mar 18 13:28:33 2011 -0700
    32.2 +++ b/src/share/vm/code/codeCache.cpp	Thu Mar 24 23:00:27 2011 -0700
    32.3 @@ -1,5 +1,5 @@
    32.4  /*
    32.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    32.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    32.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.8   *
    32.9   * This code is free software; you can redistribute it and/or modify it
   32.10 @@ -337,7 +337,6 @@
   32.11      if (is_live) {
   32.12        // Perform cur->oops_do(f), maybe just once per nmethod.
   32.13        f->do_code_blob(cur);
   32.14 -      cur->fix_oop_relocations();
   32.15      }
   32.16    }
   32.17  
   32.18 @@ -552,6 +551,19 @@
   32.19  }
   32.20  
   32.21  
   32.22 +void CodeCache::verify_oops() {
   32.23 +  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
   32.24 +  VerifyOopClosure voc;
   32.25 +  FOR_ALL_ALIVE_BLOBS(cb) {
   32.26 +    if (cb->is_nmethod()) {
   32.27 +      nmethod *nm = (nmethod*)cb;
   32.28 +      nm->oops_do(&voc);
   32.29 +      nm->verify_oop_relocations();
   32.30 +    }
   32.31 +  }
   32.32 +}
   32.33 +
   32.34 +
   32.35  address CodeCache::first_address() {
   32.36    assert_locked_or_safepoint(CodeCache_lock);
   32.37    return (address)_heap->begin();
    33.1 --- a/src/share/vm/code/codeCache.hpp	Fri Mar 18 13:28:33 2011 -0700
    33.2 +++ b/src/share/vm/code/codeCache.hpp	Thu Mar 24 23:00:27 2011 -0700
    33.3 @@ -122,6 +122,7 @@
    33.4    // GC support
    33.5    static void gc_epilogue();
    33.6    static void gc_prologue();
    33.7 +  static void verify_oops();
    33.8    // If "unloading_occurred" is true, then unloads (i.e., breaks root links
    33.9    // to) any unmarked codeBlobs in the cache.  Sets "marked_for_unloading"
   33.10    // to "true" iff some code got unloaded.
    34.1 --- a/src/share/vm/code/nmethod.cpp	Fri Mar 18 13:28:33 2011 -0700
    34.2 +++ b/src/share/vm/code/nmethod.cpp	Thu Mar 24 23:00:27 2011 -0700
    34.3 @@ -653,6 +653,9 @@
    34.4      _pc_desc_cache.reset_to(NULL);
    34.5  
    34.6      code_buffer->copy_oops_to(this);
    34.7 +    if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
    34.8 +      CodeCache::add_scavenge_root_nmethod(this);
    34.9 +    }
   34.10      debug_only(verify_scavenge_root_oops());
   34.11      CodeCache::commit(this);
   34.12    }
   34.13 @@ -1105,6 +1108,20 @@
   34.14  }
   34.15  
   34.16  
   34.17 +void nmethod::verify_oop_relocations() {
   34.18 +  // Ensure sure that the code matches the current oop values
   34.19 +  RelocIterator iter(this, NULL, NULL);
   34.20 +  while (iter.next()) {
   34.21 +    if (iter.type() == relocInfo::oop_type) {
   34.22 +      oop_Relocation* reloc = iter.oop_reloc();
   34.23 +      if (!reloc->oop_is_immediate()) {
   34.24 +        reloc->verify_oop_relocation();
   34.25 +      }
   34.26 +    }
   34.27 +  }
   34.28 +}
   34.29 +
   34.30 +
   34.31  ScopeDesc* nmethod::scope_desc_at(address pc) {
   34.32    PcDesc* pd = pc_desc_at(pc);
   34.33    guarantee(pd != NULL, "scope must be present");
   34.34 @@ -1823,6 +1840,7 @@
   34.35      assert(cur != NULL, "not NULL-terminated");
   34.36      nmethod* next = cur->_oops_do_mark_link;
   34.37      cur->_oops_do_mark_link = NULL;
   34.38 +    cur->fix_oop_relocations();
   34.39      NOT_PRODUCT(if (TraceScavenge)  cur->print_on(tty, "oops_do, unmark\n"));
   34.40      cur = next;
   34.41    }
    35.1 --- a/src/share/vm/code/nmethod.hpp	Fri Mar 18 13:28:33 2011 -0700
    35.2 +++ b/src/share/vm/code/nmethod.hpp	Thu Mar 24 23:00:27 2011 -0700
    35.3 @@ -459,6 +459,7 @@
    35.4  public:
    35.5    void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); }
    35.6    void fix_oop_relocations()                           { fix_oop_relocations(NULL, NULL, false); }
    35.7 +  void verify_oop_relocations();
    35.8  
    35.9    bool is_at_poll_return(address pc);
   35.10    bool is_at_poll_or_poll_return(address pc);
    36.1 --- a/src/share/vm/code/relocInfo.cpp	Fri Mar 18 13:28:33 2011 -0700
    36.2 +++ b/src/share/vm/code/relocInfo.cpp	Thu Mar 24 23:00:27 2011 -0700
    36.3 @@ -798,6 +798,14 @@
    36.4  }
    36.5  
    36.6  
    36.7 +void oop_Relocation::verify_oop_relocation() {
    36.8 +  if (!oop_is_immediate()) {
    36.9 +    // get the oop from the pool, and re-insert it into the instruction:
   36.10 +    verify_value(value());
   36.11 +  }
   36.12 +}
   36.13 +
   36.14 +
   36.15  RelocIterator virtual_call_Relocation::parse_ic(nmethod* &nm, address &ic_call, address &first_oop,
   36.16                                                  oop* &oop_addr, bool *is_optimized) {
   36.17    assert(ic_call != NULL, "ic_call address must be set");
    37.1 --- a/src/share/vm/code/relocInfo.hpp	Fri Mar 18 13:28:33 2011 -0700
    37.2 +++ b/src/share/vm/code/relocInfo.hpp	Thu Mar 24 23:00:27 2011 -0700
    37.3 @@ -765,7 +765,8 @@
    37.4  
    37.5   protected:
    37.6    // platform-dependent utilities for decoding and patching instructions
    37.7 -  void       pd_set_data_value       (address x, intptr_t off); // a set or mem-ref
    37.8 +  void       pd_set_data_value       (address x, intptr_t off, bool verify_only = false); // a set or mem-ref
    37.9 +  void       pd_verify_data_value    (address x, intptr_t off) { pd_set_data_value(x, off, true); }
   37.10    address    pd_call_destination     (address orig_addr = NULL);
   37.11    void       pd_set_call_destination (address x);
   37.12    void       pd_swap_in_breakpoint   (address x, short* instrs, int instrlen);
   37.13 @@ -880,6 +881,12 @@
   37.14      else
   37.15        pd_set_data_value(x, o);
   37.16    }
   37.17 +  void        verify_value(address x) {
   37.18 +    if (addr_in_const())
   37.19 +      assert(*(address*)addr() == x, "must agree");
   37.20 +    else
   37.21 +      pd_verify_data_value(x, offset());
   37.22 +  }
   37.23  
   37.24    // The "o" (displacement) argument is relevant only to split relocations
   37.25    // on RISC machines.  In some CPUs (SPARC), the set-hi and set-lo ins'ns
   37.26 @@ -950,6 +957,8 @@
   37.27  
   37.28    void fix_oop_relocation();        // reasserts oop value
   37.29  
   37.30 +  void verify_oop_relocation();
   37.31 +
   37.32    address value()  { return (address) *oop_addr(); }
   37.33  
   37.34    bool oop_is_immediate()  { return oop_index() == 0; }
    38.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Fri Mar 18 13:28:33 2011 -0700
    38.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Thu Mar 24 23:00:27 2011 -0700
    38.3 @@ -5930,14 +5930,18 @@
    38.4      }
    38.5  
    38.6      {
    38.7 -      TraceTime t("scrub symbol & string tables", PrintGCDetails, false, gclog_or_tty);
    38.8 -      // Now clean up stale oops in StringTable
    38.9 -      StringTable::unlink(&_is_alive_closure);
   38.10 +      TraceTime t("scrub symbol table", PrintGCDetails, false, gclog_or_tty);
   38.11        // Clean up unreferenced symbols in symbol table.
   38.12        SymbolTable::unlink();
   38.13      }
   38.14    }
   38.15  
   38.16 +  if (should_unload_classes() || !JavaObjectsInPerm) {
   38.17 +    TraceTime t("scrub string table", PrintGCDetails, false, gclog_or_tty);
   38.18 +    // Now clean up stale oops in StringTable
   38.19 +    StringTable::unlink(&_is_alive_closure);
   38.20 +  }
   38.21 +
   38.22    verify_work_stacks_empty();
   38.23    // Restore any preserved marks as a result of mark stack or
   38.24    // work queue overflow
    39.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Fri Mar 18 13:28:33 2011 -0700
    39.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Thu Mar 24 23:00:27 2011 -0700
    39.3 @@ -23,6 +23,7 @@
    39.4   */
    39.5  
    39.6  #include "precompiled.hpp"
    39.7 +#include "classfile/symbolTable.hpp"
    39.8  #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
    39.9  #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
   39.10  #include "gc_implementation/parallelScavenge/generationSizer.hpp"
   39.11 @@ -439,6 +440,14 @@
   39.12        reference_processor()->enqueue_discovered_references(NULL);
   39.13      }
   39.14  
   39.15 +    if (!JavaObjectsInPerm) {
   39.16 +      // Unlink any dead interned Strings
   39.17 +      StringTable::unlink(&_is_alive_closure);
   39.18 +      // Process the remaining live ones
   39.19 +      PSScavengeRootsClosure root_closure(promotion_manager);
   39.20 +      StringTable::oops_do(&root_closure);
   39.21 +    }
   39.22 +
   39.23      // Finally, flush the promotion_manager's labs, and deallocate its stacks.
   39.24      PSPromotionManager::post_scavenge();
   39.25  
    40.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp	Fri Mar 18 13:28:33 2011 -0700
    40.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp	Thu Mar 24 23:00:27 2011 -0700
    40.3 @@ -86,4 +86,21 @@
    40.4    }
    40.5  }
    40.6  
    40.7 +class PSScavengeRootsClosure: public OopClosure {
    40.8 + private:
    40.9 +  PSPromotionManager* _promotion_manager;
   40.10 +
   40.11 + protected:
   40.12 +  template <class T> void do_oop_work(T *p) {
   40.13 +    if (PSScavenge::should_scavenge(p)) {
   40.14 +      // We never card mark roots, maybe call a func without test?
   40.15 +      PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p);
   40.16 +    }
   40.17 +  }
   40.18 + public:
   40.19 +  PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
   40.20 +  void do_oop(oop* p)       { PSScavengeRootsClosure::do_oop_work(p); }
   40.21 +  void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); }
   40.22 +};
   40.23 +
   40.24  #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
    41.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp	Fri Mar 18 13:28:33 2011 -0700
    41.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp	Thu Mar 24 23:00:27 2011 -0700
    41.3 @@ -30,7 +30,7 @@
    41.4  #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
    41.5  #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
    41.6  #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
    41.7 -#include "gc_implementation/parallelScavenge/psScavenge.hpp"
    41.8 +#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
    41.9  #include "gc_implementation/parallelScavenge/psTasks.hpp"
   41.10  #include "memory/iterator.hpp"
   41.11  #include "memory/universe.hpp"
   41.12 @@ -46,24 +46,6 @@
   41.13  // ScavengeRootsTask
   41.14  //
   41.15  
   41.16 -// Define before use
   41.17 -class PSScavengeRootsClosure: public OopClosure {
   41.18 - private:
   41.19 -  PSPromotionManager* _promotion_manager;
   41.20 -
   41.21 - protected:
   41.22 -  template <class T> void do_oop_work(T *p) {
   41.23 -    if (PSScavenge::should_scavenge(p)) {
   41.24 -      // We never card mark roots, maybe call a func without test?
   41.25 -      PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p);
   41.26 -    }
   41.27 -  }
   41.28 - public:
   41.29 -  PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
   41.30 -  void do_oop(oop* p)       { PSScavengeRootsClosure::do_oop_work(p); }
   41.31 -  void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); }
   41.32 -};
   41.33 -
   41.34  void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
   41.35    assert(Universe::heap()->is_gc_active(), "called outside gc");
   41.36  
    42.1 --- a/src/share/vm/interpreter/bytecodeInterpreter.cpp	Fri Mar 18 13:28:33 2011 -0700
    42.2 +++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp	Thu Mar 24 23:00:27 2011 -0700
    42.3 @@ -656,7 +656,7 @@
    42.4            // oop rcvr = locals[0].j.r;
    42.5            oop rcvr;
    42.6            if (METHOD->is_static()) {
    42.7 -            rcvr = METHOD->constants()->pool_holder()->klass_part()->java_mirror();
    42.8 +            rcvr = METHOD->constants()->pool_holder()->java_mirror();
    42.9            } else {
   42.10              rcvr = LOCALS_OBJECT(0);
   42.11              VERIFY_OOP(rcvr);
   42.12 @@ -2111,8 +2111,8 @@
   42.13              break;
   42.14  
   42.15            case JVM_CONSTANT_Class:
   42.16 -            VERIFY_OOP(constants->resolved_klass_at(index)->klass_part()->java_mirror());
   42.17 -            SET_STACK_OBJECT(constants->resolved_klass_at(index)->klass_part()->java_mirror(), 0);
   42.18 +            VERIFY_OOP(constants->resolved_klass_at(index)->java_mirror());
   42.19 +            SET_STACK_OBJECT(constants->resolved_klass_at(index)->java_mirror(), 0);
   42.20              break;
   42.21  
   42.22            case JVM_CONSTANT_UnresolvedString:
    43.1 --- a/src/share/vm/interpreter/interpreterRuntime.cpp	Fri Mar 18 13:28:33 2011 -0700
    43.2 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Mar 24 23:00:27 2011 -0700
    43.3 @@ -118,7 +118,7 @@
    43.4  
    43.5    if (tag.is_unresolved_klass() || tag.is_klass()) {
    43.6      klassOop klass = pool->klass_at(index, CHECK);
    43.7 -    oop java_class = klass->klass_part()->java_mirror();
    43.8 +    oop java_class = klass->java_mirror();
    43.9      thread->set_vm_result(java_class);
   43.10    } else {
   43.11  #ifdef ASSERT
   43.12 @@ -983,7 +983,8 @@
   43.13  ConstantPoolCacheEntry *cp_entry))
   43.14  
   43.15    // check the access_flags for the field in the klass
   43.16 -  instanceKlass* ik = instanceKlass::cast((klassOop)cp_entry->f1());
   43.17 +
   43.18 +  instanceKlass* ik = instanceKlass::cast(java_lang_Class::as_klassOop(cp_entry->f1()));
   43.19    typeArrayOop fields = ik->fields();
   43.20    int index = cp_entry->field_index();
   43.21    assert(index < fields->length(), "holders field index is out of range");
   43.22 @@ -1009,7 +1010,7 @@
   43.23      // non-static field accessors have an object, but we need a handle
   43.24      h_obj = Handle(thread, obj);
   43.25    }
   43.26 -  instanceKlassHandle h_cp_entry_f1(thread, (klassOop)cp_entry->f1());
   43.27 +  instanceKlassHandle h_cp_entry_f1(thread, java_lang_Class::as_klassOop(cp_entry->f1()));
   43.28    jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2(), is_static);
   43.29    JvmtiExport::post_field_access(thread, method(thread), bcp(thread), h_cp_entry_f1, h_obj, fid);
   43.30  IRT_END
   43.31 @@ -1017,7 +1018,7 @@
   43.32  IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread,
   43.33    oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value))
   43.34  
   43.35 -  klassOop k = (klassOop)cp_entry->f1();
   43.36 +  klassOop k = java_lang_Class::as_klassOop(cp_entry->f1());
   43.37  
   43.38    // check the access_flags for the field in the klass
   43.39    instanceKlass* ik = instanceKlass::cast(k);
    44.1 --- a/src/share/vm/memory/compactingPermGenGen.hpp	Fri Mar 18 13:28:33 2011 -0700
    44.2 +++ b/src/share/vm/memory/compactingPermGenGen.hpp	Thu Mar 24 23:00:27 2011 -0700
    44.3 @@ -1,5 +1,5 @@
    44.4  /*
    44.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    44.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    44.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.8   *
    44.9   * This code is free software; you can redistribute it and/or modify it
   44.10 @@ -105,7 +105,7 @@
   44.11  public:
   44.12  
   44.13    enum {
   44.14 -    vtbl_list_size = 16, // number of entries in the shared space vtable list.
   44.15 +    vtbl_list_size = 17, // number of entries in the shared space vtable list.
   44.16      num_virtuals = 200   // number of virtual methods in Klass (or
   44.17                           // subclass) objects, or greater.
   44.18    };
    45.1 --- a/src/share/vm/memory/dump.cpp	Fri Mar 18 13:28:33 2011 -0700
    45.2 +++ b/src/share/vm/memory/dump.cpp	Thu Mar 24 23:00:27 2011 -0700
    45.3 @@ -1561,6 +1561,7 @@
    45.4      // thread because it requires object allocation.
    45.5      LinkClassesClosure lcc(Thread::current());
    45.6      object_iterate(&lcc);
    45.7 +    ensure_parsability(false); // arg is actually don't care
    45.8      tty->print_cr("done. ");
    45.9  
   45.10      // Create and dump the shared spaces.
    46.1 --- a/src/share/vm/memory/oopFactory.cpp	Fri Mar 18 13:28:33 2011 -0700
    46.2 +++ b/src/share/vm/memory/oopFactory.cpp	Thu Mar 24 23:00:27 2011 -0700
    46.3 @@ -1,5 +1,5 @@
    46.4  /*
    46.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    46.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    46.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.8   *
    46.9   * This code is free software; you can redistribute it and/or modify it
   46.10 @@ -117,12 +117,12 @@
   46.11  }
   46.12  
   46.13  
   46.14 -klassOop oopFactory::new_instanceKlass(int vtable_len, int itable_len,
   46.15 +klassOop oopFactory::new_instanceKlass(Symbol* name, int vtable_len, int itable_len,
   46.16                                         int static_field_size,
   46.17                                         unsigned int nonstatic_oop_map_count,
   46.18                                         ReferenceType rt, TRAPS) {
   46.19    instanceKlassKlass* ikk = instanceKlassKlass::cast(Universe::instanceKlassKlassObj());
   46.20 -  return ikk->allocate_instance_klass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_count, rt, CHECK_NULL);
   46.21 +  return ikk->allocate_instance_klass(name, vtable_len, itable_len, static_field_size, nonstatic_oop_map_count, rt, CHECK_NULL);
   46.22  }
   46.23  
   46.24  
    47.1 --- a/src/share/vm/memory/oopFactory.hpp	Fri Mar 18 13:28:33 2011 -0700
    47.2 +++ b/src/share/vm/memory/oopFactory.hpp	Thu Mar 24 23:00:27 2011 -0700
    47.3 @@ -1,5 +1,5 @@
    47.4  /*
    47.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    47.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    47.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    47.8   *
    47.9   * This code is free software; you can redistribute it and/or modify it
   47.10 @@ -72,7 +72,8 @@
   47.11                                                      TRAPS);
   47.12  
   47.13    // Instance classes
   47.14 -  static klassOop        new_instanceKlass(int vtable_len, int itable_len,
   47.15 +  static klassOop        new_instanceKlass(Symbol* name,
   47.16 +                                           int vtable_len, int itable_len,
   47.17                                             int static_field_size,
   47.18                                             unsigned int nonstatic_oop_map_count,
   47.19                                             ReferenceType rt, TRAPS);
    48.1 --- a/src/share/vm/memory/sharedHeap.cpp	Fri Mar 18 13:28:33 2011 -0700
    48.2 +++ b/src/share/vm/memory/sharedHeap.cpp	Thu Mar 24 23:00:27 2011 -0700
    48.3 @@ -171,11 +171,13 @@
    48.4    }
    48.5  
    48.6    if (!_process_strong_tasks->is_task_claimed(SH_PS_StringTable_oops_do)) {
    48.7 -     if (so & SO_Strings) {
    48.8 -       StringTable::oops_do(roots);
    48.9 -     }
   48.10 -    // Verify if the string table contents are in the perm gen
   48.11 -    NOT_PRODUCT(StringTable::oops_do(&assert_is_perm_closure));
   48.12 +    if (so & SO_Strings || (!collecting_perm_gen && !JavaObjectsInPerm)) {
   48.13 +      StringTable::oops_do(roots);
   48.14 +    }
   48.15 +    if (JavaObjectsInPerm) {
   48.16 +      // Verify the string table contents are in the perm gen
   48.17 +      NOT_PRODUCT(StringTable::oops_do(&assert_is_perm_closure));
   48.18 +    }
   48.19    }
   48.20  
   48.21    if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) {
    49.1 --- a/src/share/vm/memory/universe.cpp	Fri Mar 18 13:28:33 2011 -0700
    49.2 +++ b/src/share/vm/memory/universe.cpp	Thu Mar 24 23:00:27 2011 -0700
    49.3 @@ -1,5 +1,5 @@
    49.4  /*
    49.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    49.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    49.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    49.8   *
    49.9   * This code is free software; you can redistribute it and/or modify it
   49.10 @@ -51,6 +51,7 @@
   49.11  #include "oops/cpCacheKlass.hpp"
   49.12  #include "oops/cpCacheOop.hpp"
   49.13  #include "oops/instanceKlass.hpp"
   49.14 +#include "oops/instanceMirrorKlass.hpp"
   49.15  #include "oops/instanceKlassKlass.hpp"
   49.16  #include "oops/instanceRefKlass.hpp"
   49.17  #include "oops/klassKlass.hpp"
   49.18 @@ -521,6 +522,7 @@
   49.19    { objArrayKlassKlass o;     add_vtable(list, &n, &o, count); }
   49.20    { instanceKlassKlass o;     add_vtable(list, &n, &o, count); }
   49.21    { instanceKlass o;          add_vtable(list, &n, &o, count); }
   49.22 +  { instanceMirrorKlass o;    add_vtable(list, &n, &o, count); }
   49.23    { instanceRefKlass o;       add_vtable(list, &n, &o, count); }
   49.24    { typeArrayKlassKlass o;    add_vtable(list, &n, &o, count); }
   49.25    { typeArrayKlass o;         add_vtable(list, &n, &o, count); }
   49.26 @@ -547,7 +549,7 @@
   49.27        KlassHandle k(THREAD, klassOop(obj));
   49.28        // We will never reach the CATCH below since Exceptions::_throw will cause
   49.29        // the VM to exit if an exception is thrown during initialization
   49.30 -      java_lang_Class::create_mirror(k, CATCH);
   49.31 +      java_lang_Class::fixup_mirror(k, CATCH);
   49.32        // This call unconditionally creates a new mirror for k,
   49.33        // and links in k's component_mirror field if k is an array.
   49.34        // If k is an objArray, k's element type must already have
   49.35 @@ -605,6 +607,10 @@
   49.36    // walk over permanent objects created so far (mostly classes) and fixup their mirrors. Note
   49.37    // that the number of objects allocated at this point is very small.
   49.38    assert(SystemDictionary::Class_klass_loaded(), "java.lang.Class should be loaded");
   49.39 +
   49.40 +  // Cache the start of the static fields
   49.41 +  instanceMirrorKlass::init_offset_of_static_fields();
   49.42 +
   49.43    FixupMirrorClosure blk;
   49.44    Universe::heap()->permanent_object_iterate(&blk);
   49.45  }
   49.46 @@ -1313,6 +1319,8 @@
   49.47    JNIHandles::verify();
   49.48    if (!silent) gclog_or_tty->print("C-heap ");
   49.49    os::check_heap();
   49.50 +  if (!silent) gclog_or_tty->print("code cache ");
   49.51 +  CodeCache::verify_oops();
   49.52    if (!silent) gclog_or_tty->print_cr("]");
   49.53  
   49.54    _verify_in_progress = false;
    50.1 --- a/src/share/vm/oops/arrayKlassKlass.cpp	Fri Mar 18 13:28:33 2011 -0700
    50.2 +++ b/src/share/vm/oops/arrayKlassKlass.cpp	Thu Mar 24 23:00:27 2011 -0700
    50.3 @@ -28,6 +28,13 @@
    50.4  #include "oops/arrayKlassKlass.hpp"
    50.5  #include "oops/oop.inline.hpp"
    50.6  #include "runtime/handles.inline.hpp"
    50.7 +#ifndef SERIALGC
    50.8 +#include "gc_implementation/parNew/parOopClosures.inline.hpp"
    50.9 +#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
   50.10 +#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
   50.11 +#include "memory/cardTableRS.hpp"
   50.12 +#include "oops/oop.pcgc.inline.hpp"
   50.13 +#endif
   50.14  
   50.15  
   50.16  klassOop arrayKlassKlass::create_klass(TRAPS) {
   50.17 @@ -104,9 +111,12 @@
   50.18  int arrayKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
   50.19    assert(obj->is_klass(), "must be klass");
   50.20    arrayKlass* ak = arrayKlass::cast(klassOop(obj));
   50.21 -  blk->do_oop(ak->adr_component_mirror());
   50.22 -  blk->do_oop(ak->adr_lower_dimension());
   50.23 -  blk->do_oop(ak->adr_higher_dimension());
   50.24 +  oop* addr = ak->adr_component_mirror();
   50.25 +  if (mr.contains(addr)) blk->do_oop(addr);
   50.26 +  addr = ak->adr_lower_dimension();
   50.27 +  if (mr.contains(addr)) blk->do_oop(addr);
   50.28 +  addr = ak->adr_higher_dimension();
   50.29 +  if (mr.contains(addr)) blk->do_oop(addr);
   50.30    ak->vtable()->oop_oop_iterate_m(blk, mr);
   50.31    return klassKlass::oop_oop_iterate_m(obj, blk, mr);
   50.32  }
   50.33 @@ -114,6 +124,12 @@
   50.34  #ifndef SERIALGC
   50.35  void arrayKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
   50.36    assert(obj->blueprint()->oop_is_arrayKlass(),"must be an array klass");
   50.37 +  arrayKlass* ak = arrayKlass::cast(klassOop(obj));
   50.38 +  oop* p = ak->adr_component_mirror();
   50.39 +  if (PSScavenge::should_scavenge(p)) {
   50.40 +    pm->claim_or_forward_depth(p);
   50.41 +  }
   50.42 +  klassKlass::oop_push_contents(pm, obj);
   50.43  }
   50.44  
   50.45  int arrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
    51.1 --- a/src/share/vm/oops/constantPoolKlass.cpp	Fri Mar 18 13:28:33 2011 -0700
    51.2 +++ b/src/share/vm/oops/constantPoolKlass.cpp	Thu Mar 24 23:00:27 2011 -0700
    51.3 @@ -285,10 +285,11 @@
    51.4  void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
    51.5    assert(obj->is_constantPool(), "should be constant pool");
    51.6    constantPoolOop cp = (constantPoolOop) obj;
    51.7 -  if (AnonymousClasses && cp->has_pseudo_string() && cp->tags() != NULL) {
    51.8 -    oop* base = (oop*)cp->base();
    51.9 -    for (int i = 0; i < cp->length(); ++i, ++base) {
   51.10 +  if (cp->tags() != NULL &&
   51.11 +      (!JavaObjectsInPerm || (AnonymousClasses && cp->has_pseudo_string()))) {
   51.12 +    for (int i = 1; i < cp->length(); ++i) {
   51.13        if (cp->tag_at(i).is_string()) {
   51.14 +        oop* base = cp->obj_at_addr_raw(i);
   51.15          if (PSScavenge::should_scavenge(base)) {
   51.16            pm->claim_or_forward_depth(base);
   51.17          }
   51.18 @@ -460,7 +461,8 @@
   51.19        if (cp->tag_at(i).is_string()) {
   51.20          if (!cp->has_pseudo_string()) {
   51.21            if (entry.is_oop()) {
   51.22 -            guarantee(entry.get_oop()->is_perm(),   "should be in permspace");
   51.23 +            guarantee(!JavaObjectsInPerm || entry.get_oop()->is_perm(),
   51.24 +                      "should be in permspace");
   51.25              guarantee(entry.get_oop()->is_instance(), "should be instance");
   51.26            }
   51.27          } else {
    52.1 --- a/src/share/vm/oops/constantPoolOop.cpp	Fri Mar 18 13:28:33 2011 -0700
    52.2 +++ b/src/share/vm/oops/constantPoolOop.cpp	Thu Mar 24 23:00:27 2011 -0700
    52.3 @@ -1,5 +1,5 @@
    52.4  /*
    52.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    52.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    52.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    52.8   *
    52.9   * This code is free software; you can redistribute it and/or modify it
   52.10 @@ -481,7 +481,7 @@
   52.11      {
   52.12        klassOop resolved = klass_at_impl(this_oop, index, CHECK_NULL);
   52.13        // ldc wants the java mirror.
   52.14 -      result_oop = resolved->klass_part()->java_mirror();
   52.15 +      result_oop = resolved->java_mirror();
   52.16        break;
   52.17      }
   52.18  
    53.1 --- a/src/share/vm/oops/cpCacheKlass.cpp	Fri Mar 18 13:28:33 2011 -0700
    53.2 +++ b/src/share/vm/oops/cpCacheKlass.cpp	Thu Mar 24 23:00:27 2011 -0700
    53.3 @@ -168,22 +168,18 @@
    53.4  void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
    53.5                                                 oop obj) {
    53.6    assert(obj->is_constantPoolCache(), "should be constant pool");
    53.7 -  if (EnableInvokeDynamic) {
    53.8 +  if (ScavengeRootsInCode) {
    53.9      constantPoolCacheOop cache = (constantPoolCacheOop)obj;
   53.10      // during a scavenge, it is safe to inspect my pool, since it is perm
   53.11      constantPoolOop pool = cache->constant_pool();
   53.12      assert(pool->is_constantPool(), "should be constant pool");
   53.13 -    if (pool->has_invokedynamic()) {
   53.14 -      for (int i = 0; i < cache->length(); i++) {
   53.15 -        ConstantPoolCacheEntry* e = cache->entry_at(i);
   53.16 -        oop* p = (oop*)&e->_f1;
   53.17 -        if (e->is_secondary_entry()) {
   53.18 -          if (PSScavenge::should_scavenge(p))
   53.19 -            pm->claim_or_forward_depth(p);
   53.20 -          assert(!(e->is_vfinal() && PSScavenge::should_scavenge((oop*)&e->_f2)),
   53.21 -                 "no live oops here");
   53.22 -        }
   53.23 -      }
   53.24 +    for (int i = 0; i < cache->length(); i++) {
   53.25 +      ConstantPoolCacheEntry* e = cache->entry_at(i);
   53.26 +      oop* p = (oop*)&e->_f1;
   53.27 +      if (PSScavenge::should_scavenge(p))
   53.28 +        pm->claim_or_forward_depth(p);
   53.29 +      assert(!(e->is_vfinal() && PSScavenge::should_scavenge((oop*)&e->_f2)),
   53.30 +             "no live oops here");
   53.31      }
   53.32    }
   53.33  }
    54.1 --- a/src/share/vm/oops/cpCacheOop.cpp	Fri Mar 18 13:28:33 2011 -0700
    54.2 +++ b/src/share/vm/oops/cpCacheOop.cpp	Thu Mar 24 23:00:27 2011 -0700
    54.3 @@ -133,7 +133,7 @@
    54.4                                         TosState field_type,
    54.5                                         bool is_final,
    54.6                                         bool is_volatile) {
    54.7 -  set_f1(field_holder());
    54.8 +  set_f1(field_holder()->java_mirror());
    54.9    set_f2(field_offset);
   54.10    // The field index is used by jvm/ti and is the index into fields() array
   54.11    // in holder instanceKlass.  This is scaled by instanceKlass::next_offset.
    55.1 --- a/src/share/vm/oops/instanceKlass.cpp	Fri Mar 18 13:28:33 2011 -0700
    55.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Thu Mar 24 23:00:27 2011 -0700
    55.3 @@ -37,6 +37,7 @@
    55.4  #include "memory/oopFactory.hpp"
    55.5  #include "memory/permGen.hpp"
    55.6  #include "oops/instanceKlass.hpp"
    55.7 +#include "oops/instanceMirrorKlass.hpp"
    55.8  #include "oops/instanceOop.hpp"
    55.9  #include "oops/methodOop.hpp"
   55.10  #include "oops/objArrayKlassKlass.hpp"
   55.11 @@ -649,6 +650,7 @@
   55.12  }
   55.13  
   55.14  instanceOop instanceKlass::allocate_instance(TRAPS) {
   55.15 +  assert(!oop_is_instanceMirror(), "wrong allocation path");
   55.16    bool has_finalizer_flag = has_finalizer(); // Query before possible GC
   55.17    int size = size_helper();  // Query before forming handle.
   55.18  
   55.19 @@ -669,6 +671,7 @@
   55.20    // instances so simply disallow finalizable perm objects.  This can
   55.21    // be relaxed if a need for it is found.
   55.22    assert(!has_finalizer(), "perm objects not allowed to have finalizers");
   55.23 +  assert(!oop_is_instanceMirror(), "wrong allocation path");
   55.24    int size = size_helper();  // Query before forming handle.
   55.25    KlassHandle h_k(THREAD, as_klassOop());
   55.26    instanceOop i = (instanceOop)
   55.27 @@ -898,6 +901,7 @@
   55.28    }
   55.29  }
   55.30  
   55.31 +
   55.32  void instanceKlass::do_local_static_fields(FieldClosure* cl) {
   55.33    fieldDescriptor fd;
   55.34    int length = fields()->length();
   55.35 @@ -1609,36 +1613,6 @@
   55.36  // The following macros call specialized macros, passing either oop or
   55.37  // narrowOop as the specialization type.  These test the UseCompressedOops
   55.38  // flag.
   55.39 -#define InstanceKlass_OOP_ITERATE(start_p, count,    \
   55.40 -                                  do_oop, assert_fn) \
   55.41 -{                                                    \
   55.42 -  if (UseCompressedOops) {                           \
   55.43 -    InstanceKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
   55.44 -      start_p, count,                                \
   55.45 -      do_oop, assert_fn)                             \
   55.46 -  } else {                                           \
   55.47 -    InstanceKlass_SPECIALIZED_OOP_ITERATE(oop,       \
   55.48 -      start_p, count,                                \
   55.49 -      do_oop, assert_fn)                             \
   55.50 -  }                                                  \
   55.51 -}
   55.52 -
   55.53 -#define InstanceKlass_BOUNDED_OOP_ITERATE(start_p, count, low, high,    \
   55.54 -                                          do_oop, assert_fn) \
   55.55 -{                                                            \
   55.56 -  if (UseCompressedOops) {                                   \
   55.57 -    InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop, \
   55.58 -      start_p, count,                                        \
   55.59 -      low, high,                                             \
   55.60 -      do_oop, assert_fn)                                     \
   55.61 -  } else {                                                   \
   55.62 -    InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop,       \
   55.63 -      start_p, count,                                        \
   55.64 -      low, high,                                             \
   55.65 -      do_oop, assert_fn)                                     \
   55.66 -  }                                                          \
   55.67 -}
   55.68 -
   55.69  #define InstanceKlass_OOP_MAP_ITERATE(obj, do_oop, assert_fn)            \
   55.70  {                                                                        \
   55.71    /* Compute oopmap block range. The common case                         \
   55.72 @@ -1711,38 +1685,6 @@
   55.73    }                                                                      \
   55.74  }
   55.75  
   55.76 -void instanceKlass::follow_static_fields() {
   55.77 -  InstanceKlass_OOP_ITERATE( \
   55.78 -    start_of_static_fields(), static_oop_field_size(), \
   55.79 -    MarkSweep::mark_and_push(p), \
   55.80 -    assert_is_in_closed_subset)
   55.81 -}
   55.82 -
   55.83 -#ifndef SERIALGC
   55.84 -void instanceKlass::follow_static_fields(ParCompactionManager* cm) {
   55.85 -  InstanceKlass_OOP_ITERATE( \
   55.86 -    start_of_static_fields(), static_oop_field_size(), \
   55.87 -    PSParallelCompact::mark_and_push(cm, p), \
   55.88 -    assert_is_in)
   55.89 -}
   55.90 -#endif // SERIALGC
   55.91 -
   55.92 -void instanceKlass::adjust_static_fields() {
   55.93 -  InstanceKlass_OOP_ITERATE( \
   55.94 -    start_of_static_fields(), static_oop_field_size(), \
   55.95 -    MarkSweep::adjust_pointer(p), \
   55.96 -    assert_nothing)
   55.97 -}
   55.98 -
   55.99 -#ifndef SERIALGC
  55.100 -void instanceKlass::update_static_fields() {
  55.101 -  InstanceKlass_OOP_ITERATE( \
  55.102 -    start_of_static_fields(), static_oop_field_size(), \
  55.103 -    PSParallelCompact::adjust_pointer(p), \
  55.104 -    assert_nothing)
  55.105 -}
  55.106 -#endif // SERIALGC
  55.107 -
  55.108  void instanceKlass::oop_follow_contents(oop obj) {
  55.109    assert(obj != NULL, "can't follow the content of NULL object");
  55.110    obj->follow_header();
  55.111 @@ -1829,22 +1771,6 @@
  55.112  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
  55.113  #endif // !SERIALGC
  55.114  
  55.115 -void instanceKlass::iterate_static_fields(OopClosure* closure) {
  55.116 -    InstanceKlass_OOP_ITERATE( \
  55.117 -      start_of_static_fields(), static_oop_field_size(), \
  55.118 -      closure->do_oop(p), \
  55.119 -      assert_is_in_reserved)
  55.120 -}
  55.121 -
  55.122 -void instanceKlass::iterate_static_fields(OopClosure* closure,
  55.123 -                                          MemRegion mr) {
  55.124 -  InstanceKlass_BOUNDED_OOP_ITERATE( \
  55.125 -    start_of_static_fields(), static_oop_field_size(), \
  55.126 -    mr.start(), mr.end(), \
  55.127 -    (closure)->do_oop_v(p), \
  55.128 -    assert_is_in_closed_subset)
  55.129 -}
  55.130 -
  55.131  int instanceKlass::oop_adjust_pointers(oop obj) {
  55.132    int size = size_helper();
  55.133    InstanceKlass_OOP_MAP_ITERATE( \
  55.134 @@ -1873,21 +1799,6 @@
  55.135    return size_helper();
  55.136  }
  55.137  
  55.138 -void instanceKlass::push_static_fields(PSPromotionManager* pm) {
  55.139 -  InstanceKlass_OOP_ITERATE( \
  55.140 -    start_of_static_fields(), static_oop_field_size(), \
  55.141 -    if (PSScavenge::should_scavenge(p)) { \
  55.142 -      pm->claim_or_forward_depth(p); \
  55.143 -    }, \
  55.144 -    assert_nothing )
  55.145 -}
  55.146 -
  55.147 -void instanceKlass::copy_static_fields(ParCompactionManager* cm) {
  55.148 -  InstanceKlass_OOP_ITERATE( \
  55.149 -    start_of_static_fields(), static_oop_field_size(), \
  55.150 -    PSParallelCompact::adjust_pointer(p), \
  55.151 -    assert_is_in)
  55.152 -}
  55.153  #endif // SERIALGC
  55.154  
  55.155  // This klass is alive but the implementor link is not followed/updated.
  55.156 @@ -2002,6 +1913,11 @@
  55.157    if (_source_debug_extension != NULL) _source_debug_extension->increment_refcount();
  55.158  }
  55.159  
  55.160 +address instanceKlass::static_field_addr(int offset) {
  55.161 +  return (address)(offset + instanceMirrorKlass::offset_of_static_fields() + (intptr_t)java_mirror());
  55.162 +}
  55.163 +
  55.164 +
  55.165  const char* instanceKlass::signature_name() const {
  55.166    const char* src = (const char*) (name()->as_C_string());
  55.167    const int src_length = (int)strlen(src);
  55.168 @@ -2369,7 +2285,7 @@
  55.169  
  55.170  void FieldPrinter::do_field(fieldDescriptor* fd) {
  55.171    _st->print(BULLET);
  55.172 -   if (fd->is_static() || (_obj == NULL)) {
  55.173 +   if (_obj == NULL) {
  55.174       fd->print_on(_st);
  55.175       _st->cr();
  55.176     } else {
  55.177 @@ -2399,8 +2315,8 @@
  55.178    }
  55.179  
  55.180    st->print_cr(BULLET"---- fields (total size %d words):", oop_size(obj));
  55.181 -  FieldPrinter print_nonstatic_field(st, obj);
  55.182 -  do_nonstatic_fields(&print_nonstatic_field);
  55.183 +  FieldPrinter print_field(st, obj);
  55.184 +  do_nonstatic_fields(&print_field);
  55.185  
  55.186    if (as_klassOop() == SystemDictionary::Class_klass()) {
  55.187      st->print(BULLET"signature: ");
  55.188 @@ -2418,6 +2334,12 @@
  55.189      st->print(BULLET"fake entry for array: ");
  55.190      array_klass->print_value_on(st);
  55.191      st->cr();
  55.192 +    st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj));
  55.193 +    st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj));
  55.194 +    klassOop real_klass = java_lang_Class::as_klassOop(obj);
  55.195 +    if (real_klass && real_klass->klass_part()->oop_is_instance()) {
  55.196 +      instanceKlass::cast(real_klass)->do_local_static_fields(&print_field);
  55.197 +    }
  55.198    } else if (as_klassOop() == SystemDictionary::MethodType_klass()) {
  55.199      st->print(BULLET"signature: ");
  55.200      java_lang_invoke_MethodType::print_signature(obj, st);
  55.201 @@ -2560,7 +2482,7 @@
  55.202  
  55.203  
  55.204  void JNIid::verify(klassOop holder) {
  55.205 -  int first_field_offset  = instanceKlass::cast(holder)->offset_of_static_fields();
  55.206 +  int first_field_offset  = instanceMirrorKlass::offset_of_static_fields();
  55.207    int end_field_offset;
  55.208    end_field_offset = first_field_offset + (instanceKlass::cast(holder)->static_field_size() * wordSize);
  55.209  
    56.1 --- a/src/share/vm/oops/instanceKlass.hpp	Fri Mar 18 13:28:33 2011 -0700
    56.2 +++ b/src/share/vm/oops/instanceKlass.hpp	Thu Mar 24 23:00:27 2011 -0700
    56.3 @@ -75,8 +75,6 @@
    56.4  //    [Java vtable length         ]
    56.5  //    [oop map cache (stack maps) ]
    56.6  //    [EMBEDDED Java vtable             ] size in words = vtable_len
    56.7 -//    [EMBEDDED static oop fields       ] size in words = static_oop_fields_size
    56.8 -//    [         static non-oop fields   ] size in words = static_field_size - static_oop_fields_size
    56.9  //    [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
   56.10  //
   56.11  //    The embedded nonstatic oop-map blocks are short pairs (offset, length) indicating
   56.12 @@ -230,7 +228,7 @@
   56.13    // (including inherited fields but after header_size()).
   56.14    int             _nonstatic_field_size;
   56.15    int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
   56.16 -  int             _static_oop_field_size;// number of static oop fields in this klass
   56.17 +  int             _static_oop_field_count;// number of static oop fields in this klass
   56.18    int             _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
   56.19    bool            _is_marked_dependent;  // used for marking during flushing and deoptimization
   56.20    bool            _rewritten;            // methods rewritten.
   56.21 @@ -281,8 +279,8 @@
   56.22    int static_field_size() const            { return _static_field_size; }
   56.23    void set_static_field_size(int size)     { _static_field_size = size; }
   56.24  
   56.25 -  int static_oop_field_size() const        { return _static_oop_field_size; }
   56.26 -  void set_static_oop_field_size(int size) { _static_oop_field_size = size; }
   56.27 +  int static_oop_field_count() const        { return _static_oop_field_count; }
   56.28 +  void set_static_oop_field_count(int size) { _static_oop_field_count = size; }
   56.29  
   56.30    // Java vtable
   56.31    int  vtable_length() const               { return _vtable_len; }
   56.32 @@ -660,6 +658,7 @@
   56.33  
   56.34    // Casting from klassOop
   56.35    static instanceKlass* cast(klassOop k) {
   56.36 +    assert(k->is_klass(), "must be");
   56.37      Klass* kp = k->klass_part();
   56.38      assert(kp->null_vtbl() || kp->oop_is_instance_slow(), "cast to instanceKlass");
   56.39      return (instanceKlass*) kp;
   56.40 @@ -667,7 +666,7 @@
   56.41  
   56.42    // Sizing (in words)
   56.43    static int header_size()            { return align_object_offset(oopDesc::header_size() + sizeof(instanceKlass)/HeapWordSize); }
   56.44 -  int object_size() const             { return object_size(align_object_offset(vtable_length()) + align_object_offset(itable_length()) + static_field_size() + nonstatic_oop_map_size()); }
   56.45 +  int object_size() const             { return object_size(align_object_offset(vtable_length()) + align_object_offset(itable_length()) + nonstatic_oop_map_size()); }
   56.46    static int vtable_start_offset()    { return header_size(); }
   56.47    static int vtable_length_offset()   { return oopDesc::header_size() + offset_of(instanceKlass, _vtable_len) / HeapWordSize; }
   56.48    static int object_size(int extra)   { return align_object_size(header_size() + extra); }
   56.49 @@ -676,20 +675,12 @@
   56.50    intptr_t* start_of_itable() const        { return start_of_vtable() + align_object_offset(vtable_length()); }
   56.51    int  itable_offset_in_words() const { return start_of_itable() - (intptr_t*)as_klassOop(); }
   56.52  
   56.53 -  // Static field offset is an offset into the Heap, should be converted by
   56.54 -  // based on UseCompressedOop for traversal
   56.55 -  HeapWord* start_of_static_fields() const {
   56.56 -    return (HeapWord*)(start_of_itable() + align_object_offset(itable_length()));
   56.57 -  }
   56.58 -
   56.59    intptr_t* end_of_itable() const          { return start_of_itable() + itable_length(); }
   56.60  
   56.61 -  int offset_of_static_fields() const {
   56.62 -    return (intptr_t)start_of_static_fields() - (intptr_t)as_klassOop();
   56.63 -  }
   56.64 +  address static_field_addr(int offset);
   56.65  
   56.66    OopMapBlock* start_of_nonstatic_oop_maps() const {
   56.67 -    return (OopMapBlock*) (start_of_static_fields() + static_field_size());
   56.68 +    return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
   56.69    }
   56.70  
   56.71    // Allocation profiling support
   56.72 @@ -719,8 +710,6 @@
   56.73  
   56.74    // Garbage collection
   56.75    void oop_follow_contents(oop obj);
   56.76 -  void follow_static_fields();
   56.77 -  void adjust_static_fields();
   56.78    int  oop_adjust_pointers(oop obj);
   56.79    bool object_is_parsable() const { return _init_state != unparsable_by_gc; }
   56.80         // Value of _init_state must be zero (unparsable_by_gc) when klass field is set.
   56.81 @@ -732,16 +721,6 @@
   56.82    // Parallel Scavenge and Parallel Old
   56.83    PARALLEL_GC_DECLS
   56.84  
   56.85 -#ifndef SERIALGC
   56.86 -  // Parallel Scavenge
   56.87 -  void push_static_fields(PSPromotionManager* pm);
   56.88 -
   56.89 -  // Parallel Old
   56.90 -  void follow_static_fields(ParCompactionManager* cm);
   56.91 -  void copy_static_fields(ParCompactionManager* cm);
   56.92 -  void update_static_fields();
   56.93 -#endif // SERIALGC
   56.94 -
   56.95    // Naming
   56.96    const char* signature_name() const;
   56.97  
   56.98 @@ -770,9 +749,6 @@
   56.99    ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
  56.100  #endif // !SERIALGC
  56.101  
  56.102 -  void iterate_static_fields(OopClosure* closure);
  56.103 -  void iterate_static_fields(OopClosure* closure, MemRegion mr);
  56.104 -
  56.105  private:
  56.106    // initialization state
  56.107  #ifdef ASSERT
  56.108 @@ -926,6 +902,10 @@
  56.109    // Identifier lookup
  56.110    JNIid* find(int offset);
  56.111  
  56.112 +  bool find_local_field(fieldDescriptor* fd) {
  56.113 +    return instanceKlass::cast(holder())->find_local_field_from_offset(offset(), true, fd);
  56.114 +  }
  56.115 +
  56.116    // Garbage collection support
  56.117    oop* holder_addr() { return (oop*)&_holder; }
  56.118    void oops_do(OopClosure* f);
    57.1 --- a/src/share/vm/oops/instanceKlassKlass.cpp	Fri Mar 18 13:28:33 2011 -0700
    57.2 +++ b/src/share/vm/oops/instanceKlassKlass.cpp	Thu Mar 24 23:00:27 2011 -0700
    57.3 @@ -31,6 +31,7 @@
    57.4  #include "memory/gcLocker.hpp"
    57.5  #include "oops/constantPoolOop.hpp"
    57.6  #include "oops/instanceKlass.hpp"
    57.7 +#include "oops/instanceMirrorKlass.hpp"
    57.8  #include "oops/instanceKlassKlass.hpp"
    57.9  #include "oops/instanceRefKlass.hpp"
   57.10  #include "oops/objArrayKlassKlass.hpp"
   57.11 @@ -86,7 +87,6 @@
   57.12    assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass");
   57.13  
   57.14    instanceKlass* ik = instanceKlass::cast(klassOop(obj));
   57.15 -  ik->follow_static_fields();
   57.16    {
   57.17      HandleMark hm;
   57.18      ik->vtable()->oop_follow_contents();
   57.19 @@ -127,7 +127,6 @@
   57.20    assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass");
   57.21  
   57.22    instanceKlass* ik = instanceKlass::cast(klassOop(obj));
   57.23 -  ik->follow_static_fields(cm);
   57.24    ik->vtable()->oop_follow_contents(cm);
   57.25    ik->itable()->oop_follow_contents(cm);
   57.26  
   57.27 @@ -168,7 +167,6 @@
   57.28    // Don't call size() or oop_size() since that is a virtual call.
   57.29    int size = ik->object_size();
   57.30  
   57.31 -  ik->iterate_static_fields(blk);
   57.32    ik->vtable()->oop_oop_iterate(blk);
   57.33    ik->itable()->oop_oop_iterate(blk);
   57.34  
   57.35 @@ -209,7 +207,6 @@
   57.36    // Don't call size() or oop_size() since that is a virtual call.
   57.37    int size = ik->object_size();
   57.38  
   57.39 -  ik->iterate_static_fields(blk, mr);
   57.40    ik->vtable()->oop_oop_iterate_m(blk, mr);
   57.41    ik->itable()->oop_oop_iterate_m(blk, mr);
   57.42  
   57.43 @@ -266,7 +263,6 @@
   57.44    assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass");
   57.45  
   57.46    instanceKlass* ik = instanceKlass::cast(klassOop(obj));
   57.47 -  ik->adjust_static_fields();
   57.48    ik->vtable()->oop_adjust_pointers();
   57.49    ik->itable()->oop_adjust_pointers();
   57.50  
   57.51 @@ -300,7 +296,6 @@
   57.52  #ifndef SERIALGC
   57.53  void instanceKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
   57.54    instanceKlass* ik = instanceKlass::cast(klassOop(obj));
   57.55 -  ik->push_static_fields(pm);
   57.56  
   57.57    oop* loader_addr = ik->adr_class_loader();
   57.58    if (PSScavenge::should_scavenge(loader_addr)) {
   57.59 @@ -336,7 +331,6 @@
   57.60           "must be instance klass");
   57.61  
   57.62    instanceKlass* ik = instanceKlass::cast(klassOop(obj));
   57.63 -  ik->update_static_fields();
   57.64    ik->vtable()->oop_update_pointers(cm);
   57.65    ik->itable()->oop_update_pointers(cm);
   57.66  
   57.67 @@ -356,22 +350,28 @@
   57.68  #endif // SERIALGC
   57.69  
   57.70  klassOop
   57.71 -instanceKlassKlass::allocate_instance_klass(int vtable_len, int itable_len,
   57.72 +instanceKlassKlass::allocate_instance_klass(Symbol* name, int vtable_len, int itable_len,
   57.73                                              int static_field_size,
   57.74                                              unsigned nonstatic_oop_map_count,
   57.75                                              ReferenceType rt, TRAPS) {
   57.76  
   57.77    const int nonstatic_oop_map_size =
   57.78      instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count);
   57.79 -  int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + static_field_size + nonstatic_oop_map_size);
   57.80 +  int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + nonstatic_oop_map_size);
   57.81  
   57.82    // Allocation
   57.83    KlassHandle h_this_klass(THREAD, as_klassOop());
   57.84    KlassHandle k;
   57.85    if (rt == REF_NONE) {
   57.86 -    // regular klass
   57.87 -    instanceKlass o;
   57.88 -    k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
   57.89 +    if (name != vmSymbols::java_lang_Class()) {
   57.90 +      // regular klass
   57.91 +      instanceKlass o;
   57.92 +      k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
   57.93 +    } else {
   57.94 +      // Class
   57.95 +      instanceMirrorKlass o;
   57.96 +      k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
   57.97 +    }
   57.98    } else {
   57.99      // reference klass
  57.100      instanceRefKlass o;
  57.101 @@ -408,7 +408,7 @@
  57.102      ik->set_source_debug_extension(NULL);
  57.103      ik->set_array_name(NULL);
  57.104      ik->set_inner_classes(NULL);
  57.105 -    ik->set_static_oop_field_size(0);
  57.106 +    ik->set_static_oop_field_count(0);
  57.107      ik->set_nonstatic_field_size(0);
  57.108      ik->set_is_marked_dependent(false);
  57.109      ik->set_init_state(instanceKlass::allocated);
  57.110 @@ -442,9 +442,6 @@
  57.111      // To get verify to work - must be set to partial loaded before first GC point.
  57.112      k()->set_partially_loaded();
  57.113    }
  57.114 -
  57.115 -  // GC can happen here
  57.116 -  java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
  57.117    return k();
  57.118  }
  57.119  
  57.120 @@ -566,13 +563,6 @@
  57.121    FieldPrinter print_nonstatic_field(st);
  57.122    ik->do_nonstatic_fields(&print_nonstatic_field);
  57.123  
  57.124 -  st->print(BULLET"static oop maps:     ");
  57.125 -  if (ik->static_oop_field_size() > 0) {
  57.126 -    int first_offset = ik->offset_of_static_fields();
  57.127 -    st->print("%d-%d", first_offset, first_offset + ik->static_oop_field_size() - 1);
  57.128 -  }
  57.129 -  st->cr();
  57.130 -
  57.131    st->print(BULLET"non-static oop maps: ");
  57.132    OopMapBlock* map     = ik->start_of_nonstatic_oop_maps();
  57.133    OopMapBlock* end_map = map + ik->nonstatic_oop_map_count();
  57.134 @@ -630,7 +620,6 @@
  57.135  
  57.136      // Verify static fields
  57.137      VerifyFieldClosure blk;
  57.138 -    ik->iterate_static_fields(&blk);
  57.139  
  57.140      // Verify vtables
  57.141      if (ik->is_linked()) {
    58.1 --- a/src/share/vm/oops/instanceKlassKlass.hpp	Fri Mar 18 13:28:33 2011 -0700
    58.2 +++ b/src/share/vm/oops/instanceKlassKlass.hpp	Thu Mar 24 23:00:27 2011 -0700
    58.3 @@ -1,5 +1,5 @@
    58.4  /*
    58.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    58.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    58.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    58.8   *
    58.9   * This code is free software; you can redistribute it and/or modify it
   58.10 @@ -41,7 +41,8 @@
   58.11    // Allocation
   58.12    DEFINE_ALLOCATE_PERMANENT(instanceKlassKlass);
   58.13    static klassOop create_klass(TRAPS);
   58.14 -  klassOop allocate_instance_klass(int vtable_len,
   58.15 +  klassOop allocate_instance_klass(Symbol* name,
   58.16 +                                   int vtable_len,
   58.17                                     int itable_len,
   58.18                                     int static_field_size,
   58.19                                     unsigned int nonstatic_oop_map_count,
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/src/share/vm/oops/instanceMirrorKlass.cpp	Thu Mar 24 23:00:27 2011 -0700
    59.3 @@ -0,0 +1,313 @@
    59.4 +/*
    59.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    59.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    59.7 + *
    59.8 + * This code is free software; you can redistribute it and/or modify it
    59.9 + * under the terms of the GNU General Public License version 2 only, as
   59.10 + * published by the Free Software Foundation.
   59.11 + *
   59.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   59.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   59.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   59.15 + * version 2 for more details (a copy is included in the LICENSE file that
   59.16 + * accompanied this code).
   59.17 + *
   59.18 + * You should have received a copy of the GNU General Public License version
   59.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   59.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   59.21 + *
   59.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   59.23 + * or visit www.oracle.com if you need additional information or have any
   59.24 + * questions.
   59.25 + *
   59.26 + */
   59.27 +
   59.28 +#include "precompiled.hpp"
   59.29 +#include "classfile/javaClasses.hpp"
   59.30 +#include "classfile/systemDictionary.hpp"
   59.31 +#include "gc_implementation/shared/markSweep.inline.hpp"
   59.32 +#include "gc_interface/collectedHeap.inline.hpp"
   59.33 +#include "memory/genOopClosures.inline.hpp"
   59.34 +#include "memory/oopFactory.hpp"
   59.35 +#include "memory/permGen.hpp"
   59.36 +#include "oops/instanceKlass.hpp"
   59.37 +#include "oops/instanceMirrorKlass.hpp"
   59.38 +#include "oops/instanceOop.hpp"
   59.39 +#include "oops/oop.inline.hpp"
   59.40 +#include "oops/symbol.hpp"
   59.41 +#include "runtime/handles.inline.hpp"
   59.42 +#ifndef SERIALGC
   59.43 +#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
   59.44 +#include "gc_implementation/g1/g1OopClosures.inline.hpp"
   59.45 +#include "gc_implementation/g1/g1RemSet.inline.hpp"
   59.46 +#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
   59.47 +#include "gc_implementation/parNew/parOopClosures.inline.hpp"
   59.48 +#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
   59.49 +#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
   59.50 +#include "oops/oop.pcgc.inline.hpp"
   59.51 +#endif
   59.52 +
   59.53 +int instanceMirrorKlass::_offset_of_static_fields = 0;
   59.54 +
   59.55 +#ifdef ASSERT
   59.56 +template <class T> void assert_is_in(T *p) {
   59.57 +  T heap_oop = oopDesc::load_heap_oop(p);
   59.58 +  if (!oopDesc::is_null(heap_oop)) {
   59.59 +    oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
   59.60 +    assert(Universe::heap()->is_in(o), "should be in heap");
   59.61 +  }
   59.62 +}
   59.63 +template <class T> void assert_is_in_closed_subset(T *p) {
   59.64 +  T heap_oop = oopDesc::load_heap_oop(p);
   59.65 +  if (!oopDesc::is_null(heap_oop)) {
   59.66 +    oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
   59.67 +    assert(Universe::heap()->is_in_closed_subset(o), "should be in closed");
   59.68 +  }
   59.69 +}
   59.70 +template <class T> void assert_is_in_reserved(T *p) {
   59.71 +  T heap_oop = oopDesc::load_heap_oop(p);
   59.72 +  if (!oopDesc::is_null(heap_oop)) {
   59.73 +    oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
   59.74 +    assert(Universe::heap()->is_in_reserved(o), "should be in reserved");
   59.75 +  }
   59.76 +}
   59.77 +template <class T> void assert_nothing(T *p) {}
   59.78 +
   59.79 +#else
   59.80 +template <class T> void assert_is_in(T *p) {}
   59.81 +template <class T> void assert_is_in_closed_subset(T *p) {}
   59.82 +template <class T> void assert_is_in_reserved(T *p) {}
   59.83 +template <class T> void assert_nothing(T *p) {}
   59.84 +#endif // ASSERT
   59.85 +
   59.86 +#define InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE( \
   59.87 +  T, start_p, count, do_oop,                         \
   59.88 +  assert_fn)                                         \
   59.89 +{                                                    \
   59.90 +  T* p         = (T*)(start_p);                      \
   59.91 +  T* const end = p + (count);                        \
   59.92 +  while (p < end) {                                  \
   59.93 +    (assert_fn)(p);                                  \
   59.94 +    do_oop;                                          \
   59.95 +    ++p;                                             \
   59.96 +  }                                                  \
   59.97 +}
   59.98 +
   59.99 +#define InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE( \
  59.100 +  T, start_p, count, low, high,                              \
  59.101 +  do_oop, assert_fn)                                         \
  59.102 +{                                                            \
  59.103 +  T* const l = (T*)(low);                                    \
  59.104 +  T* const h = (T*)(high);                                   \
  59.105 +  assert(mask_bits((intptr_t)l, sizeof(T)-1) == 0 &&         \
  59.106 +         mask_bits((intptr_t)h, sizeof(T)-1) == 0,           \
  59.107 +         "bounded region must be properly aligned");         \
  59.108 +  T* p       = (T*)(start_p);                                \
  59.109 +  T* end     = p + (count);                                  \
  59.110 +  if (p < l) p = l;                                          \
  59.111 +  if (end > h) end = h;                                      \
  59.112 +  while (p < end) {                                          \
  59.113 +    (assert_fn)(p);                                          \
  59.114 +    do_oop;                                                  \
  59.115 +    ++p;                                                     \
  59.116 +  }                                                          \
  59.117 +}
  59.118 +
  59.119 +
  59.120 +#define InstanceMirrorKlass_OOP_ITERATE(start_p, count,    \
  59.121 +                                  do_oop, assert_fn)       \
  59.122 +{                                                          \
  59.123 +  if (UseCompressedOops) {                                 \
  59.124 +    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
  59.125 +      start_p, count,                                      \
  59.126 +      do_oop, assert_fn)                                   \
  59.127 +  } else {                                                 \
  59.128 +    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE(oop,       \
  59.129 +      start_p, count,                                      \
  59.130 +      do_oop, assert_fn)                                   \
  59.131 +  }                                                        \
  59.132 +}
  59.133 +
  59.134 +// The following macros call specialized macros, passing either oop or
  59.135 +// narrowOop as the specialization type.  These test the UseCompressedOops
  59.136 +// flag.
  59.137 +#define InstanceMirrorKlass_BOUNDED_OOP_ITERATE(start_p, count, low, high, \
  59.138 +                                          do_oop, assert_fn)               \
  59.139 +{                                                                          \
  59.140 +  if (UseCompressedOops) {                                                 \
  59.141 +    InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop,         \
  59.142 +      start_p, count,                                                      \
  59.143 +      low, high,                                                           \
  59.144 +      do_oop, assert_fn)                                                   \
  59.145 +  } else {                                                                 \
  59.146 +    InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop,               \
  59.147 +      start_p, count,                                                      \
  59.148 +      low, high,                                                           \
  59.149 +      do_oop, assert_fn)                                                   \
  59.150 +  }                                                                        \
  59.151 +}
  59.152 +
  59.153 +
  59.154 +void instanceMirrorKlass::oop_follow_contents(oop obj) {
  59.155 +  instanceKlass::oop_follow_contents(obj);
  59.156 +  InstanceMirrorKlass_OOP_ITERATE(                                                    \
  59.157 +    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
  59.158 +    MarkSweep::mark_and_push(p),                                                      \
  59.159 +    assert_is_in_closed_subset)
  59.160 +}
  59.161 +
  59.162 +#ifndef SERIALGC
  59.163 +void instanceMirrorKlass::oop_follow_contents(ParCompactionManager* cm,
  59.164 +                                              oop obj) {
  59.165 +  instanceKlass::oop_follow_contents(cm, obj);
  59.166 +  InstanceMirrorKlass_OOP_ITERATE(                                                    \
  59.167 +    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
  59.168 +    PSParallelCompact::mark_and_push(cm, p),                                          \
  59.169 +    assert_is_in)
  59.170 +}
  59.171 +#endif // SERIALGC
  59.172 +
  59.173 +int instanceMirrorKlass::oop_adjust_pointers(oop obj) {
  59.174 +  int size = oop_size(obj);
  59.175 +  instanceKlass::oop_adjust_pointers(obj);
  59.176 +  InstanceMirrorKlass_OOP_ITERATE(                                                    \
  59.177 +    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
  59.178 +    MarkSweep::adjust_pointer(p),                                                     \
  59.179 +    assert_nothing)
  59.180 +  return size;
  59.181 +}
  59.182 +
  59.183 +#define InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(T, nv_suffix)                \
  59.184 +  InstanceMirrorKlass_OOP_ITERATE(                                                    \
  59.185 +    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
  59.186 +      (closure)->do_oop##nv_suffix(p),                                                \
  59.187 +    assert_is_in_closed_subset)                                                       \
  59.188 +  return oop_size(obj);                                                               \
  59.189 +
  59.190 +#define InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(T, nv_suffix, mr)         \
  59.191 +  InstanceMirrorKlass_BOUNDED_OOP_ITERATE(                                            \
  59.192 +    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
  59.193 +    mr.start(), mr.end(),                                                             \
  59.194 +      (closure)->do_oop##nv_suffix(p),                                                \
  59.195 +    assert_is_in_closed_subset)                                                       \
  59.196 +  return oop_size(obj);                                                               \
  59.197 +
  59.198 +
  59.199 +// Macro to define instanceMirrorKlass::oop_oop_iterate for virtual/nonvirtual for
  59.200 +// all closures.  Macros calling macros above for each oop size.
  59.201 +
  59.202 +#define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)           \
  59.203 +                                                                                      \
  59.204 +int instanceMirrorKlass::                                                             \
  59.205 +oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) {                        \
  59.206 +  /* Get size before changing pointers */                                             \
  59.207 +  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);      \
  59.208 +                                                                                      \
  59.209 +  instanceKlass::oop_oop_iterate##nv_suffix(obj, closure);                            \
  59.210 +                                                                                      \
  59.211 +  if (UseCompressedOops) {                                                            \
  59.212 +    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(narrowOop, nv_suffix);           \
  59.213 +  } else {                                                                            \
  59.214 +    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(oop, nv_suffix);                 \
  59.215 +  }                                                                                   \
  59.216 +}
  59.217 +
  59.218 +#ifndef SERIALGC
  59.219 +#define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \
  59.220 +                                                                                      \
  59.221 +int instanceMirrorKlass::                                                             \
  59.222 +oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) {              \
  59.223 +  /* Get size before changing pointers */                                             \
  59.224 +  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);      \
  59.225 +                                                                                      \
  59.226 +  instanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure);                  \
  59.227 +                                                                                      \
  59.228 +  if (UseCompressedOops) {                                                            \
  59.229 +    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(narrowOop, nv_suffix);           \
  59.230 +  } else {                                                                            \
  59.231 +    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(oop, nv_suffix);                 \
  59.232 +  }                                                                                   \
  59.233 +}
  59.234 +#endif // !SERIALGC
  59.235 +
  59.236 +
  59.237 +#define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix)         \
  59.238 +                                                                                      \
  59.239 +int instanceMirrorKlass::                                                             \
  59.240 +oop_oop_iterate##nv_suffix##_m(oop obj,                                               \
  59.241 +                               OopClosureType* closure,                               \
  59.242 +                               MemRegion mr) {                                        \
  59.243 +  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);      \
  59.244 +                                                                                      \
  59.245 +  instanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr);                    \
  59.246 +  if (UseCompressedOops) {                                                            \
  59.247 +    InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, mr);    \
  59.248 +  } else {                                                                            \
  59.249 +    InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, mr);          \
  59.250 +  }                                                                                   \
  59.251 +}
  59.252 +
  59.253 +ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN)
  59.254 +ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN)
  59.255 +#ifndef SERIALGC
  59.256 +ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
  59.257 +ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
  59.258 +#endif // SERIALGC
  59.259 +ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m)
  59.260 +ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m)
  59.261 +
  59.262 +#ifndef SERIALGC
  59.263 +void instanceMirrorKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
  59.264 +  instanceKlass::oop_push_contents(pm, obj);
  59.265 +  InstanceMirrorKlass_OOP_ITERATE(                                            \
  59.266 +    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\
  59.267 +    if (PSScavenge::should_scavenge(p)) {                                     \
  59.268 +      pm->claim_or_forward_depth(p);                                          \
  59.269 +    },                                                                        \
  59.270 +    assert_nothing )
  59.271 +}
  59.272 +
  59.273 +int instanceMirrorKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
  59.274 +  instanceKlass::oop_update_pointers(cm, obj);
  59.275 +  InstanceMirrorKlass_OOP_ITERATE(                                            \
  59.276 +    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\
  59.277 +    PSParallelCompact::adjust_pointer(p),                                     \
  59.278 +    assert_nothing)
  59.279 +  return oop_size(obj);
  59.280 +}
  59.281 +#endif // SERIALGC
  59.282 +
  59.283 +int instanceMirrorKlass::instance_size(KlassHandle k) {
  59.284 +  if (k() != NULL && k->oop_is_instance()) {
  59.285 +    return align_object_size(size_helper() + instanceKlass::cast(k())->static_field_size());
  59.286 +  }
  59.287 +  return size_helper();
  59.288 +}
  59.289 +
  59.290 +instanceOop instanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) {
  59.291 +  // Query before forming handle.
  59.292 +  int size = instance_size(k);
  59.293 +  KlassHandle h_k(THREAD, as_klassOop());
  59.294 +  instanceOop i;
  59.295 +
  59.296 +  if (JavaObjectsInPerm) {
  59.297 +    i = (instanceOop) CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
  59.298 +  } else {
  59.299 +    assert(ScavengeRootsInCode > 0, "must be");
  59.300 +    i = (instanceOop) CollectedHeap::obj_allocate(h_k, size, CHECK_NULL);
  59.301 +  }
  59.302 +
  59.303 +  return i;
  59.304 +}
  59.305 +
  59.306 +int instanceMirrorKlass::oop_size(oop obj) const {
  59.307 +  return java_lang_Class::oop_size(obj);
  59.308 +}
  59.309 +
  59.310 +int instanceMirrorKlass::compute_static_oop_field_count(oop obj) {
  59.311 +  klassOop k = java_lang_Class::as_klassOop(obj);
  59.312 +  if (k != NULL && k->klass_part()->oop_is_instance()) {
  59.313 +    return instanceKlass::cast(k)->static_oop_field_count();
  59.314 +  }
  59.315 +  return 0;
  59.316 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/src/share/vm/oops/instanceMirrorKlass.hpp	Thu Mar 24 23:00:27 2011 -0700
    60.3 @@ -0,0 +1,110 @@
    60.4 +/*
    60.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    60.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    60.7 + *
    60.8 + * This code is free software; you can redistribute it and/or modify it
    60.9 + * under the terms of the GNU General Public License version 2 only, as
   60.10 + * published by the Free Software Foundation.
   60.11 + *
   60.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   60.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   60.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   60.15 + * version 2 for more details (a copy is included in the LICENSE file that
   60.16 + * accompanied this code).
   60.17 + *
   60.18 + * You should have received a copy of the GNU General Public License version
   60.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   60.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   60.21 + *
   60.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   60.23 + * or visit www.oracle.com if you need additional information or have any
   60.24 + * questions.
   60.25 + *
   60.26 + */
   60.27 +
   60.28 +#ifndef SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
   60.29 +#define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
   60.30 +
   60.31 +#include "oops/instanceKlass.hpp"
   60.32 +
   60.33 +// An instanceMirrorKlass is a specialized instanceKlass for
   60.34 +// java.lang.Class instances.  These instances are special because
   60.35 +// they contain the static fields of the class in addition to the
   60.36 +// normal fields of Class.  This means they are variable sized
   60.37 +// instances and need special logic for computing their size and for
   60.38 +// iteration of their oops.
   60.39 +
   60.40 +
   60.41 +class instanceMirrorKlass: public instanceKlass {
   60.42 + private:
   60.43 +  static int _offset_of_static_fields;
   60.44 +
   60.45 + public:
   60.46 +  // Type testing
   60.47 +  bool oop_is_instanceMirror() const             { return true; }
   60.48 +
   60.49 +  // Casting from klassOop
   60.50 +  static instanceMirrorKlass* cast(klassOop k) {
   60.51 +    assert(k->klass_part()->oop_is_instanceMirror(), "cast to instanceMirrorKlass");
   60.52 +    return (instanceMirrorKlass*) k->klass_part();
   60.53 +  }
   60.54 +
   60.55 +  // Returns the size of the instance including the extra static fields.
   60.56 +  virtual int oop_size(oop obj) const;
   60.57 +
   60.58 +  // Static field offset is an offset into the Heap, should be converted by
   60.59 +  // based on UseCompressedOop for traversal
   60.60 +  static HeapWord* start_of_static_fields(oop obj) {
   60.61 +    return (HeapWord*)((intptr_t)obj + offset_of_static_fields());
   60.62 +  }
   60.63 +
   60.64 +  static void init_offset_of_static_fields() {
   60.65 +    // Cache the offset of the static fields in the Class instance
   60.66 +    assert(_offset_of_static_fields == 0, "once");
   60.67 +    _offset_of_static_fields = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
   60.68 +  }
   60.69 +
   60.70 +  static int offset_of_static_fields() {
   60.71 +    return _offset_of_static_fields;
   60.72 +  }
   60.73 +
   60.74 +  int compute_static_oop_field_count(oop obj);
   60.75 +
   60.76 +  // Given a Klass return the size of the instance
   60.77 +  int instance_size(KlassHandle k);
   60.78 +
   60.79 +  // allocation
   60.80 +  DEFINE_ALLOCATE_PERMANENT(instanceMirrorKlass);
   60.81 +  instanceOop allocate_instance(KlassHandle k, TRAPS);
   60.82 +
   60.83 +  // Garbage collection
   60.84 +  int  oop_adjust_pointers(oop obj);
   60.85 +  void oop_follow_contents(oop obj);
   60.86 +
   60.87 +  // Parallel Scavenge and Parallel Old
   60.88 +  PARALLEL_GC_DECLS
   60.89 +
   60.90 +  int oop_oop_iterate(oop obj, OopClosure* blk) {
   60.91 +    return oop_oop_iterate_v(obj, blk);
   60.92 +  }
   60.93 +  int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
   60.94 +    return oop_oop_iterate_v_m(obj, blk, mr);
   60.95 +  }
   60.96 +
   60.97 +#define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)           \
   60.98 +  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);                       \
   60.99 +  int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
  60.100 +
  60.101 +  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
  60.102 +  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
  60.103 +
  60.104 +#ifndef SERIALGC
  60.105 +#define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \
  60.106 +  int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
  60.107 +
  60.108 +  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
  60.109 +  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
  60.110 +#endif // !SERIALGC
  60.111 +};
  60.112 +
  60.113 +#endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
    61.1 --- a/src/share/vm/oops/klass.hpp	Fri Mar 18 13:28:33 2011 -0700
    61.2 +++ b/src/share/vm/oops/klass.hpp	Thu Mar 24 23:00:27 2011 -0700
    61.3 @@ -1,5 +1,5 @@
    61.4  /*
    61.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    61.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    61.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    61.8   *
    61.9   * This code is free software; you can redistribute it and/or modify it
   61.10 @@ -577,6 +577,7 @@
   61.11   public:
   61.12    // type testing operations
   61.13    virtual bool oop_is_instance_slow()       const { return false; }
   61.14 +  virtual bool oop_is_instanceMirror()      const { return false; }
   61.15    virtual bool oop_is_instanceRef()         const { return false; }
   61.16    virtual bool oop_is_array()               const { return false; }
   61.17    virtual bool oop_is_objArray_slow()       const { return false; }
   61.18 @@ -811,4 +812,8 @@
   61.19  #endif
   61.20  };
   61.21  
   61.22 +
   61.23 +inline oop klassOopDesc::java_mirror() const                        { return klass_part()->java_mirror(); }
   61.24 +
   61.25 +
   61.26  #endif // SHARE_VM_OOPS_KLASS_HPP
    62.1 --- a/src/share/vm/oops/klassKlass.cpp	Fri Mar 18 13:28:33 2011 -0700
    62.2 +++ b/src/share/vm/oops/klassKlass.cpp	Thu Mar 24 23:00:27 2011 -0700
    62.3 @@ -41,6 +41,10 @@
    62.4  #include "oops/typeArrayKlass.hpp"
    62.5  #include "runtime/handles.inline.hpp"
    62.6  #ifndef SERIALGC
    62.7 +#include "gc_implementation/parNew/parOopClosures.inline.hpp"
    62.8 +#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
    62.9 +#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
   62.10 +#include "memory/cardTableRS.hpp"
   62.11  #include "oops/oop.pcgc.inline.hpp"
   62.12  #endif
   62.13  
   62.14 @@ -175,6 +179,12 @@
   62.15  
   62.16  #ifndef SERIALGC
   62.17  void klassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
   62.18 +  Klass* k = Klass::cast(klassOop(obj));
   62.19 +
   62.20 +  oop* p = k->adr_java_mirror();
   62.21 +  if (PSScavenge::should_scavenge(p)) {
   62.22 +    pm->claim_or_forward_depth(p);
   62.23 +  }
   62.24  }
   62.25  
   62.26  int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
   62.27 @@ -233,7 +243,7 @@
   62.28  
   62.29    if (k->java_mirror() != NULL || (k->oop_is_instance() && instanceKlass::cast(klassOop(obj))->is_loaded())) {
   62.30      guarantee(k->java_mirror() != NULL,          "should be allocated");
   62.31 -    guarantee(k->java_mirror()->is_perm(),       "should be in permspace");
   62.32 +    guarantee(k->java_mirror()->is_perm() || !JavaObjectsInPerm,       "should be in permspace");
   62.33      guarantee(k->java_mirror()->is_instance(),   "should be instance");
   62.34    }
   62.35  }
    63.1 --- a/src/share/vm/oops/klassOop.hpp	Fri Mar 18 13:28:33 2011 -0700
    63.2 +++ b/src/share/vm/oops/klassOop.hpp	Thu Mar 24 23:00:27 2011 -0700
    63.3 @@ -1,5 +1,5 @@
    63.4  /*
    63.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    63.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    63.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    63.8   *
    63.9   * This code is free software; you can redistribute it and/or modify it
   63.10 @@ -45,7 +45,73 @@
   63.11    static int klass_part_offset_in_bytes()        { return sizeof(klassOopDesc); }
   63.12  
   63.13    // returns the Klass part containing dispatching behavior
   63.14 -  Klass* klass_part()                            { return (Klass*)((address)this + klass_part_offset_in_bytes()); }
   63.15 +  Klass* klass_part() const                      { return (Klass*)((address)this + klass_part_offset_in_bytes()); }
   63.16 +
   63.17 +  // Convenience wrapper
   63.18 +  inline oop java_mirror() const;
   63.19 +
   63.20 + private:
   63.21 +  // These have no implementation since klassOop should never be accessed in this fashion
   63.22 +  oop obj_field(int offset) const;
   63.23 +  void obj_field_put(int offset, oop value);
   63.24 +  void obj_field_raw_put(int offset, oop value);
   63.25 +
   63.26 +  jbyte byte_field(int offset) const;
   63.27 +  void byte_field_put(int offset, jbyte contents);
   63.28 +
   63.29 +  jchar char_field(int offset) const;
   63.30 +  void char_field_put(int offset, jchar contents);
   63.31 +
   63.32 +  jboolean bool_field(int offset) const;
   63.33 +  void bool_field_put(int offset, jboolean contents);
   63.34 +
   63.35 +  jint int_field(int offset) const;
   63.36 +  void int_field_put(int offset, jint contents);
   63.37 +
   63.38 +  jshort short_field(int offset) const;
   63.39 +  void short_field_put(int offset, jshort contents);
   63.40 +
   63.41 +  jlong long_field(int offset) const;
   63.42 +  void long_field_put(int offset, jlong contents);
   63.43 +
   63.44 +  jfloat float_field(int offset) const;
   63.45 +  void float_field_put(int offset, jfloat contents);
   63.46 +
   63.47 +  jdouble double_field(int offset) const;
   63.48 +  void double_field_put(int offset, jdouble contents);
   63.49 +
   63.50 +  address address_field(int offset) const;
   63.51 +  void address_field_put(int offset, address contents);
   63.52 +
   63.53 +  oop obj_field_acquire(int offset) const;
   63.54 +  void release_obj_field_put(int offset, oop value);
   63.55 +
   63.56 +  jbyte byte_field_acquire(int offset) const;
   63.57 +  void release_byte_field_put(int offset, jbyte contents);
   63.58 +
   63.59 +  jchar char_field_acquire(int offset) const;
   63.60 +  void release_char_field_put(int offset, jchar contents);
   63.61 +
   63.62 +  jboolean bool_field_acquire(int offset) const;
   63.63 +  void release_bool_field_put(int offset, jboolean contents);
   63.64 +
   63.65 +  jint int_field_acquire(int offset) const;
   63.66 +  void release_int_field_put(int offset, jint contents);
   63.67 +
   63.68 +  jshort short_field_acquire(int offset) const;
   63.69 +  void release_short_field_put(int offset, jshort contents);
   63.70 +
   63.71 +  jlong long_field_acquire(int offset) const;
   63.72 +  void release_long_field_put(int offset, jlong contents);
   63.73 +
   63.74 +  jfloat float_field_acquire(int offset) const;
   63.75 +  void release_float_field_put(int offset, jfloat contents);
   63.76 +
   63.77 +  jdouble double_field_acquire(int offset) const;
   63.78 +  void release_double_field_put(int offset, jdouble contents);
   63.79 +
   63.80 +  address address_field_acquire(int offset) const;
   63.81 +  void release_address_field_put(int offset, address contents);
   63.82  };
   63.83  
   63.84  #endif // SHARE_VM_OOPS_KLASSOOP_HPP
    64.1 --- a/src/share/vm/oops/klassVtable.cpp	Fri Mar 18 13:28:33 2011 -0700
    64.2 +++ b/src/share/vm/oops/klassVtable.cpp	Thu Mar 24 23:00:27 2011 -0700
    64.3 @@ -1095,7 +1095,7 @@
    64.4    itableOffsetEntry* ioe = (itableOffsetEntry*)klass->start_of_itable();
    64.5    itableMethodEntry* ime = (itableMethodEntry*)(ioe + nof_interfaces);
    64.6    intptr_t* end               = klass->end_of_itable();
    64.7 -  assert((oop*)(ime + nof_methods) <= (oop*)klass->start_of_static_fields(), "wrong offset calculation (1)");
    64.8 +  assert((oop*)(ime + nof_methods) <= (oop*)klass->start_of_nonstatic_oop_maps(), "wrong offset calculation (1)");
    64.9    assert((oop*)(end) == (oop*)(ime + nof_methods),                      "wrong offset calculation (2)");
   64.10  
   64.11    // Visit all interfaces and initialize itable offset table
    65.1 --- a/src/share/vm/oops/objArrayKlassKlass.cpp	Fri Mar 18 13:28:33 2011 -0700
    65.2 +++ b/src/share/vm/oops/objArrayKlassKlass.cpp	Thu Mar 24 23:00:27 2011 -0700
    65.3 @@ -31,6 +31,13 @@
    65.4  #include "oops/objArrayKlassKlass.hpp"
    65.5  #include "oops/oop.inline.hpp"
    65.6  #include "oops/oop.inline2.hpp"
    65.7 +#ifndef SERIALGC
    65.8 +#include "gc_implementation/parNew/parOopClosures.inline.hpp"
    65.9 +#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
   65.10 +#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
   65.11 +#include "memory/cardTableRS.hpp"
   65.12 +#include "oops/oop.pcgc.inline.hpp"
   65.13 +#endif
   65.14  
   65.15  klassOop objArrayKlassKlass::create_klass(TRAPS) {
   65.16    objArrayKlassKlass o;
   65.17 @@ -236,12 +243,23 @@
   65.18    addr = oak->bottom_klass_addr();
   65.19    if (mr.contains(addr)) blk->do_oop(addr);
   65.20  
   65.21 -  return arrayKlassKlass::oop_oop_iterate(obj, blk);
   65.22 +  return arrayKlassKlass::oop_oop_iterate_m(obj, blk, mr);
   65.23  }
   65.24  
   65.25  #ifndef SERIALGC
   65.26  void objArrayKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
   65.27    assert(obj->blueprint()->oop_is_objArrayKlass(),"must be an obj array klass");
   65.28 +  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
   65.29 +  oop* p = oak->element_klass_addr();
   65.30 +  if (PSScavenge::should_scavenge(p)) {
   65.31 +    pm->claim_or_forward_depth(p);
   65.32 +  }
   65.33 +  p = oak->bottom_klass_addr();
   65.34 +  if (PSScavenge::should_scavenge(p)) {
   65.35 +    pm->claim_or_forward_depth(p);
   65.36 +  }
   65.37 +
   65.38 +  arrayKlassKlass::oop_push_contents(pm, obj);
   65.39  }
   65.40  
   65.41  int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
   65.42 @@ -287,7 +305,7 @@
   65.43  // Verification
   65.44  
   65.45  void objArrayKlassKlass::oop_verify_on(oop obj, outputStream* st) {
   65.46 -  klassKlass::oop_verify_on(obj, st);
   65.47 +  arrayKlassKlass::oop_verify_on(obj, st);
   65.48    objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
   65.49    guarantee(oak->element_klass()->is_perm(),  "should be in permspace");
   65.50    guarantee(oak->element_klass()->is_klass(), "should be klass");
    66.1 --- a/src/share/vm/oops/oop.hpp	Fri Mar 18 13:28:33 2011 -0700
    66.2 +++ b/src/share/vm/oops/oop.hpp	Thu Mar 24 23:00:27 2011 -0700
    66.3 @@ -129,6 +129,7 @@
    66.4  
    66.5    // type test operations (inlined in oop.inline.h)
    66.6    bool is_instance()           const;
    66.7 +  bool is_instanceMirror()     const;
    66.8    bool is_instanceRef()        const;
    66.9    bool is_array()              const;
   66.10    bool is_objArray()           const;
    67.1 --- a/src/share/vm/oops/oop.inline.hpp	Fri Mar 18 13:28:33 2011 -0700
    67.2 +++ b/src/share/vm/oops/oop.inline.hpp	Thu Mar 24 23:00:27 2011 -0700
    67.3 @@ -1,5 +1,5 @@
    67.4  /*
    67.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    67.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    67.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    67.8   *
    67.9   * This code is free software; you can redistribute it and/or modify it
   67.10 @@ -141,6 +141,7 @@
   67.11  inline bool oopDesc::is_a(klassOop k)        const { return blueprint()->is_subtype_of(k); }
   67.12  
   67.13  inline bool oopDesc::is_instance()           const { return blueprint()->oop_is_instance(); }
   67.14 +inline bool oopDesc::is_instanceMirror()     const { return blueprint()->oop_is_instanceMirror(); }
   67.15  inline bool oopDesc::is_instanceRef()        const { return blueprint()->oop_is_instanceRef(); }
   67.16  inline bool oopDesc::is_array()              const { return blueprint()->oop_is_array(); }
   67.17  inline bool oopDesc::is_objArray()           const { return blueprint()->oop_is_objArray(); }
   67.18 @@ -399,7 +400,7 @@
   67.19  
   67.20  inline int oopDesc::size_given_klass(Klass* klass)  {
   67.21    int lh = klass->layout_helper();
   67.22 -  int s  = lh >> LogHeapWordSize;  // deliver size scaled by wordSize
   67.23 +  int s;
   67.24  
   67.25    // lh is now a value computed at class initialization that may hint
   67.26    // at the size.  For instances, this is positive and equal to the
   67.27 @@ -412,7 +413,13 @@
   67.28    // alive or dead.  So the speed here is equal in importance to the
   67.29    // speed of allocation.
   67.30  
   67.31 -  if (lh <= Klass::_lh_neutral_value) {
   67.32 +  if (lh > Klass::_lh_neutral_value) {
   67.33 +    if (!Klass::layout_helper_needs_slow_path(lh)) {
   67.34 +      s = lh >> LogHeapWordSize;  // deliver size scaled by wordSize
   67.35 +    } else {
   67.36 +      s = klass->oop_size(this);
   67.37 +    }
   67.38 +  } else if (lh <= Klass::_lh_neutral_value) {
   67.39      // The most common case is instances; fall through if so.
   67.40      if (lh < Klass::_lh_neutral_value) {
   67.41        // Second most common case is arrays.  We have to fetch the
    68.1 --- a/src/share/vm/oops/oopsHierarchy.hpp	Fri Mar 18 13:28:33 2011 -0700
    68.2 +++ b/src/share/vm/oops/oopsHierarchy.hpp	Thu Mar 24 23:00:27 2011 -0700
    68.3 @@ -1,5 +1,5 @@
    68.4  /*
    68.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    68.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    68.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    68.8   *
    68.9   * This code is free software; you can redistribute it and/or modify it
   68.10 @@ -174,6 +174,7 @@
   68.11  
   68.12  class Klass;
   68.13  class   instanceKlass;
   68.14 +class     instanceMirrorKlass;
   68.15  class     instanceRefKlass;
   68.16  class   methodKlass;
   68.17  class   constMethodKlass;
    69.1 --- a/src/share/vm/opto/compile.cpp	Fri Mar 18 13:28:33 2011 -0700
    69.2 +++ b/src/share/vm/opto/compile.cpp	Thu Mar 24 23:00:27 2011 -0700
    69.3 @@ -1,5 +1,5 @@
    69.4  /*
    69.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    69.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    69.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    69.8   *
    69.9   * This code is free software; you can redistribute it and/or modify it
   69.10 @@ -1202,11 +1202,15 @@
   69.11    // Oop pointers need some flattening
   69.12    const TypeInstPtr *to = tj->isa_instptr();
   69.13    if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) {
   69.14 +    ciInstanceKlass *k = to->klass()->as_instance_klass();
   69.15      if( ptr == TypePtr::Constant ) {
   69.16 -      // No constant oop pointers (such as Strings); they alias with
   69.17 -      // unknown strings.
   69.18 -      assert(!is_known_inst, "not scalarizable allocation");
   69.19 -      tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
   69.20 +      if (to->klass() != ciEnv::current()->Class_klass() ||
   69.21 +          offset < k->size_helper() * wordSize) {
   69.22 +        // No constant oop pointers (such as Strings); they alias with
   69.23 +        // unknown strings.
   69.24 +        assert(!is_known_inst, "not scalarizable allocation");
   69.25 +        tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
   69.26 +      }
   69.27      } else if( is_known_inst ) {
   69.28        tj = to; // Keep NotNull and klass_is_exact for instance type
   69.29      } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
   69.30 @@ -1216,7 +1220,6 @@
   69.31        tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
   69.32      }
   69.33      // Canonicalize the holder of this field
   69.34 -    ciInstanceKlass *k = to->klass()->as_instance_klass();
   69.35      if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) {
   69.36        // First handle header references such as a LoadKlassNode, even if the
   69.37        // object's klass is unloaded at compile time (4965979).
   69.38 @@ -1224,9 +1227,13 @@
   69.39          tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset);
   69.40        }
   69.41      } else if (offset < 0 || offset >= k->size_helper() * wordSize) {
   69.42 -      to = NULL;
   69.43 -      tj = TypeOopPtr::BOTTOM;
   69.44 -      offset = tj->offset();
   69.45 +      // Static fields are in the space above the normal instance
   69.46 +      // fields in the java.lang.Class instance.
   69.47 +      if (to->klass() != ciEnv::current()->Class_klass()) {
   69.48 +        to = NULL;
   69.49 +        tj = TypeOopPtr::BOTTOM;
   69.50 +        offset = tj->offset();
   69.51 +      }
   69.52      } else {
   69.53        ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset);
   69.54        if (!k->equals(canonical_holder) || tj->offset() != offset) {
   69.55 @@ -1399,7 +1406,7 @@
   69.56  
   69.57  
   69.58  //--------------------------------find_alias_type------------------------------
   69.59 -Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create) {
   69.60 +Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create, ciField* original_field) {
   69.61    if (_AliasLevel == 0)
   69.62      return alias_type(AliasIdxBot);
   69.63  
   69.64 @@ -1464,22 +1471,28 @@
   69.65      // but the base pointer type is not distinctive enough to identify
   69.66      // references into JavaThread.)
   69.67  
   69.68 -    // Check for final instance fields.
   69.69 +    // Check for final fields.
   69.70      const TypeInstPtr* tinst = flat->isa_instptr();
   69.71      if (tinst && tinst->offset() >= instanceOopDesc::base_offset_in_bytes()) {
   69.72 -      ciInstanceKlass *k = tinst->klass()->as_instance_klass();
   69.73 -      ciField* field = k->get_field_by_offset(tinst->offset(), false);
   69.74 +      ciField* field;
   69.75 +      if (tinst->const_oop() != NULL &&
   69.76 +          tinst->klass() == ciEnv::current()->Class_klass() &&
   69.77 +          tinst->offset() >= (tinst->klass()->as_instance_klass()->size_helper() * wordSize)) {
   69.78 +        // static field
   69.79 +        ciInstanceKlass* k = tinst->const_oop()->as_instance()->java_lang_Class_klass()->as_instance_klass();
   69.80 +        field = k->get_field_by_offset(tinst->offset(), true);
   69.81 +      } else {
   69.82 +        ciInstanceKlass *k = tinst->klass()->as_instance_klass();
   69.83 +        field = k->get_field_by_offset(tinst->offset(), false);
   69.84 +      }
   69.85 +      assert(field == NULL ||
   69.86 +             original_field == NULL ||
   69.87 +             (field->holder() == original_field->holder() &&
   69.88 +              field->offset() == original_field->offset() &&
   69.89 +              field->is_static() == original_field->is_static()), "wrong field?");
   69.90        // Set field() and is_rewritable() attributes.
   69.91        if (field != NULL)  alias_type(idx)->set_field(field);
   69.92      }
   69.93 -    const TypeKlassPtr* tklass = flat->isa_klassptr();
   69.94 -    // Check for final static fields.
   69.95 -    if (tklass && tklass->klass()->is_instance_klass()) {
   69.96 -      ciInstanceKlass *k = tklass->klass()->as_instance_klass();
   69.97 -      ciField* field = k->get_field_by_offset(tklass->offset(), true);
   69.98 -      // Set field() and is_rewritable() attributes.
   69.99 -      if (field != NULL)   alias_type(idx)->set_field(field);
  69.100 -    }
  69.101    }
  69.102  
  69.103    // Fill the cache for next time.
  69.104 @@ -1502,10 +1515,10 @@
  69.105  Compile::AliasType* Compile::alias_type(ciField* field) {
  69.106    const TypeOopPtr* t;
  69.107    if (field->is_static())
  69.108 -    t = TypeKlassPtr::make(field->holder());
  69.109 +    t = TypeInstPtr::make(field->holder()->java_mirror());
  69.110    else
  69.111      t = TypeOopPtr::make_from_klass_raw(field->holder());
  69.112 -  AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()));
  69.113 +  AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()), field);
  69.114    assert(field->is_final() == !atp->is_rewritable(), "must get the rewritable bits correct");
  69.115    return atp;
  69.116  }
  69.117 @@ -1522,7 +1535,7 @@
  69.118    if (adr_type == NULL)             return true;
  69.119    if (adr_type == TypePtr::BOTTOM)  return true;
  69.120  
  69.121 -  return find_alias_type(adr_type, true) != NULL;
  69.122 +  return find_alias_type(adr_type, true, NULL) != NULL;
  69.123  }
  69.124  
  69.125  //-----------------------------must_alias--------------------------------------
    70.1 --- a/src/share/vm/opto/compile.hpp	Fri Mar 18 13:28:33 2011 -0700
    70.2 +++ b/src/share/vm/opto/compile.hpp	Thu Mar 24 23:00:27 2011 -0700
    70.3 @@ -1,5 +1,5 @@
    70.4  /*
    70.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    70.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    70.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    70.8   *
    70.9   * This code is free software; you can redistribute it and/or modify it
   70.10 @@ -596,7 +596,7 @@
   70.11    }
   70.12  
   70.13    AliasType*        alias_type(int                idx)  { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
   70.14 -  AliasType*        alias_type(const TypePtr* adr_type) { return find_alias_type(adr_type, false); }
   70.15 +  AliasType*        alias_type(const TypePtr* adr_type, ciField* field = NULL) { return find_alias_type(adr_type, false, field); }
   70.16    bool         have_alias_type(const TypePtr* adr_type);
   70.17    AliasType*        alias_type(ciField*         field);
   70.18  
   70.19 @@ -835,7 +835,7 @@
   70.20    void grow_alias_types();
   70.21    AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
   70.22    const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
   70.23 -  AliasType* find_alias_type(const TypePtr* adr_type, bool no_create);
   70.24 +  AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field);
   70.25  
   70.26    void verify_top(Node*) const PRODUCT_RETURN;
   70.27  
    71.1 --- a/src/share/vm/opto/library_call.cpp	Fri Mar 18 13:28:33 2011 -0700
    71.2 +++ b/src/share/vm/opto/library_call.cpp	Thu Mar 24 23:00:27 2011 -0700
    71.3 @@ -1116,7 +1116,7 @@
    71.4    Node* sourcea       = basic_plus_adr(string_object, string_object, value_offset);
    71.5    Node* source        = make_load(no_ctrl, sourcea, source_type, T_OBJECT, string_type->add_offset(value_offset));
    71.6  
    71.7 -  Node* target = _gvn.transform( makecon(TypeOopPtr::make_from_constant(target_array)) );
    71.8 +  Node* target = _gvn.transform( makecon(TypeOopPtr::make_from_constant(target_array, true)) );
    71.9    jint target_length = target_array->length();
   71.10    const TypeAry* target_array_type = TypeAry::make(TypeInt::CHAR, TypeInt::make(0, target_length, Type::WidenMin));
   71.11    const TypeAryPtr* target_type = TypeAryPtr::make(TypePtr::BotPTR, target_array_type, target_array->klass(), true, Type::OffsetBot);
    72.1 --- a/src/share/vm/opto/memnode.cpp	Fri Mar 18 13:28:33 2011 -0700
    72.2 +++ b/src/share/vm/opto/memnode.cpp	Thu Mar 24 23:00:27 2011 -0700
    72.3 @@ -1573,9 +1573,9 @@
    72.4              return TypeInt::make(constant.as_int());
    72.5            } else if (constant.basic_type() == T_ARRAY) {
    72.6              if (adr->bottom_type()->is_ptr_to_narrowoop()) {
    72.7 -              return TypeNarrowOop::make_from_constant(constant.as_object());
    72.8 +              return TypeNarrowOop::make_from_constant(constant.as_object(), true);
    72.9              } else {
   72.10 -              return TypeOopPtr::make_from_constant(constant.as_object());
   72.11 +              return TypeOopPtr::make_from_constant(constant.as_object(), true);
   72.12              }
   72.13            }
   72.14          }
    73.1 --- a/src/share/vm/opto/parse.hpp	Fri Mar 18 13:28:33 2011 -0700
    73.2 +++ b/src/share/vm/opto/parse.hpp	Thu Mar 24 23:00:27 2011 -0700
    73.3 @@ -1,5 +1,5 @@
    73.4  /*
    73.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    73.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    73.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    73.8   *
    73.9   * This code is free software; you can redistribute it and/or modify it
   73.10 @@ -483,8 +483,8 @@
   73.11    bool static_field_ok_in_clinit(ciField *field, ciMethod *method);
   73.12  
   73.13    // common code for actually performing the load or store
   73.14 -  void do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field);
   73.15 -  void do_put_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field);
   73.16 +  void do_get_xxx(Node* obj, ciField* field, bool is_field);
   73.17 +  void do_put_xxx(Node* obj, ciField* field, bool is_field);
   73.18  
   73.19    // loading from a constant field or the constant pool
   73.20    // returns false if push failed (non-perm field constants only, not ldcs)
    74.1 --- a/src/share/vm/opto/parse3.cpp	Fri Mar 18 13:28:33 2011 -0700
    74.2 +++ b/src/share/vm/opto/parse3.cpp	Thu Mar 24 23:00:27 2011 -0700
    74.3 @@ -112,29 +112,31 @@
    74.4      // Compile-time detect of null-exception?
    74.5      if (stopped())  return;
    74.6  
    74.7 +#ifdef ASSERT
    74.8      const TypeInstPtr *tjp = TypeInstPtr::make(TypePtr::NotNull, iter().get_declared_field_holder());
    74.9      assert(_gvn.type(obj)->higher_equal(tjp), "cast_up is no longer needed");
   74.10 +#endif
   74.11  
   74.12      if (is_get) {
   74.13        --_sp;  // pop receiver before getting
   74.14 -      do_get_xxx(tjp, obj, field, is_field);
   74.15 +      do_get_xxx(obj, field, is_field);
   74.16      } else {
   74.17 -      do_put_xxx(tjp, obj, field, is_field);
   74.18 +      do_put_xxx(obj, field, is_field);
   74.19        --_sp;  // pop receiver after putting
   74.20      }
   74.21    } else {
   74.22 -    const TypeKlassPtr* tkp = TypeKlassPtr::make(field_holder);
   74.23 -    obj = _gvn.makecon(tkp);
   74.24 +    const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
   74.25 +    obj = _gvn.makecon(tip);
   74.26      if (is_get) {
   74.27 -      do_get_xxx(tkp, obj, field, is_field);
   74.28 +      do_get_xxx(obj, field, is_field);
   74.29      } else {
   74.30 -      do_put_xxx(tkp, obj, field, is_field);
   74.31 +      do_put_xxx(obj, field, is_field);
   74.32      }
   74.33    }
   74.34  }
   74.35  
   74.36  
   74.37 -void Parse::do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
   74.38 +void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
   74.39    // Does this field have a constant value?  If so, just push the value.
   74.40    if (field->is_constant()) {
   74.41      if (field->is_static()) {
   74.42 @@ -231,7 +233,7 @@
   74.43    }
   74.44  }
   74.45  
   74.46 -void Parse::do_put_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
   74.47 +void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
   74.48    bool is_vol = field->is_volatile();
   74.49    // If reference is volatile, prevent following memory ops from
   74.50    // floating down past the volatile write.  Also prevents commoning
    75.1 --- a/src/share/vm/opto/stringopts.cpp	Fri Mar 18 13:28:33 2011 -0700
    75.2 +++ b/src/share/vm/opto/stringopts.cpp	Thu Mar 24 23:00:27 2011 -0700
    75.3 @@ -910,7 +910,7 @@
    75.4        ciObject* con = field->constant_value().as_object();
    75.5        // Do not "join" in the previous type; it doesn't add value,
    75.6        // and may yield a vacuous result if the field is of interface type.
    75.7 -      type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
    75.8 +      type = TypeOopPtr::make_from_constant(con, true)->isa_oopptr();
    75.9        assert(type != NULL, "field singleton type must be consistent");
   75.10      } else {
   75.11        type = TypeOopPtr::make_from_klass(field_klass->as_klass());
    76.1 --- a/src/share/vm/opto/type.cpp	Fri Mar 18 13:28:33 2011 -0700
    76.2 +++ b/src/share/vm/opto/type.cpp	Thu Mar 24 23:00:27 2011 -0700
    76.3 @@ -32,6 +32,7 @@
    76.4  #include "memory/oopFactory.hpp"
    76.5  #include "memory/resourceArea.hpp"
    76.6  #include "oops/instanceKlass.hpp"
    76.7 +#include "oops/instanceMirrorKlass.hpp"
    76.8  #include "oops/klassKlass.hpp"
    76.9  #include "oops/objArrayKlass.hpp"
   76.10  #include "oops/typeArrayKlass.hpp"
   76.11 @@ -2241,43 +2242,49 @@
   76.12      } else if (this->isa_aryptr()) {
   76.13        _is_ptr_to_narrowoop = (klass()->is_obj_array_klass() &&
   76.14                               _offset != arrayOopDesc::length_offset_in_bytes());
   76.15 -    } else if (klass() == ciEnv::current()->Class_klass() &&
   76.16 -               (_offset == java_lang_Class::klass_offset_in_bytes() ||
   76.17 -                _offset == java_lang_Class::array_klass_offset_in_bytes())) {
   76.18 -      // Special hidden fields from the Class.
   76.19 -      assert(this->isa_instptr(), "must be an instance ptr.");
   76.20 -      _is_ptr_to_narrowoop = true;
   76.21      } else if (klass()->is_instance_klass()) {
   76.22        ciInstanceKlass* ik = klass()->as_instance_klass();
   76.23        ciField* field = NULL;
   76.24        if (this->isa_klassptr()) {
   76.25 -        // Perm objects don't use compressed references, except for
   76.26 -        // static fields which are currently compressed.
   76.27 -        field = ik->get_field_by_offset(_offset, true);
   76.28 -        if (field != NULL) {
   76.29 -          BasicType basic_elem_type = field->layout_type();
   76.30 -          _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
   76.31 -                                  basic_elem_type == T_ARRAY);
   76.32 -        }
   76.33 +        // Perm objects don't use compressed references
   76.34        } else if (_offset == OffsetBot || _offset == OffsetTop) {
   76.35          // unsafe access
   76.36          _is_ptr_to_narrowoop = true;
   76.37        } else { // exclude unsafe ops
   76.38          assert(this->isa_instptr(), "must be an instance ptr.");
   76.39 -        // Field which contains a compressed oop references.
   76.40 -        field = ik->get_field_by_offset(_offset, false);
   76.41 -        if (field != NULL) {
   76.42 +
   76.43 +        if (klass() == ciEnv::current()->Class_klass() &&
   76.44 +            (_offset == java_lang_Class::klass_offset_in_bytes() ||
   76.45 +             _offset == java_lang_Class::array_klass_offset_in_bytes())) {
   76.46 +          // Special hidden fields from the Class.
   76.47 +          assert(this->isa_instptr(), "must be an instance ptr.");
   76.48 +          _is_ptr_to_narrowoop = true;
   76.49 +        } else if (klass() == ciEnv::current()->Class_klass() &&
   76.50 +                   _offset >= instanceMirrorKlass::offset_of_static_fields()) {
   76.51 +          // Static fields
   76.52 +          assert(o != NULL, "must be constant");
   76.53 +          ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
   76.54 +          ciField* field = k->get_field_by_offset(_offset, true);
   76.55 +          assert(field != NULL, "missing field");
   76.56            BasicType basic_elem_type = field->layout_type();
   76.57            _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
   76.58                                    basic_elem_type == T_ARRAY);
   76.59 -        } else if (klass()->equals(ciEnv::current()->Object_klass())) {
   76.60 -          // Compile::find_alias_type() cast exactness on all types to verify
   76.61 -          // that it does not affect alias type.
   76.62 -          _is_ptr_to_narrowoop = true;
   76.63          } else {
   76.64 -          // Type for the copy start in LibraryCallKit::inline_native_clone().
   76.65 -          assert(!klass_is_exact(), "only non-exact klass");
   76.66 -          _is_ptr_to_narrowoop = true;
   76.67 +          // Instance fields which contains a compressed oop references.
   76.68 +          field = ik->get_field_by_offset(_offset, false);
   76.69 +          if (field != NULL) {
   76.70 +            BasicType basic_elem_type = field->layout_type();
   76.71 +            _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
   76.72 +                                    basic_elem_type == T_ARRAY);
   76.73 +          } else if (klass()->equals(ciEnv::current()->Object_klass())) {
   76.74 +            // Compile::find_alias_type() cast exactness on all types to verify
   76.75 +            // that it does not affect alias type.
   76.76 +            _is_ptr_to_narrowoop = true;
   76.77 +          } else {
   76.78 +            // Type for the copy start in LibraryCallKit::inline_native_clone().
   76.79 +            assert(!klass_is_exact(), "only non-exact klass");
   76.80 +            _is_ptr_to_narrowoop = true;
   76.81 +          }
   76.82          }
   76.83        }
   76.84      }
    77.1 --- a/src/share/vm/opto/type.hpp	Fri Mar 18 13:28:33 2011 -0700
    77.2 +++ b/src/share/vm/opto/type.hpp	Thu Mar 24 23:00:27 2011 -0700
    77.3 @@ -988,8 +988,8 @@
    77.4  
    77.5    static const TypeNarrowOop *make( const TypePtr* type);
    77.6  
    77.7 -  static const TypeNarrowOop* make_from_constant(ciObject* con) {
    77.8 -    return make(TypeOopPtr::make_from_constant(con));
    77.9 +  static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
   77.10 +    return make(TypeOopPtr::make_from_constant(con, require_constant));
   77.11    }
   77.12  
   77.13    // returns the equivalent ptr type for this compressed pointer
    78.1 --- a/src/share/vm/prims/jni.cpp	Fri Mar 18 13:28:33 2011 -0700
    78.2 +++ b/src/share/vm/prims/jni.cpp	Thu Mar 24 23:00:27 2011 -0700
    78.3 @@ -1,5 +1,5 @@
    78.4  /*
    78.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    78.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    78.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    78.8   *
    78.9   * This code is free software; you can redistribute it and/or modify it
   78.10 @@ -1858,7 +1858,7 @@
   78.11      // Static field. The fieldID a JNIid specifying the field holder and the offset within the klassOop.
   78.12      JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID);
   78.13      assert(id->is_static_field_id(), "invalid static field id");
   78.14 -    found = instanceKlass::cast(id->holder())->find_local_field_from_offset(id->offset(), true, &fd);
   78.15 +    found = id->find_local_field(&fd);
   78.16    } else {
   78.17      // Non-static field. The fieldID is really the offset of the field within the instanceOop.
   78.18      int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID);
   78.19 @@ -1906,9 +1906,7 @@
   78.20    JNIid* id = instanceKlass::cast(fd.field_holder())->jni_id_for(fd.offset());
   78.21    debug_only(id->set_is_static_field_id();)
   78.22  
   78.23 -  debug_only(int first_offset = instanceKlass::cast(fd.field_holder())->offset_of_static_fields();)
   78.24 -  debug_only(int end_offset = first_offset + (instanceKlass::cast(fd.field_holder())->static_field_size() * wordSize);)
   78.25 -  assert(id->offset() >= first_offset && id->offset() < end_offset, "invalid static field offset");
   78.26 +  debug_only(id->verify(fd.field_holder()));
   78.27  
   78.28    ret = jfieldIDWorkaround::to_static_jfieldID(id);
   78.29    return ret;
   78.30 @@ -1928,7 +1926,7 @@
   78.31    if (JvmtiExport::should_post_field_access()) {
   78.32      JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true);
   78.33    }
   78.34 -  jobject ret = JNIHandles::make_local(id->holder()->obj_field(id->offset()));
   78.35 +  jobject ret = JNIHandles::make_local(id->holder()->java_mirror()->obj_field(id->offset()));
   78.36    DTRACE_PROBE1(hotspot_jni, GetStaticObjectField__return, ret);
   78.37    return ret;
   78.38  JNI_END
   78.39 @@ -1950,7 +1948,7 @@
   78.40    if (JvmtiExport::should_post_field_access()) { \
   78.41      JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \
   78.42    } \
   78.43 -  ret = id->holder()-> Fieldname##_field (id->offset()); \
   78.44 +  ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \
   78.45    return ret;\
   78.46  JNI_END
   78.47  
   78.48 @@ -1976,7 +1974,7 @@
   78.49      field_value.l = value;
   78.50      JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value);
   78.51    }
   78.52 -  id->holder()->obj_field_put(id->offset(), JNIHandles::resolve(value));
   78.53 +  id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value));
   78.54    DTRACE_PROBE(hotspot_jni, SetStaticObjectField__return);
   78.55  JNI_END
   78.56  
   78.57 @@ -1999,7 +1997,7 @@
   78.58      field_value.unionType = value; \
   78.59      JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \
   78.60    } \
   78.61 -  id->holder()-> Fieldname##_field_put (id->offset(), value); \
   78.62 +  id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \
   78.63    DTRACE_PROBE(hotspot_jni, SetStatic##Result##Field__return);\
   78.64  JNI_END
   78.65  
    79.1 --- a/src/share/vm/prims/jniCheck.cpp	Fri Mar 18 13:28:33 2011 -0700
    79.2 +++ b/src/share/vm/prims/jniCheck.cpp	Thu Mar 24 23:00:27 2011 -0700
    79.3 @@ -1,5 +1,5 @@
    79.4  /*
    79.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
    79.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
    79.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    79.8   *
    79.9   * This code is free software; you can redistribute it and/or modify it
   79.10 @@ -224,8 +224,7 @@
   79.11      ReportJNIFatalError(thr, fatal_wrong_static_field);
   79.12  
   79.13    /* check for proper field type */
   79.14 -  if (!instanceKlass::cast(f_oop)->find_local_field_from_offset(
   79.15 -          id->offset(), true, &fd))
   79.16 +  if (!id->find_local_field(&fd))
   79.17      ReportJNIFatalError(thr, fatal_static_field_not_found);
   79.18    if ((fd.field_type() != ftype) &&
   79.19        !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
    80.1 --- a/src/share/vm/prims/jvm.cpp	Fri Mar 18 13:28:33 2011 -0700
    80.2 +++ b/src/share/vm/prims/jvm.cpp	Thu Mar 24 23:00:27 2011 -0700
    80.3 @@ -1808,7 +1808,7 @@
    80.4      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index");
    80.5    }
    80.6    klassOop k = cp->klass_at(index, CHECK_NULL);
    80.7 -  return (jclass) JNIHandles::make_local(k->klass_part()->java_mirror());
    80.8 +  return (jclass) JNIHandles::make_local(k->java_mirror());
    80.9  }
   80.10  JVM_END
   80.11  
   80.12 @@ -1824,7 +1824,7 @@
   80.13    }
   80.14    klassOop k = constantPoolOopDesc::klass_at_if_loaded(cp, index);
   80.15    if (k == NULL) return NULL;
   80.16 -  return (jclass) JNIHandles::make_local(k->klass_part()->java_mirror());
   80.17 +  return (jclass) JNIHandles::make_local(k->java_mirror());
   80.18  }
   80.19  JVM_END
   80.20  
    81.1 --- a/src/share/vm/prims/jvmtiEnvBase.cpp	Fri Mar 18 13:28:33 2011 -0700
    81.2 +++ b/src/share/vm/prims/jvmtiEnvBase.cpp	Thu Mar 24 23:00:27 2011 -0700
    81.3 @@ -1,5 +1,5 @@
    81.4  /*
    81.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    81.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    81.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    81.8   *
    81.9   * This code is free software; you can redistribute it and/or modify it
   81.10 @@ -616,9 +616,7 @@
   81.11    bool found = false;
   81.12    if (jfieldIDWorkaround::is_static_jfieldID(field)) {
   81.13      JNIid* id = jfieldIDWorkaround::from_static_jfieldID(field);
   81.14 -    int offset = id->offset();
   81.15 -    klassOop holder = id->holder();
   81.16 -    found = instanceKlass::cast(holder)->find_local_field_from_offset(offset, true, fd);
   81.17 +    found = id->find_local_field(fd);
   81.18    } else {
   81.19      // Non-static field. The fieldID is really the offset of the field within the object.
   81.20      int offset = jfieldIDWorkaround::from_instance_jfieldID(k, field);
    82.1 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp	Fri Mar 18 13:28:33 2011 -0700
    82.2 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp	Thu Mar 24 23:00:27 2011 -0700
    82.3 @@ -3350,11 +3350,12 @@
    82.4  
    82.5    for (Klass *subk = ik->subklass(); subk != NULL;
    82.6         subk = subk->next_sibling()) {
    82.7 -    klassOop sub = subk->as_klassOop();
    82.8 -    instanceKlass *subik = (instanceKlass *)sub->klass_part();
    82.9 -
   82.10 -    // recursively do subclasses of the current subclass
   82.11 -    increment_class_counter(subik, THREAD);
   82.12 +    if (subk->oop_is_instance()) {
   82.13 +      // Only update instanceKlasses
   82.14 +      instanceKlass *subik = (instanceKlass*)subk;
   82.15 +      // recursively do subclasses of the current subclass
   82.16 +      increment_class_counter(subik, THREAD);
   82.17 +    }
   82.18    }
   82.19  }
   82.20  
    83.1 --- a/src/share/vm/prims/jvmtiTagMap.cpp	Fri Mar 18 13:28:33 2011 -0700
    83.2 +++ b/src/share/vm/prims/jvmtiTagMap.cpp	Thu Mar 24 23:00:27 2011 -0700
    83.3 @@ -1,5 +1,5 @@
    83.4  /*
    83.5 - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    83.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    83.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    83.8   *
    83.9   * This code is free software; you can redistribute it and/or modify it
   83.10 @@ -27,6 +27,7 @@
   83.11  #include "classfile/systemDictionary.hpp"
   83.12  #include "classfile/vmSymbols.hpp"
   83.13  #include "jvmtifiles/jvmtiEnv.hpp"
   83.14 +#include "oops/instanceMirrorKlass.hpp"
   83.15  #include "oops/objArrayKlass.hpp"
   83.16  #include "oops/oop.inline2.hpp"
   83.17  #include "prims/jvmtiEventController.hpp"
   83.18 @@ -2594,6 +2595,11 @@
   83.19      if (o->is_klass()) {
   83.20        klassOop k = (klassOop)o;
   83.21        o = Klass::cast(k)->java_mirror();
   83.22 +      if (o == NULL) {
   83.23 +        // Classes without mirrors don't correspond to real Java
   83.24 +        // classes so just ignore them.
   83.25 +        return;
   83.26 +      }
   83.27      } else {
   83.28  
   83.29        // SystemDictionary::always_strong_oops_do reports the application
   83.30 @@ -2834,10 +2840,10 @@
   83.31  
   83.32  // verify that a static oop field is in range
   83.33  static inline bool verify_static_oop(instanceKlass* ik,
   83.34 -                                     klassOop k, int offset) {
   83.35 -  address obj_p = (address)k + offset;
   83.36 -  address start = (address)ik->start_of_static_fields();
   83.37 -  address end = start + (ik->static_oop_field_size() * heapOopSize);
   83.38 +                                     oop mirror, int offset) {
   83.39 +  address obj_p = (address)mirror + offset;
   83.40 +  address start = (address)instanceMirrorKlass::start_of_static_fields(mirror);
   83.41 +  address end = start + (java_lang_Class::static_oop_field_count(mirror) * heapOopSize);
   83.42    assert(end >= start, "sanity check");
   83.43  
   83.44    if (obj_p >= start && obj_p < end) {
   83.45 @@ -2938,8 +2944,8 @@
   83.46        ClassFieldDescriptor* field = field_map->field_at(i);
   83.47        char type = field->field_type();
   83.48        if (!is_primitive_field_type(type)) {
   83.49 -        oop fld_o = k->obj_field(field->field_offset());
   83.50 -        assert(verify_static_oop(ik, k, field->field_offset()), "sanity check");
   83.51 +        oop fld_o = mirror->obj_field(field->field_offset());
   83.52 +        assert(verify_static_oop(ik, mirror, field->field_offset()), "sanity check");
   83.53          if (fld_o != NULL) {
   83.54            int slot = field->field_index();
   83.55            if (!CallbackInvoker::report_static_field_reference(mirror, fld_o, slot)) {
   83.56 @@ -2949,7 +2955,7 @@
   83.57          }
   83.58        } else {
   83.59           if (is_reporting_primitive_fields()) {
   83.60 -           address addr = (address)k + field->field_offset();
   83.61 +           address addr = (address)mirror + field->field_offset();
   83.62             int slot = field->field_index();
   83.63             if (!CallbackInvoker::report_primitive_static_field(mirror, slot, addr, type)) {
   83.64               delete field_map;
    84.1 --- a/src/share/vm/prims/unsafe.cpp	Fri Mar 18 13:28:33 2011 -0700
    84.2 +++ b/src/share/vm/prims/unsafe.cpp	Thu Mar 24 23:00:27 2011 -0700
    84.3 @@ -688,7 +688,7 @@
    84.4      THROW_0(vmSymbols::java_lang_IllegalArgumentException());
    84.5    }
    84.6  
    84.7 -  return JNIHandles::make_local(env, java_lang_Class::as_klassOop(mirror));
    84.8 +  return JNIHandles::make_local(env, mirror);
    84.9  UNSAFE_END
   84.10  
   84.11  //@deprecated
   84.12 @@ -706,7 +706,7 @@
   84.13    if (clazz == NULL) {
   84.14      THROW_0(vmSymbols::java_lang_NullPointerException());
   84.15    }
   84.16 -  return JNIHandles::make_local(env, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz)));
   84.17 +  return JNIHandles::make_local(env, JNIHandles::resolve_non_null(clazz));
   84.18  UNSAFE_END
   84.19  
   84.20  UNSAFE_ENTRY(void, Unsafe_EnsureClassInitialized(JNIEnv *env, jobject unsafe, jobject clazz))
    85.1 --- a/src/share/vm/runtime/arguments.cpp	Fri Mar 18 13:28:33 2011 -0700
    85.2 +++ b/src/share/vm/runtime/arguments.cpp	Thu Mar 24 23:00:27 2011 -0700
    85.3 @@ -2819,22 +2819,38 @@
    85.4  }
    85.5  
    85.6  void Arguments::set_shared_spaces_flags() {
    85.7 +  const bool must_share = DumpSharedSpaces || RequireSharedSpaces;
    85.8 +  const bool might_share = must_share || UseSharedSpaces;
    85.9 +
   85.10 +  // The string table is part of the shared archive so the size must match.
   85.11 +  if (!FLAG_IS_DEFAULT(StringTableSize)) {
   85.12 +    // Disable sharing.
   85.13 +    if (must_share) {
   85.14 +      warning("disabling shared archive %s because of non-default "
   85.15 +              "StringTableSize", DumpSharedSpaces ? "creation" : "use");
   85.16 +    }
   85.17 +    if (might_share) {
   85.18 +      FLAG_SET_DEFAULT(DumpSharedSpaces, false);
   85.19 +      FLAG_SET_DEFAULT(RequireSharedSpaces, false);
   85.20 +      FLAG_SET_DEFAULT(UseSharedSpaces, false);
   85.21 +    }
   85.22 +    return;
   85.23 +  }
   85.24 +
   85.25    // Check whether class data sharing settings conflict with GC, compressed oops
   85.26    // or page size, and fix them up.  Explicit sharing options override other
   85.27    // settings.
   85.28    const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode ||
   85.29      UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC ||
   85.30      UseCompressedOops || UseLargePages && FLAG_IS_CMDLINE(UseLargePages);
   85.31 -  const bool must_share = DumpSharedSpaces || RequireSharedSpaces;
   85.32 -  const bool might_share = must_share || UseSharedSpaces;
   85.33    if (cannot_share) {
   85.34      if (must_share) {
   85.35 -      warning("selecting serial gc and disabling large pages %s"
   85.36 -              "because of %s", "" LP64_ONLY("and compressed oops "),
   85.37 -              DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on");
   85.38 -      force_serial_gc();
   85.39 -      FLAG_SET_CMDLINE(bool, UseLargePages, false);
   85.40 -      LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false));
   85.41 +        warning("selecting serial gc and disabling large pages %s"
   85.42 +                "because of %s", "" LP64_ONLY("and compressed oops "),
   85.43 +                DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on");
   85.44 +        force_serial_gc();
   85.45 +        FLAG_SET_CMDLINE(bool, UseLargePages, false);
   85.46 +        LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false));
   85.47      } else {
   85.48        if (UseSharedSpaces && Verbose) {
   85.49          warning("turning off use of shared archive because of "
   85.50 @@ -2976,6 +2992,12 @@
   85.51      }
   85.52      ScavengeRootsInCode = 1;
   85.53    }
   85.54 +  if (!JavaObjectsInPerm && ScavengeRootsInCode == 0) {
   85.55 +    if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
   85.56 +      warning("forcing ScavengeRootsInCode non-zero because JavaObjectsInPerm is false");
   85.57 +    }
   85.58 +    ScavengeRootsInCode = 1;
   85.59 +  }
   85.60  
   85.61    if (PrintGCDetails) {
   85.62      // Turn on -verbose:gc options as well
    86.1 --- a/src/share/vm/runtime/globals.hpp	Fri Mar 18 13:28:33 2011 -0700
    86.2 +++ b/src/share/vm/runtime/globals.hpp	Thu Mar 24 23:00:27 2011 -0700
    86.3 @@ -851,7 +851,7 @@
    86.4    diagnostic(bool, TraceNMethodInstalls, false,                             \
    86.5               "Trace nmethod intallation")                                   \
    86.6                                                                              \
    86.7 -  diagnostic(intx, ScavengeRootsInCode, 0,                                  \
    86.8 +  diagnostic(intx, ScavengeRootsInCode, 1,                                  \
    86.9               "0: do not allow scavengable oops in the code cache; "         \
   86.10               "1: allow scavenging from the code cache; "                    \
   86.11               "2: emit as many constants as the compiler can see")           \
   86.12 @@ -1221,6 +1221,11 @@
   86.13            "Decay time (in milliseconds) to re-enable bulk rebiasing of a "  \
   86.14            "type after previous bulk rebias")                                \
   86.15                                                                              \
   86.16 +  develop(bool, JavaObjectsInPerm, false,                                   \
   86.17 +          "controls whether Classes and interned Strings are allocated"     \
   86.18 +          "in perm.  This purely intended to allow debugging issues"        \
   86.19 +          "in production.")                                                 \
   86.20 +                                                                            \
   86.21    /* tracing */                                                             \
   86.22                                                                              \
   86.23    notproduct(bool, TraceRuntimeCalls, false,                                \
   86.24 @@ -3751,6 +3756,9 @@
   86.25    diagnostic(bool, PrintDTraceDOF, false,                                   \
   86.26               "Print the DTrace DOF passed to the system for JSDT probes")   \
   86.27                                                                              \
   86.28 +  product(uintx, StringTableSize, 1009,                                     \
   86.29 +          "Number of buckets in the interned String table")                 \
   86.30 +                                                                            \
   86.31    product(bool, UseVMInterruptibleIO, false,                                \
   86.32            "(Unstable, Solaris-specific) Thread interrupt before or with "   \
   86.33            "EINTR for I/O operations results in OS_INTRPT. The default value"\
    87.1 --- a/src/share/vm/runtime/reflection.cpp	Fri Mar 18 13:28:33 2011 -0700
    87.2 +++ b/src/share/vm/runtime/reflection.cpp	Thu Mar 24 23:00:27 2011 -0700
    87.3 @@ -1,5 +1,5 @@
    87.4  /*
    87.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    87.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    87.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    87.8   *
    87.9   * This code is free software; you can redistribute it and/or modify it
   87.10 @@ -649,7 +649,7 @@
   87.11        if (TraceClassResolution) {
   87.12          trace_class_resolution(k);
   87.13        }
   87.14 -      return k->klass_part()->java_mirror();
   87.15 +      return k->java_mirror();
   87.16    };
   87.17  }
   87.18  
    88.1 --- a/src/share/vm/runtime/thread.cpp	Fri Mar 18 13:28:33 2011 -0700
    88.2 +++ b/src/share/vm/runtime/thread.cpp	Thu Mar 24 23:00:27 2011 -0700
    88.3 @@ -3166,7 +3166,7 @@
    88.4          fieldDescriptor fd;
    88.5          // Possible we might not find this field; if so, don't break
    88.6          if (ik->find_local_field(vmSymbols::frontCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
    88.7 -          k()->bool_field_put(fd.offset(), true);
    88.8 +          k()->java_mirror()->bool_field_put(fd.offset(), true);
    88.9          }
   88.10        }
   88.11  
   88.12 @@ -3182,7 +3182,7 @@
   88.13            fieldDescriptor fd;
   88.14            // Possible we might not find this field: if so, silently don't break
   88.15            if (ik->find_local_field(vmSymbols::stringCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
   88.16 -            k()->bool_field_put(fd.offset(), true);
   88.17 +            k()->java_mirror()->bool_field_put(fd.offset(), true);
   88.18            }
   88.19          }
   88.20        }
    89.1 --- a/src/share/vm/runtime/vmStructs.cpp	Fri Mar 18 13:28:33 2011 -0700
    89.2 +++ b/src/share/vm/runtime/vmStructs.cpp	Thu Mar 24 23:00:27 2011 -0700
    89.3 @@ -269,7 +269,7 @@
    89.4    nonstatic_field(instanceKlass,               _inner_classes,                                typeArrayOop)                          \
    89.5    nonstatic_field(instanceKlass,               _nonstatic_field_size,                         int)                                   \
    89.6    nonstatic_field(instanceKlass,               _static_field_size,                            int)                                   \
    89.7 -  nonstatic_field(instanceKlass,               _static_oop_field_size,                        int)                                   \
    89.8 +  nonstatic_field(instanceKlass,               _static_oop_field_count,                       int)                                   \
    89.9    nonstatic_field(instanceKlass,               _nonstatic_oop_map_size,                       int)                                   \
   89.10    nonstatic_field(instanceKlass,               _is_marked_dependent,                          bool)                                  \
   89.11    nonstatic_field(instanceKlass,               _minor_version,                                u2)                                    \
   89.12 @@ -945,6 +945,15 @@
   89.13    static_field(Arguments,                      _num_jvm_args,                                 int)                                   \
   89.14    static_field(Arguments,                      _java_command,                                 char*)                                 \
   89.15                                                                                                                                       \
   89.16 +  /*********************************/                                                                                                \
   89.17 +  /* java_lang_Class fields        */                                                                                                \
   89.18 +  /*********************************/                                                                                                \
   89.19 +                                                                                                                                     \
   89.20 +  static_field(java_lang_Class,                klass_offset,                                  int)                                   \
   89.21 +  static_field(java_lang_Class,                resolved_constructor_offset,                   int)                                   \
   89.22 +  static_field(java_lang_Class,                array_klass_offset,                            int)                                   \
   89.23 +  static_field(java_lang_Class,                oop_size_offset,                               int)                                   \
   89.24 +  static_field(java_lang_Class,                static_oop_field_count_offset,                 int)                                   \
   89.25                                                                                                                                       \
   89.26    /************************/                                                                                                         \
   89.27    /* Miscellaneous fields */                                                                                                         \
   89.28 @@ -1414,6 +1423,7 @@
   89.29    declare_toplevel_type(intptr_t*)                                        \
   89.30     declare_unsigned_integer_type(InvocationCounter) /* FIXME: wrong type (not integer) */ \
   89.31    declare_toplevel_type(JavaThread*)                                      \
   89.32 +  declare_toplevel_type(java_lang_Class)                                  \
   89.33    declare_toplevel_type(jbyte*)                                           \
   89.34    declare_toplevel_type(jbyte**)                                          \
   89.35    declare_toplevel_type(jint*)                                            \
   89.36 @@ -1543,12 +1553,6 @@
   89.37                                                                            \
   89.38    declare_constant(SymbolTable::symbol_table_size)                        \
   89.39                                                                            \
   89.40 -  /***************/                                                       \
   89.41 -  /* StringTable */                                                       \
   89.42 -  /***************/                                                       \
   89.43 -                                                                          \
   89.44 -  declare_constant(StringTable::string_table_size)                        \
   89.45 -                                                                          \
   89.46    /********************/                                                  \
   89.47    /* SystemDictionary */                                                  \
   89.48    /********************/                                                  \
   89.49 @@ -1700,15 +1704,6 @@
   89.50                                                                            \
   89.51    declare_constant(ConstantPoolCacheEntry::tosBits)                       \
   89.52                                                                            \
   89.53 -  /*********************************/                                     \
   89.54 -  /* java_lang_Class field offsets */                                     \
   89.55 -  /*********************************/                                     \
   89.56 -                                                                          \
   89.57 -  declare_constant(java_lang_Class::hc_klass_offset)                      \
   89.58 -  declare_constant(java_lang_Class::hc_array_klass_offset)                \
   89.59 -  declare_constant(java_lang_Class::hc_resolved_constructor_offset)       \
   89.60 -  declare_constant(java_lang_Class::hc_number_of_fake_oop_fields)         \
   89.61 -                                                                          \
   89.62    /***************************************/                               \
   89.63    /* java_lang_Thread::ThreadStatus enum */                               \
   89.64    /***************************************/                               \
    90.1 --- a/src/share/vm/services/heapDumper.cpp	Fri Mar 18 13:28:33 2011 -0700
    90.2 +++ b/src/share/vm/services/heapDumper.cpp	Thu Mar 24 23:00:27 2011 -0700
    90.3 @@ -832,7 +832,7 @@
    90.4  
    90.5        // value
    90.6        int offset = fld.offset();
    90.7 -      address addr = (address)k + offset;
    90.8 +      address addr = (address)ikh->java_mirror() + offset;
    90.9  
   90.10        dump_field_value(writer, sig->byte_at(0), addr);
   90.11      }
    91.1 --- a/src/share/vm/shark/sharkNativeWrapper.cpp	Fri Mar 18 13:28:33 2011 -0700
    91.2 +++ b/src/share/vm/shark/sharkNativeWrapper.cpp	Thu Mar 24 23:00:27 2011 -0700
    91.3 @@ -101,7 +101,7 @@
    91.4      builder()->CreateStore(
    91.5        builder()->CreateInlineOop(
    91.6          JNIHandles::make_local(
    91.7 -          target()->method_holder()->klass_part()->java_mirror())),
    91.8 +          target()->method_holder()->java_mirror())),
    91.9        oop_tmp_slot());
   91.10  
   91.11      param_types.push_back(box_type);

mercurial