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      public ITable[] getBacking() {
043        if (VM.VerifyAssertions) VM._assert(!VM.runningVM);
044        return backingData;
045      }
046    
047      /**
048       * Create a new TIB of the specified size.
049       *
050       * @param size The size of the TIB
051       * @return The created TIB instance.
052       */
053      public static ITableArray allocate(int size) {
054        if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED);
055        return new ITableArray(size);
056      }
057    
058      /**
059       * Get a TIB entry.
060       *
061       * @param index The index of the entry to get
062       * @return The value of that entry
063       */
064      @Intrinsic
065      @Uninterruptible
066      public ITable get(int index) {
067        if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED);
068        return backingData[index];
069      }
070    
071      /**
072       * Set a TIB entry.
073       *
074       * @param index The index of the entry to set
075       * @param value The value to set the entry to.
076       */
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 TIB
086       */
087      @Intrinsic
088      @Uninterruptible
089      public int length() {
090        if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED);
091        return backingData.length;
092      }
093    }