src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/G1HeapRegionTable.java
changeset 48820 9a411a9a17f0
parent 47619 74f5b6c267e3
equal deleted inserted replaced
48819:ee513596f3ee 48820:9a411a9a17f0
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2018, 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.
   132 
   132 
   133     public G1HeapRegionTable(Address addr) {
   133     public G1HeapRegionTable(Address addr) {
   134         super(addr);
   134         super(addr);
   135     }
   135     }
   136 
   136 
   137     public HeapRegion getByAddress(Address addr) {
   137     public HeapRegion getByAddress(Address target) {
   138         long biasedIndex = addr.asLongValue() >>> shiftBy();
   138         Address arrayAddr = biasedBaseField.getValue(addr);
       
   139         long biasedIndex = target.asLongValue() >>> shiftBy();
   139         long offset = biasedIndex * HeapRegion.getPointerSize();
   140         long offset = biasedIndex * HeapRegion.getPointerSize();
   140         Address result = (addr instanceof OopHandle) ? addr.addOffsetToAsOopHandle(offset)
   141         Address regionAddr = arrayAddr.getAddressAt(offset);
   141                                                      : addr.addOffsetTo(offset);
   142         return (HeapRegion)VMObjectFactory.newObject(HeapRegion.class, regionAddr);
   142         return new HeapRegion(result);
       
   143     }
   143     }
   144 }
   144 }