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.field.set;
 24 
 25 import org.openjdk.bench.valhalla.field.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 Inline64long extends StatesQ64long {
 32 
 33     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 34     public static Object getObj(int i) {
 35         return new Q64long(i);
 36     }
 37 
 38     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 39     public static Int64 getInt(int i) {
 40         return new Q64long(i);
 41     }
 42 
 43     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 44     public static Q64long.ref getRef(int i) {
 45         return new Q64long(i);
 46     }
 47 
 48     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 49     public static Q64long getVal(int i) {
 50         return new Q64long(i);
 51     }
 52 
 53     @Benchmark
 54     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 55     public void New_to_Val_set(ValState st) {
 56         ValWrapper[] arr = st.arr;
 57         for (int i = 0; i < arr.length; i++) {
 58             arr[i].f = new Q64long(i);
 59         }
 60     }
 61 
 62     @Benchmark
 63     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 64     public void Obj_to_Val_set(ValState st) {
 65         ValWrapper[] arr = st.arr;
 66         for (int i = 0; i < arr.length; i++) {
 67             arr[i].f = (Q64long) getObj(i);
 68         }
 69     }
 70 
 71     @Benchmark
 72     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 73     public void Int_to_Val_set(ValState st) {
 74         ValWrapper[] arr = st.arr;
 75         for (int i = 0; i < arr.length; i++) {
 76             arr[i].f = (Q64long) getInt(i);
 77         }
 78     }
 79 
 80     @Benchmark
 81     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 82     public void Ref_to_Val_set(ValState st) {
 83         ValWrapper[] arr = st.arr;
 84         for (int i = 0; i < arr.length; i++) {
 85             arr[i].f = getRef(i);
 86         }
 87     }
 88 
 89     @Benchmark
 90     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 91     public void Val_to_Val_set(ValState st) {
 92         ValWrapper[] arr = st.arr;
 93         for (int i = 0; i < arr.length; i++) {
 94             arr[i].f = getVal(i);
 95         }
 96     }
 97 
 98     @Benchmark
 99     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
100     public void Def_to_Val_set(ValState st) {
101         ValWrapper[] arr = st.arr;
102         for (int i = 0; i < arr.length; i++) {
103             arr[i].f = Q64long.default;
104         }
105     }
106 
107     @Benchmark
108     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
109     public void New_to_Ref_set(RefState st) {
110         RefWrapper[] arr = st.arr;
111         for (int i = 0; i < arr.length; i++) {
112             arr[i].f = new Q64long(i);
113         }
114     }
115 
116     @Benchmark
117     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
118     public void Obj_to_Ref_set(RefState st) {
119         RefWrapper[] arr = st.arr;
120         for (int i = 0; i < arr.length; i++) {
121             arr[i].f = (Q64long) getObj(i);
122         }
123     }
124 
125     @Benchmark
126     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
127     public void Int_to_Ref_set(RefState st) {
128         RefWrapper[] arr = st.arr;
129         for (int i = 0; i < arr.length; i++) {
130             arr[i].f = (Q64long) getInt(i);
131         }
132     }
133 
134     @Benchmark
135     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
136     public void Ref_to_Ref_set(RefState st) {
137         RefWrapper[] arr = st.arr;
138         for (int i = 0; i < arr.length; i++) {
139             arr[i].f = getRef(i);
140         }
141     }
142 
143     @Benchmark
144     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
145     public void Val_to_Ref_set(RefState st) {
146         RefWrapper[] arr = st.arr;
147         for (int i = 0; i < arr.length; i++) {
148             arr[i].f = getVal(i);
149         }
150     }
151 
152     @Benchmark
153     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
154     public void Def_to_Ref_set(RefState st) {
155         RefWrapper[] arr = st.arr;
156         for (int i = 0; i < arr.length; i++) {
157             arr[i].f = Q64long.default;
158         }
159     }
160 
161 
162 }