From 0a4a42279ca546b6cd56a02fc6b28badf189610e Mon Sep 17 00:00:00 2001
From: katherine-hough <32645020+katherine-hough@users.noreply.github.com>
Date: Tue, 28 Nov 2023 20:29:45 -0500
Subject: [PATCH] * Started fixing masking issues
---
.../runtime/mask/SunUnsafeMasker.java | 220 +++++++++---------
.../runtime/mask/UnsafeMaskerHelper.java | 3 +-
integration-tests/pom.xml | 11 -
integration-tests/runDacapo.sh | 6 -
4 files changed, 112 insertions(+), 128 deletions(-)
diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/SunUnsafeMasker.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/SunUnsafeMasker.java
index ad8702347..bd2ef47f0 100644
--- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/SunUnsafeMasker.java
+++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/SunUnsafeMasker.java
@@ -15,11 +15,11 @@
@SuppressWarnings("unused")
public final class SunUnsafeMasker {
- private static UnsafeAdapter adapter;
+ private static final UnsafeAdapter ADAPTER = UnsafeMaskerHelper.ADAPTER;
@Mask(owner = Unsafe.class)
public static Class> defineClass(
- Unsafe unsafe,
+ Object unsafe,
String name,
byte[] b,
int off,
@@ -31,47 +31,47 @@ public static Class> defineClass(
byte[] buffer = new byte[len];
System.arraycopy(b, off, buffer, 0, len);
byte[] instrumented = Phosphor.instrumentClassBytes(buffer);
- return adapter.defineClass(name, instrumented, 0, instrumented.length, loader, protectionDomain);
+ return ADAPTER.defineClass(name, instrumented, 0, instrumented.length, loader, protectionDomain);
}
- return adapter.defineClass(name, b, off, len, loader, protectionDomain);
+ return ADAPTER.defineClass(name, b, off, len, loader, protectionDomain);
}
@Mask(owner = Unsafe.class)
- public static Object getObject(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static Object getObject(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
return getObjectPolicy(o, offset, frame, SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static Object getObjectVolatile(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static Object getObjectVolatile(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
return getObjectPolicy(o, offset, frame, SpecialAccessPolicy.VOLATILE);
}
@Mask(owner = Unsafe.class)
public static boolean compareAndSwapInt(
- Unsafe unsafe, Object o, long offset, int expected, int x, PhosphorStackFrame frame) {
+ Object unsafe, Object o, long offset, int expected, int x, PhosphorStackFrame frame) {
frame.returnTaint = Taint.emptyTaint();
- return swapTag(o, offset, frame, adapter.compareAndSwapInt(unwrap(o), offset, expected, x));
+ return swapTag(o, offset, frame, ADAPTER.compareAndSwapInt(unwrap(o), offset, expected, x));
}
@Mask(owner = Unsafe.class)
public static boolean compareAndSwapLong(
- Unsafe unsafe, Object o, long offset, long expected, long x, PhosphorStackFrame frame) {
+ Object unsafe, Object o, long offset, long expected, long x, PhosphorStackFrame frame) {
frame.returnTaint = Taint.emptyTaint();
- return swapTag(o, offset, frame, adapter.compareAndSwapLong(unwrap(o), offset, expected, x));
+ return swapTag(o, offset, frame, ADAPTER.compareAndSwapLong(unwrap(o), offset, expected, x));
}
@Mask(owner = Unsafe.class)
public static boolean compareAndSwapObject(
- Unsafe unsafe, Object o, long offset, Object expected, Object x, PhosphorStackFrame frame) {
+ Object unsafe, Object o, long offset, Object expected, Object x, PhosphorStackFrame frame) {
frame.returnTaint = Taint.emptyTaint();
boolean ret = false;
if (o instanceof TaggedReferenceArray) {
Taint> valueTaint = frame.getArgTaint(4);
TaggedReferenceArray array = (TaggedReferenceArray) o;
- ret = adapter.compareAndSwapObject(array.val, offset, expected, x);
+ ret = ADAPTER.compareAndSwapObject(array.val, offset, expected, x);
if (ret) {
if (array.getVal() != null && array.getVal().getClass().isArray()) {
- int index = getArrayIndex(adapter, (TaggedArray) o, offset);
+ int index = getArrayIndex(ADAPTER, (TaggedArray) o, offset);
array.setTaint(index, valueTaint);
}
}
@@ -81,11 +81,11 @@ public static boolean compareAndSwapObject(
if (x instanceof TaggedArray || expected instanceof TaggedArray) {
// Need to be careful - maybe we are hitting a 1D primitive array field
if (o != null) {
- pair = getOffsetPair(adapter, o, offset);
+ pair = getOffsetPair(ADAPTER, o, offset);
}
if (pair != null && pair.wrappedFieldOffset != UnsafeProxy.INVALID_FIELD_OFFSET) {
// We are doing a CAS on a 1d primitive array field
- ret = adapter.compareAndSwapObject(
+ ret = ADAPTER.compareAndSwapObject(
o, offset, MultiDArrayUtils.unbox1DOrNull(expected), MultiDArrayUtils.unbox1DOrNull(x));
didCAS = true;
}
@@ -93,17 +93,17 @@ public static boolean compareAndSwapObject(
if (!didCAS) {
// Either this is not a wrapped array, or we are storing it to the place where it should be stored
// without unwrapping
- ret = adapter.compareAndSwapObject(o, offset, expected, x);
+ ret = ADAPTER.compareAndSwapObject(o, offset, expected, x);
if (pair == null && o != null) {
- pair = getOffsetPair(adapter, o, offset);
+ pair = getOffsetPair(ADAPTER, o, offset);
}
}
if (pair != null && ret) {
if (pair.tagFieldOffset != UnsafeProxy.INVALID_FIELD_OFFSET) {
- adapter.putObjectVolatile(o, pair.tagFieldOffset, frame.getArgTaint(4));
+ ADAPTER.putObjectVolatile(o, pair.tagFieldOffset, frame.getArgTaint(4));
}
if (pair.wrappedFieldOffset != UnsafeProxy.INVALID_FIELD_OFFSET) {
- adapter.putObjectVolatile(o, pair.wrappedFieldOffset, x);
+ ADAPTER.putObjectVolatile(o, pair.wrappedFieldOffset, x);
}
}
}
@@ -111,269 +111,269 @@ public static boolean compareAndSwapObject(
}
@Mask(owner = Unsafe.class)
- public static boolean getBoolean(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static boolean getBoolean(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.NONE);
- return adapter.getBoolean(unwrap(o), offset);
+ return ADAPTER.getBoolean(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static boolean getBooleanVolatile(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static boolean getBooleanVolatile(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.VOLATILE);
- return adapter.getBooleanVolatile(unwrap(0), offset);
+ return ADAPTER.getBooleanVolatile(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static byte getByte(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static byte getByte(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.NONE);
- return adapter.getByte(unwrap(0), offset);
+ return ADAPTER.getByte(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static byte getByteVolatile(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static byte getByteVolatile(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.VOLATILE);
- return adapter.getByteVolatile(unwrap(0), offset);
+ return ADAPTER.getByteVolatile(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static char getChar(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static char getChar(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.NONE);
- return adapter.getChar(unwrap(0), offset);
+ return ADAPTER.getChar(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static char getCharVolatile(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static char getCharVolatile(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.VOLATILE);
- return adapter.getCharVolatile(unwrap(0), offset);
+ return ADAPTER.getCharVolatile(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static double getDouble(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static double getDouble(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.NONE);
- return adapter.getDouble(unwrap(0), offset);
+ return ADAPTER.getDouble(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static double getDoubleVolatile(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static double getDoubleVolatile(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.VOLATILE);
- return adapter.getDoubleVolatile(unwrap(0), offset);
+ return ADAPTER.getDoubleVolatile(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static float getFloat(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static float getFloat(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.NONE);
- return adapter.getFloat(unwrap(0), offset);
+ return ADAPTER.getFloat(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static float getFloatVolatile(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static float getFloatVolatile(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.VOLATILE);
- return adapter.getFloatVolatile(unwrap(0), offset);
+ return ADAPTER.getFloatVolatile(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static int getInt(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static int getInt(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.NONE);
- return adapter.getInt(unwrap(0), offset);
+ return ADAPTER.getInt(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static int getIntVolatile(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static int getIntVolatile(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.VOLATILE);
- return adapter.getIntVolatile(unwrap(0), offset);
+ return ADAPTER.getIntVolatile(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static long getLong(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static long getLong(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.NONE);
- return adapter.getLong(unwrap(0), offset);
+ return ADAPTER.getLong(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static long getLongVolatile(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static long getLongVolatile(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.VOLATILE);
- return adapter.getLongVolatile(unwrap(0), offset);
+ return ADAPTER.getLongVolatile(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static short getShort(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static short getShort(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.NONE);
- return adapter.getShort(unwrap(0), offset);
+ return ADAPTER.getShort(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
- public static short getShortVolatile(Unsafe unsafe, Object o, long offset, PhosphorStackFrame frame) {
+ public static short getShortVolatile(Object unsafe, Object o, long offset, PhosphorStackFrame frame) {
getTagPrimitive(o, offset, frame, SpecialAccessPolicy.VOLATILE);
- return adapter.getShortVolatile(unwrap(0), offset);
+ return ADAPTER.getShortVolatile(unwrap(o), offset);
}
@Mask(owner = Unsafe.class)
public static void copyMemory(
- Unsafe unsafe,
+ Object unsafe,
Object srcBase,
long srcOffset,
Object destBase,
long destOffset,
long bytes,
PhosphorStackFrame frame) {
- adapter.copyMemory(unwrap(srcBase), srcOffset, unwrap(destBase), destOffset, bytes);
+ ADAPTER.copyMemory(unwrap(srcBase), srcOffset, unwrap(destBase), destOffset, bytes);
}
@Mask(owner = Unsafe.class)
public static void copyMemory(
- Unsafe unsafe, long srcAddress, long destAddress, long length, PhosphorStackFrame frame) {
- adapter.copyMemory(srcAddress, destAddress, length);
+ Object unsafe, long srcAddress, long destAddress, long length, PhosphorStackFrame frame) {
+ ADAPTER.copyMemory(srcAddress, destAddress, length);
}
@Mask(owner = Unsafe.class)
- public static void putBoolean(Unsafe unsafe, Object o, long offset, boolean x, PhosphorStackFrame frame) {
- adapter.putBoolean(unwrap(o), offset, x);
+ public static void putBoolean(Object unsafe, Object o, long offset, boolean x, PhosphorStackFrame frame) {
+ ADAPTER.putBoolean(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static void putBooleanVolatile(Unsafe unsafe, Object o, long offset, boolean x, PhosphorStackFrame frame) {
- adapter.putBooleanVolatile(unwrap(o), offset, x);
+ public static void putBooleanVolatile(Object unsafe, Object o, long offset, boolean x, PhosphorStackFrame frame) {
+ ADAPTER.putBooleanVolatile(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.VOLATILE);
}
@Mask(owner = Unsafe.class)
- public static void putByte(Unsafe unsafe, Object o, long offset, byte x, PhosphorStackFrame frame) {
- adapter.putByte(unwrap(o), offset, x);
+ public static void putByte(Object unsafe, Object o, long offset, byte x, PhosphorStackFrame frame) {
+ ADAPTER.putByte(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static void putByteVolatile(Unsafe unsafe, Object o, long offset, byte x, PhosphorStackFrame frame) {
- adapter.putByteVolatile(unwrap(o), offset, x);
+ public static void putByteVolatile(Object unsafe, Object o, long offset, byte x, PhosphorStackFrame frame) {
+ ADAPTER.putByteVolatile(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.VOLATILE);
}
@Mask(owner = Unsafe.class)
- public static void putChar(Unsafe unsafe, Object o, long offset, char x, PhosphorStackFrame frame) {
- adapter.putChar(unwrap(o), offset, x);
+ public static void putChar(Object unsafe, Object o, long offset, char x, PhosphorStackFrame frame) {
+ ADAPTER.putChar(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static void putCharVolatile(Unsafe unsafe, Object o, long offset, char x, PhosphorStackFrame frame) {
- adapter.putCharVolatile(unwrap(o), offset, x);
+ public static void putCharVolatile(Object unsafe, Object o, long offset, char x, PhosphorStackFrame frame) {
+ ADAPTER.putCharVolatile(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.VOLATILE);
}
@Mask(owner = Unsafe.class)
- public static void putDouble(Unsafe unsafe, Object o, long offset, double x, PhosphorStackFrame frame) {
- adapter.putDouble(unwrap(o), offset, x);
+ public static void putDouble(Object unsafe, Object o, long offset, double x, PhosphorStackFrame frame) {
+ ADAPTER.putDouble(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static void putDoubleVolatile(Unsafe unsafe, Object o, long offset, double x, PhosphorStackFrame frame) {
- adapter.putDoubleVolatile(unwrap(o), offset, x);
+ public static void putDoubleVolatile(Object unsafe, Object o, long offset, double x, PhosphorStackFrame frame) {
+ ADAPTER.putDoubleVolatile(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.VOLATILE);
}
@Mask(owner = Unsafe.class)
- public static void putFloat(Unsafe unsafe, Object o, long offset, float x, PhosphorStackFrame frame) {
- adapter.putFloat(unwrap(o), offset, x);
+ public static void putFloat(Object unsafe, Object o, long offset, float x, PhosphorStackFrame frame) {
+ ADAPTER.putFloat(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static void putFloatVolatile(Unsafe unsafe, Object o, long offset, float x, PhosphorStackFrame frame) {
- adapter.putFloatVolatile(unwrap(o), offset, x);
+ public static void putFloatVolatile(Object unsafe, Object o, long offset, float x, PhosphorStackFrame frame) {
+ ADAPTER.putFloatVolatile(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.VOLATILE);
}
@Mask(owner = Unsafe.class)
- public static void putInt(Unsafe unsafe, Object o, long offset, int x, PhosphorStackFrame frame) {
- adapter.putInt(unwrap(o), offset, x);
+ public static void putInt(Object unsafe, Object o, long offset, int x, PhosphorStackFrame frame) {
+ ADAPTER.putInt(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static void putIntVolatile(Unsafe unsafe, Object o, long offset, int x, PhosphorStackFrame frame) {
- adapter.putIntVolatile(unwrap(o), offset, x);
+ public static void putIntVolatile(Object unsafe, Object o, long offset, int x, PhosphorStackFrame frame) {
+ ADAPTER.putIntVolatile(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.VOLATILE);
}
@Mask(owner = Unsafe.class)
- public static void putLong(Unsafe unsafe, Object o, long offset, long x, PhosphorStackFrame frame) {
- adapter.putLong(unwrap(o), offset, x);
+ public static void putLong(Object unsafe, Object o, long offset, long x, PhosphorStackFrame frame) {
+ ADAPTER.putLong(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static void putLongVolatile(Unsafe unsafe, Object o, long offset, long x, PhosphorStackFrame frame) {
- adapter.putLongVolatile(unwrap(o), offset, x);
+ public static void putLongVolatile(Object unsafe, Object o, long offset, long x, PhosphorStackFrame frame) {
+ ADAPTER.putLongVolatile(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.VOLATILE);
}
@Mask(owner = Unsafe.class)
- public static void putObject(Unsafe unsafe, Object o, long offset, Object x, PhosphorStackFrame frame) {
+ public static void putObject(Object unsafe, Object o, long offset, Object x, PhosphorStackFrame frame) {
putObject(o, offset, x, frame, SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static void putObjectVolatile(Unsafe unsafe, Object o, long offset, Object x, PhosphorStackFrame frame) {
+ public static void putObjectVolatile(Object unsafe, Object o, long offset, Object x, PhosphorStackFrame frame) {
putObject(o, offset, x, frame, SpecialAccessPolicy.VOLATILE);
}
@Mask(owner = Unsafe.class)
- public static void putOrderedInt(Unsafe unsafe, Object o, long offset, int x, PhosphorStackFrame frame) {
- adapter.putOrderedInt(unwrap(o), offset, x);
+ public static void putOrderedInt(Object unsafe, Object o, long offset, int x, PhosphorStackFrame frame) {
+ ADAPTER.putOrderedInt(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.ORDERED);
}
@Mask(owner = Unsafe.class)
- public static void putOrderedLong(Unsafe unsafe, Object o, long offset, long x, PhosphorStackFrame frame) {
- adapter.putOrderedLong(unwrap(o), offset, x);
+ public static void putOrderedLong(Object unsafe, Object o, long offset, long x, PhosphorStackFrame frame) {
+ ADAPTER.putOrderedLong(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.ORDERED);
}
@Mask(owner = Unsafe.class)
- public static void putOrderedObject(Unsafe unsafe, Object o, long offset, Object x, PhosphorStackFrame frame) {
+ public static void putOrderedObject(Object unsafe, Object o, long offset, Object x, PhosphorStackFrame frame) {
putObject(o, offset, x, frame, SpecialAccessPolicy.ORDERED);
}
@Mask(owner = Unsafe.class)
- public static void putShort(Unsafe unsafe, Object o, long offset, short x, PhosphorStackFrame frame) {
- adapter.putShort(unwrap(o), offset, x);
+ public static void putShort(Object unsafe, Object o, long offset, short x, PhosphorStackFrame frame) {
+ ADAPTER.putShort(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.NONE);
}
@Mask(owner = Unsafe.class)
- public static void putShortVolatile(Unsafe unsafe, Object o, long offset, short x, PhosphorStackFrame frame) {
- adapter.putShortVolatile(unwrap(o), offset, x);
+ public static void putShortVolatile(Object unsafe, Object o, long offset, short x, PhosphorStackFrame frame) {
+ ADAPTER.putShortVolatile(unwrap(o), offset, x);
putTagPrimitive(o, offset, frame.getArgTaint(3), SpecialAccessPolicy.VOLATILE);
}
private static void getTagPrimitive(Object o, long offset, PhosphorStackFrame frame, SpecialAccessPolicy policy) {
if (o instanceof TaggedArray) {
TaggedArray array = (TaggedArray) o;
- int index = getArrayIndex(adapter, array, offset);
+ int index = getArrayIndex(ADAPTER, array, offset);
frame.returnTaint = array.getTaintOrEmpty(index);
} else {
- getTag(adapter, o, offset, frame, policy);
+ getTag(ADAPTER, o, offset, frame, policy);
}
}
private static void putTagPrimitive(Object o, long offset, Taint> valTaint, SpecialAccessPolicy policy) {
if (o instanceof TaggedArray) {
TaggedArray array = (TaggedArray) o;
- int index = getArrayIndex(adapter, array, offset);
+ int index = getArrayIndex(ADAPTER, array, offset);
array.setTaint(index, valTaint);
} else {
- putTag(adapter, o, offset, valTaint, policy);
+ putTag(ADAPTER, o, offset, valTaint, policy);
}
}
private static void putObject(Object o, long offset, Object x, SpecialAccessPolicy policy) {
switch (policy) {
case NONE:
- adapter.putObject(o, offset, x);
+ ADAPTER.putObject(o, offset, x);
return;
case VOLATILE:
- adapter.putObjectVolatile(o, offset, x);
+ ADAPTER.putObjectVolatile(o, offset, x);
return;
default:
throw new IllegalArgumentException();
@@ -384,20 +384,20 @@ private static Object getObjectPolicy(Object o, long offset, PhosphorStackFrame
if (o instanceof TaggedReferenceArray) {
// Push the taint from the `offset` argument to the `idx` argument for get
TaggedReferenceArray array = (TaggedReferenceArray) o;
- int index = getArrayIndex(adapter, array, offset);
+ int index = getArrayIndex(ADAPTER, array, offset);
return array.get(index, frame.getArgTaint(1), frame);
} else {
// Is this trying to return a field that is wrapped?
- RuntimeJDKInternalUnsafePropagator.OffsetPair pair = getOffsetPair(adapter, o, offset);
+ RuntimeJDKInternalUnsafePropagator.OffsetPair pair = getOffsetPair(ADAPTER, o, offset);
if (pair != null && pair.wrappedFieldOffset != UnsafeProxy.INVALID_FIELD_OFFSET) {
offset = pair.wrappedFieldOffset;
}
- getTag(adapter, o, offset, frame, policy);
+ getTag(ADAPTER, o, offset, frame, policy);
switch (policy) {
case NONE:
- return adapter.getObject(o, offset);
+ return ADAPTER.getObject(o, offset);
case VOLATILE:
- return adapter.getObjectVolatile(o, offset);
+ return ADAPTER.getObjectVolatile(o, offset);
default:
throw new IllegalArgumentException();
}
@@ -408,12 +408,12 @@ private static void putObject(
Object o, long offset, Object x, PhosphorStackFrame frame, SpecialAccessPolicy policy) {
if (o instanceof TaggedReferenceArray) {
TaggedReferenceArray array = (TaggedReferenceArray) o;
- int index = getArrayIndex(adapter, array, offset);
+ int index = getArrayIndex(ADAPTER, array, offset);
array.set(index, x, frame.getArgTaint(3));
} else {
RuntimeJDKInternalUnsafePropagator.OffsetPair pair = null;
if (o != null) {
- pair = getOffsetPair(adapter, o, offset);
+ pair = getOffsetPair(ADAPTER, o, offset);
}
if (pair != null) {
if (pair.tagFieldOffset != UnsafeProxy.INVALID_FIELD_OFFSET) {
@@ -437,14 +437,14 @@ private static boolean swapTag(Object o, long offset, PhosphorStackFrame frame,
Taint> valueTaint = frame.getArgTaint(4);
TaggedArray array = (TaggedArray) o;
if (array.getVal() != null && array.getVal().getClass().isArray()) {
- int index = getArrayIndex(adapter, array, offset);
+ int index = getArrayIndex(ADAPTER, array, offset);
array.setTaint(index, valueTaint);
}
} else if (o != null) {
- RuntimeJDKInternalUnsafePropagator.OffsetPair pair = getOffsetPair(adapter, o, offset);
+ RuntimeJDKInternalUnsafePropagator.OffsetPair pair = getOffsetPair(ADAPTER, o, offset);
if (pair != null) {
if (pair.tagFieldOffset != UnsafeProxy.INVALID_FIELD_OFFSET) {
- adapter.putObjectVolatile(o, pair.tagFieldOffset, frame.getArgTaint(4));
+ ADAPTER.putObjectVolatile(o, pair.tagFieldOffset, frame.getArgTaint(4));
}
}
}
diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/UnsafeMaskerHelper.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/UnsafeMaskerHelper.java
index 930805bdf..5449a4574 100644
--- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/UnsafeMaskerHelper.java
+++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/UnsafeMaskerHelper.java
@@ -21,7 +21,8 @@ private UnsafeMaskerHelper() {
// Prevents this class from being instantiated
}
- public static final UnsafeAdapter ADAPTER = new SunUnsafeAdapter();
+ public static final UnsafeAdapter ADAPTER =
+ Configuration.IS_JAVA_8 ? new SunUnsafeAdapter() : new JdkUnsafeAdapter();
/* Used to disambiguate between a static field of a given type and an instance field of java.lang.Class */
static long LAST_INSTANCE_OFFSET_JAVA_LANG_CLASS = ADAPTER.getInvalidFieldOffset();
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 46b9f620a..fef0f7c5e 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -19,7 +19,6 @@
false
${edu.gmu.swe.phosphor:Phosphor:jar}
${edu.gmu.swe.phosphor:phosphor-driver:jar}
- false
@@ -108,15 +107,6 @@
-
- java8
-
- 1.8
-
-
- true
-
-
dacapo
@@ -148,7 +138,6 @@
${phosphor.jar}
${phosphor.driver.jar}
${data.flow.java}/bin/java
- ${isJava8}
diff --git a/integration-tests/runDacapo.sh b/integration-tests/runDacapo.sh
index 9e2e030a3..359c1a26c 100755
--- a/integration-tests/runDacapo.sh
+++ b/integration-tests/runDacapo.sh
@@ -4,7 +4,6 @@ readonly BUILD_DIR=$1
readonly PHOSPHOR_JAR=$2
readonly DRIVER_JAR=$3
readonly INST_JVM=$4
-readonly IS_JAVA_8=$5
readonly DACAPO_DIR=$BUILD_DIR/dacapo
readonly INST_DACAPO_DIR=$BUILD_DIR/dacapo-inst
readonly BENCHMARKS=(avrora fop h2 jython luindex pmd sunflow xalan)
@@ -24,11 +23,6 @@ if [ ! -d "$DACAPO_DIR" ]; then
fi
cd "$BUILD_DIR"
-phosphor_args=""
-if [ "$IS_JAVA_8" == "true" ]; then
- phosphor_args="-java8"
-fi
-
if [ ! -d "$INST_DACAPO_DIR" ]; then
echo "Creating data flow instrumented dacapo"
java -Xmx8g -jar "$DRIVER_JAR" -q -forceUnboxAcmpEq -withEnumsByValue $phosphor_args "$DACAPO_DIR" "$INST_DACAPO_DIR"