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 package org.jikesrvm.osr.ia32;
014
015 import org.jikesrvm.VM;
016 import org.jikesrvm.ia32.ArchConstants;
017 import org.jikesrvm.ia32.Registers;
018 import org.vmmagic.unboxed.Address;
019 import org.vmmagic.unboxed.WordArray;
020
021 /**
022 * Temporary register set.
023 * see: Registers
024 */
025 public class TempRegisters implements ArchConstants {
026
027 final Address ip; // next instruction address
028 final WordArray gprs;
029 final double[] fprs;
030
031 /**
032 * if a GPR hold a reference to an object, we convert the raw memory
033 * address to a reference. When objs[i] is null, the GPR[i] is not
034 * holding a reference.
035 */
036 final Object[] objs;
037
038 public TempRegisters(Registers contextRegisters) {
039 gprs = WordArray.create(NUM_GPRS);
040 fprs = new double[NUM_FPRS];
041 objs = new Object[NUM_GPRS];
042
043 for (int i = 0; i < NUM_GPRS; i++) {
044 gprs.set(i, contextRegisters.gprs.get(i));
045 }
046 System.arraycopy(contextRegisters.fprs, 0, fprs, 0, NUM_FPRS);
047 ip = contextRegisters.ip;
048 }
049
050 public void dumpContents() {
051 System.err.println("OSR_TempRegister: @" + VM.addressAsHexString(ip));
052 System.err.println(" GPRS: ");
053 for (int i = 0; i < NUM_GPRS; i++) {
054 System.err.println(" (" + i + "," + VM.addressAsHexString(gprs.get(i).toAddress()) + ")");
055 }
056
057 System.err.println();
058 System.err.println(" OBJS: ");
059 for (int i = 0; i < NUM_GPRS; i++) {
060 if (objs[i] != null) {
061 System.err.println(" (" + i + "," + objs[i] + ")");
062 }
063 }
064
065 System.err.println();
066 System.err.println(" FPRS ");
067 for (int i = 0; i < NUM_FPRS; i++) {
068 System.err.println(" (" + i + "," + fprs[i] + ")");
069 }
070 }
071 }