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.util;
 24 
 25 import org.openjdk.bench.valhalla.types.ByInt;
 26 import org.openjdk.bench.valhalla.types.Int64;
 27 import org.openjdk.bench.valhalla.types.Q64int;
 28 import org.openjdk.bench.valhalla.util.SizeBase;
 29 import org.openjdk.jmh.annotations.Setup;
 30 
 31 public class StatesQ64int extends SizeBase {
 32 
 33     public static abstract class ObjState extends SizeState {
 34         public Object[] arr;
 35         void fill() {
 36             for (int i = 0; i < arr.length; i++) {
 37                 arr[i] = new Q64int(i);
 38             }
 39         }
 40     }
 41 
 42     public static abstract class IntState extends SizeState {
 43         public Int64[] arr;
 44         void fill() {
 45             for (int i = 0; i < arr.length; i++) {
 46                 arr[i] = new Q64int(i);
 47             }
 48         }
 49     }
 50 
 51     public static abstract class RefState extends SizeState {
 52         public Q64int[] arr;
 53         void fill() {
 54             for (int i = 0; i < arr.length; i++) {
 55                 arr[i] = new Q64int(i);
 56             }
 57         }
 58     }
 59 
 60     public static abstract class ValState extends SizeState {
 61         public Q64int[] arr;
 62         void fill() {
 63             for (int i = 0; i < arr.length; i++) {
 64                 arr[i] = new Q64int(i);
 65             }
 66         }
 67     }
 68 
 69     // naming convention: <runtime array type>_as_<static array type>
 70 
 71     public static class Obj_as_Obj extends ObjState {
 72         @Setup
 73         public void setup() {
 74             arr = new Object[size];
 75             fill();
 76         }
 77     }
 78 
 79     public static class Int_as_Obj extends ObjState {
 80         @Setup
 81         public void setup() {
 82             arr = new Int64[size];
 83             fill();
 84         }
 85     }
 86 
 87     public static class Ref_as_Obj extends ObjState {
 88         @Setup
 89         public void setup() {
 90             arr = new Q64int[size];
 91             fill();
 92         }
 93     }
 94 
 95     public static class Val_as_Obj extends ObjState {
 96         @Setup
 97         public void setup() {
 98             arr = new Q64int[size];
 99             fill();
100         }
101     }
102 
103     public static class Int_as_Int extends IntState {
104         @Setup
105         public void setup() {
106             arr = new Int64[size];
107             fill();
108         }
109     }
110 
111     public static class Ref_as_Int extends IntState {
112         @Setup
113         public void setup() {
114             arr = new Q64int[size];
115             fill();
116         }
117     }
118 
119     public static class Val_as_Int extends IntState {
120         @Setup
121         public void setup() {
122             arr = new Q64int[size];
123             fill();
124         }
125     }
126 
127     public static class Ref_as_Ref extends RefState {
128         @Setup
129         public void setup() {
130             arr = new Q64int[size];
131             fill();
132         }
133     }
134 
135     public static class Val_as_Ref extends RefState {
136         @Setup
137         public void setup() {
138             arr = new Q64int[size];
139             fill();
140         }
141     }
142 
143     public static class Val_as_Val extends ValState {
144         @Setup
145         public void setup() {
146             arr = new Q64int[size];
147             fill();
148         }
149     }
150 
151     public static abstract class ByState extends SizeState {
152         public ByInt[] arr;
153         void fill() {
154             for (int i = 0; i < arr.length; i++) {
155                 arr[i] = new Q64int(i);
156             }
157         }
158     }
159 
160     public static class Val_as_By extends StatesQ32int.ByState {
161         @Setup
162         public void setup() {
163             arr = new Q64int[size];
164             fill();
165         }
166     }
167 
168     public static class Ref_as_By extends StatesQ32int.ByState {
169         @Setup
170         public void setup() {
171             arr = new Q64int[size];
172             fill();
173         }
174     }
175 
176     public static class By_as_By extends StatesQ32int.ByState {
177         @Setup
178         public void setup() {
179             arr = new ByInt[size];
180             fill();
181         }
182     }
183 
184 
185 }