diff agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java @ 6123:2fe087c3e814

7172967: Eliminate constMethod's _method backpointer to methodOop. Summary: Eliminate constMethod's _method backpointer to methodOop, and move the _constant field from methodOop to constMethod. Reviewed-by: roland, bdelsart, kamg
author jiangli
date Wed, 06 Jun 2012 14:33:43 -0400
parents 6a991dcb52bb
children 8150fa46d2ed
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java	Fri Jun 01 15:30:44 2012 -0700
+++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java	Wed Jun 06 14:33:43 2012 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,8 +50,7 @@
 
   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
     Type type                  = db.lookupType("constMethodOopDesc");
-    // Backpointer to non-const methodOop
-    method                     = new OopField(type.getOopField("_method"), 0);
+    constants                  = new OopField(type.getOopField("_constants"), 0);
     // The exception handler table. 4-tuples of ints [start_pc, end_pc,
     // handler_pc, catch_type index] For methods with no exceptions the
     // table is pointing to Universe::the_empty_int_array
@@ -69,6 +68,7 @@
     nameIndex                  = new CIntField(type.getCIntegerField("_name_index"), 0);
     signatureIndex             = new CIntField(type.getCIntegerField("_signature_index"), 0);
     genericSignatureIndex      = new CIntField(type.getCIntegerField("_generic_signature_index"),0);
+    idnum                      = new CIntField(type.getCIntegerField("_method_idnum"), 0);
 
     // start of byte code
     bytecodeOffset = type.getSize();
@@ -85,7 +85,7 @@
   }
 
   // Fields
-  private static OopField  method;
+  private static OopField  constants;
   private static OopField  exceptionTable;
   private static CIntField constMethodSize;
   private static ByteField flags;
@@ -93,6 +93,7 @@
   private static CIntField nameIndex;
   private static CIntField signatureIndex;
   private static CIntField genericSignatureIndex;
+  private static CIntField idnum;
 
   // start of bytecode
   private static long bytecodeOffset;
@@ -100,9 +101,15 @@
   private static long checkedExceptionElementSize;
   private static long localVariableTableElementSize;
 
+  public Method getMethod() {
+    InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder();
+    ObjArray methods = ik.getMethods();
+    return (Method)methods.getObjAt(getIdNum());
+  }
+
   // Accessors for declared fields
-  public Method getMethod() {
-    return (Method) method.getValue(this);
+  public ConstantPool getConstants() {
+    return (ConstantPool) constants.getValue(this);
   }
 
   public TypeArray getExceptionTable() {
@@ -133,6 +140,10 @@
     return genericSignatureIndex.getValue(this);
   }
 
+  public long getIdNum() {
+    return idnum.getValue(this);
+  }
+
   public Symbol getName() {
     return getMethod().getName();
   }
@@ -223,7 +234,7 @@
   public void iterateFields(OopVisitor visitor, boolean doVMFields) {
     super.iterateFields(visitor, doVMFields);
     if (doVMFields) {
-      visitor.doOop(method, true);
+      visitor.doOop(constants, true);
       visitor.doOop(exceptionTable, true);
       visitor.doCInt(constMethodSize, true);
       visitor.doByte(flags, true);