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.util;
 24 
 25 import org.openjdk.bench.valhalla.types.Int64;
 26 import org.openjdk.bench.valhalla.types.R64int;
 27 import org.openjdk.bench.valhalla.util.SizeBase;
 28 import org.openjdk.jmh.annotations.Setup;
 29 
 30 public class StatesR64int 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 R64int(i);
 37             }
 38         }
 39     }
 40 
 41     public static abstract class IntState extends SizeState {
 42         public Int64[] arr;
 43         void fill() {
 44             for (int i = 0; i < arr.length; i++) {
 45                 arr[i] = new R64int(i);
 46             }
 47         }
 48     }
 49 
 50     public static abstract class RefState extends SizeState {
 51         public R64int[] arr;
 52         void fill() {
 53             for (int i = 0; i < arr.length; i++) {
 54                 arr[i] = new R64int(i);
 55             }
 56         }
 57     }
 58 
 59     // naming convention: <runtime array type>_as_<static array type>
 60 
 61     public static class Obj_as_Obj extends ObjState {
 62         @Setup
 63         public void setup() {
 64             arr = new Object[size];
 65             fill();
 66         }
 67     }
 68 
 69     public static class Int_as_Obj extends ObjState {
 70         @Setup
 71         public void setup() {
 72             arr = new Int64[size];
 73             fill();
 74         }
 75     }
 76 
 77     public static class Ref_as_Obj extends ObjState {
 78         @Setup
 79         public void setup() {
 80             arr = new R64int[size];
 81             fill();
 82         }
 83     }
 84 
 85     public static class Int_as_Int extends IntState {
 86         @Setup
 87         public void setup() {
 88             arr = new Int64[size];
 89             fill();
 90         }
 91     }
 92 
 93     public static class Ref_as_Int extends IntState {
 94         @Setup
 95         public void setup() {
 96             arr = new R64int[size];
 97             fill();
 98         }
 99     }
100 
101     public static class Ref_as_Ref extends RefState {
102         @Setup
103         public void setup() {
104             arr = new R64int[size];
105             fill();
106         }
107     }
108 }