src/share/vm/prims/methodHandles.hpp

changeset 2895
167b70ff3abc
parent 2806
2a23b1b5a0a8
child 2903
fabcf26ee72f
     1.1 --- a/src/share/vm/prims/methodHandles.hpp	Fri May 06 12:12:29 2011 -0700
     1.2 +++ b/src/share/vm/prims/methodHandles.hpp	Fri May 06 16:33:13 2011 -0700
     1.3 @@ -66,8 +66,8 @@
     1.4      _adapter_drop_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS,
     1.5      _adapter_collect_args  = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS,
     1.6      _adapter_spread_args   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS,
     1.7 -    _adapter_flyby         = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_FLYBY,
     1.8 -    _adapter_ricochet      = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RICOCHET,
     1.9 +    _adapter_fold_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_FOLD_ARGS,
    1.10 +    _adapter_unused_13     = _adapter_mh_first + 13,  //hole in the CONV_OP enumeration
    1.11      _adapter_mh_last       = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT - 1,
    1.12  
    1.13      // Optimized adapter types
    1.14 @@ -93,10 +93,99 @@
    1.15      _adapter_opt_unboxi,
    1.16      _adapter_opt_unboxl,
    1.17  
    1.18 -    // spreading (array length cases 0, 1, >=2)
    1.19 -    _adapter_opt_spread_0,
    1.20 -    _adapter_opt_spread_1,
    1.21 -    _adapter_opt_spread_more,
    1.22 +    // %% Maybe tame the following with a VM_SYMBOLS_DO type macro?
    1.23 +
    1.24 +    // how a blocking adapter returns (platform-dependent)
    1.25 +    _adapter_opt_return_ref,
    1.26 +    _adapter_opt_return_int,
    1.27 +    _adapter_opt_return_long,
    1.28 +    _adapter_opt_return_float,
    1.29 +    _adapter_opt_return_double,
    1.30 +    _adapter_opt_return_void,
    1.31 +    _adapter_opt_return_S0_ref,  // return ref to S=0 (last slot)
    1.32 +    _adapter_opt_return_S1_ref,  // return ref to S=1 (2nd-to-last slot)
    1.33 +    _adapter_opt_return_S2_ref,
    1.34 +    _adapter_opt_return_S3_ref,
    1.35 +    _adapter_opt_return_S4_ref,
    1.36 +    _adapter_opt_return_S5_ref,
    1.37 +    _adapter_opt_return_any,     // dynamically select r/i/l/f/d
    1.38 +    _adapter_opt_return_FIRST = _adapter_opt_return_ref,
    1.39 +    _adapter_opt_return_LAST  = _adapter_opt_return_any,
    1.40 +
    1.41 +    // spreading (array length cases 0, 1, ...)
    1.42 +    _adapter_opt_spread_0,       // spread empty array to N=0 arguments
    1.43 +    _adapter_opt_spread_1_ref,   // spread Object[] to N=1 argument
    1.44 +    _adapter_opt_spread_2_ref,   // spread Object[] to N=2 arguments
    1.45 +    _adapter_opt_spread_3_ref,   // spread Object[] to N=3 arguments
    1.46 +    _adapter_opt_spread_4_ref,   // spread Object[] to N=4 arguments
    1.47 +    _adapter_opt_spread_5_ref,   // spread Object[] to N=5 arguments
    1.48 +    _adapter_opt_spread_ref,     // spread Object[] to N arguments
    1.49 +    _adapter_opt_spread_byte,    // spread byte[] or boolean[] to N arguments
    1.50 +    _adapter_opt_spread_char,    // spread char[], etc., to N arguments
    1.51 +    _adapter_opt_spread_short,   // spread short[], etc., to N arguments
    1.52 +    _adapter_opt_spread_int,     // spread int[], short[], etc., to N arguments
    1.53 +    _adapter_opt_spread_long,    // spread long[] to N arguments
    1.54 +    _adapter_opt_spread_float,   // spread float[] to N arguments
    1.55 +    _adapter_opt_spread_double,  // spread double[] to N arguments
    1.56 +    _adapter_opt_spread_FIRST = _adapter_opt_spread_0,
    1.57 +    _adapter_opt_spread_LAST  = _adapter_opt_spread_double,
    1.58 +
    1.59 +    // blocking filter/collect conversions
    1.60 +    // These collect N arguments and replace them (at slot S) by a return value
    1.61 +    // which is passed to the final target, along with the unaffected arguments.
    1.62 +    // collect_{N}_{T} collects N arguments at any position into a T value
    1.63 +    // collect_{N}_S{S}_{T} collects N arguments at slot S into a T value
    1.64 +    // collect_{T} collects any number of arguments at any position
    1.65 +    // filter_S{S}_{T} is the same as collect_1_S{S}_{T} (a unary collection)
    1.66 +    // (collect_2 is also usable as a filter, with long or double arguments)
    1.67 +    _adapter_opt_collect_ref,    // combine N arguments, replace with a reference
    1.68 +    _adapter_opt_collect_int,    // combine N arguments, replace with an int, short, etc.
    1.69 +    _adapter_opt_collect_long,   // combine N arguments, replace with a long
    1.70 +    _adapter_opt_collect_float,  // combine N arguments, replace with a float
    1.71 +    _adapter_opt_collect_double, // combine N arguments, replace with a double
    1.72 +    _adapter_opt_collect_void,   // combine N arguments, replace with nothing
    1.73 +    // if there is a small fixed number to push, do so without a loop:
    1.74 +    _adapter_opt_collect_0_ref,  // collect N=0 arguments, insert a reference
    1.75 +    _adapter_opt_collect_1_ref,  // collect N=1 argument, replace with a reference
    1.76 +    _adapter_opt_collect_2_ref,  // combine N=2 arguments, replace with a reference
    1.77 +    _adapter_opt_collect_3_ref,  // combine N=3 arguments, replace with a reference
    1.78 +    _adapter_opt_collect_4_ref,  // combine N=4 arguments, replace with a reference
    1.79 +    _adapter_opt_collect_5_ref,  // combine N=5 arguments, replace with a reference
    1.80 +    // filters are an important special case because they never move arguments:
    1.81 +    _adapter_opt_filter_S0_ref,  // filter N=1 argument at S=0, replace with a reference
    1.82 +    _adapter_opt_filter_S1_ref,  // filter N=1 argument at S=1, replace with a reference
    1.83 +    _adapter_opt_filter_S2_ref,  // filter N=1 argument at S=2, replace with a reference
    1.84 +    _adapter_opt_filter_S3_ref,  // filter N=1 argument at S=3, replace with a reference
    1.85 +    _adapter_opt_filter_S4_ref,  // filter N=1 argument at S=4, replace with a reference
    1.86 +    _adapter_opt_filter_S5_ref,  // filter N=1 argument at S=5, replace with a reference
    1.87 +    // these move arguments, but they are important for boxing
    1.88 +    _adapter_opt_collect_2_S0_ref,  // combine last N=2 arguments, replace with a reference
    1.89 +    _adapter_opt_collect_2_S1_ref,  // combine N=2 arguments at S=1, replace with a reference
    1.90 +    _adapter_opt_collect_2_S2_ref,  // combine N=2 arguments at S=2, replace with a reference
    1.91 +    _adapter_opt_collect_2_S3_ref,  // combine N=2 arguments at S=3, replace with a reference
    1.92 +    _adapter_opt_collect_2_S4_ref,  // combine N=2 arguments at S=4, replace with a reference
    1.93 +    _adapter_opt_collect_2_S5_ref,  // combine N=2 arguments at S=5, replace with a reference
    1.94 +    _adapter_opt_collect_FIRST = _adapter_opt_collect_ref,
    1.95 +    _adapter_opt_collect_LAST  = _adapter_opt_collect_2_S5_ref,
    1.96 +
    1.97 +    // blocking folding conversions
    1.98 +    // these are like collects, but retain all the N arguments for the final target
    1.99 +    //_adapter_opt_fold_0_ref,   // same as _adapter_opt_collect_0_ref
   1.100 +    // fold_{N}_{T} processes N arguments at any position into a T value, which it inserts
   1.101 +    // fold_{T} processes any number of arguments at any position
   1.102 +    _adapter_opt_fold_ref,       // process N arguments, prepend a reference
   1.103 +    _adapter_opt_fold_int,       // process N arguments, prepend an int, short, etc.
   1.104 +    _adapter_opt_fold_long,      // process N arguments, prepend a long
   1.105 +    _adapter_opt_fold_float,     // process N arguments, prepend a float
   1.106 +    _adapter_opt_fold_double,    // process N arguments, prepend a double
   1.107 +    _adapter_opt_fold_void,      // process N arguments, but leave the list unchanged
   1.108 +    _adapter_opt_fold_1_ref,     // process N=1 argument, prepend a reference
   1.109 +    _adapter_opt_fold_2_ref,     // process N=2 arguments, prepend a reference
   1.110 +    _adapter_opt_fold_3_ref,     // process N=3 arguments, prepend a reference
   1.111 +    _adapter_opt_fold_4_ref,     // process N=4 arguments, prepend a reference
   1.112 +    _adapter_opt_fold_5_ref,     // process N=5 arguments, prepend a reference
   1.113 +    _adapter_opt_fold_FIRST = _adapter_opt_fold_ref,
   1.114 +    _adapter_opt_fold_LAST  = _adapter_opt_fold_5_ref,
   1.115  
   1.116      _EK_LIMIT,
   1.117      _EK_FIRST = 0
   1.118 @@ -110,6 +199,7 @@
   1.119    enum {  // import java_lang_invoke_AdapterMethodHandle::CONV_OP_*
   1.120      CONV_OP_LIMIT         = java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT,
   1.121      CONV_OP_MASK          = java_lang_invoke_AdapterMethodHandle::CONV_OP_MASK,
   1.122 +    CONV_TYPE_MASK        = java_lang_invoke_AdapterMethodHandle::CONV_TYPE_MASK,
   1.123      CONV_VMINFO_MASK      = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_MASK,
   1.124      CONV_VMINFO_SHIFT     = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_SHIFT,
   1.125      CONV_OP_SHIFT         = java_lang_invoke_AdapterMethodHandle::CONV_OP_SHIFT,
   1.126 @@ -123,6 +213,7 @@
   1.127    static MethodHandleEntry* _entries[_EK_LIMIT];
   1.128    static const char*        _entry_names[_EK_LIMIT+1];
   1.129    static jobject            _raise_exception_method;
   1.130 +  static address            _adapter_return_handlers[CONV_TYPE_MASK+1];
   1.131  
   1.132    // Adapters.
   1.133    static MethodHandlesAdapterBlob* _adapter_code;
   1.134 @@ -147,39 +238,195 @@
   1.135    }
   1.136  
   1.137    // Some adapter helper functions.
   1.138 -  static void get_ek_bound_mh_info(EntryKind ek, BasicType& arg_type, int& arg_mask, int& arg_slots) {
   1.139 +  static EntryKind ek_original_kind(EntryKind ek) {
   1.140 +    if (ek <= _adapter_mh_last)  return ek;
   1.141      switch (ek) {
   1.142 -    case _bound_int_mh        : // fall-thru
   1.143 -    case _bound_int_direct_mh : arg_type = T_INT;    arg_mask = _INSERT_INT_MASK;  break;
   1.144 -    case _bound_long_mh       : // fall-thru
   1.145 -    case _bound_long_direct_mh: arg_type = T_LONG;   arg_mask = _INSERT_LONG_MASK; break;
   1.146 -    case _bound_ref_mh        : // fall-thru
   1.147 -    case _bound_ref_direct_mh : arg_type = T_OBJECT; arg_mask = _INSERT_REF_MASK;  break;
   1.148 -    default: ShouldNotReachHere();
   1.149 +    case _adapter_opt_swap_1:
   1.150 +    case _adapter_opt_swap_2:
   1.151 +      return _adapter_swap_args;
   1.152 +    case _adapter_opt_rot_1_up:
   1.153 +    case _adapter_opt_rot_1_down:
   1.154 +    case _adapter_opt_rot_2_up:
   1.155 +    case _adapter_opt_rot_2_down:
   1.156 +      return _adapter_rot_args;
   1.157 +    case _adapter_opt_i2i:
   1.158 +    case _adapter_opt_l2i:
   1.159 +    case _adapter_opt_d2f:
   1.160 +    case _adapter_opt_i2l:
   1.161 +    case _adapter_opt_f2d:
   1.162 +      return _adapter_prim_to_prim;
   1.163 +    case _adapter_opt_unboxi:
   1.164 +    case _adapter_opt_unboxl:
   1.165 +      return _adapter_ref_to_prim;
   1.166      }
   1.167 -    arg_slots = type2size[arg_type];
   1.168 +    if (ek >= _adapter_opt_spread_FIRST && ek <= _adapter_opt_spread_LAST)
   1.169 +      return _adapter_spread_args;
   1.170 +    if (ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST)
   1.171 +      return _adapter_collect_args;
   1.172 +    if (ek >= _adapter_opt_fold_FIRST && ek <= _adapter_opt_fold_LAST)
   1.173 +      return _adapter_fold_args;
   1.174 +    if (ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST)
   1.175 +      return _adapter_opt_return_any;
   1.176 +    assert(false, "oob");
   1.177 +    return _EK_LIMIT;
   1.178    }
   1.179  
   1.180 -  static void get_ek_adapter_opt_swap_rot_info(EntryKind ek, int& swap_bytes, int& rotate) {
   1.181 -    int swap_slots = 0;
   1.182 +  static bool ek_supported(MethodHandles::EntryKind ek);
   1.183 +
   1.184 +  static BasicType ek_bound_mh_arg_type(EntryKind ek) {
   1.185      switch (ek) {
   1.186 -    case _adapter_opt_swap_1:     swap_slots = 1; rotate =  0; break;
   1.187 -    case _adapter_opt_swap_2:     swap_slots = 2; rotate =  0; break;
   1.188 -    case _adapter_opt_rot_1_up:   swap_slots = 1; rotate =  1; break;
   1.189 -    case _adapter_opt_rot_1_down: swap_slots = 1; rotate = -1; break;
   1.190 -    case _adapter_opt_rot_2_up:   swap_slots = 2; rotate =  1; break;
   1.191 -    case _adapter_opt_rot_2_down: swap_slots = 2; rotate = -1; break;
   1.192 -    default: ShouldNotReachHere();
   1.193 +    case _bound_int_mh         : // fall-thru
   1.194 +    case _bound_int_direct_mh  : return T_INT;
   1.195 +    case _bound_long_mh        : // fall-thru
   1.196 +    case _bound_long_direct_mh : return T_LONG;
   1.197 +    default                    : return T_OBJECT;
   1.198      }
   1.199 -    // Return the size of the stack slots to move in bytes.
   1.200 -    swap_bytes = swap_slots * Interpreter::stackElementSize;
   1.201    }
   1.202  
   1.203 -  static int get_ek_adapter_opt_spread_info(EntryKind ek) {
   1.204 +  static int ek_adapter_opt_swap_slots(EntryKind ek) {
   1.205      switch (ek) {
   1.206 -    case _adapter_opt_spread_0: return  0;
   1.207 -    case _adapter_opt_spread_1: return  1;
   1.208 -    default                   : return -1;
   1.209 +    case _adapter_opt_swap_1        : return  1;
   1.210 +    case _adapter_opt_swap_2        : return  2;
   1.211 +    case _adapter_opt_rot_1_up      : return  1;
   1.212 +    case _adapter_opt_rot_1_down    : return  1;
   1.213 +    case _adapter_opt_rot_2_up      : return  2;
   1.214 +    case _adapter_opt_rot_2_down    : return  2;
   1.215 +    default : ShouldNotReachHere();   return -1;
   1.216 +    }
   1.217 +  }
   1.218 +
   1.219 +  static int ek_adapter_opt_swap_mode(EntryKind ek) {
   1.220 +    switch (ek) {
   1.221 +    case _adapter_opt_swap_1       : return  0;
   1.222 +    case _adapter_opt_swap_2       : return  0;
   1.223 +    case _adapter_opt_rot_1_up     : return  1;
   1.224 +    case _adapter_opt_rot_1_down   : return -1;
   1.225 +    case _adapter_opt_rot_2_up     : return  1;
   1.226 +    case _adapter_opt_rot_2_down   : return -1;
   1.227 +    default : ShouldNotReachHere();  return  0;
   1.228 +    }
   1.229 +  }
   1.230 +
   1.231 +  static int ek_adapter_opt_collect_count(EntryKind ek) {
   1.232 +    assert(ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST ||
   1.233 +           ek >= _adapter_opt_fold_FIRST    && ek <= _adapter_opt_fold_LAST, "");
   1.234 +    switch (ek) {
   1.235 +    case _adapter_opt_collect_0_ref    : return  0;
   1.236 +    case _adapter_opt_filter_S0_ref    :
   1.237 +    case _adapter_opt_filter_S1_ref    :
   1.238 +    case _adapter_opt_filter_S2_ref    :
   1.239 +    case _adapter_opt_filter_S3_ref    :
   1.240 +    case _adapter_opt_filter_S4_ref    :
   1.241 +    case _adapter_opt_filter_S5_ref    :
   1.242 +    case _adapter_opt_fold_1_ref       :
   1.243 +    case _adapter_opt_collect_1_ref    : return  1;
   1.244 +    case _adapter_opt_collect_2_S0_ref :
   1.245 +    case _adapter_opt_collect_2_S1_ref :
   1.246 +    case _adapter_opt_collect_2_S2_ref :
   1.247 +    case _adapter_opt_collect_2_S3_ref :
   1.248 +    case _adapter_opt_collect_2_S4_ref :
   1.249 +    case _adapter_opt_collect_2_S5_ref :
   1.250 +    case _adapter_opt_fold_2_ref       :
   1.251 +    case _adapter_opt_collect_2_ref    : return  2;
   1.252 +    case _adapter_opt_fold_3_ref       :
   1.253 +    case _adapter_opt_collect_3_ref    : return  3;
   1.254 +    case _adapter_opt_fold_4_ref       :
   1.255 +    case _adapter_opt_collect_4_ref    : return  4;
   1.256 +    case _adapter_opt_fold_5_ref       :
   1.257 +    case _adapter_opt_collect_5_ref    : return  5;
   1.258 +    default                            : return -1;  // sentinel value for "variable"
   1.259 +    }
   1.260 +  }
   1.261 +
   1.262 +  static int ek_adapter_opt_collect_slot(EntryKind ek) {
   1.263 +    assert(ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST ||
   1.264 +           ek >= _adapter_opt_fold_FIRST    && ek <= _adapter_opt_fold_LAST, "");
   1.265 +    switch (ek) {
   1.266 +    case _adapter_opt_collect_2_S0_ref  :
   1.267 +    case _adapter_opt_filter_S0_ref     : return 0;
   1.268 +    case _adapter_opt_collect_2_S1_ref  :
   1.269 +    case _adapter_opt_filter_S1_ref     : return 1;
   1.270 +    case _adapter_opt_collect_2_S2_ref  :
   1.271 +    case _adapter_opt_filter_S2_ref     : return 2;
   1.272 +    case _adapter_opt_collect_2_S3_ref  :
   1.273 +    case _adapter_opt_filter_S3_ref     : return 3;
   1.274 +    case _adapter_opt_collect_2_S4_ref  :
   1.275 +    case _adapter_opt_filter_S4_ref     : return 4;
   1.276 +    case _adapter_opt_collect_2_S5_ref  :
   1.277 +    case _adapter_opt_filter_S5_ref     : return 5;
   1.278 +    default                             : return -1;  // sentinel value for "variable"
   1.279 +    }
   1.280 +  }
   1.281 +
   1.282 +  static BasicType ek_adapter_opt_collect_type(EntryKind ek) {
   1.283 +    assert(ek >= _adapter_opt_collect_FIRST && ek <= _adapter_opt_collect_LAST ||
   1.284 +           ek >= _adapter_opt_fold_FIRST    && ek <= _adapter_opt_fold_LAST, "");
   1.285 +    switch (ek) {
   1.286 +    case _adapter_opt_fold_int          :
   1.287 +    case _adapter_opt_collect_int       : return T_INT;
   1.288 +    case _adapter_opt_fold_long         :
   1.289 +    case _adapter_opt_collect_long      : return T_LONG;
   1.290 +    case _adapter_opt_fold_float        :
   1.291 +    case _adapter_opt_collect_float     : return T_FLOAT;
   1.292 +    case _adapter_opt_fold_double       :
   1.293 +    case _adapter_opt_collect_double    : return T_DOUBLE;
   1.294 +    case _adapter_opt_fold_void         :
   1.295 +    case _adapter_opt_collect_void      : return T_VOID;
   1.296 +    default                             : return T_OBJECT;
   1.297 +    }
   1.298 +  }
   1.299 +
   1.300 +  static int ek_adapter_opt_return_slot(EntryKind ek) {
   1.301 +    assert(ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST, "");
   1.302 +    switch (ek) {
   1.303 +    case _adapter_opt_return_S0_ref : return 0;
   1.304 +    case _adapter_opt_return_S1_ref : return 1;
   1.305 +    case _adapter_opt_return_S2_ref : return 2;
   1.306 +    case _adapter_opt_return_S3_ref : return 3;
   1.307 +    case _adapter_opt_return_S4_ref : return 4;
   1.308 +    case _adapter_opt_return_S5_ref : return 5;
   1.309 +    default                         : return -1;  // sentinel value for "variable"
   1.310 +    }
   1.311 +  }
   1.312 +
   1.313 +  static BasicType ek_adapter_opt_return_type(EntryKind ek) {
   1.314 +    assert(ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST, "");
   1.315 +    switch (ek) {
   1.316 +    case _adapter_opt_return_int    : return T_INT;
   1.317 +    case _adapter_opt_return_long   : return T_LONG;
   1.318 +    case _adapter_opt_return_float  : return T_FLOAT;
   1.319 +    case _adapter_opt_return_double : return T_DOUBLE;
   1.320 +    case _adapter_opt_return_void   : return T_VOID;
   1.321 +    case _adapter_opt_return_any    : return T_CONFLICT;  // sentinel value for "variable"
   1.322 +    default                         : return T_OBJECT;
   1.323 +    }
   1.324 +  }
   1.325 +
   1.326 +  static int ek_adapter_opt_spread_count(EntryKind ek) {
   1.327 +    assert(ek >= _adapter_opt_spread_FIRST && ek <= _adapter_opt_spread_LAST, "");
   1.328 +    switch (ek) {
   1.329 +    case _adapter_opt_spread_0     : return  0;
   1.330 +    case _adapter_opt_spread_1_ref : return  1;
   1.331 +    case _adapter_opt_spread_2_ref : return  2;
   1.332 +    case _adapter_opt_spread_3_ref : return  3;
   1.333 +    case _adapter_opt_spread_4_ref : return  4;
   1.334 +    case _adapter_opt_spread_5_ref : return  5;
   1.335 +    default                        : return -1;  // sentinel value for "variable"
   1.336 +    }
   1.337 +  }
   1.338 +
   1.339 +  static BasicType ek_adapter_opt_spread_type(EntryKind ek) {
   1.340 +    assert(ek >= _adapter_opt_spread_FIRST && ek <= _adapter_opt_spread_LAST, "");
   1.341 +    switch (ek) {
   1.342 +    // (there is no _adapter_opt_spread_boolean; we use byte)
   1.343 +    case _adapter_opt_spread_byte   : return T_BYTE;
   1.344 +    case _adapter_opt_spread_char   : return T_CHAR;
   1.345 +    case _adapter_opt_spread_short  : return T_SHORT;
   1.346 +    case _adapter_opt_spread_int    : return T_INT;
   1.347 +    case _adapter_opt_spread_long   : return T_LONG;
   1.348 +    case _adapter_opt_spread_float  : return T_FLOAT;
   1.349 +    case _adapter_opt_spread_double : return T_DOUBLE;
   1.350 +    default                         : return T_OBJECT;
   1.351      }
   1.352    }
   1.353  
   1.354 @@ -228,12 +475,21 @@
   1.355    // Bit mask of conversion_op values.  May vary by platform.
   1.356    static int adapter_conversion_ops_supported_mask();
   1.357  
   1.358 +  static bool conv_op_supported(int conv_op) {
   1.359 +    assert(conv_op_valid(conv_op), "");
   1.360 +    return ((adapter_conversion_ops_supported_mask() & nth_bit(conv_op)) != 0);
   1.361 +  }
   1.362 +
   1.363    // Offset in words that the interpreter stack pointer moves when an argument is pushed.
   1.364    // The stack_move value must always be a multiple of this.
   1.365    static int stack_move_unit() {
   1.366      return frame::interpreter_frame_expression_stack_direction() * Interpreter::stackElementWords;
   1.367    }
   1.368  
   1.369 +  // Adapter frame traversal.  (Implementation-specific.)
   1.370 +  static frame ricochet_frame_sender(const frame& fr, RegisterMap* reg_map);
   1.371 +  static void ricochet_frame_oops_do(const frame& fr, OopClosure* blk, const RegisterMap* reg_map);
   1.372 +
   1.373    enum { CONV_VMINFO_SIGN_FLAG = 0x80 };
   1.374    // Shift values for prim-to-prim conversions.
   1.375    static int adapter_prim_to_prim_subword_vminfo(BasicType dest) {
   1.376 @@ -429,6 +685,7 @@
   1.377  
   1.378    // Fill in the fields of an AdapterMethodHandle mh.  (MH.type must be pre-filled.)
   1.379    static void init_AdapterMethodHandle(Handle mh, Handle target, int argnum, TRAPS);
   1.380 +  static void ensure_vmlayout_field(Handle target, TRAPS);
   1.381  
   1.382  #ifdef ASSERT
   1.383    static bool spot_check_entry_names();
   1.384 @@ -448,12 +705,54 @@
   1.385      return same_basic_type_for_arguments(src, dst, raw, true);
   1.386    }
   1.387  
   1.388 -  enum {                        // arg_mask values
   1.389 +  static Symbol* convert_to_signature(oop type_str, bool polymorphic, TRAPS);
   1.390 +
   1.391 +#ifdef TARGET_ARCH_x86
   1.392 +# include "methodHandles_x86.hpp"
   1.393 +#endif
   1.394 +#ifdef TARGET_ARCH_sparc
   1.395 +#define TARGET_ARCH_NYI_6939861 1 //FIXME
   1.396 +//# include "methodHandles_sparc.hpp"
   1.397 +#endif
   1.398 +#ifdef TARGET_ARCH_zero
   1.399 +#define TARGET_ARCH_NYI_6939861 1 //FIXME
   1.400 +//# include "methodHandles_zero.hpp"
   1.401 +#endif
   1.402 +#ifdef TARGET_ARCH_arm
   1.403 +#define TARGET_ARCH_NYI_6939861 1 //FIXME
   1.404 +//# include "methodHandles_arm.hpp"
   1.405 +#endif
   1.406 +#ifdef TARGET_ARCH_ppc
   1.407 +#define TARGET_ARCH_NYI_6939861 1 //FIXME
   1.408 +//# include "methodHandles_ppc.hpp"
   1.409 +#endif
   1.410 +
   1.411 +#ifdef TARGET_ARCH_NYI_6939861
   1.412 +  // Here are some backward compatible declarations until the 6939861 ports are updated.
   1.413 +  #define _adapter_flyby    (_EK_LIMIT + 10)
   1.414 +  #define _adapter_ricochet (_EK_LIMIT + 11)
   1.415 +  #define _adapter_opt_spread_1    _adapter_opt_spread_1_ref
   1.416 +  #define _adapter_opt_spread_more _adapter_opt_spread_ref
   1.417 +  enum {
   1.418      _INSERT_NO_MASK   = -1,
   1.419      _INSERT_REF_MASK  = 0,
   1.420      _INSERT_INT_MASK  = 1,
   1.421      _INSERT_LONG_MASK = 3
   1.422    };
   1.423 +  static void get_ek_bound_mh_info(EntryKind ek, BasicType& arg_type, int& arg_mask, int& arg_slots) {
   1.424 +    arg_type = ek_bound_mh_arg_type(ek);
   1.425 +    arg_mask = 0;
   1.426 +    arg_slots = type2size[arg_type];;
   1.427 +  }
   1.428 +  static void get_ek_adapter_opt_swap_rot_info(EntryKind ek, int& swap_bytes, int& rotate) {
   1.429 +    int swap_slots = ek_adapter_opt_swap_slots(ek);
   1.430 +    rotate = ek_adapter_opt_swap_mode(ek);
   1.431 +    swap_bytes = swap_slots * Interpreter::stackElementSize;
   1.432 +  }
   1.433 +  static int get_ek_adapter_opt_spread_info(EntryKind ek) {
   1.434 +    return ek_adapter_opt_spread_count(ek);
   1.435 +  }
   1.436 +
   1.437    static void insert_arg_slots(MacroAssembler* _masm,
   1.438                                 RegisterOrConstant arg_slots,
   1.439                                 int arg_mask,
   1.440 @@ -466,8 +765,7 @@
   1.441                                 Register temp_reg, Register temp2_reg, Register temp3_reg = noreg);
   1.442  
   1.443    static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN;
   1.444 -
   1.445 -  static Symbol* convert_to_signature(oop type_str, bool polymorphic, TRAPS);
   1.446 +#endif //TARGET_ARCH_NYI_6939861
   1.447  };
   1.448  
   1.449  

mercurial