jdk/src/share/classes/java/lang/invoke/BoundMethodHandle.java
author twisti
Tue, 07 Aug 2012 14:31:52 -0700
changeset 13424 5de7e57cdc02
parent 13423 17843fff200d
child 13610 28122b96858e
permissions -rw-r--r--
7188911: nightly failures after JSR 292 lazy method handle update (round 2) Reviewed-by: kvn, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     1
/*
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
     2
 * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     4
 *
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    10
 *
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    15
 * accompanied this code).
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    16
 *
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
    23
 * questions.
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    24
 */
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    25
8822
8145ab9f5f86 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8821
diff changeset
    26
package java.lang.invoke;
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    27
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    28
import static com.sun.xml.internal.ws.org.objectweb.asm.Opcodes.*;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    29
import static java.lang.invoke.LambdaForm.basicTypes;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    30
import static java.lang.invoke.MethodHandleNatives.Constants.REF_invokeStatic;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    31
import static java.lang.invoke.MethodHandleStatics.*;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    32
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    33
import java.lang.invoke.LambdaForm.Name;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    34
import java.lang.invoke.LambdaForm.NamedFunction;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    35
import java.lang.invoke.MethodHandles.Lookup;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    36
import java.lang.reflect.Field;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    37
import java.util.Arrays;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    38
import java.util.HashMap;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    39
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    40
import sun.invoke.util.ValueConversions;
8822
8145ab9f5f86 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8821
diff changeset
    41
import sun.invoke.util.Wrapper;
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    42
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    43
import com.sun.xml.internal.ws.org.objectweb.asm.ClassWriter;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    44
import com.sun.xml.internal.ws.org.objectweb.asm.MethodVisitor;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    45
import com.sun.xml.internal.ws.org.objectweb.asm.Type;
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    46
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    47
/**
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    48
 * The flavor of method handle which emulates an invoke instruction
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    49
 * on a predetermined argument.  The JVM dispatches to the correct method
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    50
 * when the handle is created, not when it is invoked.
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    51
 *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    52
 * All bound arguments are encapsulated in dedicated species.
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    53
 */
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    54
/* non-public */ abstract class BoundMethodHandle extends MethodHandle {
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    55
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    56
    /* non-public */ BoundMethodHandle(MethodType type, LambdaForm form) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    57
        super(type, form);
4537
7c3c7f8d5195 6914665: update jdk code for JSR 292 (post 6858164)
jrose
parents: 2707
diff changeset
    58
    }
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    59
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    60
    //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    61
    // BMH API and internals
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    62
    //
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    63
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    64
    static MethodHandle bindSingle(MethodType type, LambdaForm form, char xtype, Object x) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    65
        // for some type signatures, there exist pre-defined concrete BMH classes
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    66
        try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    67
            switch (xtype) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    68
            case 'L':
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    69
                if (true)  return bindSingle(type, form, x);  // Use known fast path.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    70
                return (BoundMethodHandle) SpeciesData.EMPTY.extendWithType('L').constructor[0].invokeBasic(type, form, x);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    71
            case 'I':
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    72
                return (BoundMethodHandle) SpeciesData.EMPTY.extendWithType('I').constructor[0].invokeBasic(type, form, ValueConversions.widenSubword(x));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    73
            case 'J':
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    74
                return (BoundMethodHandle) SpeciesData.EMPTY.extendWithType('J').constructor[0].invokeBasic(type, form, (long) x);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    75
            case 'F':
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    76
                return (BoundMethodHandle) SpeciesData.EMPTY.extendWithType('F').constructor[0].invokeBasic(type, form, (float) x);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    77
            case 'D':
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    78
                return (BoundMethodHandle) SpeciesData.EMPTY.extendWithType('D').constructor[0].invokeBasic(type, form, (double) x);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    79
            default : throw new InternalError("unexpected xtype: " + xtype);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    80
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    81
        } catch (Throwable t) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    82
            throw new InternalError(t);
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    83
        }
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    84
    }
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    85
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    86
    static MethodHandle bindSingle(MethodType type, LambdaForm form, Object x) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    87
            return new Species_L(type, form, x);
4537
7c3c7f8d5195 6914665: update jdk code for JSR 292 (post 6858164)
jrose
parents: 2707
diff changeset
    88
    }
