6991596: JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC

Mon, 18 Oct 2010 01:54:24 -0700

author
twisti
date
Mon, 18 Oct 2010 01:54:24 -0700
changeset 2256
7aff5786cc02
parent 2255
e5c3d73017ab
child 2257
0357ff4bd6b2
child 2258
87d6a4d1ecbc

6991596: JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC
Reviewed-by: kvn, jrose, dsamersoff

src/cpu/sparc/vm/methodHandles_sparc.cpp file | annotate | diff | comparison | revisions
test/Makefile file | annotate | diff | comparison | revisions
test/compiler/6991596/Test6991596.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/cpu/sparc/vm/methodHandles_sparc.cpp	Fri Oct 15 02:59:48 2010 -0700
     1.2 +++ b/src/cpu/sparc/vm/methodHandles_sparc.cpp	Mon Oct 18 01:54:24 2010 -0700
     1.3 @@ -630,9 +630,15 @@
     1.4  
     1.5        switch (ek) {
     1.6        case _adapter_opt_i2i:
     1.7 +        value = vmarg;
     1.8 +        break;
     1.9        case _adapter_opt_l2i:
    1.10 -        __ unimplemented(entry_name(ek));
    1.11 -        value = vmarg;
    1.12 +        {
    1.13 +          // just delete the extra slot
    1.14 +          __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
    1.15 +          remove_arg_slots(_masm, -stack_move_unit(), O0_argslot, O1_scratch, O2_scratch, O3_scratch);
    1.16 +          value = vmarg = Address(O0_argslot, 0);
    1.17 +        }
    1.18          break;
    1.19        case _adapter_opt_unboxi:
    1.20          {
     2.1 --- a/test/Makefile	Fri Oct 15 02:59:48 2010 -0700
     2.2 +++ b/test/Makefile	Mon Oct 18 01:54:24 2010 -0700
     2.3 @@ -78,7 +78,11 @@
     2.4  TEST_ROOT := $(shell pwd)
     2.5  
     2.6  # Root of all test results
     2.7 -ABS_BUILD_ROOT = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)
     2.8 +ifdef ALT_OUTPUTDIR
     2.9 +  ABS_BUILD_ROOT = $(ALT_OUTPUTDIR)/$(PLATFORM)-$(ARCH)
    2.10 +else
    2.11 +  ABS_BUILD_ROOT = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)
    2.12 +endif
    2.13  ABS_TEST_OUTPUT_DIR = $(ABS_BUILD_ROOT)/testoutput
    2.14  
    2.15  # Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test)
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/compiler/6991596/Test6991596.java	Mon Oct 18 01:54:24 2010 -0700
     3.3 @@ -0,0 +1,447 @@
     3.4 +/*
     3.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + *
    3.26 + */
    3.27 +
    3.28 +/**
    3.29 + * @test
    3.30 + * @bug 6991596
    3.31 + * @summary JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC
    3.32 + *
    3.33 + * @run main/othervm -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6991596
    3.34 + */
    3.35 +
    3.36 +import java.dyn.*;
    3.37 +
    3.38 +public class Test6991596 {
    3.39 +    private static final Class   CLASS = Test6991596.class;
    3.40 +    private static final String  NAME  = "foo";
    3.41 +    private static final boolean DEBUG = false;
    3.42 +
    3.43 +    public static void main(String[] args) throws Throwable {
    3.44 +        testboolean();
    3.45 +        testbyte();
    3.46 +        testchar();
    3.47 +        testshort();
    3.48 +        testint();
    3.49 +        testlong();
    3.50 +    }
    3.51 +
    3.52 +    // Helpers to get various methods.
    3.53 +    static MethodHandle getmh1(Class ret, Class arg) {
    3.54 +        return MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(ret, arg));
    3.55 +    }
    3.56 +    static MethodHandle getmh2(MethodHandle mh1, Class ret, Class arg) {
    3.57 +        return MethodHandles.convertArguments(mh1, MethodType.methodType(ret, arg));
    3.58 +    }
    3.59 +    static MethodHandle getmh3(MethodHandle mh1, Class ret, Class arg) {
    3.60 +        return MethodHandles.convertArguments(mh1, MethodType.methodType(ret, arg));
    3.61 +    }
    3.62 +
    3.63 +    // test adapter_opt_i2i
    3.64 +    static void testboolean() throws Throwable {
    3.65 +        boolean[] a = new boolean[] {
    3.66 +            true,
    3.67 +            false
    3.68 +        };
    3.69 +        for (int i = 0; i < a.length; i++) {
    3.70 +            doboolean(a[i]);
    3.71 +        }
    3.72 +    }
    3.73 +    static void doboolean(boolean x) throws Throwable {
    3.74 +        if (DEBUG)  System.out.println("boolean=" + x);
    3.75 +
    3.76 +        // boolean
    3.77 +        {
    3.78 +            MethodHandle mh1 = getmh1(     boolean.class, boolean.class);
    3.79 +            MethodHandle mh2 = getmh2(mh1, boolean.class, boolean.class);
    3.80 +            // TODO add this for all cases when the bugs are fixed.
    3.81 +            //MethodHandle mh3 = getmh3(mh1, boolean.class, boolean.class);
    3.82 +            boolean a = mh1.<boolean>invokeExact((boolean) x);
    3.83 +            boolean b = mh2.<boolean>invokeExact(x);
    3.84 +            //boolean c = mh3.<boolean>invokeExact((boolean) x);
    3.85 +            assert a == b : a + " != " + b;
    3.86 +            //assert c == x : c + " != " + x;
    3.87 +        }
    3.88 +
    3.89 +        // byte
    3.90 +        {
    3.91 +            MethodHandle mh1 = getmh1(     byte.class,    byte.class   );
    3.92 +            MethodHandle mh2 = getmh2(mh1, byte.class,    boolean.class);
    3.93 +            byte    a = mh1.<byte>invokeExact((byte) (x ? 1 : 0));
    3.94 +            byte    b = mh2.<byte>invokeExact(x);
    3.95 +            assert a == b : a + " != " + b;
    3.96 +        }
    3.97 +
    3.98 +        // char
    3.99 +        {
   3.100 +            MethodHandle mh1 = getmh1(     char.class, char.class);
   3.101 +            MethodHandle mh2 = getmh2(mh1, char.class, boolean.class);
   3.102 +            char a = mh1.<char>invokeExact((char) (x ? 1 : 0));
   3.103 +            char b = mh2.<char>invokeExact(x);
   3.104 +            assert a == b : a + " != " + b;
   3.105 +        }
   3.106 +
   3.107 +        // short
   3.108 +        {
   3.109 +            MethodHandle mh1 = getmh1(     short.class, short.class);
   3.110 +            MethodHandle mh2 = getmh2(mh1, short.class, boolean.class);
   3.111 +            short a = mh1.<short>invokeExact((short) (x ? 1 : 0));
   3.112 +            short b = mh2.<short>invokeExact(x);
   3.113 +            assert a == b : a + " != " + b;
   3.114 +        }
   3.115 +    }
   3.116 +
   3.117 +    static void testbyte() throws Throwable {
   3.118 +        byte[] a = new byte[] {
   3.119 +            Byte.MIN_VALUE,
   3.120 +            Byte.MIN_VALUE + 1,
   3.121 +            -0x0F,
   3.122 +            -1,
   3.123 +            0,
   3.124 +            1,
   3.125 +            0x0F,
   3.126 +            Byte.MAX_VALUE - 1,
   3.127 +            Byte.MAX_VALUE
   3.128 +        };
   3.129 +        for (int i = 0; i < a.length; i++) {
   3.130 +            dobyte(a[i]);
   3.131 +        }
   3.132 +    }
   3.133 +    static void dobyte(byte x) throws Throwable {
   3.134 +        if (DEBUG)  System.out.println("byte=" + x);
   3.135 +
   3.136 +        // boolean
   3.137 +        {
   3.138 +            MethodHandle mh1 = getmh1(     boolean.class, boolean.class);
   3.139 +            MethodHandle mh2 = getmh2(mh1, boolean.class, byte.class);
   3.140 +            boolean a = mh1.<boolean>invokeExact((x & 1) == 1);
   3.141 +            boolean b = mh2.<boolean>invokeExact(x);
   3.142 +            assert a == b : a + " != " + b;
   3.143 +        }
   3.144 +
   3.145 +        // byte
   3.146 +        {
   3.147 +            MethodHandle mh1 = getmh1(     byte.class, byte.class);
   3.148 +            MethodHandle mh2 = getmh2(mh1, byte.class, byte.class);
   3.149 +            byte a = mh1.<byte>invokeExact((byte) x);
   3.150 +            byte b = mh2.<byte>invokeExact(x);
   3.151 +            assert a == b : a + " != " + b;
   3.152 +        }
   3.153 +
   3.154 +        // char
   3.155 +        {
   3.156 +            MethodHandle mh1 = getmh1(     char.class, char.class);
   3.157 +            MethodHandle mh2 = getmh2(mh1, char.class, byte.class);
   3.158 +            char a = mh1.<char>invokeExact((char) x);
   3.159 +            char b = mh2.<char>invokeExact(x);
   3.160 +            assert a == b : a + " != " + b;
   3.161 +        }
   3.162 +
   3.163 +        // short
   3.164 +        {
   3.165 +            MethodHandle mh1 = getmh1(     short.class, short.class);
   3.166 +            MethodHandle mh2 = getmh2(mh1, short.class, byte.class);
   3.167 +            short a = mh1.<short>invokeExact((short) x);
   3.168 +            short b = mh2.<short>invokeExact(x);
   3.169 +            assert a == b : a + " != " + b;
   3.170 +        }
   3.171 +    }
   3.172 +
   3.173 +    static void testchar() throws Throwable {
   3.174 +        char[] a = new char[] {
   3.175 +            Character.MIN_VALUE,
   3.176 +            Character.MIN_VALUE + 1,
   3.177 +            0x000F,
   3.178 +            0x00FF,
   3.179 +            0x0FFF,
   3.180 +            Character.MAX_VALUE - 1,
   3.181 +            Character.MAX_VALUE
   3.182 +        };
   3.183 +        for (int i = 0; i < a.length; i++) {
   3.184 +            dochar(a[i]);
   3.185 +        }
   3.186 +    }
   3.187 +    static void dochar(char x) throws Throwable {
   3.188 +        if (DEBUG)  System.out.println("char=" + x);
   3.189 +
   3.190 +        // boolean
   3.191 +        {
   3.192 +            MethodHandle mh1 = getmh1(     boolean.class, boolean.class);
   3.193 +            MethodHandle mh2 = getmh2(mh1, boolean.class, char.class);
   3.194 +            boolean a = mh1.<boolean>invokeExact((x & 1) == 1);
   3.195 +            boolean b = mh2.<boolean>invokeExact(x);
   3.196 +            assert a == b : a + " != " + b;
   3.197 +        }
   3.198 +
   3.199 +        // byte
   3.200 +        {
   3.201 +            MethodHandle mh1 = getmh1(     byte.class, byte.class);
   3.202 +            MethodHandle mh2 = getmh2(mh1, byte.class, char.class);
   3.203 +            byte a = mh1.<byte>invokeExact((byte) x);
   3.204 +            byte b = mh2.<byte>invokeExact(x);
   3.205 +            assert a == b : a + " != " + b;
   3.206 +        }
   3.207 +
   3.208 +        // char
   3.209 +        {
   3.210 +            MethodHandle mh1 = getmh1(     char.class, char.class);
   3.211 +            MethodHandle mh2 = getmh2(mh1, char.class, char.class);
   3.212 +            char a = mh1.<char>invokeExact((char) x);
   3.213 +            char b = mh2.<char>invokeExact(x);
   3.214 +            assert a == b : a + " != " + b;
   3.215 +        }
   3.216 +
   3.217 +        // short
   3.218 +        {
   3.219 +            MethodHandle mh1 = getmh1(     short.class, short.class);
   3.220 +            MethodHandle mh2 = getmh2(mh1, short.class, char.class);
   3.221 +            short a = mh1.<short>invokeExact((short) x);
   3.222 +            short b = mh2.<short>invokeExact(x);
   3.223 +            assert a == b : a + " != " + b;
   3.224 +        }
   3.225 +    }
   3.226 +
   3.227 +    static void testshort() throws Throwable {
   3.228 +        short[] a = new short[] {
   3.229 +            Short.MIN_VALUE,
   3.230 +            Short.MIN_VALUE + 1,
   3.231 +            -0x0FFF,
   3.232 +            -0x00FF,
   3.233 +            -0x000F,
   3.234 +            -1,
   3.235 +            0,
   3.236 +            1,
   3.237 +            0x000F,
   3.238 +            0x00FF,
   3.239 +            0x0FFF,
   3.240 +            Short.MAX_VALUE - 1,
   3.241 +            Short.MAX_VALUE
   3.242 +        };
   3.243 +        for (int i = 0; i < a.length; i++) {
   3.244 +            doshort(a[i]);
   3.245 +        }
   3.246 +    }
   3.247 +    static void doshort(short x) throws Throwable {
   3.248 +        if (DEBUG)  System.out.println("short=" + x);
   3.249 +
   3.250 +        // boolean
   3.251 +        {
   3.252 +            MethodHandle mh1 = getmh1(     boolean.class, boolean.class);
   3.253 +            MethodHandle mh2 = getmh2(mh1, boolean.class, short.class);
   3.254 +            boolean a = mh1.<boolean>invokeExact((x & 1) == 1);
   3.255 +            boolean b = mh2.<boolean>invokeExact(x);
   3.256 +            assert a == b : a + " != " + b;
   3.257 +        }
   3.258 +
   3.259 +        // byte
   3.260 +        {
   3.261 +            MethodHandle mh1 = getmh1(     byte.class, byte.class);
   3.262 +            MethodHandle mh2 = getmh2(mh1, byte.class, short.class);
   3.263 +            byte a = mh1.<byte>invokeExact((byte) x);
   3.264 +            byte b = mh2.<byte>invokeExact(x);
   3.265 +            assert a == b : a + " != " + b;
   3.266 +        }
   3.267 +
   3.268 +        // char
   3.269 +        {
   3.270 +            MethodHandle mh1 = getmh1(     char.class, char.class);
   3.271 +            MethodHandle mh2 = getmh2(mh1, char.class, short.class);
   3.272 +            char a = mh1.<char>invokeExact((char) x);
   3.273 +            char b = mh2.<char>invokeExact(x);
   3.274 +            assert a == b : a + " != " + b;
   3.275 +        }
   3.276 +
   3.277 +        // short
   3.278 +        {
   3.279 +            MethodHandle mh1 = getmh1(     short.class, short.class);
   3.280 +            MethodHandle mh2 = getmh2(mh1, short.class, short.class);
   3.281 +            short a = mh1.<short>invokeExact((short) x);
   3.282 +            short b = mh2.<short>invokeExact(x);
   3.283 +            assert a == b : a + " != " + b;
   3.284 +        }
   3.285 +    }
   3.286 +
   3.287 +    static void testint() throws Throwable {
   3.288 +        int[] a = new int[] {
   3.289 +            Integer.MIN_VALUE,
   3.290 +            Integer.MIN_VALUE + 1,
   3.291 +            -0x0FFFFFFF,
   3.292 +            -0x00FFFFFF,
   3.293 +            -0x000FFFFF,
   3.294 +            -0x0000FFFF,
   3.295 +            -0x00000FFF,
   3.296 +            -0x000000FF,
   3.297 +            -0x0000000F,
   3.298 +            -1,
   3.299 +            0,
   3.300 +            1,
   3.301 +            0x0000000F,
   3.302 +            0x000000FF,
   3.303 +            0x00000FFF,
   3.304 +            0x0000FFFF,
   3.305 +            0x000FFFFF,
   3.306 +            0x00FFFFFF,
   3.307 +            0x0FFFFFFF,
   3.308 +            Integer.MAX_VALUE - 1,
   3.309 +            Integer.MAX_VALUE
   3.310 +        };
   3.311 +        for (int i = 0; i < a.length; i++) {
   3.312 +            doint(a[i]);
   3.313 +        }
   3.314 +    }
   3.315 +    static void doint(int x) throws Throwable {
   3.316 +        if (DEBUG)  System.out.println("int=" + x);
   3.317 +
   3.318 +        // boolean
   3.319 +        {
   3.320 +            MethodHandle mh1 = getmh1(     boolean.class, boolean.class);
   3.321 +            MethodHandle mh2 = getmh2(mh1, boolean.class, int.class);
   3.322 +            boolean a = mh1.<boolean>invokeExact((x & 1) == 1);
   3.323 +            boolean b = mh2.<boolean>invokeExact(x);
   3.324 +            assert a == b : a + " != " + b;
   3.325 +        }
   3.326 +
   3.327 +        // byte
   3.328 +        {
   3.329 +            MethodHandle mh1 = getmh1(     byte.class, byte.class);
   3.330 +            MethodHandle mh2 = getmh2(mh1, byte.class, int.class);
   3.331 +            byte a = mh1.<byte>invokeExact((byte) x);
   3.332 +            byte b = mh2.<byte>invokeExact(x);
   3.333 +            assert a == b : a + " != " + b;
   3.334 +        }
   3.335 +
   3.336 +        // char
   3.337 +        {
   3.338 +            MethodHandle mh1 = getmh1(     char.class, char.class);
   3.339 +            MethodHandle mh2 = getmh2(mh1, char.class, int.class);
   3.340 +            char a = mh1.<char>invokeExact((char) x);
   3.341 +            char b = mh2.<char>invokeExact(x);
   3.342 +            assert a == b : a + " != " + b;
   3.343 +        }
   3.344 +
   3.345 +        // short
   3.346 +        {
   3.347 +            MethodHandle mh1 = getmh1(     short.class, short.class);
   3.348 +            MethodHandle mh2 = getmh2(mh1, short.class, int.class);
   3.349 +            short a = mh1.<short>invokeExact((short) x);
   3.350 +            short b = mh2.<short>invokeExact(x);
   3.351 +            assert a == b : a + " != " + b;
   3.352 +        }
   3.353 +
   3.354 +        // int
   3.355 +        {
   3.356 +            MethodHandle mh1 = getmh1(     int.class, int.class);
   3.357 +            MethodHandle mh2 = getmh2(mh1, int.class, int.class);
   3.358 +            int a = mh1.<int>invokeExact((int) x);
   3.359 +            int b = mh2.<int>invokeExact(x);
   3.360 +            assert a == b : a + " != " + b;
   3.361 +        }
   3.362 +    }
   3.363 +
   3.364 +    // test adapter_opt_l2i
   3.365 +    static void testlong() throws Throwable {
   3.366 +        long[] a = new long[] {
   3.367 +            Long.MIN_VALUE,
   3.368 +            Long.MIN_VALUE + 1,
   3.369 +            -0x000000000FFFFFFFL,
   3.370 +            -0x0000000000FFFFFFL,
   3.371 +            -0x00000000000FFFFFL,
   3.372 +            -0x000000000000FFFFL,
   3.373 +            -0x0000000000000FFFL,
   3.374 +            -0x00000000000000FFL,
   3.375 +            -0x000000000000000FL,
   3.376 +            -1L,
   3.377 +            0L,
   3.378 +            1L,
   3.379 +            0x000000000000000FL,
   3.380 +            0x00000000000000FFL,
   3.381 +            0x0000000000000FFFL,
   3.382 +            0x0000000000000FFFL,
   3.383 +            0x000000000000FFFFL,
   3.384 +            0x00000000000FFFFFL,
   3.385 +            0x0000000000FFFFFFL,
   3.386 +            0x000000000FFFFFFFL,
   3.387 +            Long.MAX_VALUE - 1,
   3.388 +            Long.MAX_VALUE
   3.389 +        };
   3.390 +        for (int i = 0; i < a.length; i++) {
   3.391 +            dolong(a[i]);
   3.392 +        }
   3.393 +    }
   3.394 +    static void dolong(long x) throws Throwable {
   3.395 +        if (DEBUG)  System.out.println("long=" + x);
   3.396 +
   3.397 +        // boolean
   3.398 +        {
   3.399 +            MethodHandle mh1 = getmh1(     boolean.class, boolean.class);
   3.400 +            MethodHandle mh2 = getmh2(mh1, boolean.class, long.class);
   3.401 +            boolean a = mh1.<boolean>invokeExact((x & 1L) == 1L);
   3.402 +            boolean b = mh2.<boolean>invokeExact(x);
   3.403 +            assert a == b : a + " != " + b;
   3.404 +        }
   3.405 +
   3.406 +        // byte
   3.407 +        {
   3.408 +            MethodHandle mh1 = getmh1(     byte.class, byte.class);
   3.409 +            MethodHandle mh2 = getmh2(mh1, byte.class, long.class);
   3.410 +            byte a = mh1.<byte>invokeExact((byte) x);
   3.411 +            byte b = mh2.<byte>invokeExact(x);
   3.412 +            assert a == b : a + " != " + b;
   3.413 +        }
   3.414 +
   3.415 +        // char
   3.416 +        {
   3.417 +            MethodHandle mh1 = getmh1(     char.class, char.class);
   3.418 +            MethodHandle mh2 = getmh2(mh1, char.class, long.class);
   3.419 +            char a = mh1.<char>invokeExact((char) x);
   3.420 +            char b = mh2.<char>invokeExact(x);
   3.421 +            assert a == b : a + " != " + b;
   3.422 +        }
   3.423 +
   3.424 +        // short
   3.425 +        {
   3.426 +            MethodHandle mh1 = getmh1(     short.class, short.class);
   3.427 +            MethodHandle mh2 = getmh2(mh1, short.class, long.class);
   3.428 +            short a = mh1.<short>invokeExact((short) x);
   3.429 +            short b = mh2.<short>invokeExact(x);
   3.430 +            assert a == b : a + " != " + b;
   3.431 +        }
   3.432 +
   3.433 +        // int
   3.434 +        {
   3.435 +            MethodHandle mh1 = getmh1(     int.class, int.class);
   3.436 +            MethodHandle mh2 = getmh2(mh1, int.class, long.class);
   3.437 +            int a = mh1.<int>invokeExact((int) x);
   3.438 +            int b = mh2.<int>invokeExact(x);
   3.439 +            assert a == b : a + " != " + b;
   3.440 +        }
   3.441 +
   3.442 +    }
   3.443 +
   3.444 +    // to int
   3.445 +    public static boolean foo(boolean i) { return i; }
   3.446 +    public static byte    foo(byte    i) { return i; }
   3.447 +    public static char    foo(char    i) { return i; }
   3.448 +    public static short   foo(short   i) { return i; }
   3.449 +    public static int     foo(int     i) { return i; }
   3.450 +}

mercurial