1 /*
  2  * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 package org.openjdk.bench.valhalla.field.read;
 24 
 25 import org.openjdk.bench.valhalla.field.util.StatesQ64long;
 26 import org.openjdk.bench.valhalla.types.Int64;
 27 import org.openjdk.bench.valhalla.types.Q64long;
 28 import org.openjdk.jmh.annotations.Benchmark;
 29 import org.openjdk.jmh.annotations.CompilerControl;
 30 
 31 public class Inline64long extends StatesQ64long {
 32 
 33     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 34     public void val_consume(Q64long v) {
 35     }
 36 
 37     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 38     public void ref_consume(Q64long v) {
 39     }
 40 
 41     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 42     public void int_consume(Int64 v) {
 43     }
 44 
 45     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 46     public void obj_consume(Object v) {
 47     }
 48 
 49     @Benchmark
 50     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 51     public void Val_to_Val_read(ValState st) {
 52         ValWrapper[] arr = st.arr;
 53         for(int i=0; i < arr.length; i++) {
 54             val_consume(arr[i].f);
 55         }
 56     }
 57 
 58     @Benchmark
 59     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 60     public void Val_to_Ref_read(ValState st) {
 61         ValWrapper[] arr = st.arr;
 62         for(int i=0; i < arr.length; i++) {
 63             ref_consume(arr[i].f);
 64         }
 65     }
 66 
 67     @Benchmark
 68     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 69     public void Val_to_Int_read(ValState st) {
 70         ValWrapper[] arr = st.arr;
 71         for(int i=0; i < arr.length; i++) {
 72             int_consume(arr[i].f);
 73         }
 74     }
 75 
 76     @Benchmark
 77     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 78     public void Val_to_Obj_read(ValState st) {
 79         ValWrapper[] arr = st.arr;
 80         for(int i=0; i < arr.length; i++) {
 81             obj_consume(arr[i].f);
 82         }
 83     }
 84 
 85     @Benchmark
 86     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 87     public void Ref_to_Val_read(RefState st) {
 88         RefWrapper[] arr = st.arr;
 89         for(int i=0; i < arr.length; i++) {
 90             val_consume(arr[i].f);
 91         }
 92     }
 93 
 94     @Benchmark
 95     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 96     public void Ref_to_Ref_read(RefState st) {
 97         RefWrapper[] arr = st.arr;
 98         for(int i=0; i < arr.length; i++) {
 99             ref_consume(arr[i].f);
100         }
101     }
102 
103     @Benchmark
104     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
105     public void Ref_to_Int_read(RefState st) {
106         RefWrapper[] arr = st.arr;
107         for(int i=0; i < arr.length; i++) {
108             int_consume(arr[i].f);
109         }
110     }
111 
112     @Benchmark
113     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
114     public void Ref_to_Obj_read(RefState st) {
115         RefWrapper[] arr = st.arr;
116         for(int i=0; i < arr.length; i++) {
117             obj_consume(arr[i].f);
118         }
119     }
120 
121 }