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.field.util;
 24 
 25 import org.openjdk.bench.valhalla.util.SizeBase;
 26 import org.openjdk.jmh.annotations.Setup;
 27 
 28 public class PrimitiveStates extends SizeBase {
 29 
 30     public static class P64byte {
 31 
 32         public byte f0;
 33         public byte f1;
 34         public byte f2;
 35         public byte f3;
 36         public byte f4;
 37         public byte f5;
 38         public byte f6;
 39         public byte f7;
 40 
 41         public P64byte(long v) {
 42             this((byte) (v >>> 56), (byte) (v >>> 48), (byte) (v >>> 40), (byte) (v >>> 32), (byte) (v >>> 24), (byte) (v >>> 16), (byte) (v >>> 8), (byte) (v));
 43         }
 44 
 45         public P64byte(byte v0, byte v1, byte v2, byte v3, byte v4, byte v5, byte v6, byte v7) {
 46             this.f0 = v0;
 47             this.f1 = v1;
 48             this.f2 = v2;
 49             this.f3 = v3;
 50             this.f4 = v4;
 51             this.f5 = v5;
 52             this.f6 = v6;
 53             this.f7 = v7;
 54         }
 55 
 56     }
 57 
 58     public static class Primitive64byte extends SizeState {
 59         public P64byte[] arr;
 60         @Setup
 61         public void setup() {
 62             arr = new P64byte[size];
 63             for (int i = 0; i < arr.length; i++) {
 64                 arr[i] = new P64byte(i);
 65             }
 66         }
 67     }
 68 
 69 
 70     public static class P64int {
 71 
 72         public int f0;
 73         public int f1;
 74 
 75         public P64int(long v) {
 76             this((int) (v >>> 32), (int) v);
 77         }
 78 
 79         public P64int(int hi, int lo) {
 80             this.f0 = hi;
 81             this.f1 = lo;
 82         }
 83 
 84     }
 85 
 86     public static class Primitive64int extends SizeState {
 87         public P64int[] arr;
 88         @Setup
 89         public void setup() {
 90             arr = new P64int[size];
 91             for (int i = 0; i < arr.length; i++) {
 92                 arr[i] = new P64int(i);
 93             }
 94         }
 95     }
 96 
 97     public static class P64long {
 98 
 99         public long f0;
100 
101         public P64long(long v0) {
102             this.f0 = v0;
103         }
104 
105     }
106 
107     public static class Primitive64long extends SizeState {
108         public P64long[] arr;
109         @Setup
110         public void setup() {
111             arr = new P64long[size];
112             for (int i = 0; i < arr.length; i++) {
113                 arr[i] = new P64long(i);
114             }
115         }
116     }
117 
118 
119     public static class P32int {
120 
121         public int f0;
122 
123         public P32int(int val) {
124             this.f0 = val;
125         }
126     }
127 
128     public static class Primitive32int extends SizeState {
129         public P32int[] arr;
130         @Setup
131         public void setup() {
132             arr = new P32int[size];
133             for (int i = 0; i < arr.length; i++) {
134                 arr[i] = new P32int(i);
135             }
136         }
137     }
138 
139     public static class P128int {
140 
141         public int f0;
142         public int f1;
143         public int f2;
144         public int f3;
145 
146         public P128int(long v) {
147             this(0, 0, (int) (v >>> 32), (int) v);
148         }
149 
150         public P128int(int v0, int v1, int v2, int v3) {
151             this.f0 = v0;
152             this.f1 = v1;
153             this.f2 = v2;
154             this.f3 = v3;
155         }
156     }
157 
158     public static class Primitive128int extends SizeState {
159         public P128int[] arr;
160         @Setup
161         public void setup() {
162             arr = new P128int[size];
163             for (int i = 0; i < arr.length; i++) {
164                 arr[i] = new P128int(i);
165             }
166         }
167     }
168 
169 }
170