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