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.array.set; 24 25 import org.openjdk.bench.valhalla.array.util.StatesQ64byte; 26 import org.openjdk.bench.valhalla.types.Q64byte; 27 import org.openjdk.jmh.annotations.Benchmark; 28 import org.openjdk.jmh.annotations.CompilerControl; 29 30 public class Inline64byte extends StatesQ64byte { 31 32 @Benchmark 33 @CompilerControl(CompilerControl.Mode.DONT_INLINE) 34 public void New_to_Val_as_Val_set(Val_as_Val st) { 35 Q64byte[] arr = st.arr; 36 for (int i = 0; i < arr.length; i++) { 37 arr[i] = new Q64byte(i); 38 } 39 } 40 41 @Benchmark 42 @CompilerControl(CompilerControl.Mode.DONT_INLINE) 43 public void New_to_Ref_as_Ref_set(Ref_as_Ref st) { 44 Q64byte[] arr = st.arr; 45 for (int i = 0; i < arr.length; i++) { 46 arr[i] = new Q64byte(i); 47 } 48 } 49 50 @CompilerControl(CompilerControl.Mode.DONT_INLINE) 51 public static Q64byte getRef(int i) { 52 return new Q64byte(i); 53 } 54 55 @CompilerControl(CompilerControl.Mode.DONT_INLINE) 56 public static Q64byte getVal(int i) { 57 return new Q64byte(i); 58 } 59 60 @Benchmark 61 @CompilerControl(CompilerControl.Mode.DONT_INLINE) 62 public void Ref_to_Val_as_Val_set(Val_as_Val st) { 63 Q64byte[] arr = st.arr; 64 for (int i = 0; i < arr.length; i++) { 65 arr[i] = getRef(i); 66 } 67 } 68 69 @Benchmark 70 @CompilerControl(CompilerControl.Mode.DONT_INLINE) 71 public void Ref_to_Ref_as_Ref_set(Ref_as_Ref st) { 72 Q64byte[] arr = st.arr; 73 for (int i = 0; i < arr.length; i++) { 74 arr[i] = getRef(i); 75 } 76 } 77 78 @Benchmark 79 @CompilerControl(CompilerControl.Mode.DONT_INLINE) 80 public void Val_to_Val_as_Val_set(Val_as_Val st) { 81 Q64byte[] arr = st.arr; 82 for (int i = 0; i < arr.length; i++) { 83 arr[i] = getVal(i); 84 } 85 } 86 87 @Benchmark 88 @CompilerControl(CompilerControl.Mode.DONT_INLINE) 89 public void Val_to_Ref_as_Ref_set(Ref_as_Ref st) { 90 Q64byte[] arr = st.arr; 91 for (int i = 0; i < arr.length; i++) { 92 arr[i] = getVal(i); 93 } 94 } 95 96 97 98 }