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.arraytotal.read;
 24 
 25 import org.openjdk.bench.valhalla.arraytotal.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_as_Val_to_Val_read(Val_as_Val st) {
 52         Q64long[] arr = st.arr;
 53         for(int i=0; i < arr.length; i++) {
 54             val_consume(arr[i]);
 55         }
 56     }
 57 
 58     @Benchmark
 59     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 60     public void Val_as_Val_to_Ref_read(Val_as_Val st) {
 61         Q64long[] arr = st.arr;
 62         for(int i=0; i < arr.length; i++) {
 63             ref_consume(arr[i]);
 64         }
 65     }
 66 
 67     @Benchmark
 68     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 69     public void Val_as_Val_to_Int_read(Val_as_Val st) {
 70         Q64long[] arr = st.arr;
 71         for(int i=0; i < arr.length; i++) {
 72             int_consume(arr[i]);
 73         }
 74     }
 75 
 76     @Benchmark
 77     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 78     public void Val_as_Val_to_Obj_read(Val_as_Val st) {
 79         Q64long[] arr = st.arr;
 80         for(int i=0; i < arr.length; i++) {
 81             obj_consume(arr[i]);
 82         }
 83     }
 84 
 85     @Benchmark
 86     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 87     public void Val_as_Ref_to_Val_read(Val_as_Ref st) {
 88         Q64long[] arr = st.arr;
 89         for(int i=0; i < arr.length; i++) {
 90             val_consume(arr[i]);
 91         }
 92     }
 93 
 94     @Benchmark
 95     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 96     public void Val_as_Ref_to_Ref_read(Val_as_Ref st) {
 97         Q64long[] arr = st.arr;
 98         for(int i=0; i < arr.length; i++) {
 99             ref_consume(arr[i]);
100         }
101     }
102 
103     @Benchmark
104     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
105     public void Val_as_Ref_to_Int_read(Val_as_Ref st) {
106         Q64long[] arr = st.arr;
107         for(int i=0; i < arr.length; i++) {
108             int_consume(arr[i]);
109         }
110     }
111 
112     @Benchmark
113     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
114     public void Val_as_Ref_to_Obj_read(Val_as_Ref st) {
115         Q64long[] arr = st.arr;
116         for(int i=0; i < arr.length; i++) {
117             obj_consume(arr[i]);
118         }
119     }
120 
121     @Benchmark
122     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
123     public void Val_as_Int_to_Int_read(Val_as_Int st) {
124         Int64[] arr = st.arr;
125         for(int i=0; i < arr.length; i++) {
126             int_consume(arr[i]);
127         }
128     }
129 
130     @Benchmark
131     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
132     public void Val_as_Int_to_Obj_read(Val_as_Int st) {
133         Int64[] arr = st.arr;
134         for(int i=0; i < arr.length; i++) {
135             obj_consume(arr[i]);
136         }
137     }
138 
139     @Benchmark
140     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
141     public void Val_as_Obj_to_Obj_read(Val_as_Obj st) {
142         Object[] arr = st.arr;
143         for(int i=0; i < arr.length; i++) {
144             obj_consume(arr[i]);
145         }
146     }
147 
148     @Benchmark
149     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
150     public void Ref_as_Ref_to_Val_read(Ref_as_Ref st) {
151         Q64long[] arr = st.arr;
152         for(int i=0; i < arr.length; i++) {
153             val_consume(arr[i]);
154         }
155     }
156 
157     @Benchmark
158     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
159     public void Ref_as_Ref_to_Ref_read(Ref_as_Ref st) {
160         Q64long[] arr = st.arr;
161         for(int i=0; i < arr.length; i++) {
162             ref_consume(arr[i]);
163         }
164     }
165 
166     @Benchmark
167     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
168     public void Ref_as_Ref_to_Int_read(Ref_as_Ref st) {
169         Q64long[] arr = st.arr;
170         for(int i=0; i < arr.length; i++) {
171             int_consume(arr[i]);
172         }
173     }
174 
175     @Benchmark
176     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
177     public void Ref_as_Ref_to_Obj_read(Ref_as_Ref st) {
178         Q64long[] arr = st.arr;
179         for(int i=0; i < arr.length; i++) {
180             obj_consume(arr[i]);
181         }
182     }
183 
184     @Benchmark
185     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
186     public void Ref_as_Int_to_Int_read(Ref_as_Int st) {
187         Int64[] arr = st.arr;
188         for(int i=0; i < arr.length; i++) {
189             int_consume(arr[i]);
190         }
191     }
192 
193     @Benchmark
194     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
195     public void Ref_as_Int_to_Obj_read(Ref_as_Int st) {
196         Int64[] arr = st.arr;
197         for(int i=0; i < arr.length; i++) {
198             obj_consume(arr[i]);
199         }
200     }
201 
202     @Benchmark
203     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
204     public void Ref_as_Obj_to_Obj_read(Ref_as_Obj st) {
205         Object[] arr = st.arr;
206         for(int i=0; i < arr.length; i++) {
207             obj_consume(arr[i]);
208         }
209     }
210 
211 }