prefetch instructions in Hotspot
Vladimir Kozlov
vladimir.kozlov at oracle.com
Wed Apr 2 16:24:01 UTC 2014
You need to download Hotspot JVM sources too that is where library_call.cpp.
Vladimir
On 4/2/14 5:59 AM, Mahmood Naderan wrote:
> Vlad,
> I added the decelerations and can be verified as below
>
> mahmood at orca:~$ grep -r "public native" /usr/lib/jvm/java-6-openjdk-amd64/sun/misc/Unsafe.java
> public native void prefetchRead (Object o, long offset);
> public native void prefetchWrite(Object o, long offset);
> public native int getInt(Object o, long offset);
> public native void putInt(Object o, long offset, int x);
> public native Object getObject(Object o, long offset);
> public native void putObject(Object o, long offset, Object x);
> public native boolean getBoolean(Object o, long offset);
> public native void putBoolean(Object o, long offset, boolean x);
> public native byte getByte(Object o, long offset);
> public native void putByte(Object o, long offset, byte x);
> public native short getShort(Object o, long offset);
> public native void putShort(Object o, long offset, short x);
> public native char getChar(Object o, long offset);
> public native void putChar(Object o, long offset, char x);
> public native long getLong(Object o, long offset);
> public native void putLong(Object o, long offset, long x);
> public native float getFloat(Object o, long offset);
> public native void putFloat(Object o, long offset, float x);
> public native double getDouble(Object o, long offset);
> public native void putDouble(Object o, long offset, double x);
> public native byte getByte(long address);
> public native void putByte(long address, byte x);
> public native short getShort(long address);
> public native void putShort(long address, short x);
> public native char getChar(long address);
> public native void putChar(long address, char x);
> public native int getInt(long address);
> public native void putInt(long address, int x);
> public native long getLong(long address);
> public native void putLong(long address, long x);
> public native float getFloat(long address);
> public native void putFloat(long address, float x);
> public native double getDouble(long address);
> public native void putDouble(long address, double x);
> public native long getAddress(long address);
> public native void putAddress(long address, long x);
> public native long allocateMemory(long bytes);
> public native long reallocateMemory(long address, long bytes);
> public native void setMemory(long address, long bytes, byte value);
> public native void copyMemory(Object srcBase, long srcOffset,
> public native void freeMemory(long address);
> public native long staticFieldOffset(Field f);
> public native long objectFieldOffset(Field f);
> public native Object staticFieldBase(Field f);
> public native void ensureClassInitialized(Class c);
> public native int arrayBaseOffset(Class arrayClass);
> public native int arrayIndexScale(Class arrayClass);
> public native int addressSize();
> public native int pageSize();
> public native Class defineClass(String name, byte[] b, int off, int len,
> public native Class defineClass(String name, byte[] b, int off, int len);
> public native Object allocateInstance(Class cls)
> public native void monitorEnter(Object o);
> public native void monitorExit(Object o);
> public native boolean tryMonitorEnter(Object o);
> public native void throwException(Throwable ee);
> public native Object getObjectVolatile(Object o, long offset);
> public native void putObjectVolatile(Object o, long offset, Object x);
> public native int getIntVolatile(Object o, long offset);
> public native void putIntVolatile(Object o, long offset, int x);
> public native boolean getBooleanVolatile(Object o, long offset);
> public native void putBooleanVolatile(Object o, long offset, boolean x);
> public native byte getByteVolatile(Object o, long offset);
> public native void putByteVolatile(Object o, long offset, byte x);
> public native short getShortVolatile(Object o, long offset);
> public native void putShortVolatile(Object o, long offset, short x);
> public native char getCharVolatile(Object o, long offset);
> public native void putCharVolatile(Object o, long offset, char x);
> public native long getLongVolatile(Object o, long offset);
> public native void putLongVolatile(Object o, long offset, long x);
> public native float getFloatVolatile(Object o, long offset);
> public native void putFloatVolatile(Object o, long offset, float x);
> public native double getDoubleVolatile(Object o, long offset);
> public native void putDoubleVolatile(Object o, long offset, double x);
> public native void putOrderedObject(Object o, long offset, Object x);
> public native void putOrderedInt(Object o, long offset, int x);
> public native void putOrderedLong(Object o, long offset, long x);
> public native void unpark(Object thread);
> public native void park(boolean isAbsolute, long time);
> public native int getLoadAverage(double[] loadavg, int nelems);
>
> mahmood at orca:~$ grep -r "public static" /usr/lib/jvm/java-6-openjdk-amd64/sun/misc/Unsafe.java
> public static native void prefetchReadStatic (Object o, long offset);
> public static native void prefetchWriteStatic(Object o, long offset);
> public static Unsafe getUnsafe() {
> public static final int INVALID_FIELD_OFFSET = -1;
>
>
>
>
> But there is no library_call.cpp in /usr/lib/jvm/java-6-openjdk-amd64
>
>
>
> Regards,
> Mahmood
> On Monday, March 31, 2014 11:58 PM, Vladimir Kozlov <vladimir.kozlov at oracle.com> wrote:
>
> Hi Mahmood
>
> You don't need anything additional if you can build and execute java from sources you have.
>
> Do you want to use readPrefetch from java code?
> If yes, you need to add declarations into jdk/src/share/classessun/misc/Unsafe.java:
>
> public native void prefetchRead (Object o, long offset);
> public native void prefetchWrite(Object o, long offset);
> public static native void prefetchReadStatic (Object o, long offset);
> public static native void prefetchWriteStatic(Object o, long offset);
>
> And we already have corresponding intrinsics in Hotspot:
>
> hotspot/src/share/vm/opto/library_call.cpp
> LibraryCallKit::inline_unsafe_prefetch()
>
> Regards,
> Vladimir
>
>
>
> On 3/31/14 5:38 AM, Mahmood Naderan wrote:
>> Hi,
>>
>> I have some naive questions so any answer to the following questions are appreciated.
>>
>> 1- I have open-jdk 1.6 and 1.7. Do I have to install additional things?
>>
>> 2- I want to use some intrinsics (readPrefetch) but there are little information on how to use the intrinsics. Is there any example for that? The only thing I see is https://bugs.openjdk.java.net/browse/JDK-2146656
>>
>>
>> Regards,
>> Mahmood
>>
More information about the hotspot-dev
mailing list