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