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.objectmodel;
014
015 import org.jikesrvm.VM;
016 import org.jikesrvm.ArchitectureSpecific.CodeArray;
017 import org.vmmagic.Intrinsic;
018 import org.vmmagic.pragma.NonMoving;
019 import org.vmmagic.pragma.Uninterruptible;
020 import org.vmmagic.pragma.UninterruptibleNoWarn;
021
022 /**
023 * This class represents an instance of an interface method table, at runtime it
024 * is an array with CodeArray elements.
025 */
026 @NonMoving
027 public final class IMT implements RuntimeTable<CodeArray> {
028
029 /**
030 * The backing data used during boot image writing.
031 */
032 private final CodeArray[] data;
033
034 /**
035 * Private constructor. Can not create instances.
036 */
037 private IMT() {
038 this.data = new CodeArray[TIBLayoutConstants.IMT_METHOD_SLOTS];
039 }
040
041 /**
042 * Return the backing array (for boot image writing)
043 */
044 public CodeArray[] getBacking() {
045 if (VM.VerifyAssertions) VM._assert(!VM.runningVM);
046 return data;
047 }
048
049 /**
050 * Create an IMT.
051 *
052 * @return The created IMT instance.
053 */
054 public static IMT allocate() {
055 if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED);
056 return new IMT();
057 }
058
059 /**
060 * Get a TIB entry.
061 *
062 * @param index The index of the entry to get
063 * @return The value of that entry
064 */
065 @Intrinsic
066 @Uninterruptible
067 public CodeArray get(int index) {
068 if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED);
069 return data[index];
070 }
071
072 /**
073 * Set a TIB entry.
074 *
075 * @param index The index of the entry to set
076 * @param value The value to set the entry to.
077 */
078 @Intrinsic
079 @UninterruptibleNoWarn("Interruptible code not reachable at runtime")
080 public void set(int index, CodeArray value) {
081 if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED);
082 data[index] = value;
083 }
084
085 /**
086 * Return the length of the TIB
087 */
088 @Intrinsic
089 @Uninterruptible
090 public int length() {
091 if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED);
092 return data.length;
093 }
094 }