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.fill;
 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 import java.util.Arrays;
 31 
 32 public class Inline64longFillDef extends StatesQ64long {
 33 
 34     @Benchmark
 35     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 36     public void Def_to_Val_as_Val_fill0(Val_as_Val st) {
 37         Q64long[] arr = st.arr;
 38         for (int i = 0; i < arr.length; i++) {
 39             arr[i] = new Q64long()  ;
 40         }
 41     }
 42 
 43     @Benchmark
 44     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 45     public void Def_to_Val_as_Val_fill1(Val_as_Val st) {
 46         int len = st.arr.length;
 47         for (int i = 0; i < len; i++) {
 48             st.arr[i] = new Q64long()  ;
 49         }
 50     }
 51 
 52     @Benchmark
 53     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 54     public void Def_to_Val_as_Ref_fill0(Val_as_Ref st) {
 55         Q64long[] arr = st.arr;
 56         for (int i = 0; i < arr.length; i++) {
 57             arr[i] = new Q64long()  ;
 58         }
 59     }
 60 
 61     @Benchmark
 62     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 63     public void Def_to_Val_as_Ref_fill1(Val_as_Ref st) {
 64         int len = st.arr.length;
 65         for (int i = 0; i < len; i++) {
 66             st.arr[i] = new Q64long()  ;
 67         }
 68     }
 69 
 70     @Benchmark
 71     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 72     public void Def_to_Ref_as_Ref_fill0(Ref_as_Ref st) {
 73         Q64long[] arr = st.arr;
 74         for (int i = 0; i < arr.length; i++) {
 75             arr[i] = new Q64long()  ;
 76         }
 77     }
 78 
 79     @Benchmark
 80     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 81     public void Def_to_Ref_as_Ref_fill1(Ref_as_Ref st) {
 82         int len = st.arr.length;
 83         for (int i = 0; i < len; i++) {
 84             st.arr[i] = new Q64long()  ;
 85         }
 86     }
 87 
 88     @Benchmark
 89     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 90     public void Def_to_Val_as_Int_fill0(Val_as_Int st) {
 91         Int64[] arr = st.arr;
 92         for (int i = 0; i < arr.length; i++) {
 93             arr[i] = new Q64long()  ;
 94         }
 95     }
 96 
 97     @Benchmark
 98     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 99     public void Def_to_Val_as_Int_fill1(Val_as_Int st) {
100         int len = st.arr.length;
101         for (int i = 0; i < len; i++) {
102             st.arr[i] = new Q64long()  ;
103         }
104     }
105 
106     @Benchmark
107     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
108     public void Def_to_Ref_as_Int_fill0(Ref_as_Int st) {
109         Int64[] arr = st.arr;
110         for (int i = 0; i < arr.length; i++) {
111             arr[i] = new Q64long()  ;
112         }
113     }
114 
115     @Benchmark
116     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
117     public void Def_to_Ref_as_Int_fill1(Ref_as_Int st) {
118         int len = st.arr.length;
119         for (int i = 0; i < len; i++) {
120             st.arr[i] = new Q64long()  ;
121         }
122     }
123 
124     @Benchmark
125     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
126     public void Def_to_Int_as_Int_fill0(Int_as_Int st) {
127         Int64[] arr = st.arr;
128         for (int i = 0; i < arr.length; i++) {
129             arr[i] = new Q64long()  ;
130         }
131     }
132 
133     @Benchmark
134     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
135     public void Def_to_Int_as_Int_fill1(Int_as_Int st) {
136         int len = st.arr.length;
137         for (int i = 0; i < len; i++) {
138             st.arr[i] = new Q64long()  ;
139         }
140     }
141 
142     @Benchmark
143     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
144     public void Def_to_Val_as_Obj_fill0(Val_as_Obj st) {
145         Object[] arr = st.arr;
146         for (int i = 0; i < arr.length; i++) {
147             arr[i] = new Q64long()  ;
148         }
149     }
150 
151     @Benchmark
152     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
153     public void Def_to_Val_as_Obj_fill1(Val_as_Obj st) {
154         int len = st.arr.length;
155         for (int i = 0; i < len; i++) {
156             st.arr[i] = new Q64long()  ;
157         }
158     }
159 
160     @Benchmark
161     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
162     public void Def_to_Ref_as_Obj_fill0(Ref_as_Obj st) {
163         Object[] arr = st.arr;
164         for (int i = 0; i < arr.length; i++) {
165             arr[i] = new Q64long()  ;
166         }
167     }
168 
169     @Benchmark
170     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
171     public void Def_to_Ref_as_Obj_fill1(Ref_as_Obj st) {
172         int len = st.arr.length;
173         for (int i = 0; i < len; i++) {
174             st.arr[i] = new Q64long()  ;
175         }
176     }
177 
178     @Benchmark
179     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
180     public void Def_to_Int_as_Obj_fill0(Int_as_Obj st) {
181         Object[] arr = st.arr;
182         for (int i = 0; i < arr.length; i++) {
183             arr[i] = new Q64long()  ;
184         }
185     }
186 
187     @Benchmark
188     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
189     public void Def_to_Int_as_Obj_fill1(Int_as_Obj st) {
190         int len = st.arr.length;
191         for (int i = 0; i < len; i++) {
192             st.arr[i] = new Q64long()  ;
193         }
194     }
195 
196     @Benchmark
197     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
198     public void Def_to_Obj_as_Obj_fill0(Obj_as_Obj st) {
199         Object[] arr = st.arr;
200         for (int i = 0; i < arr.length; i++) {
201             arr[i] = new Q64long()  ;
202         }
203     }
204 
205     @Benchmark
206     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
207     public void Def_to_Obj_as_Obj_fill1(Obj_as_Obj st) {
208         int len = st.arr.length;
209         for (int i = 0; i < len; i++) {
210             st.arr[i] = new Q64long()  ;
211         }
212     }
213 
214     @Benchmark
215     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
216     public void Def_to_Val_as_Val_arrayfill(Val_as_Val st) {
217         Arrays.fill(st.arr, new Q64long()  );
218     }
219 
220     @Benchmark
221     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
222     public void Def_to_Val_as_Ref_arrayfill(Val_as_Ref st) {
223         Arrays.fill(st.arr, new Q64long()  );
224     }
225 
226     @Benchmark
227     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
228     public void Def_to_Ref_as_Ref_arrayfill(Ref_as_Ref st) {
229         Arrays.fill(st.arr, new Q64long()  );
230     }
231 
232     @Benchmark
233     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
234     public void Def_to_Val_as_Int_arrayfill(Val_as_Int st) {
235         Arrays.fill(st.arr, new Q64long()  );
236     }
237 
238     @Benchmark
239     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
240     public void Def_to_Ref_as_Int_arrayfill(Ref_as_Int st) {
241         Arrays.fill(st.arr, new Q64long()  );
242     }
243 
244     @Benchmark
245     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
246     public void Def_to_Int_as_Int_arrayfill(Int_as_Int st) {
247         Arrays.fill(st.arr, new Q64long()  );
248     }
249 
250     @Benchmark
251     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
252     public void Def_to_Val_as_Obj_arrayfill(Val_as_Obj st) {
253         Arrays.fill(st.arr, new Q64long()  );
254     }
255 
256     @Benchmark
257     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
258     public void Def_to_Ref_as_Obj_arrayfill(Ref_as_Obj st) {
259         Arrays.fill(st.arr, new Q64long()  );
260     }
261 
262     @Benchmark
263     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
264     public void Def_to_Int_as_Obj_arrayfill(Int_as_Obj st) {
265         Arrays.fill(st.arr, new Q64long()  );
266     }
267 
268     @Benchmark
269     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
270     public void Def_to_Obj_as_Obj_arrayfill(Obj_as_Obj st) {
271         Arrays.fill(st.arr, new Q64long()  );
272     }
273 
274 }