hotspot/src/share/vm/prims/methodHandles.hpp
author bdelsart
Wed, 14 Sep 2011 16:28:39 +0200
changeset 10551 095307d09cb3
parent 10514 e229a19078cf
child 11487 f45d945367d4
permissions -rw-r--r--
7077806: ARM: java.lang.InternalError: bound subword value does not fit into the subword type Summary: shared fix necessary for ARM/PPC Reviewed-by: twisti, roland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     1
/*
7887
7aa0354cbf25 7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
twisti
parents: 7712
diff changeset
     2
 * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     4
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     7
 * published by the Free Software Foundation.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     8
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    13
 * accompanied this code).
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    14
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
diff changeset
    21
 * questions.
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    22
 *
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    23
 */
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    25
#ifndef SHARE_VM_PRIMS_METHODHANDLES_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    26
#define SHARE_VM_PRIMS_METHODHANDLES_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    28
#include "classfile/javaClasses.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    29
#include "classfile/vmSymbols.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    30
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    31
#include "runtime/globals.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    32
#include "runtime/interfaceSupport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
    33
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    34
class MacroAssembler;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    35
class Label;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    36
class MethodHandleEntry;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    37
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    38
class MethodHandles: AllStatic {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    39
  // JVM support for MethodHandle, MethodType, and related types
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    40
  // in java.lang.invoke and sun.invoke.
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    41
  // See also  javaClasses for layouts java_lang_invoke_Method{Handle,Type,Type::Form}.
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    42
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    43
  enum EntryKind {
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
    44
    _raise_exception,           // stub for error generation from other stubs
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    45
    _invokestatic_mh,           // how a MH emulates invokestatic
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    46
    _invokespecial_mh,          // ditto for the other invokes...
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    47
    _invokevirtual_mh,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    48
    _invokeinterface_mh,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    49
    _bound_ref_mh,              // reference argument is bound
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    50
    _bound_int_mh,              // int argument is bound (via an Integer or Float)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    51
    _bound_long_mh,             // long argument is bound (via a Long or Double)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    52
    _bound_ref_direct_mh,       // same as above, with direct linkage to methodOop
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    53
    _bound_int_direct_mh,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    54
    _bound_long_direct_mh,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    55
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    56
    _adapter_mh_first,     // adapter sequence goes here...
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    57
    _adapter_retype_only   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    58
    _adapter_retype_raw    = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    59
    _adapter_check_cast    = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    60
    _adapter_prim_to_prim  = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    61
    _adapter_ref_to_prim   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    62
    _adapter_prim_to_ref   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    63
    _adapter_swap_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    64
    _adapter_rot_args      = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    65
    _adapter_dup_args      = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    66
    _adapter_drop_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    67
    _adapter_collect_args  = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    68
    _adapter_spread_args   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS,
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
    69
    _adapter_fold_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_FOLD_ARGS,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
    70
    _adapter_unused_13     = _adapter_mh_first + 13,  //hole in the CONV_OP enumeration
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
    71
    _adapter_mh_last       = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT - 1,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    72
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    73
    // Optimized adapter types
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    74
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    75
    // argument list reordering
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    76
    _adapter_opt_swap_1,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    77
    _adapter_opt_swap_2,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    78
    _adapter_opt_rot_1_up,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    79
    _adapter_opt_rot_1_down,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    80
    _adapter_opt_rot_2_up,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    81
    _adapter_opt_rot_2_down,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    82
    // primitive single to single:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    83
    _adapter_opt_i2i,           // i2c, i2z, i2b, i2s
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    84
    // primitive double to single:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    85
    _adapter_opt_l2i,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    86
    _adapter_opt_d2f,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    87
    // primitive single to double:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    88
    _adapter_opt_i2l,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    89
    _adapter_opt_f2d,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    90
    // conversion between floating point and integer type is handled by Java
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    91
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    92
    // reference to primitive:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    93
    _adapter_opt_unboxi,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    94
    _adapter_opt_unboxl,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
    95
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
    96
    // %% Maybe tame the following with a VM_SYMBOLS_DO type macro?
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
    97
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
    98
    // how a blocking adapter returns (platform-dependent)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
    99
    _adapter_opt_return_ref,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   100
    _adapter_opt_return_int,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   101
    _adapter_opt_return_long,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   102
    _adapter_opt_return_float,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   103
    _adapter_opt_return_double,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   104
    _adapter_opt_return_void,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   105
    _adapter_opt_return_S0_ref,  // return ref to S=0 (last slot)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   106
    _adapter_opt_return_S1_ref,  // return ref to S=1 (2nd-to-last slot)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   107
    _adapter_opt_return_S2_ref,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   108
    _adapter_opt_return_S3_ref,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   109
    _adapter_opt_return_S4_ref,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   110
    _adapter_opt_return_S5_ref,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   111
    _adapter_opt_return_any,     // dynamically select r/i/l/f/d
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   112
    _adapter_opt_return_FIRST = _adapter_opt_return_ref,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   113
    _adapter_opt_return_LAST  = _adapter_opt_return_any,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   114
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   115
    // spreading (array length cases 0, 1, ...)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   116
    _adapter_opt_spread_0,       // spread empty array to N=0 arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   117
    _adapter_opt_spread_1_ref,   // spread Object[] to N=1 argument
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   118
    _adapter_opt_spread_2_ref,   // spread Object[] to N=2 arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   119
    _adapter_opt_spread_3_ref,   // spread Object[] to N=3 arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   120
    _adapter_opt_spread_4_ref,   // spread Object[] to N=4 arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   121
    _adapter_opt_spread_5_ref,   // spread Object[] to N=5 arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   122
    _adapter_opt_spread_ref,     // spread Object[] to N arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   123
    _adapter_opt_spread_byte,    // spread byte[] or boolean[] to N arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   124
    _adapter_opt_spread_char,    // spread char[], etc., to N arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   125
    _adapter_opt_spread_short,   // spread short[], etc., to N arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   126
    _adapter_opt_spread_int,     // spread int[], short[], etc., to N arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   127
    _adapter_opt_spread_long,    // spread long[] to N arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   128
    _adapter_opt_spread_float,   // spread float[] to N arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   129
    _adapter_opt_spread_double,  // spread double[] to N arguments
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   130
    _adapter_opt_spread_FIRST = _adapter_opt_spread_0,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   131
    _adapter_opt_spread_LAST  = _adapter_opt_spread_double,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   132
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   133
    // blocking filter/collect conversions
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   134
    // These collect N arguments and replace them (at slot S) by a return value
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   135
    // which is passed to the final target, along with the unaffected arguments.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   136
    // collect_{N}_{T} collects N arguments at any position into a T value
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   137
    // collect_{N}_S{S}_{T} collects N arguments at slot S into a T value
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   138
    // collect_{T} collects any number of arguments at any position
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   139
    // filter_S{S}_{T} is the same as collect_1_S{S}_{T} (a unary collection)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   140
    // (collect_2 is also usable as a filter, with long or double arguments)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   141
    _adapter_opt_collect_ref,    // combine N arguments, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   142
    _adapter_opt_collect_int,    // combine N arguments, replace with an int, short, etc.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   143
    _adapter_opt_collect_long,   // combine N arguments, replace with a long
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   144
    _adapter_opt_collect_float,  // combine N arguments, replace with a float
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   145
    _adapter_opt_collect_double, // combine N arguments, replace with a double
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   146
    _adapter_opt_collect_void,   // combine N arguments, replace with nothing
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   147
    // if there is a small fixed number to push, do so without a loop:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   148
    _adapter_opt_collect_0_ref,  // collect N=0 arguments, insert a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   149
    _adapter_opt_collect_1_ref,  // collect N=1 argument, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   150
    _adapter_opt_collect_2_ref,  // combine N=2 arguments, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   151
    _adapter_opt_collect_3_ref,  // combine N=3 arguments, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   152
    _adapter_opt_collect_4_ref,  // combine N=4 arguments, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   153
    _adapter_opt_collect_5_ref,  // combine N=5 arguments, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   154
    // filters are an important special case because they never move arguments:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   155
    _adapter_opt_filter_S0_ref,  // filter N=1 argument at S=0, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   156
    _adapter_opt_filter_S1_ref,  // filter N=1 argument at S=1, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   157
    _adapter_opt_filter_S2_ref,  // filter N=1 argument at S=2, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   158
    _adapter_opt_filter_S3_ref,  // filter N=1 argument at S=3, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   159
    _adapter_opt_filter_S4_ref,  // filter N=1 argument at S=4, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   160
    _adapter_opt_filter_S5_ref,  // filter N=1 argument at S=5, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   161
    // these move arguments, but they are important for boxing
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   162
    _adapter_opt_collect_2_S0_ref,  // combine last N=2 arguments, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   163
    _adapter_opt_collect_2_S1_ref,  // combine N=2 arguments at S=1, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   164
    _adapter_opt_collect_2_S2_ref,  // combine N=2 arguments at S=2, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   165
    _adapter_opt_collect_2_S3_ref,  // combine N=2 arguments at S=3, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   166
    _adapter_opt_collect_2_S4_ref,  // combine N=2 arguments at S=4, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   167
    _adapter_opt_collect_2_S5_ref,  // combine N=2 arguments at S=5, replace with a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   168
    _adapter_opt_collect_FIRST = _adapter_opt_collect_ref,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   169
    _adapter_opt_collect_LAST  = _adapter_opt_collect_2_S5_ref,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   170
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   171
    // blocking folding conversions
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   172
    // these are like collects, but retain all the N arguments for the final target
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   173
    //_adapter_opt_fold_0_ref,   // same as _adapter_opt_collect_0_ref
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   174
    // fold_{N}_{T} processes N arguments at any position into a T value, which it inserts
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   175
    // fold_{T} processes any number of arguments at any position
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   176
    _adapter_opt_fold_ref,       // process N arguments, prepend a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   177
    _adapter_opt_fold_int,       // process N arguments, prepend an int, short, etc.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   178
    _adapter_opt_fold_long,      // process N arguments, prepend a long
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   179
    _adapter_opt_fold_float,     // process N arguments, prepend a float
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   180
    _adapter_opt_fold_double,    // process N arguments, prepend a double
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   181
    _adapter_opt_fold_void,      // process N arguments, but leave the list unchanged
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   182
    _adapter_opt_fold_1_ref,     // process N=1 argument, prepend a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   183
    _adapter_opt_fold_2_ref,     // process N=2 arguments, prepend a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   184
    _adapter_opt_fold_3_ref,     // process N=3 arguments, prepend a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   185
    _adapter_opt_fold_4_ref,     // process N=4 arguments, prepend a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   186
    _adapter_opt_fold_5_ref,     // process N=5 arguments, prepend a reference
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   187
    _adapter_opt_fold_FIRST = _adapter_opt_fold_ref,
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   188
    _adapter_opt_fold_LAST  = _adapter_opt_fold_5_ref,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   189
10514
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 10008
diff changeset
   190
    _adapter_opt_profiling,
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 10008
diff changeset
   191
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   192
    _EK_LIMIT,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   193
    _EK_FIRST = 0
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   194
  };
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   195
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   196
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   197
  static bool enabled()                         { return _enabled; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   198
  static void set_enabled(bool z);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   199
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   200
 private:
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   201
  enum {  // import java_lang_invoke_AdapterMethodHandle::CONV_OP_*
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   202
    CONV_OP_LIMIT         = java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   203
    CONV_OP_MASK          = java_lang_invoke_AdapterMethodHandle::CONV_OP_MASK,
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   204
    CONV_TYPE_MASK        = java_lang_invoke_AdapterMethodHandle::CONV_TYPE_MASK,
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   205
    CONV_VMINFO_MASK      = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_MASK,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   206
    CONV_VMINFO_SHIFT     = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_SHIFT,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   207
    CONV_OP_SHIFT         = java_lang_invoke_AdapterMethodHandle::CONV_OP_SHIFT,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   208
    CONV_DEST_TYPE_SHIFT  = java_lang_invoke_AdapterMethodHandle::CONV_DEST_TYPE_SHIFT,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   209
    CONV_SRC_TYPE_SHIFT   = java_lang_invoke_AdapterMethodHandle::CONV_SRC_TYPE_SHIFT,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   210
    CONV_STACK_MOVE_SHIFT = java_lang_invoke_AdapterMethodHandle::CONV_STACK_MOVE_SHIFT,
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   211
    CONV_STACK_MOVE_MASK  = java_lang_invoke_AdapterMethodHandle::CONV_STACK_MOVE_MASK
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   212
  };
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   213
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   214
  static bool _enabled;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   215
  static MethodHandleEntry* _entries[_EK_LIMIT];
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   216
  static const char*        _entry_names[_EK_LIMIT+1];
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   217
  static jobject            _raise_exception_method;
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   218
  static address            _adapter_return_handlers[CONV_TYPE_MASK+1];
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   219
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   220
  // Adapters.
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   221
  static MethodHandlesAdapterBlob* _adapter_code;
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   222
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   223
  static bool ek_valid(EntryKind ek)            { return (uint)ek < (uint)_EK_LIMIT; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   224
  static bool conv_op_valid(int op)             { return (uint)op < (uint)CONV_OP_LIMIT; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   225
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   226
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   227
  static bool    have_entry(EntryKind ek)       { return ek_valid(ek) && _entries[ek] != NULL; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   228
  static MethodHandleEntry* entry(EntryKind ek) { assert(ek_valid(ek), "initialized");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   229
                                                  return _entries[ek]; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   230
  static const char* entry_name(EntryKind ek)   { assert(ek_valid(ek), "oob");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   231
                                                  return _entry_names[ek]; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   232
  static EntryKind adapter_entry_kind(int op)   { assert(conv_op_valid(op), "oob");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   233
                                                  return EntryKind(_adapter_mh_first + op); }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   234
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   235
  static void init_entry(EntryKind ek, MethodHandleEntry* me) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   236
    assert(ek_valid(ek), "oob");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   237
    assert(_entries[ek] == NULL, "no double initialization");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   238
    _entries[ek] = me;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   239
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   240
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   241
  // Some adapter helper functions.
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   242
  static EntryKind ek_original_kind(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   243
    if (ek <= _adapter_mh_last)  return ek;
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   244
    switch (ek) {
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   245
    case _adapter_opt_swap_1:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   246
    case _adapter_opt_swap_2:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   247
      return _adapter_swap_args;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   248
    case _adapter_opt_rot_1_up:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   249
    case _adapter_opt_rot_1_down:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   250
    case _adapter_opt_rot_2_up:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   251
    case _adapter_opt_rot_2_down:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   252
      return _adapter_rot_args;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   253
    case _adapter_opt_i2i:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   254
    case _adapter_opt_l2i:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   255
    case _adapter_opt_d2f:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   256
    case _adapter_opt_i2l:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   257
    case _adapter_opt_f2d:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   258
      return _adapter_prim_to_prim;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   259
    case _adapter_opt_unboxi:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   260
    case _adapter_opt_unboxl:
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   261
      return _adapter_ref_to_prim;
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   262
    }
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   263
    if (ek >= _adapter_opt_spread_FIRST && ek <= _adapter_opt_spread_LAST)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   264
      return _adapter_spread_args;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   265
    if (ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   266
      return _adapter_collect_args;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   267
    if (ek >= _adapter_opt_fold_FIRST && ek <= _adapter_opt_fold_LAST)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   268
      return _adapter_fold_args;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   269
    if (ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   270
      return _adapter_opt_return_any;
10514
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 10008
diff changeset
   271
    if (ek == _adapter_opt_profiling)
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 10008
diff changeset
   272
      return _adapter_retype_only;
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   273
    assert(false, "oob");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   274
    return _EK_LIMIT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   275
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   276
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   277
  static bool ek_supported(MethodHandles::EntryKind ek);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   278
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   279
  static BasicType ek_bound_mh_arg_type(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   280
    switch (ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   281
    case _bound_int_mh         : // fall-thru
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   282
    case _bound_int_direct_mh  : return T_INT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   283
    case _bound_long_mh        : // fall-thru
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   284
    case _bound_long_direct_mh : return T_LONG;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   285
    default                    : return T_OBJECT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   286
    }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   287
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   288
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   289
  static int ek_adapter_opt_swap_slots(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   290
    switch (ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   291
    case _adapter_opt_swap_1        : return  1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   292
    case _adapter_opt_swap_2        : return  2;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   293
    case _adapter_opt_rot_1_up      : return  1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   294
    case _adapter_opt_rot_1_down    : return  1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   295
    case _adapter_opt_rot_2_up      : return  2;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   296
    case _adapter_opt_rot_2_down    : return  2;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   297
    default : ShouldNotReachHere();   return -1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   298
    }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   299
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   300
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   301
  static int ek_adapter_opt_swap_mode(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   302
    switch (ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   303
    case _adapter_opt_swap_1       : return  0;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   304
    case _adapter_opt_swap_2       : return  0;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   305
    case _adapter_opt_rot_1_up     : return  1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   306
    case _adapter_opt_rot_1_down   : return -1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   307
    case _adapter_opt_rot_2_up     : return  1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   308
    case _adapter_opt_rot_2_down   : return -1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   309
    default : ShouldNotReachHere();  return  0;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   310
    }
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   311
  }
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   312
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   313
  static int ek_adapter_opt_collect_count(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   314
    assert(ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST ||
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   315
           ek >= _adapter_opt_fold_FIRST    && ek <= _adapter_opt_fold_LAST, "");
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   316
    switch (ek) {
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   317
    case _adapter_opt_collect_0_ref    : return  0;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   318
    case _adapter_opt_filter_S0_ref    :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   319
    case _adapter_opt_filter_S1_ref    :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   320
    case _adapter_opt_filter_S2_ref    :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   321
    case _adapter_opt_filter_S3_ref    :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   322
    case _adapter_opt_filter_S4_ref    :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   323
    case _adapter_opt_filter_S5_ref    :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   324
    case _adapter_opt_fold_1_ref       :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   325
    case _adapter_opt_collect_1_ref    : return  1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   326
    case _adapter_opt_collect_2_S0_ref :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   327
    case _adapter_opt_collect_2_S1_ref :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   328
    case _adapter_opt_collect_2_S2_ref :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   329
    case _adapter_opt_collect_2_S3_ref :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   330
    case _adapter_opt_collect_2_S4_ref :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   331
    case _adapter_opt_collect_2_S5_ref :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   332
    case _adapter_opt_fold_2_ref       :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   333
    case _adapter_opt_collect_2_ref    : return  2;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   334
    case _adapter_opt_fold_3_ref       :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   335
    case _adapter_opt_collect_3_ref    : return  3;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   336
    case _adapter_opt_fold_4_ref       :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   337
    case _adapter_opt_collect_4_ref    : return  4;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   338
    case _adapter_opt_fold_5_ref       :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   339
    case _adapter_opt_collect_5_ref    : return  5;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   340
    default                            : return -1;  // sentinel value for "variable"
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   341
    }
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   342
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   343
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   344
  static int ek_adapter_opt_collect_slot(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   345
    assert(ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST ||
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   346
           ek >= _adapter_opt_fold_FIRST    && ek <= _adapter_opt_fold_LAST, "");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   347
    switch (ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   348
    case _adapter_opt_collect_2_S0_ref  :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   349
    case _adapter_opt_filter_S0_ref     : return 0;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   350
    case _adapter_opt_collect_2_S1_ref  :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   351
    case _adapter_opt_filter_S1_ref     : return 1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   352
    case _adapter_opt_collect_2_S2_ref  :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   353
    case _adapter_opt_filter_S2_ref     : return 2;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   354
    case _adapter_opt_collect_2_S3_ref  :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   355
    case _adapter_opt_filter_S3_ref     : return 3;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   356
    case _adapter_opt_collect_2_S4_ref  :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   357
    case _adapter_opt_filter_S4_ref     : return 4;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   358
    case _adapter_opt_collect_2_S5_ref  :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   359
    case _adapter_opt_filter_S5_ref     : return 5;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   360
    default                             : return -1;  // sentinel value for "variable"
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   361
    }
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   362
  }
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   363
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   364
  static BasicType ek_adapter_opt_collect_type(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   365
    assert(ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST ||
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   366
           ek >= _adapter_opt_fold_FIRST    && ek <= _adapter_opt_fold_LAST, "");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   367
    switch (ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   368
    case _adapter_opt_fold_int          :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   369
    case _adapter_opt_collect_int       : return T_INT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   370
    case _adapter_opt_fold_long         :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   371
    case _adapter_opt_collect_long      : return T_LONG;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   372
    case _adapter_opt_fold_float        :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   373
    case _adapter_opt_collect_float     : return T_FLOAT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   374
    case _adapter_opt_fold_double       :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   375
    case _adapter_opt_collect_double    : return T_DOUBLE;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   376
    case _adapter_opt_fold_void         :
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   377
    case _adapter_opt_collect_void      : return T_VOID;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   378
    default                             : return T_OBJECT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   379
    }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   380
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   381
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   382
  static int ek_adapter_opt_return_slot(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   383
    assert(ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST, "");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   384
    switch (ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   385
    case _adapter_opt_return_S0_ref : return 0;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   386
    case _adapter_opt_return_S1_ref : return 1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   387
    case _adapter_opt_return_S2_ref : return 2;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   388
    case _adapter_opt_return_S3_ref : return 3;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   389
    case _adapter_opt_return_S4_ref : return 4;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   390
    case _adapter_opt_return_S5_ref : return 5;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   391
    default                         : return -1;  // sentinel value for "variable"
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   392
    }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   393
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   394
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   395
  static BasicType ek_adapter_opt_return_type(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   396
    assert(ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST, "");
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   397
    switch (ek) {
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   398
    case _adapter_opt_return_int    : return T_INT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   399
    case _adapter_opt_return_long   : return T_LONG;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   400
    case _adapter_opt_return_float  : return T_FLOAT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   401
    case _adapter_opt_return_double : return T_DOUBLE;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   402
    case _adapter_opt_return_void   : return T_VOID;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   403
    case _adapter_opt_return_any    : return T_CONFLICT;  // sentinel value for "variable"
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   404
    default                         : return T_OBJECT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   405
    }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   406
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   407
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   408
  static int ek_adapter_opt_spread_count(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   409
    assert(ek >= _adapter_opt_spread_FIRST && ek <= _adapter_opt_spread_LAST, "");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   410
    switch (ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   411
    case _adapter_opt_spread_0     : return  0;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   412
    case _adapter_opt_spread_1_ref : return  1;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   413
    case _adapter_opt_spread_2_ref : return  2;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   414
    case _adapter_opt_spread_3_ref : return  3;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   415
    case _adapter_opt_spread_4_ref : return  4;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   416
    case _adapter_opt_spread_5_ref : return  5;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   417
    default                        : return -1;  // sentinel value for "variable"
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   418
    }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   419
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   420
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   421
  static BasicType ek_adapter_opt_spread_type(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   422
    assert(ek >= _adapter_opt_spread_FIRST && ek <= _adapter_opt_spread_LAST, "");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   423
    switch (ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   424
    // (there is no _adapter_opt_spread_boolean; we use byte)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   425
    case _adapter_opt_spread_byte   : return T_BYTE;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   426
    case _adapter_opt_spread_char   : return T_CHAR;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   427
    case _adapter_opt_spread_short  : return T_SHORT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   428
    case _adapter_opt_spread_int    : return T_INT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   429
    case _adapter_opt_spread_long   : return T_LONG;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   430
    case _adapter_opt_spread_float  : return T_FLOAT;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   431
    case _adapter_opt_spread_double : return T_DOUBLE;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   432
    default                         : return T_OBJECT;
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   433
    }
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   434
  }
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   435
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   436
  static methodOop raise_exception_method() {
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   437
    oop rem = JNIHandles::resolve(_raise_exception_method);
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   438
    assert(rem == NULL || rem->is_method(), "");
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   439
    return (methodOop) rem;
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   440
  }
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   441
  static void set_raise_exception_method(methodOop rem) {
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   442
    assert(_raise_exception_method == NULL, "");
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   443
    _raise_exception_method = JNIHandles::make_global(Handle(rem));
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   444
  }
9967
9ddc1c490930 7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents: 9943
diff changeset
   445
  static methodOop resolve_raise_exception_method(TRAPS);
9ddc1c490930 7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents: 9943
diff changeset
   446
  // call raise_exception_method from C code:
9ddc1c490930 7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents: 9943
diff changeset
   447
  static void raise_exception(int code, oop actual, oop required, TRAPS);
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   448
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   449
  static jint adapter_conversion(int conv_op, BasicType src, BasicType dest,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   450
                                 int stack_move = 0, int vminfo = 0) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   451
    assert(conv_op_valid(conv_op), "oob");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   452
    jint conv = ((conv_op      << CONV_OP_SHIFT)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   453
                 | (src        << CONV_SRC_TYPE_SHIFT)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   454
                 | (dest       << CONV_DEST_TYPE_SHIFT)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   455
                 | (stack_move << CONV_STACK_MOVE_SHIFT)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   456
                 | (vminfo     << CONV_VMINFO_SHIFT)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   457
                 );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   458
    assert(adapter_conversion_op(conv) == conv_op, "decode conv_op");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   459
    assert(adapter_conversion_src_type(conv) == src, "decode src");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   460
    assert(adapter_conversion_dest_type(conv) == dest, "decode dest");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   461
    assert(adapter_conversion_stack_move(conv) == stack_move, "decode stack_move");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   462
    assert(adapter_conversion_vminfo(conv) == vminfo, "decode vminfo");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   463
    return conv;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   464
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   465
  static int adapter_conversion_op(jint conv) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   466
    return ((conv >> CONV_OP_SHIFT) & 0xF);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   467
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   468
  static BasicType adapter_conversion_src_type(jint conv) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   469
    return (BasicType)((conv >> CONV_SRC_TYPE_SHIFT) & 0xF);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   470
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   471
  static BasicType adapter_conversion_dest_type(jint conv) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   472
    return (BasicType)((conv >> CONV_DEST_TYPE_SHIFT) & 0xF);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   473
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   474
  static int adapter_conversion_stack_move(jint conv) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   475
    return (conv >> CONV_STACK_MOVE_SHIFT);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   476
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   477
  static int adapter_conversion_vminfo(jint conv) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   478
    return (conv >> CONV_VMINFO_SHIFT) & CONV_VMINFO_MASK;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   479
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   480
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   481
  // Bit mask of conversion_op values.  May vary by platform.
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   482
  static int adapter_conversion_ops_supported_mask();
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   483
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   484
  static bool conv_op_supported(int conv_op) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   485
    assert(conv_op_valid(conv_op), "");
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   486
    return ((adapter_conversion_ops_supported_mask() & nth_bit(conv_op)) != 0);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   487
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   488
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   489
  // Offset in words that the interpreter stack pointer moves when an argument is pushed.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   490
  // The stack_move value must always be a multiple of this.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   491
  static int stack_move_unit() {
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 5416
diff changeset
   492
    return frame::interpreter_frame_expression_stack_direction() * Interpreter::stackElementWords;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   493
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   494
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   495
  // Adapter frame traversal.  (Implementation-specific.)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   496
  static frame ricochet_frame_sender(const frame& fr, RegisterMap* reg_map);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   497
  static void ricochet_frame_oops_do(const frame& fr, OopClosure* blk, const RegisterMap* reg_map);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   498
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   499
  enum { CONV_VMINFO_SIGN_FLAG = 0x80 };
6775
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   500
  // Shift values for prim-to-prim conversions.
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   501
  static int adapter_prim_to_prim_subword_vminfo(BasicType dest) {
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   502
    if (dest == T_BOOLEAN) return (BitsPerInt - 1);  // boolean is 1 bit
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   503
    if (dest == T_CHAR)    return (BitsPerInt - BitsPerShort);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   504
    if (dest == T_BYTE)    return (BitsPerInt - BitsPerByte ) | CONV_VMINFO_SIGN_FLAG;
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   505
    if (dest == T_SHORT)   return (BitsPerInt - BitsPerShort) | CONV_VMINFO_SIGN_FLAG;
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   506
    return 0;                   // case T_INT
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   507
  }
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   508
  // Shift values for unboxing a primitive.
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   509
  static int adapter_unbox_subword_vminfo(BasicType dest) {
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   510
    if (dest == T_BOOLEAN) return (BitsPerInt - BitsPerByte );  // implemented as 1 byte
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   511
    if (dest == T_CHAR)    return (BitsPerInt - BitsPerShort);
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   512
    if (dest == T_BYTE)    return (BitsPerInt - BitsPerByte ) | CONV_VMINFO_SIGN_FLAG;
633e4ce534ac 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 6463
diff changeset
   513
    if (dest == T_SHORT)   return (BitsPerInt - BitsPerShort) | CONV_VMINFO_SIGN_FLAG;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   514
    return 0;                   // case T_INT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   515
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   516
  // Here is the transformation the i2i adapter must perform:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   517
  static int truncate_subword_from_vminfo(jint value, int vminfo) {
10551
095307d09cb3 7077806: ARM: java.lang.InternalError: bound subword value does not fit into the subword type
bdelsart
parents: 10514
diff changeset
   518
    int shift = vminfo & ~CONV_VMINFO_SIGN_FLAG;
095307d09cb3 7077806: ARM: java.lang.InternalError: bound subword value does not fit into the subword type
bdelsart
parents: 10514
diff changeset
   519
    jint tem = value << shift;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   520
    if ((vminfo & CONV_VMINFO_SIGN_FLAG) != 0) {
10551
095307d09cb3 7077806: ARM: java.lang.InternalError: bound subword value does not fit into the subword type
bdelsart
parents: 10514
diff changeset
   521
      return (jint)tem >> shift;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   522
    } else {
10551
095307d09cb3 7077806: ARM: java.lang.InternalError: bound subword value does not fit into the subword type
bdelsart
parents: 10514
diff changeset
   523
      return (juint)tem >> shift;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   524
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   525
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   526
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   527
  static inline address from_compiled_entry(EntryKind ek);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   528
  static inline address from_interpreted_entry(EntryKind ek);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   529
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   530
  // helpers for decode_method.
9323
20cc2230dc8a 7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents: 8676
diff changeset
   531
  static methodOop    decode_methodOop(methodOop m, int& decode_flags_result);
20cc2230dc8a 7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents: 8676
diff changeset
   532
  static methodHandle decode_vmtarget(oop vmtarget, int vmindex, oop mtype, KlassHandle& receiver_limit_result, int& decode_flags_result);
20cc2230dc8a 7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents: 8676
diff changeset
   533
  static methodHandle decode_MemberName(oop mname, KlassHandle& receiver_limit_result, int& decode_flags_result);
20cc2230dc8a 7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents: 8676
diff changeset
   534
  static methodHandle decode_MethodHandle(oop mh, KlassHandle& receiver_limit_result, int& decode_flags_result);
20cc2230dc8a 7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents: 8676
diff changeset
   535
  static methodHandle decode_DirectMethodHandle(oop mh, KlassHandle& receiver_limit_result, int& decode_flags_result);
20cc2230dc8a 7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents: 8676
diff changeset
   536
  static methodHandle decode_BoundMethodHandle(oop mh, KlassHandle& receiver_limit_result, int& decode_flags_result);
20cc2230dc8a 7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents: 8676
diff changeset
   537
  static methodHandle decode_AdapterMethodHandle(oop mh, KlassHandle& receiver_limit_result, int& decode_flags_result);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   538
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   539
  // Find out how many stack slots an mh pushes or pops.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   540
  // The result is *not* reported as a multiple of stack_move_unit();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   541
  // It is a signed net number of pushes (a difference in vmslots).
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   542
  // To compare with a stack_move value, first multiply by stack_move_unit().
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   543
  static int decode_MethodHandle_stack_pushes(oop mh);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   544
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   545
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   546
  // working with member names
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   547
  static void resolve_MemberName(Handle mname, TRAPS); // compute vmtarget/vmindex from name/type
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   548
  static void expand_MemberName(Handle mname, int suppress, TRAPS);  // expand defc/name/type if missing
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   549
  static Handle new_MemberName(TRAPS);  // must be followed by init_MemberName
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   550
  static void init_MemberName(oop mname_oop, oop target); // compute vmtarget/vmindex from target
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   551
  static void init_MemberName(oop mname_oop, methodOop m, bool do_dispatch = true);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   552
  static void init_MemberName(oop mname_oop, klassOop field_holder, AccessFlags mods, int offset);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7887
diff changeset
   553
  static int find_MemberNames(klassOop k, Symbol* name, Symbol* sig,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   554
                              int mflags, klassOop caller,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   555
                              int skip, objArrayOop results);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   556
  // bit values for suppress argument to expand_MemberName:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   557
  enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 };
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   558
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   559
  // Generate MethodHandles adapters.
7887
7aa0354cbf25 7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
twisti
parents: 7712
diff changeset
   560
  static void generate_adapters();
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   561
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   562
  // Called from InterpreterGenerator and MethodHandlesAdapterGenerator.
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   563
  static address generate_method_handle_interpreter_entry(MacroAssembler* _masm);
7887
7aa0354cbf25 7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
twisti
parents: 7712
diff changeset
   564
  static void generate_method_handle_stub(MacroAssembler* _masm, EntryKind ek);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   565
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   566
  // argument list parsing
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   567
  static int argument_slot(oop method_type, int arg);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   568
  static int argument_slot_count(oop method_type) { return argument_slot(method_type, -1); }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   569
  static int argument_slot_to_argnum(oop method_type, int argslot);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   570
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   571
  // Runtime support
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   572
  enum {                        // bit-encoded flags from decode_method or decode_vmref
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   573
    _dmf_has_receiver   = 0x01, // target method has leading reference argument
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   574
    _dmf_does_dispatch  = 0x02, // method handle performs virtual or interface dispatch
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   575
    _dmf_from_interface = 0x04, // peforms interface dispatch
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   576
    _DMF_DIRECT_MASK    = (_dmf_from_interface*2 - _dmf_has_receiver),
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   577
    _dmf_binds_method   = 0x08,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   578
    _dmf_binds_argument = 0x10,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   579
    _DMF_BOUND_MASK     = (_dmf_binds_argument*2 - _dmf_binds_method),
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   580
    _dmf_adapter_lsb    = 0x20,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   581
    _DMF_ADAPTER_MASK   = (_dmf_adapter_lsb << CONV_OP_LIMIT) - _dmf_adapter_lsb
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   582
  };
9323
20cc2230dc8a 7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents: 8676
diff changeset
   583
  static methodHandle decode_method(oop x, KlassHandle& receiver_limit_result, int& decode_flags_result);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   584
  enum {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   585
    // format of query to getConstant:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   586
    GC_JVM_PUSH_LIMIT = 0,
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   587
    GC_JVM_STACK_MOVE_UNIT = 1,
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   588
    GC_CONV_OP_IMPLEMENTED_MASK = 2,
9980
a330de5dea17 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 9976
diff changeset
   589
    GC_OP_ROT_ARGS_DOWN_LIMIT_BIAS = 3,
10514
e229a19078cf 7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents: 10008
diff changeset
   590
    GC_COUNT_GWT = 4,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   591
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   592
    // format of result from getTarget / encode_target:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   593
    ETF_HANDLE_OR_METHOD_NAME = 0, // all available data (immediate MH or method)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   594
    ETF_DIRECT_HANDLE         = 1, // ultimate method handle (will be a DMH, may be self)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   595
    ETF_METHOD_NAME           = 2, // ultimate method as MemberName
9980
a330de5dea17 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 9976
diff changeset
   596
    ETF_REFLECT_METHOD        = 3, // ultimate method as java.lang.reflect object (sans refClass)
10008
d84de97ad847 7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents: 9980
diff changeset
   597
    ETF_FORCE_DIRECT_HANDLE   = 64,
d84de97ad847 7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents: 9980
diff changeset
   598
    ETF_COMPILE_DIRECT_HANDLE = 65,
9980
a330de5dea17 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 9976
diff changeset
   599
a330de5dea17 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 9976
diff changeset
   600
    // ad hoc constants
a330de5dea17 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 9976
diff changeset
   601
    OP_ROT_ARGS_DOWN_LIMIT_BIAS = -1
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   602
  };
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   603
  static int get_named_constant(int which, Handle name_box, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   604
  static oop encode_target(Handle mh, int format, TRAPS); // report vmtarget (to Java code)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   605
  static bool class_cast_needed(klassOop src, klassOop dst);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   606
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   607
  static instanceKlassHandle resolve_instance_klass(oop    java_mirror_oop, TRAPS);
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   608
  static instanceKlassHandle resolve_instance_klass(jclass java_mirror_jh,  TRAPS) {
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   609
    return resolve_instance_klass(JNIHandles::resolve(java_mirror_jh), THREAD);
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   610
  }
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5419
diff changeset
   611
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   612
 private:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   613
  // These checkers operate on a pair of whole MethodTypes:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   614
  static const char* check_method_type_change(oop src_mtype, int src_beg, int src_end,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   615
                                              int insert_argnum, oop insert_type,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   616
                                              int change_argnum, oop change_type,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   617
                                              int delete_argnum,
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   618
                                              oop dst_mtype, int dst_beg, int dst_end,
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   619
                                              bool raw = false);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   620
  static const char* check_method_type_insertion(oop src_mtype,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   621
                                                 int insert_argnum, oop insert_type,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   622
                                                 oop dst_mtype) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   623
    oop no_ref = NULL;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   624
    return check_method_type_change(src_mtype, 0, -1,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   625
                                    insert_argnum, insert_type,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   626
                                    -1, no_ref, -1, dst_mtype, 0, -1);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   627
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   628
  static const char* check_method_type_conversion(oop src_mtype,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   629
                                                  int change_argnum, oop change_type,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   630
                                                  oop dst_mtype) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   631
    oop no_ref = NULL;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   632
    return check_method_type_change(src_mtype, 0, -1, -1, no_ref,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   633
                                    change_argnum, change_type,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   634
                                    -1, dst_mtype, 0, -1);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   635
  }
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   636
  static const char* check_method_type_passthrough(oop src_mtype, oop dst_mtype, bool raw) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   637
    oop no_ref = NULL;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   638
    return check_method_type_change(src_mtype, 0, -1,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   639
                                    -1, no_ref, -1, no_ref, -1,
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   640
                                    dst_mtype, 0, -1, raw);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   641
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   642
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   643
  // These checkers operate on pairs of argument or return types:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   644
  static const char* check_argument_type_change(BasicType src_type, klassOop src_klass,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   645
                                                BasicType dst_type, klassOop dst_klass,
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   646
                                                int argnum, bool raw = false);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   647
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   648
  static const char* check_argument_type_change(oop src_type, oop dst_type,
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   649
                                                int argnum, bool raw = false) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   650
    klassOop src_klass = NULL, dst_klass = NULL;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   651
    BasicType src_bt = java_lang_Class::as_BasicType(src_type, &src_klass);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   652
    BasicType dst_bt = java_lang_Class::as_BasicType(dst_type, &dst_klass);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   653
    return check_argument_type_change(src_bt, src_klass,
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   654
                                      dst_bt, dst_klass, argnum, raw);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   655
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   656
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   657
  static const char* check_return_type_change(oop src_type, oop dst_type, bool raw = false) {
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   658
    return check_argument_type_change(src_type, dst_type, -1, raw);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   659
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   660
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   661
  static const char* check_return_type_change(BasicType src_type, klassOop src_klass,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   662
                                              BasicType dst_type, klassOop dst_klass) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   663
    return check_argument_type_change(src_type, src_klass, dst_type, dst_klass, -1);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   664
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   665
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   666
  static const char* check_method_receiver(methodOop m, klassOop passed_recv_type);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   667
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   668
  // These verifiers can block, and will throw an error if the checking fails:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   669
  static void verify_vmslots(Handle mh, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   670
  static void verify_vmargslot(Handle mh, int argnum, int argslot, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   671
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   672
  static void verify_method_type(methodHandle m, Handle mtype,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   673
                                 bool has_bound_oop,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   674
                                 KlassHandle bound_oop_type,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   675
                                 TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   676
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   677
  static void verify_method_signature(methodHandle m, Handle mtype,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   678
                                      int first_ptype_pos,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   679
                                      KlassHandle insert_ptype, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   680
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   681
  static void verify_DirectMethodHandle(Handle mh, methodHandle m, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   682
  static void verify_BoundMethodHandle(Handle mh, Handle target, int argnum,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   683
                                       bool direct_to_method, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   684
  static void verify_BoundMethodHandle_with_receiver(Handle mh, methodHandle m, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   685
  static void verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   686
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   687
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   688
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   689
  // Fill in the fields of a DirectMethodHandle mh.  (MH.type must be pre-filled.)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   690
  static void init_DirectMethodHandle(Handle mh, methodHandle method, bool do_dispatch, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   691
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   692
  // Fill in the fields of a BoundMethodHandle mh.  (MH.type, BMH.argument must be pre-filled.)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   693
  static void init_BoundMethodHandle(Handle mh, Handle target, int argnum, TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   694
  static void init_BoundMethodHandle_with_receiver(Handle mh,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   695
                                                   methodHandle original_m,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   696
                                                   KlassHandle receiver_limit,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   697
                                                   int decode_flags,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   698
                                                   TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   699
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   700
  // Fill in the fields of an AdapterMethodHandle mh.  (MH.type must be pre-filled.)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   701
  static void init_AdapterMethodHandle(Handle mh, Handle target, int argnum, TRAPS);
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   702
  static void ensure_vmlayout_field(Handle target, TRAPS);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   703
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   704
#ifdef ASSERT
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   705
  static bool spot_check_entry_names();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   706
#endif
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   707
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   708
 private:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   709
  static methodHandle dispatch_decoded_method(methodHandle m,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   710
                                              KlassHandle receiver_limit,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   711
                                              int decode_flags,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   712
                                              KlassHandle receiver_klass,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   713
                                              TRAPS);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   714
9638
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9630
diff changeset
   715
public:
a9e79f5cd83b 6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
twisti
parents: 9630
diff changeset
   716
  static bool is_float_fixed_reinterpretation_cast(BasicType src, BasicType dst);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   717
  static bool same_basic_type_for_arguments(BasicType src, BasicType dst,
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   718
                                            bool raw = false,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   719
                                            bool for_return = false);
4094
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   720
  static bool same_basic_type_for_returns(BasicType src, BasicType dst, bool raw = false) {
1f424b2b2171 6815692: method handle code needs some cleanup (post-6655638)
jrose
parents: 2534
diff changeset
   721
    return same_basic_type_for_arguments(src, dst, raw, true);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   722
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   723
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   724
  static Symbol* convert_to_signature(oop type_str, bool polymorphic, TRAPS);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   725
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   726
#ifdef TARGET_ARCH_x86
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   727
# include "methodHandles_x86.hpp"
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   728
#endif
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   729
#ifdef TARGET_ARCH_sparc
9976
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9967
diff changeset
   730
# include "methodHandles_sparc.hpp"
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   731
#endif
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   732
#ifdef TARGET_ARCH_zero
9976
6fef34e63df1 7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents: 9967
diff changeset
   733
# include "methodHandles_zero.hpp"
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   734
#endif
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   735
#ifdef TARGET_ARCH_arm
9943
a9aea2b8010f 7045515: ARM assembly code for JSR 292 ricochet frames
bdelsart
parents: 9638
diff changeset
   736
# include "methodHandles_arm.hpp"
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   737
#endif
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   738
#ifdef TARGET_ARCH_ppc
9943
a9aea2b8010f 7045515: ARM assembly code for JSR 292 ricochet frames
bdelsart
parents: 9638
diff changeset
   739
# include "methodHandles_ppc.hpp"
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   740
#endif
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   741
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   742
#ifdef TARGET_ARCH_NYI_6939861
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   743
  // Here are some backward compatible declarations until the 6939861 ports are updated.
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   744
  #define _adapter_flyby    (_EK_LIMIT + 10)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   745
  #define _adapter_ricochet (_EK_LIMIT + 11)
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   746
  #define _adapter_opt_spread_1    _adapter_opt_spread_1_ref
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   747
  #define _adapter_opt_spread_more _adapter_opt_spread_ref
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   748
  enum {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   749
    _INSERT_NO_MASK   = -1,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   750
    _INSERT_REF_MASK  = 0,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   751
    _INSERT_INT_MASK  = 1,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   752
    _INSERT_LONG_MASK = 3
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   753
  };
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   754
  static void get_ek_bound_mh_info(EntryKind ek, BasicType& arg_type, int& arg_mask, int& arg_slots) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   755
    arg_type = ek_bound_mh_arg_type(ek);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   756
    arg_mask = 0;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   757
    arg_slots = type2size[arg_type];;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   758
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   759
  static void get_ek_adapter_opt_swap_rot_info(EntryKind ek, int& swap_bytes, int& rotate) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   760
    int swap_slots = ek_adapter_opt_swap_slots(ek);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   761
    rotate = ek_adapter_opt_swap_mode(ek);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   762
    swap_bytes = swap_slots * Interpreter::stackElementSize;
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   763
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   764
  static int get_ek_adapter_opt_spread_info(EntryKind ek) {
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   765
    return ek_adapter_opt_spread_count(ek);
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   766
  }
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   767
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   768
  static void insert_arg_slots(MacroAssembler* _masm,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   769
                               RegisterOrConstant arg_slots,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   770
                               int arg_mask,
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   771
                               Register argslot_reg,
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 5055
diff changeset
   772
                               Register temp_reg, Register temp2_reg, Register temp3_reg = noreg);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   773
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   774
  static void remove_arg_slots(MacroAssembler* _masm,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   775
                               RegisterOrConstant arg_slots,
5055
743f38c6e179 6932091: JSR 292 x86 code cleanup
twisti
parents: 5050
diff changeset
   776
                               Register argslot_reg,
5416
5f6377fcfd3e 6829193: JSR 292 needs to support SPARC
twisti
parents: 5055
diff changeset
   777
                               Register temp_reg, Register temp2_reg, Register temp3_reg = noreg);
6463
f4362c8da849 6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents: 5547
diff changeset
   778
f4362c8da849 6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents: 5547
diff changeset
   779
  static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN;
9630
d6419e4395e3 6939861: JVM should handle more conversion operations
never
parents: 9323
diff changeset
   780
#endif //TARGET_ARCH_NYI_6939861
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   781
};
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   782
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   783
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8076
diff changeset
   784
// Access methods for the "entry" field of a java.lang.invoke.MethodHandle.
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   785
// The field is primarily a jump target for compiled calls.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   786
// However, we squirrel away some nice pointers for other uses,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   787
// just before the jump target.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   788
// Aspects of a method handle entry:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   789
//  - from_compiled_entry - stub used when compiled code calls the MH
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   790
//  - from_interpreted_entry - stub used when the interpreter calls the MH
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   791
//  - type_checking_entry - stub for runtime casting between MHForm siblings (NYI)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   792
class MethodHandleEntry {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   793
 public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   794
  class Data {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   795
    friend class MethodHandleEntry;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   796
    size_t              _total_size; // size including Data and code stub
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   797
    MethodHandleEntry*  _type_checking_entry;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   798
    address             _from_interpreted_entry;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   799
    MethodHandleEntry* method_entry() { return (MethodHandleEntry*)(this + 1); }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   800
  };
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   801
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   802
  Data*     data()                              { return (Data*)this - 1; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   803
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   804
  address   start_address()                     { return (address) data(); }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   805
  address   end_address()                       { return start_address() + data()->_total_size; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   806
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   807
  address   from_compiled_entry()               { return (address) this; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   808
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   809
  address   from_interpreted_entry()            { return data()->_from_interpreted_entry; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   810
  void  set_from_interpreted_entry(address e)   { data()->_from_interpreted_entry = e; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   811
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   812
  MethodHandleEntry* type_checking_entry()           { return data()->_type_checking_entry; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   813
  void set_type_checking_entry(MethodHandleEntry* e) { data()->_type_checking_entry = e; }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   814
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   815
  void set_end_address(address end_addr) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   816
    size_t total_size = end_addr - start_address();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   817
    assert(total_size > 0 && total_size < 0x1000, "reasonable end address");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   818
    data()->_total_size = total_size;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   819
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   820
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   821
  // Compiler support:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   822
  static int from_interpreted_entry_offset_in_bytes() {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   823
    return (int)( offset_of(Data, _from_interpreted_entry) - sizeof(Data) );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   824
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   825
  static int type_checking_entry_offset_in_bytes() {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   826
    return (int)( offset_of(Data, _from_interpreted_entry) - sizeof(Data) );
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   827
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   828
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   829
  static address            start_compiled_entry(MacroAssembler* _masm,
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   830
                                                 address interpreted_entry = NULL);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   831
  static MethodHandleEntry* finish_compiled_entry(MacroAssembler* masm, address start_addr);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   832
};
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   833
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   834
address MethodHandles::from_compiled_entry(EntryKind ek) { return entry(ek)->from_compiled_entry(); }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
   835
address MethodHandles::from_interpreted_entry(EntryKind ek) { return entry(ek)->from_interpreted_entry(); }
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   836
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   837
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   838
//------------------------------------------------------------------------------
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   839
// MethodHandlesAdapterGenerator
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   840
//
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   841
class MethodHandlesAdapterGenerator : public StubCodeGenerator {
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   842
public:
9980
a330de5dea17 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 9976
diff changeset
   843
  MethodHandlesAdapterGenerator(CodeBuffer* code) : StubCodeGenerator(code, PrintMethodHandleStubs) {}
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   844
7887
7aa0354cbf25 7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
twisti
parents: 7712
diff changeset
   845
  void generate();
5050
47ecd86932ce 6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents: 4094
diff changeset
   846
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
   847
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6775
diff changeset
   848
#endif // SHARE_VM_PRIMS_METHODHANDLES_HPP