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