37 static final Unsafe UNSAFE = Unsafe.getUnsafe(); 38 39 static final long F_OFFSET; 40 41 static { 42 try { 43 F_OFFSET = UNSAFE.objectFieldOffset(T.class.getDeclaredField("f")); 44 } catch (Exception e) { 45 throw new Error(e); 46 } 47 } 48 49 static class T { 50 Object f; 51 } 52 53 public static void testFieldInstanceObject(Object t) { 54 for (int c = 0; c < 20000; c++) { // trigger OSR compilation 55 // java/lang/Object+12 * 56 // _base = InstPtr, _ptr = BotPTR, _field = NULL, mismatched = true 57 UNSAFE.putObject(t, F_OFFSET, "foo"); 58 } 59 } 60 61 public static void testFieldInstanceT(T t) { 62 for (int c = 0; c < 20000; c++) { // trigger OSR compilation 63 // ...$T+12 * 64 // _base = InstPtr, _ptr = BotPTR, _field = T.f, mismatched = false 65 UNSAFE.putObject(t, F_OFFSET, "foo"); 66 } 67 } 68 public static void main(String[] args) { 69 testFieldInstanceObject(new T()); 70 testFieldInstanceT(new T()); 71 } 72 } 73 | 37 static final Unsafe UNSAFE = Unsafe.getUnsafe(); 38 39 static final long F_OFFSET; 40 41 static { 42 try { 43 F_OFFSET = UNSAFE.objectFieldOffset(T.class.getDeclaredField("f")); 44 } catch (Exception e) { 45 throw new Error(e); 46 } 47 } 48 49 static class T { 50 Object f; 51 } 52 53 public static void testFieldInstanceObject(Object t) { 54 for (int c = 0; c < 20000; c++) { // trigger OSR compilation 55 // java/lang/Object+12 * 56 // _base = InstPtr, _ptr = BotPTR, _field = NULL, mismatched = true 57 UNSAFE.putReference(t, F_OFFSET, "foo"); 58 } 59 } 60 61 public static void testFieldInstanceT(T t) { 62 for (int c = 0; c < 20000; c++) { // trigger OSR compilation 63 // ...$T+12 * 64 // _base = InstPtr, _ptr = BotPTR, _field = T.f, mismatched = false 65 UNSAFE.putReference(t, F_OFFSET, "foo"); 66 } 67 } 68 public static void main(String[] args) { 69 testFieldInstanceObject(new T()); 70 testFieldInstanceT(new T()); 71 } 72 } 73 |