7c3c7f8d5195 6914665: update jdk code for JSR 292 (post 6858164)
jrose
parents: 2707
diff changeset
    89
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    90
    MethodHandle cloneExtend(MethodType type, LambdaForm form, char xtype, Object x) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    91
        try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    92
            switch (xtype) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    93
            case 'L': return cloneExtendL(type, form, x);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    94
            case 'I': return cloneExtendI(type, form, ValueConversions.widenSubword(x));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    95
            case 'J': return cloneExtendJ(type, form, (long) x);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    96
            case 'F': return cloneExtendF(type, form, (float) x);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    97
            case 'D': return cloneExtendD(type, form, (double) x);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    98
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
    99
        } catch (Throwable t) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   100
            throw new InternalError(t);
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   101
        }
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   102
        throw new InternalError("unexpected type: " + xtype);
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   103
    }
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   104
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   105
    @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   106
    MethodHandle bindArgument(int pos, char basicType, Object value) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   107
        MethodType type = type().dropParameterTypes(pos, pos+1);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   108
        LambdaForm form = internalForm().bind(1+pos, speciesData());
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   109
        return cloneExtend(type, form, basicType, value);
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   110
    }
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   111
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   112
    @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   113
    MethodHandle dropArguments(MethodType srcType, int pos, int drops) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   114
        LambdaForm form = internalForm().addArguments(pos, srcType.parameterList().subList(pos, pos+drops));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   115
        try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   116
             return clone(srcType, form);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   117
         } catch (Throwable t) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   118
             throw new InternalError(t);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   119
         }
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   120
    }
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   121
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   122
    @Override
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   123
    MethodHandle permuteArguments(MethodType newType, int[] reorder) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   124
        try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   125
             return clone(newType, form.permuteArguments(1, reorder, basicTypes(newType.parameterList())));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   126
         } catch (Throwable t) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   127
             throw new InternalError(t);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   128
         }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   129
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   130
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   131
    static final String EXTENSION_TYPES = "LIJFD";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   132
    static final byte INDEX_L = 0, INDEX_I = 1, INDEX_J = 2, INDEX_F = 3, INDEX_D = 4;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   133
    static byte extensionIndex(char type) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   134
        int i = EXTENSION_TYPES.indexOf(type);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   135
        if (i < 0)  throw new InternalError();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   136
        return (byte) i;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   137
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   138
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   139
    /**
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   140
     * Return the {@link SpeciesData} instance representing this BMH species. All subclasses must provide a
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   141
     * static field containing this value, and they must accordingly implement this method.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   142
     */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   143
    protected abstract SpeciesData speciesData();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   144
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   145
    @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   146
    final Object internalValues() {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   147
        Object[] boundValues = new Object[speciesData().fieldCount()];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   148
        for (int i = 0; i < boundValues.length; ++i) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   149
            boundValues[i] = arg(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   150
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   151
        return Arrays.asList(boundValues);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   152
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   153
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   154
    public final Object arg(int i) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   155
        try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   156
            switch (speciesData().fieldType(i)) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   157
            case 'L': return argL(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   158
            case 'I': return argI(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   159
            case 'F': return argF(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   160
            case 'D': return argD(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   161
            case 'J': return argJ(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   162
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   163
        } catch (Throwable ex) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   164
            throw new InternalError(ex);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   165
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   166
        throw new InternalError("unexpected type: " + speciesData().types+"."+i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   167
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   168
    public final Object argL(int i) throws Throwable { return          speciesData().getters[i].invokeBasic(this); }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   169
    public final int    argI(int i) throws Throwable { return (int)    speciesData().getters[i].invokeBasic(this); }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   170
    public final float  argF(int i) throws Throwable { return (float)  speciesData().getters[i].invokeBasic(this); }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   171
    public final double argD(int i) throws Throwable { return (double) speciesData().getters[i].invokeBasic(this); }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   172
    public final long   argJ(int i) throws Throwable { return (long)   speciesData().getters[i].invokeBasic(this); }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   173
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   174
    //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   175
    // cloning API
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   176
    //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   177
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   178
    public abstract BoundMethodHandle clone(MethodType mt, LambdaForm lf) throws Throwable;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   179
    public abstract BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   180
    public abstract BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int    narg) throws Throwable;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   181
    public abstract BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long   narg) throws Throwable;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   182
    public abstract BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float  narg) throws Throwable;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   183
    public abstract BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   184
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   185
    // The following is a grossly irregular hack:
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   186
    @Override MethodHandle reinvokerTarget() {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   187
        try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   188
            return (MethodHandle) argL(0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   189
        } catch (Throwable ex) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   190
            throw new InternalError(ex);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   191
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   192
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   193
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   194
    //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   195
    // concrete BMH classes required to close bootstrap loops
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   196
    //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   197
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   198
    private  // make it private to force users to access the enclosing class first
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   199
    static final class Species_L extends BoundMethodHandle {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   200
        final Object argL0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   201
        public Species_L(MethodType mt, LambdaForm lf, Object argL0) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   202
            super(mt, lf);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   203
            this.argL0 = argL0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   204
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   205
        // The following is a grossly irregular hack:
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   206
        @Override MethodHandle reinvokerTarget() { return (MethodHandle) argL0; }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   207
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   208
        public SpeciesData speciesData() {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   209
            return SPECIES_DATA;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   210
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   211
        public static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("L", Species_L.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   212
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   213
        public final BoundMethodHandle clone(MethodType mt, LambdaForm lf) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   214
            return new Species_L(mt, lf, argL0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   215
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   216
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   217
        public final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   218
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_L).constructor[0].invokeBasic(mt, lf, argL0, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   219
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   220
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   221
        public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   222
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_I).constructor[0].invokeBasic(mt, lf, argL0, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   223
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   224
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   225
        public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   226
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_J).constructor[0].invokeBasic(mt, lf, argL0, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   227
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   228
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   229
        public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   230
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_F).constructor[0].invokeBasic(mt, lf, argL0, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   231
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   232
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   233
        public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   234
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_D).constructor[0].invokeBasic(mt, lf, argL0, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   235
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   236
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   237
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   238
/*
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   239
    static final class Species_LL extends BoundMethodHandle {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   240
        final Object argL0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   241
        final Object argL1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   242
        public Species_LL(MethodType mt, LambdaForm lf, Object argL0, Object argL1) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   243
            super(mt, lf);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   244
            this.argL0 = argL0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   245
            this.argL1 = argL1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   246
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   247
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   248
        public SpeciesData speciesData() {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   249
            return SPECIES_DATA;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   250
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   251
        public static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("LL", Species_LL.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   252
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   253
        public final BoundMethodHandle clone(MethodType mt, LambdaForm lf) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   254
            return new Species_LL(mt, lf, argL0, argL1);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   255
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   256
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   257
        public final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   258
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_L).constructor[0].invokeBasic(mt, lf, argL0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   259
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   260
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   261
        public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   262
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_I).constructor[0].invokeBasic(mt, lf, argL0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   263
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   264
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   265
        public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   266
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_J).constructor[0].invokeBasic(mt, lf, argL0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   267
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   268
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   269
        public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   270
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_F).constructor[0].invokeBasic(mt, lf, argL0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   271
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   272
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   273
        public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   274
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_D).constructor[0].invokeBasic(mt, lf, argL0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   275
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   276
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   277
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   278
    static final class Species_JL extends BoundMethodHandle {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   279
        final long argJ0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   280
        final Object argL1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   281
        public Species_JL(MethodType mt, LambdaForm lf, long argJ0, Object argL1) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   282
            super(mt, lf);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   283
            this.argJ0 = argJ0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   284
            this.argL1 = argL1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   285
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   286
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   287
        public SpeciesData speciesData() {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   288
            return SPECIES_DATA;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   289
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   290
        public static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("JL", Species_JL.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   291
        @Override public final long   argJ0() { return argJ0; }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   292
        @Override public final Object argL1() { return argL1; }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   293
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   294
        public final BoundMethodHandle clone(MethodType mt, LambdaForm lf) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   295
            return new Species_JL(mt, lf, argJ0, argL1);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   296
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   297
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   298
        public final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   299
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_L).constructor[0].invokeBasic(mt, lf, argJ0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   300
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   301
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   302
        public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   303
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_I).constructor[0].invokeBasic(mt, lf, argJ0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   304
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   305
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   306
        public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   307
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_J).constructor[0].invokeBasic(mt, lf, argJ0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   308
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   309
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   310
        public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   311
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_F).constructor[0].invokeBasic(mt, lf, argJ0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   312
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   313
        @Override
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   314
        public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   315
            return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_D).constructor[0].invokeBasic(mt, lf, argJ0, argL1, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   316
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   317
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   318
*/
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   319
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   320
    //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   321
    // BMH species meta-data
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   322
    //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   323
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   324
    /**
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   325
     * Meta-data wrapper for concrete BMH classes.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   326
     */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   327
    static class SpeciesData {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   328
        final String                             types;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   329
        final Class<? extends BoundMethodHandle> clazz;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   330
        // Bootstrapping requires circular relations MH -> BMH -> SpeciesData -> MH
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   331
        // Therefore, we need a non-final link in the chain.  Use array elements.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   332
        final MethodHandle[]                     constructor;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   333
        final MethodHandle[]                     getters;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   334
        final SpeciesData[]                      extensions;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   335
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   336
        public int fieldCount() {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   337
            return types.length();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   338
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   339
        public char fieldType(int i) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   340
            return types.charAt(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   341
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   342
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   343
        public String toString() {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   344
            return "SpeciesData["+(isPlaceholder() ? "<placeholder>" : clazz.getSimpleName())+":"+types+"]";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   345
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   346
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   347
        /**
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   348
         * Return a {@link LambdaForm.Name} containing a {@link LambdaForm.NamedFunction} that
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   349
         * represents a MH bound to a generic invoker, which in turn forwards to the corresponding
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   350
         * getter.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   351
         */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   352
        Name getterName(Name mhName, int i) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   353
            MethodHandle mh = getters[i];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   354
            assert(mh != null) : this+"."+i;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   355
            return new Name(mh, mhName);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   356
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   357
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   358
        static final SpeciesData EMPTY = new SpeciesData("", BoundMethodHandle.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   359
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   360
        private SpeciesData(String types, Class<? extends BoundMethodHandle> clazz) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   361
            this.types = types;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   362
            this.clazz = clazz;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   363
            if (!INIT_DONE) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   364
                this.constructor = new MethodHandle[1];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   365
                this.getters = new MethodHandle[types.length()];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   366
            } else {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   367
                this.constructor = Factory.makeCtors(clazz, types, null);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   368
                this.getters = Factory.makeGetters(clazz, types, null);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   369
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   370
            this.extensions = new SpeciesData[EXTENSION_TYPES.length()];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   371
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   372
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   373
        private void initForBootstrap() {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   374
            assert(!INIT_DONE);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   375
            if (constructor[0] == null) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   376
                Factory.makeCtors(clazz, types, this.constructor);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   377
                Factory.makeGetters(clazz, types, this.getters);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   378
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   379
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   380
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   381
        private SpeciesData(String types) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   382
            // Placeholder only.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   383
            this.types = types;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   384
            this.clazz = null;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   385
            this.constructor = null;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   386
            this.getters = null;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   387
            this.extensions = null;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   388
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   389
        private boolean isPlaceholder() { return clazz == null; }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   390
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   391
        private static final HashMap<String, SpeciesData> CACHE = new HashMap<>();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   392
        private static final boolean INIT_DONE;  // set after <clinit> finishes...
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   393
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   394
        SpeciesData extendWithType(char type) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   395
            int i = extensionIndex(type);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   396
            SpeciesData d = extensions[i];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   397
            if (d != null)  return d;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   398
            extensions[i] = d = get(types+type);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   399
            return d;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   400
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   401
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   402
        SpeciesData extendWithIndex(byte index) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   403
            SpeciesData d = extensions[index];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   404
            if (d != null)  return d;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   405
            extensions[index] = d = get(types+EXTENSION_TYPES.charAt(index));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   406
            return d;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   407
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   408
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   409
        private static SpeciesData get(String types) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   410
            // Acquire cache lock for query.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   411
            SpeciesData d = lookupCache(types);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   412
            if (!d.isPlaceholder())
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   413
                return d;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   414
            synchronized (d) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   415
                // Use synch. on the placeholder to prevent multiple instantiation of one species.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   416
                // Creating this class forces a recursive call to getForClass.
13424
5de7e57cdc02 7188911: nightly failures after JSR 292 lazy method handle update (round 2)
twisti
parents: 13423
diff changeset
   417
                if (lookupCache(types).isPlaceholder())
5de7e57cdc02 7188911: nightly failures after JSR 292 lazy method handle update (round 2)
twisti
parents: 13423
diff changeset
   418
                    Factory.generateConcreteBMHClass(types);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   419
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   420
            // Reacquire cache lock.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   421
            d = lookupCache(types);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   422
            // Class loading must have upgraded the cache.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   423
            assert(d != null && !d.isPlaceholder());
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   424
            return d;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   425
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   426
        static SpeciesData getForClass(String types, Class<? extends BoundMethodHandle> clazz) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   427
            // clazz is a new class which is initializing its SPECIES_DATA field
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   428
            return updateCache(types, new SpeciesData(types, clazz));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   429
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   430
        private static synchronized SpeciesData lookupCache(String types) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   431
            SpeciesData d = CACHE.get(types);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   432
            if (d != null)  return d;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   433
            d = new SpeciesData(types);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   434
            assert(d.isPlaceholder());
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   435
            CACHE.put(types, d);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   436
            return d;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   437
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   438
        private static synchronized SpeciesData updateCache(String types, SpeciesData d) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   439
            SpeciesData d2;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   440
            assert((d2 = CACHE.get(types)) == null || d2.isPlaceholder());
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   441
            assert(!d.isPlaceholder());
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   442
            CACHE.put(types, d);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   443
            return d;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   444
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   445
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   446
        static {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   447
            // pre-fill the BMH speciesdata cache with BMH's inner classes
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   448
            final Class<BoundMethodHandle> rootCls = BoundMethodHandle.class;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   449
            SpeciesData d0 = BoundMethodHandle.SPECIES_DATA;  // trigger class init
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   450
            assert(d0 == null || d0 == lookupCache("")) : d0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   451
            try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   452
                for (Class<?> c : rootCls.getDeclaredClasses()) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   453
                    if (rootCls.isAssignableFrom(c)) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   454
                        final Class<? extends BoundMethodHandle> cbmh = c.asSubclass(BoundMethodHandle.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   455
                        SpeciesData d = Factory.speciesDataFromConcreteBMHClass(cbmh);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   456
                        assert(d != null) : cbmh.getName();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   457
                        assert(d.clazz == cbmh);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   458
                        assert(d == lookupCache(d.types));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   459
                    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   460
                }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   461
            } catch (Throwable e) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   462
                throw new InternalError(e);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   463
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   464
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   465
            for (SpeciesData d : CACHE.values()) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   466
                d.initForBootstrap();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   467
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   468
            // Note:  Do not simplify this, because INIT_DONE must not be
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   469
            // a compile-time constant during bootstrapping.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   470
            INIT_DONE = Boolean.TRUE;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   471
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   472
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   473
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   474
    static SpeciesData getSpeciesData(String types) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   475
        return SpeciesData.get(types);
7555
a279ebc3b25c 6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents: 7554
diff changeset
   476
    }
a279ebc3b25c 6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents: 7554
diff changeset
   477
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   478
    /**
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   479
     * Generation of concrete BMH classes.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   480
     *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   481
     * A concrete BMH species is fit for binding a number of values adhering to a
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   482
     * given type pattern. Reference types are erased.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   483
     *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   484
     * BMH species are cached by type pattern.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   485
     *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   486
     * A BMH species has a number of fields with the concrete (possibly erased) types of
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   487
     * bound values. Setters are provided as an API in BMH. Getters are exposed as MHs,
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   488
     * which can be included as names in lambda forms.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   489
     */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   490
    static class Factory {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   491
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   492
        static final String JLO_SIG  = "Ljava/lang/Object;";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   493
        static final String JLS_SIG  = "Ljava/lang/String;";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   494
        static final String JLC_SIG  = "Ljava/lang/Class;";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   495
        static final String MH       = "java/lang/invoke/MethodHandle";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   496
        static final String MH_SIG   = "L"+MH+";";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   497
        static final String BMH      = "java/lang/invoke/BoundMethodHandle";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   498
        static final String BMH_SIG  = "L"+BMH+";";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   499
        static final String SPECIES_DATA     = "java/lang/invoke/BoundMethodHandle$SpeciesData";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   500
        static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   501
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   502
        static final String SPECIES_PREFIX_NAME = "Species_";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   503
        static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   504
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   505
        static final String BMHSPECIES_DATA_EWI_SIG = "(B)" + SPECIES_DATA_SIG;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   506
        static final String BMHSPECIES_DATA_GFC_SIG = "(" + JLS_SIG + JLC_SIG + ")" + SPECIES_DATA_SIG;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   507
        static final String MYSPECIES_DATA_SIG = "()" + SPECIES_DATA_SIG;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   508
        static final String VOID_SIG   = "()V";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   509
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   510
        static final String SIG_INCIPIT = "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   511
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   512
        static final Class<?>[] TYPES = new Class<?>[] { Object.class, int.class, long.class, float.class, double.class };
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   513
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   514
        static final String[] E_THROWABLE = new String[] { "java/lang/Throwable" };
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   515
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   516
        /**
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   517
         * Generate a concrete subclass of BMH for a given combination of bound types.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   518
         *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   519
         * A concrete BMH species adheres to the following schema:
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   520
         *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   521
         * <pre>
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   522
         * class Species_<<types>> extends BoundMethodHandle {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   523
         *     <<fields>>
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   524
         *     final SpeciesData speciesData() { return SpeciesData.get("<<types>>"); }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   525
         * }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   526
         * </pre>
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   527
         *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   528
         * The {@code <<types>>} signature is precisely the string that is passed to this
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   529
         * method.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   530
         *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   531
         * The {@code <<fields>>} section consists of one field definition per character in
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   532
         * the type signature, adhering to the naming schema described in the definition of
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   533
         * {@link #makeFieldName()}.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   534
         *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   535
         * For example, a concrete BMH species for two reference and one integral bound values
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   536
         * would have the following shape:
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   537
         *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   538
         * <pre>
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   539
         * class BoundMethodHandle { ... private static
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   540
         * final class Species_LLI extends BoundMethodHandle {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   541
         *     final Object argL0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   542
         *     final Object argL1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   543
         *     final int argI2;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   544
         *     public Species_LLI(MethodType mt, LambdaForm lf, Object argL0, Object argL1, int argI2) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   545
         *         super(mt, lf);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   546
         *         this.argL0 = argL0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   547
         *         this.argL1 = argL1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   548
         *         this.argI2 = argI2;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   549
         *     }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   550
         *     public final SpeciesData speciesData() { return SPECIES_DATA; }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   551
         *     public static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("LLI", Species_LLI.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   552
         *     public final BoundMethodHandle clone(MethodType mt, LambdaForm lf) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   553
         *         return SPECIES_DATA.constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   554
         *     }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   555
         *     public final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   556
         *         return SPECIES_DATA.extendWithIndex(INDEX_L).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   557
         *     }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   558
         *     public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   559
         *         return SPECIES_DATA.extendWithIndex(INDEX_I).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   560
         *     }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   561
         *     public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   562
         *         return SPECIES_DATA.extendWithIndex(INDEX_J).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   563
         *     }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   564
         *     public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   565
         *         return SPECIES_DATA.extendWithIndex(INDEX_F).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   566
         *     }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   567
         *     public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   568
         *         return SPECIES_DATA.extendWithIndex(INDEX_D).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   569
         *     }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   570
         * }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   571
         * </pre>
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   572
         *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   573
         * @param types the type signature, wherein reference types are erased to 'L'
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   574
         * @return the generated concrete BMH class
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   575
         */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   576
        static Class<? extends BoundMethodHandle> generateConcreteBMHClass(String types) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   577
            final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   578
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   579
            final String className  = SPECIES_PREFIX_PATH + types;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   580
            final String sourceFile = SPECIES_PREFIX_NAME + types;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   581
            cw.visit(V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, className, null, BMH, null);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   582
            cw.visitSource(sourceFile, null);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   583
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   584
            // emit static types and SPECIES_DATA fields
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   585
            cw.visitField(ACC_PUBLIC + ACC_STATIC, "SPECIES_DATA", SPECIES_DATA_SIG, null, null).visitEnd();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   586
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   587
            // emit bound argument fields
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   588
            for (int i = 0; i < types.length(); ++i) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   589
                final char t = types.charAt(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   590
                final String fieldName = makeFieldName(types, i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   591
                final String fieldDesc = t == 'L' ? JLO_SIG : String.valueOf(t);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   592
                cw.visitField(ACC_FINAL, fieldName, fieldDesc, null, null).visitEnd();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   593
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   594
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   595
            MethodVisitor mv;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   596
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   597
            // emit constructor
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   598
            mv = cw.visitMethod(ACC_PUBLIC, "<init>", makeSignature(types, true), null, null);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   599
            mv.visitCode();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   600
            mv.visitVarInsn(ALOAD, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   601
            mv.visitVarInsn(ALOAD, 1);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   602
            mv.visitVarInsn(ALOAD, 2);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   603
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   604
            mv.visitMethodInsn(INVOKESPECIAL, BMH, "<init>", makeSignature("", true));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   605
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   606
            for (int i = 0, j = 0; i < types.length(); ++i, ++j) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   607
                // i counts the arguments, j counts corresponding argument slots
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   608
                char t = types.charAt(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   609
                mv.visitVarInsn(ALOAD, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   610
                mv.visitVarInsn(typeLoadOp(t), j + 3); // parameters start at 3
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   611
                mv.visitFieldInsn(PUTFIELD, className, makeFieldName(types, i), typeSig(t));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   612
                if (t == 'J' || t == 'D') {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   613
                    ++j; // adjust argument register access
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   614
                }
4537
7c3c7f8d5195 6914665: update jdk code for JSR 292 (post 6858164)
jrose
parents: 2707
diff changeset
   615
            }
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   616
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   617
            mv.visitInsn(RETURN);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   618
            mv.visitMaxs(0, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   619
            mv.visitEnd();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   620
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   621
            // emit implementation of reinvokerTarget()
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   622
            mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "reinvokerTarget", "()" + MH_SIG, null, null);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   623
            mv.visitCode();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   624
            mv.visitVarInsn(ALOAD, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   625
            mv.visitFieldInsn(GETFIELD, className, "argL0", JLO_SIG);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   626
            mv.visitTypeInsn(CHECKCAST, MH);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   627
            mv.visitInsn(ARETURN);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   628
            mv.visitMaxs(0, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   629
            mv.visitEnd();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   630
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   631
            // emit implementation of speciesData()
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   632
            mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "speciesData", MYSPECIES_DATA_SIG, null, null);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   633
            mv.visitCode();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   634
            mv.visitFieldInsn(GETSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   635
            mv.visitInsn(ARETURN);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   636
            mv.visitMaxs(0, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   637
            mv.visitEnd();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   638
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   639
            // emit clone()
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   640
            mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "clone", makeSignature("", false), null, E_THROWABLE);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   641
            mv.visitCode();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   642
            // return speciesData().constructor[0].invokeBasic(mt, lf, argL0, ...)
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   643
            // obtain constructor
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   644
            mv.visitVarInsn(ALOAD, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   645
            mv.visitFieldInsn(GETSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   646
            mv.visitFieldInsn(GETFIELD, SPECIES_DATA, "constructor", "[" + MH_SIG);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   647
            mv.visitInsn(ICONST_0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   648
            mv.visitInsn(AALOAD);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   649
            // load mt, lf
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   650
            mv.visitVarInsn(ALOAD, 1);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   651
            mv.visitVarInsn(ALOAD, 2);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   652
            // put fields on the stack
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   653
            emitPushFields(types, className, mv);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   654
            // finally, invoke the constructor and return
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   655
            mv.visitMethodInsn(INVOKEVIRTUAL, MH, "invokeBasic", makeSignature(types, false));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   656
            mv.visitInsn(ARETURN);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   657
            mv.visitMaxs(0, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   658
            mv.visitEnd();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   659
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   660
            // for each type, emit cloneExtendT()
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   661
            for (Class<?> c : TYPES) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   662
                char t = Wrapper.basicTypeChar(c);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   663
                mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "cloneExtend" + t, makeSignature(String.valueOf(t), false), null, E_THROWABLE);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   664
                mv.visitCode();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   665
                // return SPECIES_DATA.extendWithIndex(extensionIndex(t)).constructor[0].invokeBasic(mt, lf, argL0, ..., narg)
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   666
                // obtain constructor
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   667
                mv.visitFieldInsn(GETSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   668
                int iconstInsn = ICONST_0 + extensionIndex(t);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   669
                assert(iconstInsn <= ICONST_5);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   670
                mv.visitInsn(iconstInsn);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   671
                mv.visitMethodInsn(INVOKEVIRTUAL, SPECIES_DATA, "extendWithIndex", BMHSPECIES_DATA_EWI_SIG);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   672
                mv.visitFieldInsn(GETFIELD, SPECIES_DATA, "constructor", "[" + MH_SIG);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   673
                mv.visitInsn(ICONST_0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   674
                mv.visitInsn(AALOAD);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   675
                // load mt, lf
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   676
                mv.visitVarInsn(ALOAD, 1);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   677
                mv.visitVarInsn(ALOAD, 2);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   678
                // put fields on the stack
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   679
                emitPushFields(types, className, mv);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   680
                // put narg on stack
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   681
                mv.visitVarInsn(typeLoadOp(t), 3);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   682
                // finally, invoke the constructor and return
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   683
                mv.visitMethodInsn(INVOKEVIRTUAL, MH, "invokeBasic", makeSignature(types + t, false));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   684
                mv.visitInsn(ARETURN);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   685
                mv.visitMaxs(0, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   686
                mv.visitEnd();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   687
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   688
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   689
            // emit class initializer
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   690
            mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "<clinit>", VOID_SIG, null, null);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   691
            mv.visitCode();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   692
            mv.visitLdcInsn(types);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   693
            mv.visitLdcInsn(Type.getObjectType(className));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   694
            mv.visitMethodInsn(INVOKESTATIC, SPECIES_DATA, "getForClass", BMHSPECIES_DATA_GFC_SIG);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   695
            mv.visitFieldInsn(PUTSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   696
            mv.visitInsn(RETURN);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   697
            mv.visitMaxs(0, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   698
            mv.visitEnd();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   699
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   700
            cw.visitEnd();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   701
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   702
            // load class
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   703
            final byte[] classFile = cw.toByteArray();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   704
            InvokerBytecodeGenerator.maybeDump(className, classFile);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   705
            Class<? extends BoundMethodHandle> bmhClass =
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   706
                //UNSAFE.defineAnonymousClass(BoundMethodHandle.class, classFile, null).asSubclass(BoundMethodHandle.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   707
                UNSAFE.defineClass(className, classFile, 0, classFile.length).asSubclass(BoundMethodHandle.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   708
            UNSAFE.ensureClassInitialized(bmhClass);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   709
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   710
            return bmhClass;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   711
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   712
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   713
        private static int typeLoadOp(char t) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   714
            switch (t) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   715
            case 'L': return ALOAD;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   716
            case 'I': return ILOAD;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   717
            case 'J': return LLOAD;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   718
            case 'F': return FLOAD;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   719
            case 'D': return DLOAD;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   720
            default : throw new InternalError("unrecognized type " + t);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   721
            }
4537
7c3c7f8d5195 6914665: update jdk code for JSR 292 (post 6858164)
jrose
parents: 2707
diff changeset
   722
        }
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   723
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   724
        private static void emitPushFields(String types, String className, MethodVisitor mv) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   725
            for (int i = 0; i < types.length(); ++i) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   726
                char tc = types.charAt(i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   727
                mv.visitVarInsn(ALOAD, 0);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   728
                mv.visitFieldInsn(GETFIELD, className, makeFieldName(types, i), typeSig(tc));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   729
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   730
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   731
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   732
        static String typeSig(char t) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   733
            return t == 'L' ? JLO_SIG : String.valueOf(t);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   734
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   735
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   736
        //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   737
        // Getter MH generation.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   738
        //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   739
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   740
        private static MethodHandle makeGetter(Class<?> cbmhClass, String types, int index) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   741
            String fieldName = makeFieldName(types, index);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   742
            Class<?> fieldType = Wrapper.forBasicType(types.charAt(index)).primitiveType();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   743
            try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   744
                return LOOKUP.findGetter(cbmhClass, fieldName, fieldType);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   745
            } catch (NoSuchFieldException | IllegalAccessException e) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   746
                throw new InternalError(e);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   747
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   748
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   749
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   750
        static MethodHandle[] makeGetters(Class<?> cbmhClass, String types, MethodHandle[] mhs) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   751
            if (mhs == null)  mhs = new MethodHandle[types.length()];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   752
            for (int i = 0; i < mhs.length; ++i) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   753
                mhs[i] = makeGetter(cbmhClass, types, i);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   754
                assert(mhs[i].internalMemberName().getDeclaringClass() == cbmhClass);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   755
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   756
            return mhs;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   757
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   758
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   759
        static MethodHandle[] makeCtors(Class<? extends BoundMethodHandle> cbmh, String types, MethodHandle mhs[]) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   760
            if (mhs == null)  mhs = new MethodHandle[1];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   761
            mhs[0] = makeCbmhCtor(cbmh, types);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   762
            return mhs;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   763
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   764
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   765
        //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   766
        // Auxiliary methods.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   767
        //
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   768
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   769
        static SpeciesData speciesDataFromConcreteBMHClass(Class<? extends BoundMethodHandle> cbmh) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   770
            try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   771
                Field F_SPECIES_DATA = cbmh.getDeclaredField("SPECIES_DATA");
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   772
                return (SpeciesData) F_SPECIES_DATA.get(null);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   773
            } catch (ReflectiveOperationException ex) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   774
                throw new InternalError(ex);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   775
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   776
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   777
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   778
        /**
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   779
         * Field names in concrete BMHs adhere to this pattern:
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   780
         * arg + type + index
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   781
         * where type is a single character (L, I, J, F, D).
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   782
         */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   783
        private static String makeFieldName(String types, int index) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   784
            assert index >= 0 && index < types.length();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   785
            return "arg" + types.charAt(index) + index;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   786
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   787
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   788
        private static String makeSignature(String types, boolean ctor) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   789
            StringBuilder buf = new StringBuilder(SIG_INCIPIT);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   790
            for (char c : types.toCharArray()) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   791
                buf.append(typeSig(c));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   792
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   793
            return buf.append(')').append(ctor ? "V" : BMH_SIG).toString();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   794
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   795
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   796
        static MethodHandle makeCbmhCtor(Class<? extends BoundMethodHandle> cbmh, String types) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   797
            try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   798
                return linkConstructor(LOOKUP.findConstructor(cbmh, MethodType.fromMethodDescriptorString(makeSignature(types, true), null)));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   799
            } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | TypeNotPresentException e) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   800
                throw new InternalError(e);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   801
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   802
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   803
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   804
        /**
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   805
         * Wrap a constructor call in a {@link LambdaForm}.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   806
         *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   807
         * If constructors ({@code <init>} methods) are called in LFs, problems might arise if the LFs
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   808
         * are turned into bytecode, because the call to the allocator is routed through an MH, and the
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   809
         * verifier cannot find a {@code NEW} instruction preceding the {@code INVOKESPECIAL} to
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   810
         * {@code <init>}. To avoid this, we add an indirection by invoking {@code <init>} through
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   811
         * {@link MethodHandle#linkToSpecial}.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   812
         *
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   813
         * The last {@link LambdaForm#Name Name} in the argument's form is expected to be the {@code void}
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   814
         * result of the {@code <init>} invocation. This entry is replaced.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   815
         */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   816
        private static MethodHandle linkConstructor(MethodHandle cmh) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   817
            final LambdaForm lf = cmh.form;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   818
            final int initNameIndex = lf.names.length - 1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   819
            final Name initName = lf.names[initNameIndex];
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   820
            final MemberName ctorMN = initName.function.member;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   821
            final MethodType ctorMT = ctorMN.getInvocationType();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   822
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   823
            // obtain function member (call target)
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   824
            // linker method type replaces initial parameter (BMH species) with BMH to avoid naming a species (anonymous class!)
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   825
            final MethodType linkerMT = ctorMT.changeParameterType(0, BoundMethodHandle.class).appendParameterTypes(MemberName.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   826
            MemberName linkerMN = new MemberName(MethodHandle.class, "linkToSpecial", linkerMT, REF_invokeStatic);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   827
            try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   828
                linkerMN = MemberName.getFactory().resolveOrFail(REF_invokeStatic, linkerMN, null, NoSuchMethodException.class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   829
                assert(linkerMN.isStatic());
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   830
            } catch (ReflectiveOperationException ex) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   831
                throw new InternalError(ex);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   832
            }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   833
            // extend arguments array
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   834
            Object[] newArgs = Arrays.copyOf(initName.arguments, initName.arguments.length + 1);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   835
            newArgs[newArgs.length - 1] = ctorMN;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   836
            // replace function
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   837
            final NamedFunction nf = new NamedFunction(linkerMN);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   838
            final Name linkedCtor = new Name(nf, newArgs);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   839
            linkedCtor.initIndex(initNameIndex);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   840
            lf.names[initNameIndex] = linkedCtor;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   841
            return cmh;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   842
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   843
7555
a279ebc3b25c 6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents: 7554
diff changeset
   844
    }
a279ebc3b25c 6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents: 7554
diff changeset
   845
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   846
    private static final Lookup LOOKUP = Lookup.IMPL_LOOKUP;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   847
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   848
    /**
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   849
     * All subclasses must provide such a value describing their type signature.
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   850
     */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 9752
diff changeset
   851
    static final SpeciesData SPECIES_DATA = SpeciesData.EMPTY;
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   852
}