hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java
author kvn
Thu, 27 May 2010 18:01:56 -0700
changeset 5694 1e0532a6abff
parent 3795 6227ff014cfe
child 5702 201c5cde25bb
permissions -rw-r--r--
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb Summary: Added new product ObjectAlignmentInBytes flag to control object alignment. Reviewed-by: twisti, ysr, iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
3795
6227ff014cfe 6884624: Update copyright year
xdono
parents: 3604
diff changeset
     2
 * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
package sun.jvm.hotspot.memory;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import java.io.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
import sun.jvm.hotspot.oops.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
import sun.jvm.hotspot.runtime.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
import sun.jvm.hotspot.types.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
import sun.jvm.hotspot.utilities.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
public class CompactibleFreeListSpace extends CompactibleSpace {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
   private static AddressField collectorField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    38
   // for free size, three fields
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    39
   //       FreeBlockDictionary* _dictionary;        // ptr to dictionary for large size blocks
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    40
   //       FreeList _indexedFreeList[IndexSetSize]; // indexed array for small size blocks
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    41
   //       LinearAllocBlock _smallLinearAllocBlock; // small linear alloc in TLAB
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    42
   private static AddressField indexedFreeListField;
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    43
   private static AddressField dictionaryField;
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    44
   private static long         smallLinearAllocBlockFieldOffset;
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    45
   private static long indexedFreeListSizeOf;
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    46
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    47
   private int    heapWordSize;     // 4 for 32bit, 8 for 64 bits
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    48
   private int    IndexSetStart;    // for small indexed list
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    49
   private int    IndexSetSize;
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    50
   private int    IndexSetStride;
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    51
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
   static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
      VM.registerVMInitializedObserver(new Observer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
         public void update(Observable o, Object data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
            initialize(VM.getVM().getTypeDataBase());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
      });
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
   private static synchronized void initialize(TypeDataBase db) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
      long sizeofFreeChunk = db.lookupType("FreeChunk").getSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
      VM vm = VM.getVM();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
      MinChunkSizeInBytes = numQuanta(sizeofFreeChunk, vm.getMinObjAlignmentInBytes()) *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
                     vm.getMinObjAlignmentInBytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
     Type type = db.lookupType("CompactibleFreeListSpace");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
     collectorField = type.getAddressField("_collector");
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    68
     collectorField       = type.getAddressField("_collector");
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    69
     dictionaryField      = type.getAddressField("_dictionary");
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    70
     indexedFreeListField = type.getAddressField("_indexedFreeList[0]");
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    71
     smallLinearAllocBlockFieldOffset = type.getField("_smallLinearAllocBlock").getOffset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
   public CompactibleFreeListSpace(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
      super(addr);
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3795
diff changeset
    76
      VM vm = VM.getVM();
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3795
diff changeset
    77
      heapWordSize   = vm.getHeapWordSize();
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3795
diff changeset
    78
      IndexSetStart  = vm.getMinObjAlignmentInBytes() / heapWordSize;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3795
diff changeset
    79
      IndexSetStride = IndexSetStart;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3795
diff changeset
    80
      IndexSetSize   = 257;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
   // Accessing block offset table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
   public CMSCollector collector() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    return (CMSCollector) VMObjectFactory.newObject(
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
                                 CMSCollector.class,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
                                 collectorField.getValue(addr));
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    88
   }
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    89
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    90
   public long free0() {
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    91
     return capacity() - used0();
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    92
   }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
   public long used() {
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    95
     return capacity() - free();
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    96
   }
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    97
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
    98
   public long used0() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      List regions = getLiveRegions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      long usedSize = 0L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      for (Iterator itr = regions.iterator(); itr.hasNext();) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
         MemRegion mr = (MemRegion) itr.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
         usedSize += mr.byteSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
      return usedSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
   public long free() {
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   109
      // small chunks
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   110
      long size = 0;
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   111
      Address cur = addr.addOffsetTo( indexedFreeListField.getOffset() );
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   112
      cur = cur.addOffsetTo(IndexSetStart*FreeList.sizeOf());
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   113
      for (int i=IndexSetStart; i<IndexSetSize; i += IndexSetStride) {
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   114
         FreeList freeList = (FreeList) VMObjectFactory.newObject(FreeList.class, cur);
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   115
         size += i*freeList.count();
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   116
         cur= cur.addOffsetTo(IndexSetStride*FreeList.sizeOf());
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   117
      }
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   118
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   119
      // large block
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   120
      BinaryTreeDictionary bfbd = (BinaryTreeDictionary) VMObjectFactory.newObject(BinaryTreeDictionary.class,
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   121
                                                                                   dictionaryField.getValue(addr));
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   122
      size += bfbd.size();
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   123
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   124
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   125
      // linear block in TLAB
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   126
      LinearAllocBlock lab = (LinearAllocBlock) VMObjectFactory.newObject(LinearAllocBlock.class,
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   127
                                                                          addr.addOffsetTo(smallLinearAllocBlockFieldOffset));
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   128
      size += lab.word_size();
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   129
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   130
      return size*heapWordSize;
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   131
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
   public void printOn(PrintStream tty) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
      tty.print("free-list-space");
578
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   135
      tty.print("[ " + bottom() + " , " + end() + " ) ");
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   136
      long cap = capacity();
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   137
      long used_size = used();
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   138
      long free_size = free();
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   139
      int  used_perc = (int)((double)used_size/cap*100);
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   140
      tty.print("space capacity = " + cap + " used(" + used_perc + "%)= " + used_size + " ");
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   141
      tty.print("free= " + free_size );
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   142
      tty.print("\n");
862a85ed20db 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 1
diff changeset
   143
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
   public Address skipBlockSizeUsingPrintezisBits(Address pos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
       CMSCollector collector = collector();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
       long size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
       Address addr = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
       if (collector != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
         size = collector.blockSizeUsingPrintezisBits(pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
         if (size >= 3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
           addr = pos.addOffsetTo(adjustObjectSizeInBytes(size));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
       return addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
   public List/*<MemRegion>*/ getLiveRegions() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
      List res = new ArrayList(); // List<MemRegion>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
      VM vm = VM.getVM();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
      Debugger dbg = vm.getDebugger();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
      ObjectHeap heap = vm.getObjectHeap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
      Address cur = bottom();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
      Address regionStart = cur;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
      Address limit = end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
      final long addressSize = vm.getAddressSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
      for (; cur.lessThan(limit);) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
         Address klassOop = cur.getAddressAt(addressSize);
613
2aa2b913106c 6687581: Make CMS work with compressed oops
coleenp
parents: 1
diff changeset
   172
         if (FreeChunk.indicatesFreeChunk(cur)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
            if (! cur.equals(regionStart)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
               res.add(new MemRegion(regionStart, cur));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
            FreeChunk fc = (FreeChunk) VMObjectFactory.newObject(FreeChunk.class, cur);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
            long chunkSize = fc.size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
            if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
               Assert.that(chunkSize > 0, "invalid FreeChunk size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
            // note that fc.size() gives chunk size in heap words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
            cur = cur.addOffsetTo(chunkSize * addressSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
            regionStart = cur;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
         } else if (klassOop != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
            Oop obj = heap.newOop(cur.addOffsetToAsOopHandle(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
            long objectSize = obj.getObjectSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
            cur = cur.addOffsetTo(adjustObjectSizeInBytes(objectSize));
3604
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   188
         } else {
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   189
            // FIXME: need to do a better job here.
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   190
            // can I use bitMap here?
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   191
            //Find the object size using Printezis bits and skip over
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   192
            long size = collector().blockSizeUsingPrintezisBits(cur);
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   193
            if (size == -1) {
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   194
              System.err.println("Printezis bits not set...");
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   195
              break;
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   196
            }
30fbd94d4963 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 670
diff changeset
   197
            cur = cur.addOffsetTo(adjustObjectSizeInBytes(size));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
   //-- Internals only below this point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
   // Unlike corresponding VM code, we operate on byte size rather than
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
   // HeapWord size for convenience.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
   private static long numQuanta(long x, long y) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
      return  ((x+y-1)/y);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
   public static long adjustObjectSizeInBytes(long sizeInBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      return Oop.alignObjectSize(Math.max(sizeInBytes, MinChunkSizeInBytes));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
   // FIXME: should I read this directly from VM?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
   private static long MinChunkSizeInBytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
}