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.jni; 014 015 import org.jikesrvm.VM; 016 import org.jikesrvm.objectmodel.RuntimeTable; 017 import org.vmmagic.Intrinsic; 018 import org.vmmagic.pragma.*; 019 import org.vmmagic.unboxed.AddressArray; 020 021 /** 022 * This class holds a triplet for each entry of the JNI function table. 023 */ 024 @NonMoving 025 public final class LinkageTripletTable implements RuntimeTable<AddressArray> { 026 027 /** 028 * The backing data used during boot image writing. 029 */ 030 private final AddressArray[] data; 031 032 /** 033 * Private constructor. Can not create instances. 034 */ 035 private LinkageTripletTable(int size) { 036 this.data = new AddressArray[size]; 037 } 038 039 /** 040 * Create a new LinkageTripletTable of the specified size. 041 * 042 * @param size The size of the LinkageTripletTable 043 * @return The created LinkageTripletTable instance. 044 */ 045 public static LinkageTripletTable allocate(int size) { 046 if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED); 047 return new LinkageTripletTable(size); 048 } 049 050 @Override 051 public AddressArray[] getBacking() { 052 if (VM.VerifyAssertions) VM._assert(!VM.runningVM); 053 return data; 054 } 055 056 /** 057 * Get a LinkageTripletTable entry. 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 AddressArray get(int index) { 066 if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED); 067 return data[index]; 068 } 069 070 /** 071 * Set a LinkageTripletTable entry. 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, AddressArray value) { 080 if (VM.VerifyAssertions && VM.runningVM) VM._assert(VM.NOT_REACHED); 081 data[index] = value; 082 } 083 084 /** 085 * Return the length of the LinkageTripletTable 086 */ 087 @Override 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 }