001 /* 002 * This file is part of the Jikes RVM project (http://jikesrvm.org). 003 * 004 * This file is licensed to You under the Eclipse Public License (EPL); 005 * You may not use this file except in compliance with the License. You 006 * may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/eclipse-1.0.php 009 * 010 * See the COPYRIGHT.txt file distributed with this work for information 011 * regarding copyright ownership. 012 */ 013 014 package org.jikesrvm.tuningfork; 015 016 import org.mmtk.policy.Space; 017 import org.mmtk.policy.Space.SpaceVisitor; 018 import org.mmtk.utility.Constants; 019 020 import com.ibm.tuningfork.tracegen.chunk.Chunk; 021 022 /** 023 * A chunk to encode Space index/Space name mappings. 024 */ 025 public class SpaceDescriptorChunk extends Chunk { 026 private static final int SPACE_DESCRIPTOR_CHUNK_ID = (64 * 1024) + 100; 027 028 public static final int SPACE_DESCRIPTOR_COUNT_OFFSET = DATA_OFFSET; 029 public static final int SPACE_DESCRIPTOR_DATA_OFFSET = SPACE_DESCRIPTOR_COUNT_OFFSET + ENCODING_SPACE_INT; 030 031 private int numSpaces; 032 033 SpaceDescriptorChunk() { 034 super(SPACE_DESCRIPTOR_CHUNK_ID); 035 036 /* Write mapping of space ids to logical space names */ 037 seek(SPACE_DESCRIPTOR_DATA_OFFSET); 038 numSpaces = 0; 039 Space.visitSpaces(new SpaceVisitor() { 040 @Override 041 public void visit(Space s) { 042 numSpaces++; 043 addInt(s.getIndex()); 044 addString(s.getName()); 045 } 046 }); 047 int pos = getPosition(); 048 seek(SPACE_DESCRIPTOR_COUNT_OFFSET); 049 addInt(numSpaces); 050 seek(pos); 051 052 /* Pages per byte */ 053 addInt(Constants.BYTES_IN_PAGE); 054 055 /* Possible heap range */ 056 /* TODO: Horrific 32 bit assumption. 057 * Matches equally bogus assumption in event definitions that use 058 * an int to pass addresses. 059 * MUST FIX BEFORE MERGING TO TRUNK! 060 */ 061 addInt(org.mmtk.vm.VM.HEAP_START.toInt()); 062 addInt(org.mmtk.vm.VM.HEAP_END.toInt()); 063 064 close(); 065 } 066 067 }