hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java
changeset 46427 54713555867e
parent 42087 afd6ae4fec81
child 46460 d25a320cd821
equal deleted inserted replaced
46426:02a1fc064144 46427:54713555867e
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    82     tags        = type.getAddressField("_tags");
    82     tags        = type.getAddressField("_tags");
    83     operands    = type.getAddressField("_operands");
    83     operands    = type.getAddressField("_operands");
    84     cache       = type.getAddressField("_cache");
    84     cache       = type.getAddressField("_cache");
    85     poolHolder  = new MetadataField(type.getAddressField("_pool_holder"), 0);
    85     poolHolder  = new MetadataField(type.getAddressField("_pool_holder"), 0);
    86     length      = new CIntField(type.getCIntegerField("_length"), 0);
    86     length      = new CIntField(type.getCIntegerField("_length"), 0);
    87     resolvedReferences      = type.getAddressField("_resolved_references");
       
    88     referenceMap = type.getAddressField("_reference_map");
       
    89     headerSize  = type.getSize();
    87     headerSize  = type.getSize();
    90     elementSize = 0;
    88     elementSize = 0;
    91     // fetch constants:
    89     // fetch constants:
    92     INDY_BSM_OFFSET = db.lookupIntConstant("ConstantPool::_indy_bsm_offset").intValue();
    90     INDY_BSM_OFFSET = db.lookupIntConstant("ConstantPool::_indy_bsm_offset").intValue();
    93     INDY_ARGC_OFFSET = db.lookupIntConstant("ConstantPool::_indy_argc_offset").intValue();
    91     INDY_ARGC_OFFSET = db.lookupIntConstant("ConstantPool::_indy_argc_offset").intValue();
   103   private static AddressField tags;
   101   private static AddressField tags;
   104   private static AddressField operands;
   102   private static AddressField operands;
   105   private static AddressField cache;
   103   private static AddressField cache;
   106   private static MetadataField poolHolder;
   104   private static MetadataField poolHolder;
   107   private static CIntField length; // number of elements in oop
   105   private static CIntField length; // number of elements in oop
   108   private static AddressField  resolvedReferences;
       
   109   private static AddressField  referenceMap;
       
   110 
   106 
   111   private static long headerSize;
   107   private static long headerSize;
   112   private static long elementSize;
   108   private static long elementSize;
   113 
   109 
   114   private static int INDY_BSM_OFFSET;
   110   private static int INDY_BSM_OFFSET;
   122     return (ConstantPoolCache) VMObjectFactory.newObject(ConstantPoolCache.class, addr);
   118     return (ConstantPoolCache) VMObjectFactory.newObject(ConstantPoolCache.class, addr);
   123   }
   119   }
   124   public InstanceKlass     getPoolHolder() { return (InstanceKlass)poolHolder.getValue(this); }
   120   public InstanceKlass     getPoolHolder() { return (InstanceKlass)poolHolder.getValue(this); }
   125   public int               getLength()     { return (int)length.getValue(getAddress()); }
   121   public int               getLength()     { return (int)length.getValue(getAddress()); }
   126   public Oop               getResolvedReferences() {
   122   public Oop               getResolvedReferences() {
   127     Address handle = resolvedReferences.getValue(getAddress());
   123     return getCache().getResolvedReferences();
   128     if (handle != null) {
       
   129       // Load through the handle
       
   130       OopHandle refs = handle.getOopHandleAt(0);
       
   131       return VM.getVM().getObjectHeap().newOop(refs);
       
   132     }
       
   133     return null;
       
   134   }
   124   }
   135 
   125 
   136   public U2Array referenceMap() {
   126   public U2Array referenceMap() {
   137     return new U2Array(referenceMap.getValue(getAddress()));
   127     return getCache().referenceMap();
   138   }
   128   }
   139 
   129 
   140   public int objectToCPIndex(int index) {
   130   public int objectToCPIndex(int index) {
   141     return referenceMap().at(index);
   131     return referenceMap().at(index);
   142   }
   132   }