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