/** * Set the value of a feature of a FS without checking for index corruption * (typically because the feature isn't one that can be used as a key, or * the context is one where the FS is being created, and is guaranteed not to be in any index (yet)) * * @param addr The address of the FS. * @param feat The code of the feature. * @param val The new value for the feature. * @exception ArrayIndexOutOfBoundsException * If the feature is not a legal feature, or it is not * appropriate for the type at the address. */ void setFeatureValueNoIndexCorruptionCheck(int addr, int feat, int val) { setFeatureValueNotJournaled(addr, feat, val); if (this.svd.trackingMark != null) { this.logFSUpdate(addr, addr+this.svd.casMetadata.featureOffset[feat], ModifiedHeap.FSHEAP, 1); } } /**
@Override public void ll_setIntArrayValue(int fsRef, int position, int value) { final int pos = getArrayStartAddress(fsRef) + position; this.getHeap().heap[pos] = value; if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, pos, ModifiedHeap.FSHEAP, 1); } }
@Override public void ll_setRefArrayValue(int fsRef, int position, int value) { final int pos = getArrayStartAddress(fsRef) + position; this.getHeap().heap[pos] = value; if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, pos, ModifiedHeap.FSHEAP, 1); } }
/** * Set an array value. * * @param addr * The address of the array. * @param index * The index we want to set. * @param value * The value we want to set. * @exception ArrayIndexOutOfBoundsException */ void setArrayValue(final int addr, final int index, final int value) throws ArrayIndexOutOfBoundsException { // Get the length of this array. final int arraySize = this.getHeap().heap[addr + arrayLengthFeatOffset]; // Check for boundary violation. if ((index < 0) || (index >= arraySize)) { throw new ArrayIndexOutOfBoundsException(); } this.getHeap().heap[addr + arrayContentOffset + index] = value; if (this.svd.trackingMark != null) { this.logFSUpdate(addr, addr+arrayContentOffset+index, ModifiedHeap.FSHEAP, 1); } }
/** * Copy the contents of an input array into a CAS array. * * @param src * The array to copy from. * @param srcOffset * An offset into the source from where to start copying. * @param addr * The address of the array we're copying to. * @param destOffset * Where to start copying into the destination array. * @param length * How many elements to copy. */ void copyFromArray(int[] src, int srcOffset, int addr, int destOffset, int length) { // Get the length of this array. final int arraySize = this.getHeap().heap[addr + arrayLengthFeatOffset]; // Check boundary conditions for destination array. We can rely on Java // to // complain about boundary violations for the source array. if ((destOffset < 0) || ((length + destOffset) > arraySize)) { throw new ArrayIndexOutOfBoundsException(); } // Compute the offset into the heap where the array starts. final int offset = addr + arrayContentOffset; System.arraycopy(src, srcOffset, this.getHeap().heap, offset + destOffset, length); if (this.svd.trackingMark != null) { this.logFSUpdate(addr, offset + destOffset, ModifiedHeap.FSHEAP, length); } }
@Override public void ll_setDoubleArrayValue(int fsRef, int position, double d) { final int offset = this.getHeap().heap[getArrayStartAddress(fsRef)]; long value = Double.doubleToLongBits(d); this.getLongHeap().setHeapValue(value, offset + position); if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, offset+position, ModifiedHeap.LONGHEAP, 1); } }
@Override public void ll_setFloatArrayValue(int fsRef, int position, float value) { final int pos = getArrayStartAddress(fsRef) + position; this.getHeap().heap[pos] = float2int(value); if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, pos,ModifiedHeap.FSHEAP, 1); } }
@Override public void ll_setStringArrayValue(int fsRef, int position, String value) { final int pos = getArrayStartAddress(fsRef) + position; final int stringCode = (value == null) ? NULL : addString(value); this.getHeap().heap[pos] = stringCode; if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, pos, ModifiedHeap.FSHEAP, 1); } }
@Override public void ll_setByteArrayValue(int fsRef, int position, byte value) { final int offset = this.getHeap().heap[getArrayStartAddress(fsRef)]; this.getByteHeap().setHeapValue(value, offset + position); if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, offset+position, ModifiedHeap.BYTEHEAP, 1); } }
@Override public void ll_setBooleanArrayValue(int fsRef, int position, boolean b) { byte value = (byte) (b ? CASImpl.TRUE : CASImpl.FALSE); final int offset = this.getHeap().heap[getArrayStartAddress(fsRef)]; this.getByteHeap().setHeapValue(value, offset + position); if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, offset+position, ModifiedHeap.BYTEHEAP, 1); } }
@Override public void ll_setShortArrayValue(int fsRef, int position, short value) { final int offset = this.getHeap().heap[getArrayStartAddress(fsRef)]; this.getShortHeap().setHeapValue(value, offset + position); if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, offset+position, ModifiedHeap.SHORTHEAP, 1); } }
@Override public void ll_setLongArrayValue(int fsRef, int position, long value) { final int offset = this.getHeap().heap[getArrayStartAddress(fsRef)]; this.getLongHeap().setHeapValue(value, offset + position); if (this.svd.trackingMark != null) { this.logFSUpdate(fsRef, offset+position, ModifiedHeap.LONGHEAP, 1); } }
/** * This is the common point where all sets of values in the heap come through * It implements the check for invalid feature setting and potentially the addback. * * Set the value of a feature of a FS. * * @param addr * The address of the FS. * @param feat * The code of the feature. * @param val * The new value for the feature. * @exception ArrayIndexOutOfBoundsException * If the feature is not a legal feature, or it is not * appropriate for the type at the address. */ public void setFeatureValue(int addr, int feat, int val) { boolean wasRemoved = checkForInvalidFeatureSetting(addr, feat); setFeatureValueNotJournaled(addr, feat, val); if (wasRemoved) { maybeAddback(addr); } if (this.svd.trackingMark != null) { this.logFSUpdate(addr, addr + this.svd.casMetadata.featureOffset[feat], ModifiedHeap.FSHEAP, 1); } }