8152024: MemoryAccessProvider javadoc should be modified

Reviewed-by: kvn, twisti
This commit is contained in:
Doug Simon 2016-03-31 09:16:49 -07:00
parent adb3a381c2
commit b75d50cc75
2 changed files with 12 additions and 8 deletions

View file

@ -23,7 +23,6 @@
package jdk.vm.ci.hotspot;
import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
import jdk.vm.ci.common.JVMCIError;
import jdk.vm.ci.hotspot.HotSpotVMConfig.CompressEncoding;
import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.JavaConstant;
@ -59,7 +58,7 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, Ho
return true;
}
} else {
throw new JVMCIError("%s", metaspaceObject);
throw new IllegalArgumentException(String.valueOf(metaspaceObject));
}
}
return false;
@ -75,7 +74,7 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, Ho
return prim.asLong();
}
}
throw new JVMCIError("%s", base);
throw new IllegalArgumentException(String.valueOf(base));
}
private static long readRawValue(Constant baseConstant, long displacement, int bits) {
@ -91,7 +90,7 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, Ho
case Long.SIZE:
return UNSAFE.getLong(base, displacement);
default:
throw new JVMCIError("%d", bits);
throw new IllegalArgumentException(String.valueOf(bits));
}
} else {
long pointer = asRawPointer(baseConstant);
@ -105,7 +104,7 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, Ho
case Long.SIZE:
return UNSAFE.getLong(pointer + displacement);
default:
throw new JVMCIError("%d", bits);
throw new IllegalArgumentException(String.valueOf(bits));
}
}
}
@ -178,7 +177,7 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, Ho
case Double:
return JavaConstant.forDouble(Double.longBitsToDouble(rawValue));
default:
throw new JVMCIError("Unsupported kind: %s", kind);
throw new IllegalArgumentException("Unsupported kind: " + kind);
}
} catch (NullPointerException e) {
return null;

View file

@ -35,8 +35,10 @@ public interface MemoryAccessProvider {
* @param displacement the displacement within the object in bytes
* @return the read value encapsulated in a {@link JavaConstant} object, or {@code null} if the
* value cannot be read.
* @throws IllegalArgumentException if {@code kind} is {@link JavaKind#Void} or not
* {@linkplain JavaKind#isPrimitive() primitive} kind
*/
JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant base, long displacement);
JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant base, long displacement) throws IllegalArgumentException;
/**
* Reads a primitive value using a base address and a displacement.
@ -46,8 +48,11 @@ public interface MemoryAccessProvider {
* @param displacement the displacement within the object in bytes
* @param bits the number of bits to read from memory
* @return the read value encapsulated in a {@link JavaConstant} object of {@link JavaKind} kind
* @throws IllegalArgumentException if {@code kind} is {@link JavaKind#Void} or not
* {@linkplain JavaKind#isPrimitive() primitive} kind or {@code bits} is not 8, 16,
* 32 or 64
*/
JavaConstant readPrimitiveConstant(JavaKind kind, Constant base, long displacement, int bits);
JavaConstant readPrimitiveConstant(JavaKind kind, Constant base, long displacement, int bits) throws IllegalArgumentException;
/**
* Reads a Java {@link Object} value using a base address and a displacement.