1 /*
  2  * Copyright (c) 2020, 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 
 31 import java.util.Arrays;
 32 
 33 public class Inline64longFillRef extends StatesQ64long {
 34 
 35     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 36     public static Q64long.ref get(int i) {
 37         return new Q64long(i);
 38     }
 39 
 40     @Benchmark
 41     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 42     public void Ref_to_Val_as_Val_fill0(Val_as_Val st) {
 43         Q64long[] arr = st.arr;
 44         Q64long.ref v = get(42);
 45         for (int i = 0; i < arr.length; i++) {
 46             arr[i] = v;
 47         }
 48     }
 49 
 50     @Benchmark
 51     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 52     public void Ref_to_Val_as_Val_fill1(Val_as_Val st) {
 53         int len = st.arr.length;
 54         Q64long.ref v = get(42);
 55         for (int i = 0; i < len; i++) {
 56             st.arr[i] = v;
 57         }
 58     }
 59 
 60     @Benchmark
 61     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 62     public void Ref_to_Val_as_Ref_fill0(Val_as_Ref st) {
 63         Q64long.ref[] arr = st.arr;
 64         Q64long.ref v = get(42);
 65         for (int i = 0; i < arr.length; i++) {
 66             arr[i] = v;
 67         }
 68     }
 69 
 70     @Benchmark
 71     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 72     public void Ref_to_Val_as_Ref_fill1(Val_as_Ref st) {
 73         int len = st.arr.length;
 74         Q64long.ref v = get(42);
 75         for (int i = 0; i < len; i++) {
 76             st.arr[i] = v;
 77         }
 78     }
 79 
 80     @Benchmark
 81     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 82     public void Ref_to_Ref_as_Ref_fill0(Ref_as_Ref st) {
 83         Q64long.ref[] arr = st.arr;
 84         Q64long.ref v = get(42);
 85         for (int i = 0; i < arr.length; i++) {
 86             arr[i] = v;
 87         }
 88     }
 89 
 90     @Benchmark
 91     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 92     public void Ref_to_Ref_as_Ref_fill1(Ref_as_Ref st) {
 93         int len = st.arr.length;
 94         Q64long.ref v = get(42);
 95         for (int i = 0; i < len; i++) {
 96             st.arr[i] = v;
 97         }
 98     }
 99 
100     @Benchmark
101     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
102     public void Ref_to_Val_as_Int_fill0(Val_as_Int st) {
103         Int64[] arr = st.arr;
104         Q64long.ref v = get(42);
105         for (int i = 0; i < arr.length; i++) {
106             arr[i] = v;
107         }
108     }
109 
110     @Benchmark
111     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
112     public void Ref_to_Val_as_Int_fill1(Val_as_Int st) {
113         int len = st.arr.length;
114         Q64long.ref v = get(42);
115         for (int i = 0; i < len; i++) {
116             st.arr[i] = v;
117         }
118     }
119 
120     @Benchmark
121     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
122     public void Ref_to_Ref_as_Int_fill0(Ref_as_Int st) {
123         Int64[] arr = st.arr;
124         Q64long.ref v = get(42);
125         for (int i = 0; i < arr.length; i++) {
126             arr[i] = v;
127         }
128     }
129 
130     @Benchmark
131     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
132     public void Ref_to_Ref_as_Int_fill1(Ref_as_Int st) {
133         int len = st.arr.length;
134         Q64long.ref v = get(42);
135         for (int i = 0; i < len; i++) {
136             st.arr[i] = v;
137         }
138     }
139 
140     @Benchmark
141     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
142     public void Ref_to_Int_as_Int_fill0(Int_as_Int st) {
143         Int64[] arr = st.arr;
144         Q64long.ref v = get(42);
145         for (int i = 0; i < arr.length; i++) {
146             arr[i] = v;
147         }
148     }
149 
150     @Benchmark
151     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
152     public void Ref_to_Int_as_Int_fill1(Int_as_Int st) {
153         int len = st.arr.length;
154         Q64long.ref v = get(42);
155         for (int i = 0; i < len; i++) {
156             st.arr[i] = v;
157         }
158     }
159 
160     @Benchmark
161     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
162     public void Ref_to_Val_as_Obj_fill0(Val_as_Obj st) {
163         Object[] arr = st.arr;
164         Q64long.ref v = get(42);
165         for (int i = 0; i < arr.length; i++) {
166             arr[i] = v;
167         }
168     }
169 
170     @Benchmark
171     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
172     public void Ref_to_Val_as_Obj_fill1(Val_as_Obj st) {
173         int len = st.arr.length;
174         Q64long.ref v = get(42);
175         for (int i = 0; i < len; i++) {
176             st.arr[i] = v;
177         }
178     }
179 
180     @Benchmark
181     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
182     public void Ref_to_Ref_as_Obj_fill0(Ref_as_Obj st) {
183         Object[] arr = st.arr;
184         Q64long.ref v = get(42);
185         for (int i = 0; i < arr.length; i++) {
186             arr[i] = v;
187         }
188     }
189 
190     @Benchmark
191     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
192     public void Ref_to_Ref_as_Obj_fill1(Ref_as_Obj st) {
193         int len = st.arr.length;
194         Q64long.ref v = get(42);
195         for (int i = 0; i < len; i++) {
196             st.arr[i] = v;
197         }
198     }
199 
200     @Benchmark
201     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
202     public void Ref_to_Int_as_Obj_fill0(Int_as_Obj st) {
203         Object[] arr = st.arr;
204         Q64long.ref v = get(42);
205         for (int i = 0; i < arr.length; i++) {
206             arr[i] = v;
207         }
208     }
209 
210     @Benchmark
211     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
212     public void Ref_to_Int_as_Obj_fill1(Int_as_Obj st) {
213         int len = st.arr.length;
214         Q64long.ref v = get(42);
215         for (int i = 0; i < len; i++) {
216             st.arr[i] = v;
217         }
218     }
219 
220     @Benchmark
221     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
222     public void Ref_to_Obj_as_Obj_fill0(Obj_as_Obj st) {
223         Object[] arr = st.arr;
224         Q64long.ref v = get(42);
225         for (int i = 0; i < arr.length; i++) {
226             arr[i] = v;
227         }
228     }
229 
230     @Benchmark
231     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
232     public void Ref_to_Obj_as_Obj_fill1(Obj_as_Obj st) {
233         int len = st.arr.length;
234         Q64long.ref v = get(42);
235         for (int i = 0; i < len; i++) {
236             st.arr[i] = v;
237         }
238     }
239 
240     @Benchmark
241     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
242     public void Ref_to_Val_as_Val_arrayfill(Val_as_Val st) {
243         Arrays.fill(st.arr, get(42));
244     }
245 
246     @Benchmark
247     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
248     public void Ref_to_Val_as_Ref_arrayfill(Val_as_Ref st) {
249         Arrays.fill(st.arr, get(42));
250     }
251 
252     @Benchmark
253     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
254     public void Ref_to_Ref_as_Ref_arrayfill(Ref_as_Ref st) {
255         Arrays.fill(st.arr, get(42));
256     }
257 
258     @Benchmark
259     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
260     public void Ref_to_Val_as_Int_arrayfill(Val_as_Int st) {
261         Arrays.fill(st.arr, get(42));
262     }
263 
264     @Benchmark
265     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
266     public void Ref_to_Ref_as_Int_arrayfill(Ref_as_Int st) {
267         Arrays.fill(st.arr, get(42));
268     }
269 
270     @Benchmark
271     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
272     public void Ref_to_Int_as_Int_arrayfill(Int_as_Int st) {
273         Arrays.fill(st.arr, get(42));
274     }
275 
276     @Benchmark
277     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
278     public void Ref_to_Val_as_Obj_arrayfill(Val_as_Obj st) {
279         Arrays.fill(st.arr, get(42));
280     }
281 
282     @Benchmark
283     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
284     public void Ref_to_Ref_as_Obj_arrayfill(Ref_as_Obj st) {
285         Arrays.fill(st.arr, get(42));
286     }
287 
288     @Benchmark
289     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
290     public void Ref_to_Int_as_Obj_arrayfill(Int_as_Obj st) {
291         Arrays.fill(st.arr, get(42));
292     }
293 
294     @Benchmark
295     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
296     public void Ref_to_Obj_as_Obj_arrayfill(Obj_as_Obj st) {
297         Arrays.fill(st.arr, get(42));
298     }
299 
300 }