prefetch instructions in Hotspot

Mahmood Naderan nt_mahmood at
Fri Apr 4 11:24:43 UTC 2014

OK guys. Thanks to Vladimir and others I added the declarations and compiled JDK6 successfully. Then based on the test example provided here ( I wrote the following code to see if I am using the prefetchRead correctly.

import sun.misc.Unsafe;
import java.lang.reflect.*;
public class Arr {
  static int [] a = new int[3];
  static Unsafe unsafe;
  static int baseOffset, indexScale;
  public static void main(String[] args)  throws Exception {
    a[0] = 10;
    a[1] = 20;
    a[2] = 30;
    Class c = Arr.class.getClassLoader().loadClass("sun.misc.Unsafe");
    Field f = c.getDeclaredField("theUnsafe");
    unsafe = (Unsafe)f.get(c);
    baseOffset = unsafe.arrayBaseOffset(int[].class);
    indexScale = unsafe.arrayIndexScale(int[].class);
    for (int i = 0; i < 3; i++)  {
      unsafe.prefetchReadStatic(a, baseOffset+indexScale*i);

Running the code shows everything is fine and the values are printed on the screen.
Just need a confirmation; is that a correct usage of prefetchRead()? Is that all?


On Thursday, April 3, 2014 6:36 PM, "dalibor.topic at" <dalibor.topic at> wrote:
>See top level file Readme-build.html for instructions.

>-->Oracle <>
>Dalibor Topic | Principal Product Manager
>Phone: +494089091214<tel:+494089091214> | Mobile:+491737185961<tel:+491737185961>
>Oracle Java Platform Group
>ORACLE Deutschland B.V. & Co. KG | Kühnehöfe 5 | 22761 Hamburg
>ORACLE Deutschland B.V. & Co. KG
>Hauptverwaltung: Riesstr. 25, D-80992 München
>Registergericht: Amtsgericht München, HRA 95603
>Geschäftsführer: Jürgen Kunz
>Komplementärin: ORACLE Deutschland Verwaltung B.V.
>Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
>Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
>Geschäftsführer: Alexander van der Ven, Astrid Kepper, Val Maher
>Green Oracle <> Oracle is committed to developing practices and products that help protect the environment

More information about the hotspot-dev mailing list