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.set;
 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 Inline64longSetInt extends StatesQ64long {
 32 
 33     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 34     public static Int64 get(int i) {
 35         return new Q64long(i);
 36     }
 37 
 38     @Benchmark
 39     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 40     public void Int_to_Val_as_Val_set0(Val_as_Val st) {
 41         Q64long[] arr = st.arr;
 42         for (int i = 0; i < arr.length; i++) {
 43             arr[i] = (Q64long)get(i);
 44         }
 45     }
 46 
 47     @Benchmark
 48     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 49     public void Int_to_Val_as_Val_set1(Val_as_Val st) {
 50         int len = st.arr.length;
 51         for (int i = 0; i < len; i++) {
 52             st.arr[i] = (Q64long)get(i);
 53         }
 54     }
 55 
 56     @Benchmark
 57     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 58     public void Int_to_Val_as_Ref_set0(Val_as_Ref st) {
 59         Q64long[] arr = st.arr;
 60         for (int i = 0; i < arr.length; i++) {
 61             arr[i] = (Q64long)get(i);
 62         }
 63     }
 64 
 65     @Benchmark
 66     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 67     public void Int_to_Val_as_Ref_set1(Val_as_Ref st) {
 68         int len = st.arr.length;
 69         for (int i = 0; i < len; i++) {
 70             st.arr[i] = (Q64long)get(i);
 71         }
 72     }
 73 
 74     @Benchmark
 75     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 76     public void Int_to_Ref_as_Ref_set0(Ref_as_Ref st) {
 77         Q64long[] arr = st.arr;
 78         for (int i = 0; i < arr.length; i++) {
 79             arr[i] = (Q64long)get(i);
 80         }
 81     }
 82 
 83     @Benchmark
 84     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 85     public void Int_to_Ref_as_Ref_set1(Ref_as_Ref st) {
 86         int len = st.arr.length;
 87         for (int i = 0; i < len; i++) {
 88             st.arr[i] = (Q64long)get(i);
 89         }
 90     }
 91 
 92     @Benchmark
 93     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 94     public void Int_to_Val_as_Int_set0(Val_as_Int st) {
 95         Int64[] arr = st.arr;
 96         for (int i = 0; i < arr.length; i++) {
 97             arr[i] = get(i);
 98         }
 99     }
100 
101     @Benchmark
102     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
103     public void Int_to_Val_as_Int_set1(Val_as_Int st) {
104         int len = st.arr.length;
105         for (int i = 0; i < len; i++) {
106             st.arr[i] = get(i);
107         }
108     }
109 
110     @Benchmark
111     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
112     public void Int_to_Ref_as_Int_set0(Ref_as_Int st) {
113         Int64[] arr = st.arr;
114         for (int i = 0; i < arr.length; i++) {
115             arr[i] = get(i);
116         }
117     }
118 
119     @Benchmark
120     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
121     public void Int_to_Ref_as_Int_set1(Ref_as_Int st) {
122         int len = st.arr.length;
123         for (int i = 0; i < len; i++) {
124             st.arr[i] = get(i);
125         }
126     }
127 
128     @Benchmark
129     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
130     public void Int_to_Int_as_Int_set0(Int_as_Int st) {
131         Int64[] arr = st.arr;
132         for (int i = 0; i < arr.length; i++) {
133             arr[i] = get(i);
134         }
135     }
136 
137     @Benchmark
138     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
139     public void Int_to_Int_as_Int_set1(Int_as_Int st) {
140         int len = st.arr.length;
141         for (int i = 0; i < len; i++) {
142             st.arr[i] = get(i);
143         }
144     }
145 
146     @Benchmark
147     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
148     public void Int_to_Val_as_Obj_set0(Val_as_Obj st) {
149         Object[] arr = st.arr;
150         for (int i = 0; i < arr.length; i++) {
151             arr[i] = get(i);
152         }
153     }
154 
155     @Benchmark
156     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
157     public void Int_to_Val_as_Obj_set1(Val_as_Obj st) {
158         int len = st.arr.length;
159         for (int i = 0; i < len; i++) {
160             st.arr[i] = get(i);
161         }
162     }
163 
164     @Benchmark
165     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
166     public void Int_to_Ref_as_Obj_set0(Ref_as_Obj st) {
167         Object[] arr = st.arr;
168         for (int i = 0; i < arr.length; i++) {
169             arr[i] = get(i);
170         }
171     }
172 
173     @Benchmark
174     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
175     public void Int_to_Ref_as_Obj_set1(Ref_as_Obj st) {
176         int len = st.arr.length;
177         for (int i = 0; i < len; i++) {
178             st.arr[i] = get(i);
179         }
180     }
181 
182     @Benchmark
183     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
184     public void Int_to_Int_as_Obj_set0(Int_as_Obj st) {
185         Object[] arr = st.arr;
186         for (int i = 0; i < arr.length; i++) {
187             arr[i] = get(i);
188         }
189     }
190 
191     @Benchmark
192     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
193     public void Int_to_Int_as_Obj_set1(Int_as_Obj st) {
194         int len = st.arr.length;
195         for (int i = 0; i < len; i++) {
196             st.arr[i] = get(i);
197         }
198     }
199 
200     @Benchmark
201     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
202     public void Int_to_Obj_as_Obj_set0(Obj_as_Obj st) {
203         Object[] arr = st.arr;
204         for (int i = 0; i < arr.length; i++) {
205             arr[i] = get(i);
206         }
207     }
208 
209     @Benchmark
210     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
211     public void Int_to_Obj_as_Obj_set1(Obj_as_Obj st) {
212         int len = st.arr.length;
213         for (int i = 0; i < len; i++) {
214             st.arr[i] = get(i);
215         }
216     }
217 
218 }