src/share/vm/prims/methodHandles.hpp

changeset 3969
1d7922586cf6
parent 3434
15d394228cfa
child 4037
da91efe96a93
     1.1 --- a/src/share/vm/prims/methodHandles.hpp	Mon Jul 23 13:04:59 2012 -0700
     1.2 +++ b/src/share/vm/prims/methodHandles.hpp	Tue Jul 24 10:51:00 2012 -0700
     1.3 @@ -33,523 +33,36 @@
     1.4  
     1.5  class MacroAssembler;
     1.6  class Label;
     1.7 -class MethodHandleEntry;
     1.8  
     1.9  class MethodHandles: AllStatic {
    1.10    // JVM support for MethodHandle, MethodType, and related types
    1.11    // in java.lang.invoke and sun.invoke.
    1.12    // See also  javaClasses for layouts java_lang_invoke_Method{Handle,Type,Type::Form}.
    1.13   public:
    1.14 -  enum EntryKind {
    1.15 -    _raise_exception,           // stub for error generation from other stubs
    1.16 -    _invokestatic_mh,           // how a MH emulates invokestatic
    1.17 -    _invokespecial_mh,          // ditto for the other invokes...
    1.18 -    _invokevirtual_mh,
    1.19 -    _invokeinterface_mh,
    1.20 -    _bound_ref_mh,              // reference argument is bound
    1.21 -    _bound_int_mh,              // int argument is bound (via an Integer or Float)
    1.22 -    _bound_long_mh,             // long argument is bound (via a Long or Double)
    1.23 -    _bound_ref_direct_mh,       // same as above, with direct linkage to methodOop
    1.24 -    _bound_int_direct_mh,
    1.25 -    _bound_long_direct_mh,
    1.26 -
    1.27 -    _adapter_mh_first,     // adapter sequence goes here...
    1.28 -    _adapter_retype_only   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY,
    1.29 -    _adapter_retype_raw    = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW,
    1.30 -    _adapter_check_cast    = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST,
    1.31 -    _adapter_prim_to_prim  = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM,
    1.32 -    _adapter_ref_to_prim   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM,
    1.33 -    _adapter_prim_to_ref   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF,
    1.34 -    _adapter_swap_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS,
    1.35 -    _adapter_rot_args      = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS,
    1.36 -    _adapter_dup_args      = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS,
    1.37 -    _adapter_drop_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS,
    1.38 -    _adapter_collect_args  = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS,
    1.39 -    _adapter_spread_args   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS,
    1.40 -    _adapter_fold_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_FOLD_ARGS,
    1.41 -    _adapter_unused_13     = _adapter_mh_first + 13,  //hole in the CONV_OP enumeration
    1.42 -    _adapter_mh_last       = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT - 1,
    1.43 -
    1.44 -    // Optimized adapter types
    1.45 -
    1.46 -    // argument list reordering
    1.47 -    _adapter_opt_swap_1,
    1.48 -    _adapter_opt_swap_2,
    1.49 -    _adapter_opt_rot_1_up,
    1.50 -    _adapter_opt_rot_1_down,
    1.51 -    _adapter_opt_rot_2_up,
    1.52 -    _adapter_opt_rot_2_down,
    1.53 -    // primitive single to single:
    1.54 -    _adapter_opt_i2i,           // i2c, i2z, i2b, i2s
    1.55 -    // primitive double to single:
    1.56 -    _adapter_opt_l2i,
    1.57 -    _adapter_opt_d2f,
    1.58 -    // primitive single to double:
    1.59 -    _adapter_opt_i2l,
    1.60 -    _adapter_opt_f2d,
    1.61 -    // conversion between floating point and integer type is handled by Java
    1.62 -
    1.63 -    // reference to primitive:
    1.64 -    _adapter_opt_unboxi,
    1.65 -    _adapter_opt_unboxl,
    1.66 -
    1.67 -    // %% Maybe tame the following with a VM_SYMBOLS_DO type macro?
    1.68 -
    1.69 -    // how a blocking adapter returns (platform-dependent)
    1.70 -    _adapter_opt_return_ref,
    1.71 -    _adapter_opt_return_int,
    1.72 -    _adapter_opt_return_long,
    1.73 -    _adapter_opt_return_float,
    1.74 -    _adapter_opt_return_double,
    1.75 -    _adapter_opt_return_void,
    1.76 -    _adapter_opt_return_S0_ref,  // return ref to S=0 (last slot)
    1.77 -    _adapter_opt_return_S1_ref,  // return ref to S=1 (2nd-to-last slot)
    1.78 -    _adapter_opt_return_S2_ref,
    1.79 -    _adapter_opt_return_S3_ref,
    1.80 -    _adapter_opt_return_S4_ref,
    1.81 -    _adapter_opt_return_S5_ref,
    1.82 -    _adapter_opt_return_any,     // dynamically select r/i/l/f/d
    1.83 -    _adapter_opt_return_FIRST = _adapter_opt_return_ref,
    1.84 -    _adapter_opt_return_LAST  = _adapter_opt_return_any,
    1.85 -
    1.86 -    // spreading (array length cases 0, 1, ...)
    1.87 -    _adapter_opt_spread_0,       // spread empty array to N=0 arguments
    1.88 -    _adapter_opt_spread_1_ref,   // spread Object[] to N=1 argument
    1.89 -    _adapter_opt_spread_2_ref,   // spread Object[] to N=2 arguments
    1.90 -    _adapter_opt_spread_3_ref,   // spread Object[] to N=3 arguments
    1.91 -    _adapter_opt_spread_4_ref,   // spread Object[] to N=4 arguments
    1.92 -    _adapter_opt_spread_5_ref,   // spread Object[] to N=5 arguments
    1.93 -    _adapter_opt_spread_ref,     // spread Object[] to N arguments
    1.94 -    _adapter_opt_spread_byte,    // spread byte[] or boolean[] to N arguments
    1.95 -    _adapter_opt_spread_char,    // spread char[], etc., to N arguments
    1.96 -    _adapter_opt_spread_short,   // spread short[], etc., to N arguments
    1.97 -    _adapter_opt_spread_int,     // spread int[], short[], etc., to N arguments
    1.98 -    _adapter_opt_spread_long,    // spread long[] to N arguments
    1.99 -    _adapter_opt_spread_float,   // spread float[] to N arguments
   1.100 -    _adapter_opt_spread_double,  // spread double[] to N arguments
   1.101 -    _adapter_opt_spread_FIRST = _adapter_opt_spread_0,
   1.102 -    _adapter_opt_spread_LAST  = _adapter_opt_spread_double,
   1.103 -
   1.104 -    // blocking filter/collect conversions
   1.105 -    // These collect N arguments and replace them (at slot S) by a return value
   1.106 -    // which is passed to the final target, along with the unaffected arguments.
   1.107 -    // collect_{N}_{T} collects N arguments at any position into a T value
   1.108 -    // collect_{N}_S{S}_{T} collects N arguments at slot S into a T value
   1.109 -    // collect_{T} collects any number of arguments at any position
   1.110 -    // filter_S{S}_{T} is the same as collect_1_S{S}_{T} (a unary collection)
   1.111 -    // (collect_2 is also usable as a filter, with long or double arguments)
   1.112 -    _adapter_opt_collect_ref,    // combine N arguments, replace with a reference
   1.113 -    _adapter_opt_collect_int,    // combine N arguments, replace with an int, short, etc.
   1.114 -    _adapter_opt_collect_long,   // combine N arguments, replace with a long
   1.115 -    _adapter_opt_collect_float,  // combine N arguments, replace with a float
   1.116 -    _adapter_opt_collect_double, // combine N arguments, replace with a double
   1.117 -    _adapter_opt_collect_void,   // combine N arguments, replace with nothing
   1.118 -    // if there is a small fixed number to push, do so without a loop:
   1.119 -    _adapter_opt_collect_0_ref,  // collect N=0 arguments, insert a reference
   1.120 -    _adapter_opt_collect_1_ref,  // collect N=1 argument, replace with a reference
   1.121 -    _adapter_opt_collect_2_ref,  // combine N=2 arguments, replace with a reference
   1.122 -    _adapter_opt_collect_3_ref,  // combine N=3 arguments, replace with a reference
   1.123 -    _adapter_opt_collect_4_ref,  // combine N=4 arguments, replace with a reference
   1.124 -    _adapter_opt_collect_5_ref,  // combine N=5 arguments, replace with a reference
   1.125 -    // filters are an important special case because they never move arguments:
   1.126 -    _adapter_opt_filter_S0_ref,  // filter N=1 argument at S=0, replace with a reference
   1.127 -    _adapter_opt_filter_S1_ref,  // filter N=1 argument at S=1, replace with a reference
   1.128 -    _adapter_opt_filter_S2_ref,  // filter N=1 argument at S=2, replace with a reference
   1.129 -    _adapter_opt_filter_S3_ref,  // filter N=1 argument at S=3, replace with a reference
   1.130 -    _adapter_opt_filter_S4_ref,  // filter N=1 argument at S=4, replace with a reference
   1.131 -    _adapter_opt_filter_S5_ref,  // filter N=1 argument at S=5, replace with a reference
   1.132 -    // these move arguments, but they are important for boxing
   1.133 -    _adapter_opt_collect_2_S0_ref,  // combine last N=2 arguments, replace with a reference
   1.134 -    _adapter_opt_collect_2_S1_ref,  // combine N=2 arguments at S=1, replace with a reference
   1.135 -    _adapter_opt_collect_2_S2_ref,  // combine N=2 arguments at S=2, replace with a reference
   1.136 -    _adapter_opt_collect_2_S3_ref,  // combine N=2 arguments at S=3, replace with a reference
   1.137 -    _adapter_opt_collect_2_S4_ref,  // combine N=2 arguments at S=4, replace with a reference
   1.138 -    _adapter_opt_collect_2_S5_ref,  // combine N=2 arguments at S=5, replace with a reference
   1.139 -    _adapter_opt_collect_FIRST = _adapter_opt_collect_ref,
   1.140 -    _adapter_opt_collect_LAST  = _adapter_opt_collect_2_S5_ref,
   1.141 -
   1.142 -    // blocking folding conversions
   1.143 -    // these are like collects, but retain all the N arguments for the final target
   1.144 -    //_adapter_opt_fold_0_ref,   // same as _adapter_opt_collect_0_ref
   1.145 -    // fold_{N}_{T} processes N arguments at any position into a T value, which it inserts
   1.146 -    // fold_{T} processes any number of arguments at any position
   1.147 -    _adapter_opt_fold_ref,       // process N arguments, prepend a reference
   1.148 -    _adapter_opt_fold_int,       // process N arguments, prepend an int, short, etc.
   1.149 -    _adapter_opt_fold_long,      // process N arguments, prepend a long
   1.150 -    _adapter_opt_fold_float,     // process N arguments, prepend a float
   1.151 -    _adapter_opt_fold_double,    // process N arguments, prepend a double
   1.152 -    _adapter_opt_fold_void,      // process N arguments, but leave the list unchanged
   1.153 -    _adapter_opt_fold_1_ref,     // process N=1 argument, prepend a reference
   1.154 -    _adapter_opt_fold_2_ref,     // process N=2 arguments, prepend a reference
   1.155 -    _adapter_opt_fold_3_ref,     // process N=3 arguments, prepend a reference
   1.156 -    _adapter_opt_fold_4_ref,     // process N=4 arguments, prepend a reference
   1.157 -    _adapter_opt_fold_5_ref,     // process N=5 arguments, prepend a reference
   1.158 -    _adapter_opt_fold_FIRST = _adapter_opt_fold_ref,
   1.159 -    _adapter_opt_fold_LAST  = _adapter_opt_fold_5_ref,
   1.160 -
   1.161 -    _adapter_opt_profiling,
   1.162 -
   1.163 -    _EK_LIMIT,
   1.164 -    _EK_FIRST = 0
   1.165 -  };
   1.166 -
   1.167   public:
   1.168    static bool enabled()                         { return _enabled; }
   1.169    static void set_enabled(bool z);
   1.170  
   1.171   private:
   1.172 -  enum {  // import java_lang_invoke_AdapterMethodHandle::CONV_OP_*
   1.173 -    CONV_OP_LIMIT         = java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT,
   1.174 -    CONV_OP_MASK          = java_lang_invoke_AdapterMethodHandle::CONV_OP_MASK,
   1.175 -    CONV_TYPE_MASK        = java_lang_invoke_AdapterMethodHandle::CONV_TYPE_MASK,
   1.176 -    CONV_VMINFO_MASK      = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_MASK,
   1.177 -    CONV_VMINFO_SHIFT     = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_SHIFT,
   1.178 -    CONV_OP_SHIFT         = java_lang_invoke_AdapterMethodHandle::CONV_OP_SHIFT,
   1.179 -    CONV_DEST_TYPE_SHIFT  = java_lang_invoke_AdapterMethodHandle::CONV_DEST_TYPE_SHIFT,
   1.180 -    CONV_SRC_TYPE_SHIFT   = java_lang_invoke_AdapterMethodHandle::CONV_SRC_TYPE_SHIFT,
   1.181 -    CONV_STACK_MOVE_SHIFT = java_lang_invoke_AdapterMethodHandle::CONV_STACK_MOVE_SHIFT,
   1.182 -    CONV_STACK_MOVE_MASK  = java_lang_invoke_AdapterMethodHandle::CONV_STACK_MOVE_MASK
   1.183 -  };
   1.184 -
   1.185    static bool _enabled;
   1.186 -  static MethodHandleEntry* _entries[_EK_LIMIT];
   1.187 -  static const char*        _entry_names[_EK_LIMIT+1];
   1.188 -  static jobject            _raise_exception_method;
   1.189 -  static address            _adapter_return_handlers[CONV_TYPE_MASK+1];
   1.190  
   1.191    // Adapters.
   1.192    static MethodHandlesAdapterBlob* _adapter_code;
   1.193  
   1.194 -  static bool ek_valid(EntryKind ek)            { return (uint)ek < (uint)_EK_LIMIT; }
   1.195 -  static bool conv_op_valid(int op)             { return (uint)op < (uint)CONV_OP_LIMIT; }
   1.196 -
   1.197 - public:
   1.198 -  static bool    have_entry(EntryKind ek)       { return ek_valid(ek) && _entries[ek] != NULL; }
   1.199 -  static MethodHandleEntry* entry(EntryKind ek) { assert(ek_valid(ek), "initialized");
   1.200 -                                                  return _entries[ek]; }
   1.201 -  static const char* entry_name(EntryKind ek)   { assert(ek_valid(ek), "oob");
   1.202 -                                                  return _entry_names[ek]; }
   1.203 -  static EntryKind adapter_entry_kind(int op)   { assert(conv_op_valid(op), "oob");
   1.204 -                                                  return EntryKind(_adapter_mh_first + op); }
   1.205 -
   1.206 -  static void init_entry(EntryKind ek, MethodHandleEntry* me) {
   1.207 -    assert(ek_valid(ek), "oob");
   1.208 -    assert(_entries[ek] == NULL, "no double initialization");
   1.209 -    _entries[ek] = me;
   1.210 -  }
   1.211 -
   1.212 -  // Some adapter helper functions.
   1.213 -  static EntryKind ek_original_kind(EntryKind ek) {
   1.214 -    if (ek <= _adapter_mh_last)  return ek;
   1.215 -    switch (ek) {
   1.216 -    case _adapter_opt_swap_1:
   1.217 -    case _adapter_opt_swap_2:
   1.218 -      return _adapter_swap_args;
   1.219 -    case _adapter_opt_rot_1_up:
   1.220 -    case _adapter_opt_rot_1_down:
   1.221 -    case _adapter_opt_rot_2_up:
   1.222 -    case _adapter_opt_rot_2_down:
   1.223 -      return _adapter_rot_args;
   1.224 -    case _adapter_opt_i2i:
   1.225 -    case _adapter_opt_l2i:
   1.226 -    case _adapter_opt_d2f:
   1.227 -    case _adapter_opt_i2l:
   1.228 -    case _adapter_opt_f2d:
   1.229 -      return _adapter_prim_to_prim;
   1.230 -    case _adapter_opt_unboxi:
   1.231 -    case _adapter_opt_unboxl:
   1.232 -      return _adapter_ref_to_prim;
   1.233 -    }
   1.234 -    if (ek >= _adapter_opt_spread_FIRST && ek <= _adapter_opt_spread_LAST)
   1.235 -      return _adapter_spread_args;
   1.236 -    if (ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST)
   1.237 -      return _adapter_collect_args;
   1.238 -    if (ek >= _adapter_opt_fold_FIRST && ek <= _adapter_opt_fold_LAST)
   1.239 -      return _adapter_fold_args;
   1.240 -    if (ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST)
   1.241 -      return _adapter_opt_return_any;
   1.242 -    if (ek == _adapter_opt_profiling)
   1.243 -      return _adapter_retype_only;
   1.244 -    assert(false, "oob");
   1.245 -    return _EK_LIMIT;
   1.246 -  }
   1.247 -
   1.248 -  static bool ek_supported(MethodHandles::EntryKind ek);
   1.249 -
   1.250 -  static BasicType ek_bound_mh_arg_type(EntryKind ek) {
   1.251 -    switch (ek) {
   1.252 -    case _bound_int_mh         : // fall-thru
   1.253 -    case _bound_int_direct_mh  : return T_INT;
   1.254 -    case _bound_long_mh        : // fall-thru
   1.255 -    case _bound_long_direct_mh : return T_LONG;
   1.256 -    default                    : return T_OBJECT;
   1.257 -    }
   1.258 -  }
   1.259 -
   1.260 -  static int ek_adapter_opt_swap_slots(EntryKind ek) {
   1.261 -    switch (ek) {
   1.262 -    case _adapter_opt_swap_1        : return  1;
   1.263 -    case _adapter_opt_swap_2        : return  2;
   1.264 -    case _adapter_opt_rot_1_up      : return  1;
   1.265 -    case _adapter_opt_rot_1_down    : return  1;
   1.266 -    case _adapter_opt_rot_2_up      : return  2;
   1.267 -    case _adapter_opt_rot_2_down    : return  2;
   1.268 -    default : ShouldNotReachHere();   return -1;
   1.269 -    }
   1.270 -  }
   1.271 -
   1.272 -  static int ek_adapter_opt_swap_mode(EntryKind ek) {
   1.273 -    switch (ek) {
   1.274 -    case _adapter_opt_swap_1       : return  0;
   1.275 -    case _adapter_opt_swap_2       : return  0;
   1.276 -    case _adapter_opt_rot_1_up     : return  1;
   1.277 -    case _adapter_opt_rot_1_down   : return -1;
   1.278 -    case _adapter_opt_rot_2_up     : return  1;
   1.279 -    case _adapter_opt_rot_2_down   : return -1;
   1.280 -    default : ShouldNotReachHere();  return  0;
   1.281 -    }
   1.282 -  }
   1.283 -
   1.284 -  static int ek_adapter_opt_collect_count(EntryKind ek) {
   1.285 -    assert(ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST ||
   1.286 -           ek >= _adapter_opt_fold_FIRST    && ek <= _adapter_opt_fold_LAST, "");
   1.287 -    switch (ek) {
   1.288 -    case _adapter_opt_collect_0_ref    : return  0;
   1.289 -    case _adapter_opt_filter_S0_ref    :
   1.290 -    case _adapter_opt_filter_S1_ref    :
   1.291 -    case _adapter_opt_filter_S2_ref    :
   1.292 -    case _adapter_opt_filter_S3_ref    :
   1.293 -    case _adapter_opt_filter_S4_ref    :
   1.294 -    case _adapter_opt_filter_S5_ref    :
   1.295 -    case _adapter_opt_fold_1_ref       :
   1.296 -    case _adapter_opt_collect_1_ref    : return  1;
   1.297 -    case _adapter_opt_collect_2_S0_ref :
   1.298 -    case _adapter_opt_collect_2_S1_ref :
   1.299 -    case _adapter_opt_collect_2_S2_ref :
   1.300 -    case _adapter_opt_collect_2_S3_ref :
   1.301 -    case _adapter_opt_collect_2_S4_ref :
   1.302 -    case _adapter_opt_collect_2_S5_ref :
   1.303 -    case _adapter_opt_fold_2_ref       :
   1.304 -    case _adapter_opt_collect_2_ref    : return  2;
   1.305 -    case _adapter_opt_fold_3_ref       :
   1.306 -    case _adapter_opt_collect_3_ref    : return  3;
   1.307 -    case _adapter_opt_fold_4_ref       :
   1.308 -    case _adapter_opt_collect_4_ref    : return  4;
   1.309 -    case _adapter_opt_fold_5_ref       :
   1.310 -    case _adapter_opt_collect_5_ref    : return  5;
   1.311 -    default                            : return -1;  // sentinel value for "variable"
   1.312 -    }
   1.313 -  }
   1.314 -
   1.315 -  static int ek_adapter_opt_collect_slot(EntryKind ek) {
   1.316 -    assert(ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST ||
   1.317 -           ek >= _adapter_opt_fold_FIRST    && ek <= _adapter_opt_fold_LAST, "");
   1.318 -    switch (ek) {
   1.319 -    case _adapter_opt_collect_2_S0_ref  :
   1.320 -    case _adapter_opt_filter_S0_ref     : return 0;
   1.321 -    case _adapter_opt_collect_2_S1_ref  :
   1.322 -    case _adapter_opt_filter_S1_ref     : return 1;
   1.323 -    case _adapter_opt_collect_2_S2_ref  :
   1.324 -    case _adapter_opt_filter_S2_ref     : return 2;
   1.325 -    case _adapter_opt_collect_2_S3_ref  :
   1.326 -    case _adapter_opt_filter_S3_ref     : return 3;
   1.327 -    case _adapter_opt_collect_2_S4_ref  :
   1.328 -    case _adapter_opt_filter_S4_ref     : return 4;
   1.329 -    case _adapter_opt_collect_2_S5_ref  :
   1.330 -    case _adapter_opt_filter_S5_ref     : return 5;
   1.331 -    default                             : return -1;  // sentinel value for "variable"
   1.332 -    }
   1.333 -  }
   1.334 -
   1.335 -  static BasicType ek_adapter_opt_collect_type(EntryKind ek) {
   1.336 -    assert(ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST ||
   1.337 -           ek >= _adapter_opt_fold_FIRST    && ek <= _adapter_opt_fold_LAST, "");
   1.338 -    switch (ek) {
   1.339 -    case _adapter_opt_fold_int          :
   1.340 -    case _adapter_opt_collect_int       : return T_INT;
   1.341 -    case _adapter_opt_fold_long         :
   1.342 -    case _adapter_opt_collect_long      : return T_LONG;
   1.343 -    case _adapter_opt_fold_float        :
   1.344 -    case _adapter_opt_collect_float     : return T_FLOAT;
   1.345 -    case _adapter_opt_fold_double       :
   1.346 -    case _adapter_opt_collect_double    : return T_DOUBLE;
   1.347 -    case _adapter_opt_fold_void         :
   1.348 -    case _adapter_opt_collect_void      : return T_VOID;
   1.349 -    default                             : return T_OBJECT;
   1.350 -    }
   1.351 -  }
   1.352 -
   1.353 -  static int ek_adapter_opt_return_slot(EntryKind ek) {
   1.354 -    assert(ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST, "");
   1.355 -    switch (ek) {
   1.356 -    case _adapter_opt_return_S0_ref : return 0;
   1.357 -    case _adapter_opt_return_S1_ref : return 1;
   1.358 -    case _adapter_opt_return_S2_ref : return 2;
   1.359 -    case _adapter_opt_return_S3_ref : return 3;
   1.360 -    case _adapter_opt_return_S4_ref : return 4;
   1.361 -    case _adapter_opt_return_S5_ref : return 5;
   1.362 -    default                         : return -1;  // sentinel value for "variable"
   1.363 -    }
   1.364 -  }
   1.365 -
   1.366 -  static BasicType ek_adapter_opt_return_type(EntryKind ek) {
   1.367 -    assert(ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST, "");
   1.368 -    switch (ek) {
   1.369 -    case _adapter_opt_return_int    : return T_INT;
   1.370 -    case _adapter_opt_return_long   : return T_LONG;
   1.371 -    case _adapter_opt_return_float  : return T_FLOAT;
   1.372 -    case _adapter_opt_return_double : return T_DOUBLE;
   1.373 -    case _adapter_opt_return_void   : return T_VOID;
   1.374 -    case _adapter_opt_return_any    : return T_CONFLICT;  // sentinel value for "variable"
   1.375 -    default                         : return T_OBJECT;
   1.376 -    }
   1.377 -  }
   1.378 -
   1.379 -  static int ek_adapter_opt_spread_count(EntryKind ek) {
   1.380 -    assert(ek >= _adapter_opt_spread_FIRST && ek <= _adapter_opt_spread_LAST, "");
   1.381 -    switch (ek) {
   1.382 -    case _adapter_opt_spread_0     : return  0;
   1.383 -    case _adapter_opt_spread_1_ref : return  1;
   1.384 -    case _adapter_opt_spread_2_ref : return  2;
   1.385 -    case _adapter_opt_spread_3_ref : return  3;
   1.386 -    case _adapter_opt_spread_4_ref : return  4;
   1.387 -    case _adapter_opt_spread_5_ref : return  5;
   1.388 -    default                        : return -1;  // sentinel value for "variable"
   1.389 -    }
   1.390 -  }
   1.391 -
   1.392 -  static BasicType ek_adapter_opt_spread_type(EntryKind ek) {
   1.393 -    assert(ek >= _adapter_opt_spread_FIRST && ek <= _adapter_opt_spread_LAST, "");
   1.394 -    switch (ek) {
   1.395 -    // (there is no _adapter_opt_spread_boolean; we use byte)
   1.396 -    case _adapter_opt_spread_byte   : return T_BYTE;
   1.397 -    case _adapter_opt_spread_char   : return T_CHAR;
   1.398 -    case _adapter_opt_spread_short  : return T_SHORT;
   1.399 -    case _adapter_opt_spread_int    : return T_INT;
   1.400 -    case _adapter_opt_spread_long   : return T_LONG;
   1.401 -    case _adapter_opt_spread_float  : return T_FLOAT;
   1.402 -    case _adapter_opt_spread_double : return T_DOUBLE;
   1.403 -    default                         : return T_OBJECT;
   1.404 -    }
   1.405 -  }
   1.406 -
   1.407 -  static methodOop raise_exception_method() {
   1.408 -    oop rem = JNIHandles::resolve(_raise_exception_method);
   1.409 -    assert(rem == NULL || rem->is_method(), "");
   1.410 -    return (methodOop) rem;
   1.411 -  }
   1.412 -  static void set_raise_exception_method(methodOop rem) {
   1.413 -    assert(_raise_exception_method == NULL, "");
   1.414 -    _raise_exception_method = JNIHandles::make_global(Handle(rem));
   1.415 -  }
   1.416 -  static methodOop resolve_raise_exception_method(TRAPS);
   1.417 -  // call raise_exception_method from C code:
   1.418 -  static void raise_exception(int code, oop actual, oop required, TRAPS);
   1.419 -
   1.420 -  static jint adapter_conversion(int conv_op, BasicType src, BasicType dest,
   1.421 -                                 int stack_move = 0, int vminfo = 0) {
   1.422 -    assert(conv_op_valid(conv_op), "oob");
   1.423 -    jint conv = ((conv_op      << CONV_OP_SHIFT)
   1.424 -                 | (src        << CONV_SRC_TYPE_SHIFT)
   1.425 -                 | (dest       << CONV_DEST_TYPE_SHIFT)
   1.426 -                 | (stack_move << CONV_STACK_MOVE_SHIFT)
   1.427 -                 | (vminfo     << CONV_VMINFO_SHIFT)
   1.428 -                 );
   1.429 -    assert(adapter_conversion_op(conv) == conv_op, "decode conv_op");
   1.430 -    assert(adapter_conversion_src_type(conv) == src, "decode src");
   1.431 -    assert(adapter_conversion_dest_type(conv) == dest, "decode dest");
   1.432 -    assert(adapter_conversion_stack_move(conv) == stack_move, "decode stack_move");
   1.433 -    assert(adapter_conversion_vminfo(conv) == vminfo, "decode vminfo");
   1.434 -    return conv;
   1.435 -  }
   1.436 -  static int adapter_conversion_op(jint conv) {
   1.437 -    return ((conv >> CONV_OP_SHIFT) & 0xF);
   1.438 -  }
   1.439 -  static BasicType adapter_conversion_src_type(jint conv) {
   1.440 -    return (BasicType)((conv >> CONV_SRC_TYPE_SHIFT) & 0xF);
   1.441 -  }
   1.442 -  static BasicType adapter_conversion_dest_type(jint conv) {
   1.443 -    return (BasicType)((conv >> CONV_DEST_TYPE_SHIFT) & 0xF);
   1.444 -  }
   1.445 -  static int adapter_conversion_stack_move(jint conv) {
   1.446 -    return (conv >> CONV_STACK_MOVE_SHIFT);
   1.447 -  }
   1.448 -  static int adapter_conversion_vminfo(jint conv) {
   1.449 -    return (conv >> CONV_VMINFO_SHIFT) & CONV_VMINFO_MASK;
   1.450 -  }
   1.451 -
   1.452 -  // Bit mask of conversion_op values.  May vary by platform.
   1.453 -  static int adapter_conversion_ops_supported_mask();
   1.454 -
   1.455 -  static bool conv_op_supported(int conv_op) {
   1.456 -    assert(conv_op_valid(conv_op), "");
   1.457 -    return ((adapter_conversion_ops_supported_mask() & nth_bit(conv_op)) != 0);
   1.458 -  }
   1.459 -
   1.460 -  // Offset in words that the interpreter stack pointer moves when an argument is pushed.
   1.461 -  // The stack_move value must always be a multiple of this.
   1.462 -  static int stack_move_unit() {
   1.463 -    return frame::interpreter_frame_expression_stack_direction() * Interpreter::stackElementWords;
   1.464 -  }
   1.465 -
   1.466 -  // Adapter frame traversal.  (Implementation-specific.)
   1.467 -  static frame ricochet_frame_sender(const frame& fr, RegisterMap* reg_map);
   1.468 -  static void ricochet_frame_oops_do(const frame& fr, OopClosure* blk, const RegisterMap* reg_map);
   1.469 -
   1.470 -  enum { CONV_VMINFO_SIGN_FLAG = 0x80 };
   1.471 -  // Shift values for prim-to-prim conversions.
   1.472 -  static int adapter_prim_to_prim_subword_vminfo(BasicType dest) {
   1.473 -    if (dest == T_BOOLEAN) return (BitsPerInt - 1);  // boolean is 1 bit
   1.474 -    if (dest == T_CHAR)    return (BitsPerInt - BitsPerShort);
   1.475 -    if (dest == T_BYTE)    return (BitsPerInt - BitsPerByte ) | CONV_VMINFO_SIGN_FLAG;
   1.476 -    if (dest == T_SHORT)   return (BitsPerInt - BitsPerShort) | CONV_VMINFO_SIGN_FLAG;
   1.477 -    return 0;                   // case T_INT
   1.478 -  }
   1.479 -  // Shift values for unboxing a primitive.
   1.480 -  static int adapter_unbox_subword_vminfo(BasicType dest) {
   1.481 -    if (dest == T_BOOLEAN) return (BitsPerInt - BitsPerByte );  // implemented as 1 byte
   1.482 -    if (dest == T_CHAR)    return (BitsPerInt - BitsPerShort);
   1.483 -    if (dest == T_BYTE)    return (BitsPerInt - BitsPerByte ) | CONV_VMINFO_SIGN_FLAG;
   1.484 -    if (dest == T_SHORT)   return (BitsPerInt - BitsPerShort) | CONV_VMINFO_SIGN_FLAG;
   1.485 -    return 0;                   // case T_INT
   1.486 -  }
   1.487 -  // Here is the transformation the i2i adapter must perform:
   1.488 -  static int truncate_subword_from_vminfo(jint value, int vminfo) {
   1.489 -    int shift = vminfo & ~CONV_VMINFO_SIGN_FLAG;
   1.490 -    jint tem = value << shift;
   1.491 -    if ((vminfo & CONV_VMINFO_SIGN_FLAG) != 0) {
   1.492 -      return (jint)tem >> shift;
   1.493 -    } else {
   1.494 -      return (juint)tem >> shift;
   1.495 -    }
   1.496 -  }
   1.497 -
   1.498 -  static inline address from_compiled_entry(EntryKind ek);
   1.499 -  static inline address from_interpreted_entry(EntryKind ek);
   1.500 -
   1.501 -  // helpers for decode_method.
   1.502 -  static methodOop    decode_methodOop(methodOop m, int& decode_flags_result);
   1.503 -  static methodHandle decode_vmtarget(oop vmtarget, int vmindex, oop mtype, KlassHandle& receiver_limit_result, int& decode_flags_result);
   1.504 -  static methodHandle decode_MemberName(oop mname, KlassHandle& receiver_limit_result, int& decode_flags_result);
   1.505 -  static methodHandle decode_MethodHandle(oop mh, KlassHandle& receiver_limit_result, int& decode_flags_result);
   1.506 -  static methodHandle decode_DirectMethodHandle(oop mh, KlassHandle& receiver_limit_result, int& decode_flags_result);
   1.507 -  static methodHandle decode_BoundMethodHandle(oop mh, KlassHandle& receiver_limit_result, int& decode_flags_result);
   1.508 -  static methodHandle decode_AdapterMethodHandle(oop mh, KlassHandle& receiver_limit_result, int& decode_flags_result);
   1.509 -
   1.510 -  // Find out how many stack slots an mh pushes or pops.
   1.511 -  // The result is *not* reported as a multiple of stack_move_unit();
   1.512 -  // It is a signed net number of pushes (a difference in vmslots).
   1.513 -  // To compare with a stack_move value, first multiply by stack_move_unit().
   1.514 -  static int decode_MethodHandle_stack_pushes(oop mh);
   1.515 -
   1.516   public:
   1.517    // working with member names
   1.518 -  static void resolve_MemberName(Handle mname, TRAPS); // compute vmtarget/vmindex from name/type
   1.519 +  static Handle resolve_MemberName(Handle mname, TRAPS); // compute vmtarget/vmindex from name/type
   1.520    static void expand_MemberName(Handle mname, int suppress, TRAPS);  // expand defc/name/type if missing
   1.521    static Handle new_MemberName(TRAPS);  // must be followed by init_MemberName
   1.522 -  static void init_MemberName(oop mname_oop, oop target); // compute vmtarget/vmindex from target
   1.523 -  static void init_MemberName(oop mname_oop, methodOop m, bool do_dispatch = true);
   1.524 -  static void init_MemberName(oop mname_oop, klassOop field_holder, AccessFlags mods, int offset);
   1.525 +  static oop init_MemberName(oop mname_oop, oop target_oop); // compute vmtarget/vmindex from target
   1.526 +  static oop init_method_MemberName(oop mname_oop, methodOop m, bool do_dispatch,
   1.527 +                                    klassOop receiver_limit);
   1.528 +  static oop init_field_MemberName(oop mname_oop, klassOop field_holder,
   1.529 +                                   AccessFlags mods, oop type, oop name,
   1.530 +                                   intptr_t offset, bool is_setter = false);
   1.531 +  static Handle init_method_MemberName(oop mname_oop, CallInfo& info, TRAPS);
   1.532 +  static Handle init_field_MemberName(oop mname_oop, FieldAccessInfo& info, TRAPS);
   1.533 +  static int method_ref_kind(methodOop m, bool do_dispatch_if_possible = true);
   1.534    static int find_MemberNames(klassOop k, Symbol* name, Symbol* sig,
   1.535                                int mflags, klassOop caller,
   1.536                                int skip, objArrayOop results);
   1.537 @@ -559,169 +72,113 @@
   1.538    // Generate MethodHandles adapters.
   1.539    static void generate_adapters();
   1.540  
   1.541 -  // Called from InterpreterGenerator and MethodHandlesAdapterGenerator.
   1.542 -  static address generate_method_handle_interpreter_entry(MacroAssembler* _masm);
   1.543 -  static void generate_method_handle_stub(MacroAssembler* _masm, EntryKind ek);
   1.544 +  // Called from MethodHandlesAdapterGenerator.
   1.545 +  static address generate_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid);
   1.546 +  static void generate_method_handle_dispatch(MacroAssembler* _masm,
   1.547 +                                              vmIntrinsics::ID iid,
   1.548 +                                              Register receiver_reg,
   1.549 +                                              Register member_reg,
   1.550 +                                              bool for_compiler_entry);
   1.551  
   1.552 -  // argument list parsing
   1.553 -  static int argument_slot(oop method_type, int arg);
   1.554 -  static int argument_slot_count(oop method_type) { return argument_slot(method_type, -1); }
   1.555 -  static int argument_slot_to_argnum(oop method_type, int argslot);
   1.556 +  // Queries
   1.557 +  static bool is_signature_polymorphic(vmIntrinsics::ID iid) {
   1.558 +    return (iid >= vmIntrinsics::FIRST_MH_SIG_POLY &&
   1.559 +            iid <= vmIntrinsics::LAST_MH_SIG_POLY);
   1.560 +  }
   1.561  
   1.562 -  // Runtime support
   1.563 -  enum {                        // bit-encoded flags from decode_method or decode_vmref
   1.564 -    _dmf_has_receiver   = 0x01, // target method has leading reference argument
   1.565 -    _dmf_does_dispatch  = 0x02, // method handle performs virtual or interface dispatch
   1.566 -    _dmf_from_interface = 0x04, // peforms interface dispatch
   1.567 -    _DMF_DIRECT_MASK    = (_dmf_from_interface*2 - _dmf_has_receiver),
   1.568 -    _dmf_binds_method   = 0x08,
   1.569 -    _dmf_binds_argument = 0x10,
   1.570 -    _DMF_BOUND_MASK     = (_dmf_binds_argument*2 - _dmf_binds_method),
   1.571 -    _dmf_adapter_lsb    = 0x20,
   1.572 -    _DMF_ADAPTER_MASK   = (_dmf_adapter_lsb << CONV_OP_LIMIT) - _dmf_adapter_lsb
   1.573 -  };
   1.574 -  static methodHandle decode_method(oop x, KlassHandle& receiver_limit_result, int& decode_flags_result);
   1.575 +  static bool is_signature_polymorphic_intrinsic(vmIntrinsics::ID iid) {
   1.576 +    assert(is_signature_polymorphic(iid), "");
   1.577 +    // Most sig-poly methods are intrinsics which do not require an
   1.578 +    // appeal to Java for adapter code.
   1.579 +    return (iid != vmIntrinsics::_invokeGeneric);
   1.580 +  }
   1.581 +
   1.582 +  static bool is_signature_polymorphic_static(vmIntrinsics::ID iid) {
   1.583 +    assert(is_signature_polymorphic(iid), "");
   1.584 +    return (iid >= vmIntrinsics::FIRST_MH_STATIC &&
   1.585 +            iid <= vmIntrinsics::LAST_MH_SIG_POLY);
   1.586 +  }
   1.587 +
   1.588 +  static bool has_member_arg(vmIntrinsics::ID iid) {
   1.589 +    assert(is_signature_polymorphic(iid), "");
   1.590 +    return (iid >= vmIntrinsics::_linkToVirtual &&
   1.591 +            iid <= vmIntrinsics::_linkToInterface);
   1.592 +  }
   1.593 +  static bool has_member_arg(Symbol* klass, Symbol* name) {
   1.594 +    if ((klass == vmSymbols::java_lang_invoke_MethodHandle()) &&
   1.595 +        is_signature_polymorphic_name(name)) {
   1.596 +      vmIntrinsics::ID iid = signature_polymorphic_name_id(name);
   1.597 +      return has_member_arg(iid);
   1.598 +    }
   1.599 +    return false;
   1.600 +  }
   1.601 +
   1.602 +  static Symbol* signature_polymorphic_intrinsic_name(vmIntrinsics::ID iid);
   1.603 +  static int signature_polymorphic_intrinsic_ref_kind(vmIntrinsics::ID iid);
   1.604 +
   1.605 +  static vmIntrinsics::ID signature_polymorphic_name_id(klassOop klass, Symbol* name);
   1.606 +  static vmIntrinsics::ID signature_polymorphic_name_id(Symbol* name);
   1.607 +  static bool is_signature_polymorphic_name(Symbol* name) {
   1.608 +    return signature_polymorphic_name_id(name) != vmIntrinsics::_none;
   1.609 +  }
   1.610 +  static bool is_method_handle_invoke_name(klassOop klass, Symbol* name);
   1.611 +  static bool is_signature_polymorphic_name(klassOop klass, Symbol* name) {
   1.612 +    return signature_polymorphic_name_id(klass, name) != vmIntrinsics::_none;
   1.613 +  }
   1.614 +
   1.615    enum {
   1.616      // format of query to getConstant:
   1.617 -    GC_JVM_PUSH_LIMIT = 0,
   1.618 -    GC_JVM_STACK_MOVE_UNIT = 1,
   1.619 -    GC_CONV_OP_IMPLEMENTED_MASK = 2,
   1.620 -    GC_OP_ROT_ARGS_DOWN_LIMIT_BIAS = 3,
   1.621      GC_COUNT_GWT = 4,
   1.622 -
   1.623 -    // format of result from getTarget / encode_target:
   1.624 -    ETF_HANDLE_OR_METHOD_NAME = 0, // all available data (immediate MH or method)
   1.625 -    ETF_DIRECT_HANDLE         = 1, // ultimate method handle (will be a DMH, may be self)
   1.626 -    ETF_METHOD_NAME           = 2, // ultimate method as MemberName
   1.627 -    ETF_REFLECT_METHOD        = 3, // ultimate method as java.lang.reflect object (sans refClass)
   1.628 -    ETF_FORCE_DIRECT_HANDLE   = 64,
   1.629 -    ETF_COMPILE_DIRECT_HANDLE = 65,
   1.630 -
   1.631 -    // ad hoc constants
   1.632 -    OP_ROT_ARGS_DOWN_LIMIT_BIAS = -1
   1.633 +    GC_LAMBDA_SUPPORT = 5
   1.634    };
   1.635    static int get_named_constant(int which, Handle name_box, TRAPS);
   1.636 -  static oop encode_target(Handle mh, int format, TRAPS); // report vmtarget (to Java code)
   1.637 -  static bool class_cast_needed(klassOop src, klassOop dst);
   1.638  
   1.639 -  static instanceKlassHandle resolve_instance_klass(oop    java_mirror_oop, TRAPS);
   1.640 -  static instanceKlassHandle resolve_instance_klass(jclass java_mirror_jh,  TRAPS) {
   1.641 -    return resolve_instance_klass(JNIHandles::resolve(java_mirror_jh), THREAD);
   1.642 +public:
   1.643 +  static Symbol* lookup_signature(oop type_str, bool polymorphic, TRAPS);  // use TempNewSymbol
   1.644 +  static Symbol* lookup_basic_type_signature(Symbol* sig, bool keep_last_arg, TRAPS);  // use TempNewSymbol
   1.645 +  static Symbol* lookup_basic_type_signature(Symbol* sig, TRAPS) {
   1.646 +    return lookup_basic_type_signature(sig, false, THREAD);
   1.647 +  }
   1.648 +  static bool is_basic_type_signature(Symbol* sig);
   1.649 +
   1.650 +  static Symbol* lookup_method_type(Symbol* msig, Handle mtype, TRAPS);
   1.651 +
   1.652 +  static void print_as_method_type_on(outputStream* st, Symbol* sig) {
   1.653 +    print_as_basic_type_signature_on(st, sig, true, true);
   1.654 +  }
   1.655 +  static void print_as_basic_type_signature_on(outputStream* st, Symbol* sig, bool keep_arrays = false, bool keep_basic_names = false);
   1.656 +
   1.657 +  // decoding CONSTANT_MethodHandle constants
   1.658 +  enum { JVM_REF_MIN = JVM_REF_getField, JVM_REF_MAX = JVM_REF_invokeInterface };
   1.659 +  static bool ref_kind_is_valid(int ref_kind) {
   1.660 +    return (ref_kind >= JVM_REF_MIN && ref_kind <= JVM_REF_MAX);
   1.661 +  }
   1.662 +  static bool ref_kind_is_field(int ref_kind) {
   1.663 +    assert(ref_kind_is_valid(ref_kind), "");
   1.664 +    return (ref_kind <= JVM_REF_putStatic);
   1.665 +  }
   1.666 +  static bool ref_kind_is_getter(int ref_kind) {
   1.667 +    assert(ref_kind_is_valid(ref_kind), "");
   1.668 +    return (ref_kind <= JVM_REF_getStatic);
   1.669 +  }
   1.670 +  static bool ref_kind_is_setter(int ref_kind) {
   1.671 +    return ref_kind_is_field(ref_kind) && !ref_kind_is_getter(ref_kind);
   1.672 +  }
   1.673 +  static bool ref_kind_is_method(int ref_kind) {
   1.674 +    return !ref_kind_is_field(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial);
   1.675 +  }
   1.676 +  static bool ref_kind_has_receiver(int ref_kind) {
   1.677 +    assert(ref_kind_is_valid(ref_kind), "");
   1.678 +    return (ref_kind & 1) != 0;
   1.679 +  }
   1.680 +  static bool ref_kind_is_static(int ref_kind) {
   1.681 +    return !ref_kind_has_receiver(ref_kind) && (ref_kind != JVM_REF_newInvokeSpecial);
   1.682 +  }
   1.683 +  static bool ref_kind_does_dispatch(int ref_kind) {
   1.684 +    return (ref_kind == JVM_REF_invokeVirtual ||
   1.685 +            ref_kind == JVM_REF_invokeInterface);
   1.686    }
   1.687  
   1.688 - private:
   1.689 -  // These checkers operate on a pair of whole MethodTypes:
   1.690 -  static const char* check_method_type_change(oop src_mtype, int src_beg, int src_end,
   1.691 -                                              int insert_argnum, oop insert_type,
   1.692 -                                              int change_argnum, oop change_type,
   1.693 -                                              int delete_argnum,
   1.694 -                                              oop dst_mtype, int dst_beg, int dst_end,
   1.695 -                                              bool raw = false);
   1.696 -  static const char* check_method_type_insertion(oop src_mtype,
   1.697 -                                                 int insert_argnum, oop insert_type,
   1.698 -                                                 oop dst_mtype) {
   1.699 -    oop no_ref = NULL;
   1.700 -    return check_method_type_change(src_mtype, 0, -1,
   1.701 -                                    insert_argnum, insert_type,
   1.702 -                                    -1, no_ref, -1, dst_mtype, 0, -1);
   1.703 -  }
   1.704 -  static const char* check_method_type_conversion(oop src_mtype,
   1.705 -                                                  int change_argnum, oop change_type,
   1.706 -                                                  oop dst_mtype) {
   1.707 -    oop no_ref = NULL;
   1.708 -    return check_method_type_change(src_mtype, 0, -1, -1, no_ref,
   1.709 -                                    change_argnum, change_type,
   1.710 -                                    -1, dst_mtype, 0, -1);
   1.711 -  }
   1.712 -  static const char* check_method_type_passthrough(oop src_mtype, oop dst_mtype, bool raw) {
   1.713 -    oop no_ref = NULL;
   1.714 -    return check_method_type_change(src_mtype, 0, -1,
   1.715 -                                    -1, no_ref, -1, no_ref, -1,
   1.716 -                                    dst_mtype, 0, -1, raw);
   1.717 -  }
   1.718 -
   1.719 -  // These checkers operate on pairs of argument or return types:
   1.720 -  static const char* check_argument_type_change(BasicType src_type, klassOop src_klass,
   1.721 -                                                BasicType dst_type, klassOop dst_klass,
   1.722 -                                                int argnum, bool raw = false);
   1.723 -
   1.724 -  static const char* check_argument_type_change(oop src_type, oop dst_type,
   1.725 -                                                int argnum, bool raw = false) {
   1.726 -    klassOop src_klass = NULL, dst_klass = NULL;
   1.727 -    BasicType src_bt = java_lang_Class::as_BasicType(src_type, &src_klass);
   1.728 -    BasicType dst_bt = java_lang_Class::as_BasicType(dst_type, &dst_klass);
   1.729 -    return check_argument_type_change(src_bt, src_klass,
   1.730 -                                      dst_bt, dst_klass, argnum, raw);
   1.731 -  }
   1.732 -
   1.733 -  static const char* check_return_type_change(oop src_type, oop dst_type, bool raw = false) {
   1.734 -    return check_argument_type_change(src_type, dst_type, -1, raw);
   1.735 -  }
   1.736 -
   1.737 -  static const char* check_return_type_change(BasicType src_type, klassOop src_klass,
   1.738 -                                              BasicType dst_type, klassOop dst_klass) {
   1.739 -    return check_argument_type_change(src_type, src_klass, dst_type, dst_klass, -1);
   1.740 -  }
   1.741 -
   1.742 -  static const char* check_method_receiver(methodOop m, klassOop passed_recv_type);
   1.743 -
   1.744 -  // These verifiers can block, and will throw an error if the checking fails:
   1.745 -  static void verify_vmslots(Handle mh, TRAPS);
   1.746 -  static void verify_vmargslot(Handle mh, int argnum, int argslot, TRAPS);
   1.747 -
   1.748 -  static void verify_method_type(methodHandle m, Handle mtype,
   1.749 -                                 bool has_bound_oop,
   1.750 -                                 KlassHandle bound_oop_type,
   1.751 -                                 TRAPS);
   1.752 -
   1.753 -  static void verify_method_signature(methodHandle m, Handle mtype,
   1.754 -                                      int first_ptype_pos,
   1.755 -                                      KlassHandle insert_ptype, TRAPS);
   1.756 -
   1.757 -  static void verify_DirectMethodHandle(Handle mh, methodHandle m, TRAPS);
   1.758 -  static void verify_BoundMethodHandle(Handle mh, Handle target, int argnum,
   1.759 -                                       bool direct_to_method, TRAPS);
   1.760 -  static void verify_BoundMethodHandle_with_receiver(Handle mh, methodHandle m, TRAPS);
   1.761 -  static void verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS);
   1.762 -
   1.763 - public:
   1.764 -
   1.765 -  // Fill in the fields of a DirectMethodHandle mh.  (MH.type must be pre-filled.)
   1.766 -  static void init_DirectMethodHandle(Handle mh, methodHandle method, bool do_dispatch, TRAPS);
   1.767 -
   1.768 -  // Fill in the fields of a BoundMethodHandle mh.  (MH.type, BMH.argument must be pre-filled.)
   1.769 -  static void init_BoundMethodHandle(Handle mh, Handle target, int argnum, TRAPS);
   1.770 -  static void init_BoundMethodHandle_with_receiver(Handle mh,
   1.771 -                                                   methodHandle original_m,
   1.772 -                                                   KlassHandle receiver_limit,
   1.773 -                                                   int decode_flags,
   1.774 -                                                   TRAPS);
   1.775 -
   1.776 -  // Fill in the fields of an AdapterMethodHandle mh.  (MH.type must be pre-filled.)
   1.777 -  static void init_AdapterMethodHandle(Handle mh, Handle target, int argnum, TRAPS);
   1.778 -  static void ensure_vmlayout_field(Handle target, TRAPS);
   1.779 -
   1.780 -#ifdef ASSERT
   1.781 -  static bool spot_check_entry_names();
   1.782 -#endif
   1.783 -
   1.784 - private:
   1.785 -  static methodHandle dispatch_decoded_method(methodHandle m,
   1.786 -                                              KlassHandle receiver_limit,
   1.787 -                                              int decode_flags,
   1.788 -                                              KlassHandle receiver_klass,
   1.789 -                                              TRAPS);
   1.790 -
   1.791 -public:
   1.792 -  static bool is_float_fixed_reinterpretation_cast(BasicType src, BasicType dst);
   1.793 -  static bool same_basic_type_for_arguments(BasicType src, BasicType dst,
   1.794 -                                            bool raw = false,
   1.795 -                                            bool for_return = false);
   1.796 -  static bool same_basic_type_for_returns(BasicType src, BasicType dst, bool raw = false) {
   1.797 -    return same_basic_type_for_arguments(src, dst, raw, true);
   1.798 -  }
   1.799 -
   1.800 -  static Symbol* convert_to_signature(oop type_str, bool polymorphic, TRAPS);
   1.801  
   1.802  #ifdef TARGET_ARCH_x86
   1.803  # include "methodHandles_x86.hpp"
   1.804 @@ -738,63 +195,11 @@
   1.805  #ifdef TARGET_ARCH_ppc
   1.806  # include "methodHandles_ppc.hpp"
   1.807  #endif
   1.808 +
   1.809 +
   1.810  };
   1.811  
   1.812  
   1.813 -// Access methods for the "entry" field of a java.lang.invoke.MethodHandle.
   1.814 -// The field is primarily a jump target for compiled calls.
   1.815 -// However, we squirrel away some nice pointers for other uses,
   1.816 -// just before the jump target.
   1.817 -// Aspects of a method handle entry:
   1.818 -//  - from_compiled_entry - stub used when compiled code calls the MH
   1.819 -//  - from_interpreted_entry - stub used when the interpreter calls the MH
   1.820 -//  - type_checking_entry - stub for runtime casting between MHForm siblings (NYI)
   1.821 -class MethodHandleEntry {
   1.822 - public:
   1.823 -  class Data {
   1.824 -    friend class MethodHandleEntry;
   1.825 -    size_t              _total_size; // size including Data and code stub
   1.826 -    MethodHandleEntry*  _type_checking_entry;
   1.827 -    address             _from_interpreted_entry;
   1.828 -    MethodHandleEntry* method_entry() { return (MethodHandleEntry*)(this + 1); }
   1.829 -  };
   1.830 -
   1.831 -  Data*     data()                              { return (Data*)this - 1; }
   1.832 -
   1.833 -  address   start_address()                     { return (address) data(); }
   1.834 -  address   end_address()                       { return start_address() + data()->_total_size; }
   1.835 -
   1.836 -  address   from_compiled_entry()               { return (address) this; }
   1.837 -
   1.838 -  address   from_interpreted_entry()            { return data()->_from_interpreted_entry; }
   1.839 -  void  set_from_interpreted_entry(address e)   { data()->_from_interpreted_entry = e; }
   1.840 -
   1.841 -  MethodHandleEntry* type_checking_entry()           { return data()->_type_checking_entry; }
   1.842 -  void set_type_checking_entry(MethodHandleEntry* e) { data()->_type_checking_entry = e; }
   1.843 -
   1.844 -  void set_end_address(address end_addr) {
   1.845 -    size_t total_size = end_addr - start_address();
   1.846 -    assert(total_size > 0 && total_size < 0x1000, "reasonable end address");
   1.847 -    data()->_total_size = total_size;
   1.848 -  }
   1.849 -
   1.850 -  // Compiler support:
   1.851 -  static int from_interpreted_entry_offset_in_bytes() {
   1.852 -    return (int)( offset_of(Data, _from_interpreted_entry) - sizeof(Data) );
   1.853 -  }
   1.854 -  static int type_checking_entry_offset_in_bytes() {
   1.855 -    return (int)( offset_of(Data, _from_interpreted_entry) - sizeof(Data) );
   1.856 -  }
   1.857 -
   1.858 -  static address            start_compiled_entry(MacroAssembler* _masm,
   1.859 -                                                 address interpreted_entry = NULL);
   1.860 -  static MethodHandleEntry* finish_compiled_entry(MacroAssembler* masm, address start_addr);
   1.861 -};
   1.862 -
   1.863 -address MethodHandles::from_compiled_entry(EntryKind ek) { return entry(ek)->from_compiled_entry(); }
   1.864 -address MethodHandles::from_interpreted_entry(EntryKind ek) { return entry(ek)->from_interpreted_entry(); }
   1.865 -
   1.866 -
   1.867  //------------------------------------------------------------------------------
   1.868  // MethodHandlesAdapterGenerator
   1.869  //

mercurial