1 
   2 /*
   3  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  */
  24 
  25 package runtime.valhalla.valuetypes;
  26 
  27 /*
  28  * @test Test8186715
  29  * @summary test return of buffered value passed in argument by caller
  30  * @library /test/lib
  31  * @compile -XDenableValueTypes Test8186715.java
  32  * @run main/othervm -Xint -XX:+EnableValhalla runtime.valhalla.valuetypes.Test8186715
  33  */
  34 
  35 
  36 /*
  37  * @run main/othervm -XX:+EnableValhalla runtime.valhalla.valuetypes.Test8186715
  38  */
  39 
  40 public class Test8186715 {
  41 
  42   public static void main(String[] args) {
  43     MyValueType v = MyValueType.testDefault();
  44 
  45     for (int i = 0; i < 1000000; i++)
  46       MyValueType.testBranchArg1(false, v);
  47   }
  48 }
  49 
  50 __ByValue final class MyValueType {
  51   final int i;
  52   final int j;
  53 
  54   private MyValueType()
  55   {
  56     this.i = 0;
  57     this.j = 0;
  58   }
  59 
  60   __ValueFactory static MyValueType testDefault() {
  61     return __MakeDefault MyValueType();
  62   }
  63 
  64   __ValueFactory static MyValueType testBranchArg1(boolean flag, MyValueType v1) {
  65     if (flag) {
  66       v1.i = 3;
  67       v1.j = 4;
  68     }
  69     return v1;
  70   }
  71 }