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 */
013package org.jikesrvm.compilers.baseline;
014
015import org.jikesrvm.VM;
016import org.vmmagic.pragma.Uninterruptible;
017
018/**
019 * Scratch space for JSR processing.  Used from ReferenceMaps
020 */
021@Uninterruptible
022final class JSRInfo {
023
024  int numberUnusualMaps;
025  UnusualMaps[] unusualMaps;
026  byte[] unusualReferenceMaps;
027  int freeMapSlot = 0;
028  /** Merged jsr ret and callers maps */
029  UnusualMaps extraUnusualMap = new UnusualMaps();
030  int tempIndex = 0;
031  int mergedReferenceMap = 0;       // result of jsrmerged maps - stored in referenceMaps
032  int mergedReturnAddressMap = 0;   // result of jsrmerged maps - stored return addresses
033
034  JSRInfo(int initialMaps) {
035    unusualMaps = new UnusualMaps[initialMaps];
036  }
037
038  /**
039   * Show the basic information for each of the unusual maps. This is for testing
040   * use.
041   *
042   * @param bytesPerMap size of each map
043   */
044  public void showUnusualMapInfo(int bytesPerMap) {
045    VM.sysWrite("-------------------------------------------------\n");
046    VM.sysWriteln("     numberUnusualMaps = ", numberUnusualMaps);
047
048    for (int i = 0; i < numberUnusualMaps; i++) {
049      VM.sysWrite("-----------------\n");
050      VM.sysWrite("Unusual map #", i);
051      VM.sysWrite(":\n");
052      unusualMaps[i].showInfo();
053      VM.sysWrite("    -- reference Map:   ");
054      showAnUnusualMap(unusualMaps[i].getReferenceMapIndex(), bytesPerMap);
055      VM.sysWrite("\n");
056      VM.sysWrite("    -- non-reference Map:   ");
057      showAnUnusualMap(unusualMaps[i].getNonReferenceMapIndex(), bytesPerMap);
058      VM.sysWrite("\n");
059      VM.sysWrite("    -- returnAddress Map:   ");
060      showAnUnusualMap(unusualMaps[i].getReturnAddressMapIndex(), bytesPerMap);
061      VM.sysWrite("\n");
062    }
063    VM.sysWrite("------ extraUnusualMap:   ");
064    extraUnusualMap.showInfo();
065    showAnUnusualMap(extraUnusualMap.getReferenceMapIndex(), bytesPerMap);
066    showAnUnusualMap(extraUnusualMap.getNonReferenceMapIndex(), bytesPerMap);
067    showAnUnusualMap(extraUnusualMap.getReturnAddressMapIndex(), bytesPerMap);
068    VM.sysWrite("\n");
069  }
070
071  /**
072   * Show the basic information for a single unusualmap. This is for testing use.
073   *
074   * @param mapIndex the map's index
075   * @param bytesPerMap size of a map
076   */
077  public void showAnUnusualMap(int mapIndex, int bytesPerMap) {
078    VM.sysWrite("unusualMap with index = ", mapIndex);
079    VM.sysWrite("   Map bytes =  ");
080    for (int i = 0; i < bytesPerMap; i++) {
081      VM.sysWrite(unusualReferenceMaps[mapIndex + i]);
082      VM.sysWrite("   ");
083    }
084    VM.sysWrite("   ");
085  }
086
087}