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.array.read;
 24 
 25 import org.openjdk.bench.valhalla.array.util.StatesQ64byte;
 26 import org.openjdk.bench.valhalla.types.Int64;
 27 import org.openjdk.bench.valhalla.types.Q64byte;
 28 import org.openjdk.jmh.annotations.Benchmark;
 29 import org.openjdk.jmh.annotations.CompilerControl;
 30 
 31 public class Inline64byte extends StatesQ64byte {
 32 
 33     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 34     public void val_consume(Q64byte v) {
 35     }
 36 
 37     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 38     public void ref_consume(Q64byte.ref v) {
 39     }
 40 
 41     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 42     public void int_consume(Int64 v) {
 43     }
 44 
 45     @Benchmark
 46     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 47     public void Val_as_Val_to_Val_read(Val_as_Val st) {
 48         Q64byte[] arr = st.arr;
 49         for(int i=0; i < arr.length; i++) {
 50             val_consume(arr[i]);
 51         }
 52     }
 53 
 54     @Benchmark
 55     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 56     public void Val_as_Val_to_Ref_read(Val_as_Val st) {
 57         Q64byte[] arr = st.arr;
 58         for(int i=0; i < arr.length; i++) {
 59             ref_consume(arr[i]);
 60         }
 61     }
 62 
 63     @Benchmark
 64     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 65     public void Val_as_Val_to_Int_read(Val_as_Val st) {
 66         Q64byte[] arr = st.arr;
 67         for(int i=0; i < arr.length; i++) {
 68             int_consume(arr[i]);
 69         }
 70     }
 71 
 72     @Benchmark
 73     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 74     public void Val_as_Ref_to_Val_read(Val_as_Ref st) {
 75         Q64byte.ref[] arr = st.arr;
 76         for(int i=0; i < arr.length; i++) {
 77             val_consume(arr[i]);
 78         }
 79     }
 80 
 81     @Benchmark
 82     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 83     public void Val_as_Ref_to_Ref_read(Val_as_Ref st) {
 84         Q64byte.ref[] arr = st.arr;
 85         for(int i=0; i < arr.length; i++) {
 86             ref_consume(arr[i]);
 87         }
 88     }
 89 
 90     @Benchmark
 91     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
 92     public void Val_as_Ref_to_Int_read(Val_as_Ref st) {
 93         Q64byte.ref[] arr = st.arr;
 94         for(int i=0; i < arr.length; i++) {
 95             int_consume(arr[i]);
 96         }
 97     }
 98 
 99     @Benchmark
100     @CompilerControl(CompilerControl.Mode.DONT_INLINE)
101     public void Val_as_Int_to_Int_read(Val_as_Int st) {
102         Int64[] arr = st.arr;
103         for(int i=0; i < arr.length; i++) {
104             int_consume(arr[i]);
105         }
106     }
107 
108 }