src/share/vm/prims/methodHandles.hpp

changeset 1474
987e948ebbc8
parent 1145
e5b0439ef4ae
child 1734
9eba43136cb5
     1.1 --- a/src/share/vm/prims/methodHandles.hpp	Fri Oct 16 16:14:12 2009 -0700
     1.2 +++ b/src/share/vm/prims/methodHandles.hpp	Sat Oct 17 19:51:05 2009 -0700
     1.3 @@ -32,8 +32,7 @@
     1.4    // See also  javaClasses for layouts java_dyn_Method{Handle,Type,Type::Form}.
     1.5   public:
     1.6    enum EntryKind {
     1.7 -    _check_mtype,               // how a caller calls a MH
     1.8 -    _wrong_method_type,         // what happens when there is a type mismatch
     1.9 +    _raise_exception,           // stub for error generation from other stubs
    1.10      _invokestatic_mh,           // how a MH emulates invokestatic
    1.11      _invokespecial_mh,          // ditto for the other invokes...
    1.12      _invokevirtual_mh,
    1.13 @@ -47,6 +46,7 @@
    1.14  
    1.15      _adapter_mh_first,     // adapter sequence goes here...
    1.16      _adapter_retype_only   = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY,
    1.17 +    _adapter_retype_raw    = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW,
    1.18      _adapter_check_cast    = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_CHECK_CAST,
    1.19      _adapter_prim_to_prim  = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM,
    1.20      _adapter_ref_to_prim   = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM,
    1.21 @@ -113,6 +113,8 @@
    1.22    static bool _enabled;
    1.23    static MethodHandleEntry* _entries[_EK_LIMIT];
    1.24    static const char*        _entry_names[_EK_LIMIT+1];
    1.25 +  static jobject            _raise_exception_method;
    1.26 +
    1.27    static bool ek_valid(EntryKind ek)            { return (uint)ek < (uint)_EK_LIMIT; }
    1.28    static bool conv_op_valid(int op)             { return (uint)op < (uint)CONV_OP_LIMIT; }
    1.29  
    1.30 @@ -131,6 +133,16 @@
    1.31      _entries[ek] = me;
    1.32    }
    1.33  
    1.34 +  static methodOop raise_exception_method() {
    1.35 +    oop rem = JNIHandles::resolve(_raise_exception_method);
    1.36 +    assert(rem == NULL || rem->is_method(), "");
    1.37 +    return (methodOop) rem;
    1.38 +  }
    1.39 +  static void set_raise_exception_method(methodOop rem) {
    1.40 +    assert(_raise_exception_method == NULL, "");
    1.41 +    _raise_exception_method = JNIHandles::make_global(Handle(rem));
    1.42 +  }
    1.43 +
    1.44    static jint adapter_conversion(int conv_op, BasicType src, BasicType dest,
    1.45                                   int stack_move = 0, int vminfo = 0) {
    1.46      assert(conv_op_valid(conv_op), "oob");
    1.47 @@ -243,7 +255,7 @@
    1.48    enum {
    1.49      // format of query to getConstant:
    1.50      GC_JVM_PUSH_LIMIT = 0,
    1.51 -    GC_JVM_STACK_MOVE_LIMIT = 1,
    1.52 +    GC_JVM_STACK_MOVE_UNIT = 1,
    1.53  
    1.54      // format of result from getTarget / encode_target:
    1.55      ETF_HANDLE_OR_METHOD_NAME = 0, // all available data (immediate MH or method)
    1.56 @@ -261,7 +273,8 @@
    1.57                                                int insert_argnum, oop insert_type,
    1.58                                                int change_argnum, oop change_type,
    1.59                                                int delete_argnum,
    1.60 -                                              oop dst_mtype, int dst_beg, int dst_end);
    1.61 +                                              oop dst_mtype, int dst_beg, int dst_end,
    1.62 +                                              bool raw = false);
    1.63    static const char* check_method_type_insertion(oop src_mtype,
    1.64                                                   int insert_argnum, oop insert_type,
    1.65                                                   oop dst_mtype) {
    1.66 @@ -278,29 +291,29 @@
    1.67                                      change_argnum, change_type,
    1.68                                      -1, dst_mtype, 0, -1);
    1.69    }
    1.70 -  static const char* check_method_type_passthrough(oop src_mtype, oop dst_mtype) {
    1.71 +  static const char* check_method_type_passthrough(oop src_mtype, oop dst_mtype, bool raw) {
    1.72      oop no_ref = NULL;
    1.73      return check_method_type_change(src_mtype, 0, -1,
    1.74                                      -1, no_ref, -1, no_ref, -1,
    1.75 -                                    dst_mtype, 0, -1);
    1.76 +                                    dst_mtype, 0, -1, raw);
    1.77    }
    1.78  
    1.79    // These checkers operate on pairs of argument or return types:
    1.80    static const char* check_argument_type_change(BasicType src_type, klassOop src_klass,
    1.81                                                  BasicType dst_type, klassOop dst_klass,
    1.82 -                                                int argnum);
    1.83 +                                                int argnum, bool raw = false);
    1.84  
    1.85    static const char* check_argument_type_change(oop src_type, oop dst_type,
    1.86 -                                                int argnum) {
    1.87 +                                                int argnum, bool raw = false) {
    1.88      klassOop src_klass = NULL, dst_klass = NULL;
    1.89      BasicType src_bt = java_lang_Class::as_BasicType(src_type, &src_klass);
    1.90      BasicType dst_bt = java_lang_Class::as_BasicType(dst_type, &dst_klass);
    1.91      return check_argument_type_change(src_bt, src_klass,
    1.92 -                                      dst_bt, dst_klass, argnum);
    1.93 +                                      dst_bt, dst_klass, argnum, raw);
    1.94    }
    1.95  
    1.96 -  static const char* check_return_type_change(oop src_type, oop dst_type) {
    1.97 -    return check_argument_type_change(src_type, dst_type, -1);
    1.98 +  static const char* check_return_type_change(oop src_type, oop dst_type, bool raw = false) {
    1.99 +    return check_argument_type_change(src_type, dst_type, -1, raw);
   1.100    }
   1.101  
   1.102    static const char* check_return_type_change(BasicType src_type, klassOop src_klass,
   1.103 @@ -357,9 +370,10 @@
   1.104                                                TRAPS);
   1.105  
   1.106    static bool same_basic_type_for_arguments(BasicType src, BasicType dst,
   1.107 +                                            bool raw = false,
   1.108                                              bool for_return = false);
   1.109 -  static bool same_basic_type_for_returns(BasicType src, BasicType dst) {
   1.110 -    return same_basic_type_for_arguments(src, dst, true);
   1.111 +  static bool same_basic_type_for_returns(BasicType src, BasicType dst, bool raw = false) {
   1.112 +    return same_basic_type_for_arguments(src, dst, raw, true);
   1.113    }
   1.114  
   1.115    enum {                        // arg_mask values

mercurial