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 014package org.jikesrvm.mm.mmtk; 015 016import org.jikesrvm.scheduler.RVMThread; 017import org.jikesrvm.tuningfork.TraceEngine; 018import org.mmtk.policy.Space; 019import org.vmmagic.pragma.Uninterruptible; 020import org.vmmagic.unboxed.Address; 021import org.vmmagic.unboxed.Extent; 022 023import com.ibm.tuningfork.tracegen.types.EventAttribute; 024import com.ibm.tuningfork.tracegen.types.EventType; 025import com.ibm.tuningfork.tracegen.types.ScalarType; 026 027/** 028 * Implementation of simple MMTK event generation hooks 029 * to allow MMTk to generate TuningFork events. 030 */ 031@Uninterruptible 032public class MMTk_Events extends org.mmtk.vm.MMTk_Events { 033 public static MMTk_Events events; 034 035 public final EventType gcStart; 036 public final EventType gcStop; 037 public final EventType pageAction; 038 public final EventType heapSizeChanged; 039 040 private final TraceEngine engine; 041 042 public MMTk_Events(TraceEngine engine) { 043 this.engine = engine; 044 045 /* Define events used by the MMTk subsystem */ 046 gcStart = engine.defineEvent("GC Start", "Start of a GC cycle", new EventAttribute("Reason","Encoded reason for GC",ScalarType.INT)); 047 gcStop = engine.defineEvent("GC Stop", "End of a GC Cycle"); 048 pageAction = engine.defineEvent("Page Action", "A space has acquired or released one or more pages", 049 new EventAttribute[] { 050 new EventAttribute("Space", "Space ID", ScalarType.INT), 051 new EventAttribute("Start Address", "Start address of range of released pages", ScalarType.INT), 052 new EventAttribute("Num Pages", "Number of pages released", ScalarType.INT), 053 new EventAttribute("Acquire/Release", "0 for acquire, 1 for release", ScalarType.INT)}); 054 heapSizeChanged = engine.defineEvent("Heapsize", "Current heapsize ceiling", new EventAttribute("Heapsize", "Heapsize in bytes", ScalarType.INT)); 055 events = this; 056 } 057 058 @Override 059 public void tracePageAcquired(Space space, Address startAddress, int numPages) { 060 RVMThread.getCurrentFeedlet().addEvent(pageAction, space.getIndex(), startAddress.toInt(), numPages, 0); 061 } 062 063 @Override 064 public void tracePageReleased(Space space, Address startAddress, int numPages) { 065 RVMThread.getCurrentFeedlet().addEvent(pageAction, space.getIndex(), startAddress.toInt(), numPages, 1); 066 } 067 068 @Override 069 public void heapSizeChanged(Extent heapSize) { 070 RVMThread.getCurrentFeedlet().addEvent(heapSizeChanged, heapSize.toInt()); 071 } 072}