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.runtime;
014
015import org.jikesrvm.VM;
016import org.jikesrvm.classloader.Atom;
017import org.jikesrvm.classloader.RVMField;
018import org.jikesrvm.classloader.NormalMethod;
019
020/**
021 * Entrypoints that are specific to instruction architecture.
022 */
023public final class ArchEntrypoints {
024  public static final String ArchCodeArrayName = "Lorg/jikesrvm/compilers/common/CodeArray;";
025  public static final String arch;
026  public static final NormalMethod newArrayArrayMethod;
027
028  static {
029    if (VM.BuildForIA32) {
030      arch = "ia32";
031      newArrayArrayMethod = (NormalMethod)
032          EntrypointHelper.getMethod(org.jikesrvm.ia32.MultianewarrayHelper.class,
033          Atom.findOrCreateAsciiAtom("newArrayArray"),
034          int.class, int.class, int.class, int.class, Object.class);
035      saveVolatilesInstructionsField = null;
036      restoreVolatilesInstructionsField = null;
037      registersLRField = null;
038      registersFPField =  EntrypointHelper.getField("Lorg/jikesrvm/" + arch + "/Registers;",
039          "fp", "Lorg/vmmagic/unboxed/Address;");
040      framePointerField = EntrypointHelper.getField("Lorg/jikesrvm/scheduler/RVMThread;",
041          "framePointer", "Lorg/vmmagic/unboxed/Address;");
042      hiddenSignatureIdField = EntrypointHelper.getField("Lorg/jikesrvm/scheduler/RVMThread;",
043          "hiddenSignatureId", "I");
044      arrayIndexTrapParamField = EntrypointHelper.getField("Lorg/jikesrvm/scheduler/RVMThread;",
045          "arrayIndexTrapParam", "I");
046    } else {
047      if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC);
048      arch = "ppc";
049      newArrayArrayMethod = (NormalMethod)
050          EntrypointHelper.getMethod(org.jikesrvm.ppc.MultianewarrayHelper.class,
051          Atom.findOrCreateAsciiAtom("newArrayArray"),
052          int.class, int.class, int.class, int.class, Object.class);
053      saveVolatilesInstructionsField = EntrypointHelper.getField("Lorg/jikesrvm/" +
054          arch + "/OutOfLineMachineCode;", "saveVolatilesInstructions", ArchCodeArrayName);
055      restoreVolatilesInstructionsField = EntrypointHelper.getField("Lorg/jikesrvm/" +
056          arch + "/OutOfLineMachineCode;", "restoreVolatilesInstructions", ArchCodeArrayName);
057      registersLRField = EntrypointHelper.getField("Lorg/jikesrvm/" + arch + "/Registers;",
058          "lr", "Lorg/vmmagic/unboxed/Address;");
059      registersFPField = null;
060      framePointerField = null;
061      hiddenSignatureIdField = null;
062      arrayIndexTrapParamField = null;
063    }
064  }
065
066  public static final RVMField reflectiveMethodInvokerInstructionsField =
067      EntrypointHelper.getField("Lorg/jikesrvm/" + arch + "/OutOfLineMachineCode;",
068               "reflectiveMethodInvokerInstructions",
069               ArchCodeArrayName);
070  public static final RVMField saveThreadStateInstructionsField =
071      EntrypointHelper.getField("Lorg/jikesrvm/" + arch + "/OutOfLineMachineCode;", "saveThreadStateInstructions", ArchCodeArrayName);
072  public static final RVMField threadSwitchInstructionsField =
073      EntrypointHelper.getField("Lorg/jikesrvm/" + arch + "/OutOfLineMachineCode;", "threadSwitchInstructions", ArchCodeArrayName);
074  public static final RVMField restoreHardwareExceptionStateInstructionsField =
075      EntrypointHelper.getField("Lorg/jikesrvm/" + arch + "/OutOfLineMachineCode;",
076               "restoreHardwareExceptionStateInstructions",
077               ArchCodeArrayName);
078  public static final RVMField saveVolatilesInstructionsField;
079  public static final RVMField restoreVolatilesInstructionsField;
080  public static final RVMField trampolineRegistersField =
081        EntrypointHelper.getField("Lorg/jikesrvm/scheduler/RVMThread;", "trampolineRegisters", "Lorg/jikesrvm/architecture/AbstractRegisters;");
082  public static final RVMField hijackedReturnAddressField =
083    EntrypointHelper.getField("Lorg/jikesrvm/scheduler/RVMThread;", "hijackedReturnAddress", "Lorg/vmmagic/unboxed/Address;");
084  public static final RVMField registersIPField =
085      EntrypointHelper.getField("Lorg/jikesrvm/architecture/AbstractRegisters;", "ip", "Lorg/vmmagic/unboxed/Address;");
086  public static final RVMField registersFPRsField = EntrypointHelper.getField("Lorg/jikesrvm/architecture/AbstractRegisters;", "fprs", "[D");
087  public static final RVMField registersGPRsField =
088      EntrypointHelper.getField("Lorg/jikesrvm/architecture/AbstractRegisters;", "gprs", "Lorg/vmmagic/unboxed/WordArray;");
089  public static final RVMField registersInUseField = EntrypointHelper.getField("Lorg/jikesrvm/architecture/AbstractRegisters;", "inuse", "Z");
090  public static final RVMField registersLRField;
091  public static final RVMField registersFPField;
092  public static final RVMField framePointerField;
093  public static final RVMField hiddenSignatureIdField;
094  public static final RVMField arrayIndexTrapParamField;
095
096  private ArchEntrypoints() {
097    // prevent instantiation
098  }
099
100}