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