1 /* 2 * Copyright (c) 2017, 2018, 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 24 package compiler.valhalla.valuetypes; 25 26 // Value type definition with too many fields to return in registers 27 value final class MyValue4 implements MyInterface { 28 final MyValue3.val v1; 29 final MyValue3.val v2; 30 31 private MyValue4() { 32 this.v1 = MyValue3.createDefault(); 33 this.v2 = MyValue3.createDefault(); 34 } 35 36 @ForceInline 37 static MyValue4 setV1(MyValue4 v, MyValue3 v1) { 38 v = __WithField(v.v1, v1); 39 return v; 40 } 41 42 @ForceInline 43 static MyValue4 setV2(MyValue4 v, MyValue3 v2) { 44 v = __WithField(v.v2, v2); 45 return v; 46 } 47 48 @ForceInline 49 public static MyValue4 createDefault() { 50 return MyValue4.default; 51 } 52 53 @ForceInline 54 public static MyValue4 create() { 55 MyValue4 v = createDefault(); 56 MyValue3 v1 = MyValue3.create(); 57 v = setV1(v, v1); 58 MyValue3 v2 = MyValue3.create(); 59 v = setV2(v, v2); 60 return v; 61 } 62 63 public void verify(MyValue4 other) { 64 v1.verify(other.v1); 65 v2.verify(other.v2); 66 } 67 68 @ForceInline 69 public long hash() { 70 return v1.hash() + v2.hash(); 71 } 72 }