src/share/vm/prims/methodHandleWalk.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6839872 Sdiff src/share/vm/prims

src/share/vm/prims/methodHandleWalk.cpp

Print this page
rev 2143 : 6839872: remove implementation inheritance from JSR 292 APIs
Summary: Move all JSR 292 classes into the java.dyn package.
Reviewed-by:


  83 void MethodHandleChain::set_last_method(oop target, TRAPS) {
  84   _is_last = true;
  85   klassOop receiver_limit_oop = NULL;
  86   int flags = 0;
  87   methodOop m = MethodHandles::decode_method(target, receiver_limit_oop, flags);
  88   _last_method = methodHandle(THREAD, m);
  89   if ((flags & MethodHandles::_dmf_has_receiver) == 0)
  90     _last_invoke = Bytecodes::_invokestatic;
  91   else if ((flags & MethodHandles::_dmf_does_dispatch) == 0)
  92     _last_invoke = Bytecodes::_invokespecial;
  93   else if ((flags & MethodHandles::_dmf_from_interface) != 0)
  94     _last_invoke = Bytecodes::_invokeinterface;
  95   else
  96     _last_invoke = Bytecodes::_invokevirtual;
  97 }
  98 
  99 
 100 BasicType MethodHandleChain::compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS) {
 101   // There is no direct indication of whether the argument is primitive or not.
 102   // It is implied by the _vmentry code, and by the MethodType of the target.
 103   // FIXME: Make it explicit MethodHandleImpl refactors out from MethodHandle
 104   BasicType arg_type = T_VOID;
 105   if (target != NULL) {
 106     oop mtype = java_dyn_MethodHandle::type(target);
 107     int arg_num = MethodHandles::argument_slot_to_argnum(mtype, arg_slot);
 108     if (arg_num >= 0) {
 109       oop ptype = java_dyn_MethodType::ptype(mtype, arg_num);
 110       arg_type = java_lang_Class::as_BasicType(ptype);
 111     }
 112   } else if (m != NULL) {
 113     // figure out the argument type from the slot
 114     // FIXME: make this explicit in the MH
 115     int cur_slot = m->size_of_parameters();
 116     if (arg_slot >= cur_slot)
 117       return T_VOID;
 118     if (!m->is_static()) {
 119       cur_slot -= type2size[T_OBJECT];
 120       if (cur_slot == arg_slot)
 121         return T_OBJECT;
 122     }
 123     ResourceMark rm(THREAD);


 943 
 944   return make_parameter(type, tk, index, THREAD);
 945 }
 946 
 947 
 948 // -----------------------------------------------------------------------------
 949 // MethodHandleCompiler
 950 //
 951 
 952 static jvalue zero_jvalue;
 953 
 954 // Emit bytecodes for the given invoke instruction.
 955 MethodHandleWalker::ArgToken
 956 MethodHandleCompiler::make_invoke(methodOop m, vmIntrinsics::ID iid,
 957                                   Bytecodes::Code op, bool tailcall,
 958                                   int argc, MethodHandleWalker::ArgToken* argv,
 959                                   TRAPS) {
 960   if (m == NULL) {
 961     // Get the intrinsic methodOop.
 962     m = vmIntrinsics::method_for(iid);







 963   }
 964 
 965   klassOop  klass   = m->method_holder();
 966   Symbol* name      = m->name();
 967   Symbol* signature = m->signature();
 968 
 969   if (tailcall) {
 970     // Actually, in order to make these methods more recognizable,
 971     // let's put them in holder class MethodHandle.  That way stack
 972     // walkers and compiler heuristics can recognize them.
 973     _target_klass = SystemDictionary::MethodHandle_klass();
 974   }
 975 
 976   // Inline the method.
 977   InvocationCounter* ic = m->invocation_counter();
 978   ic->set_carry_flag();
 979 
 980   for (int i = 0; i < argc; i++) {
 981     ArgToken arg = argv[i];
 982     TokenType tt = arg.token_type();




  83 void MethodHandleChain::set_last_method(oop target, TRAPS) {
  84   _is_last = true;
  85   klassOop receiver_limit_oop = NULL;
  86   int flags = 0;
  87   methodOop m = MethodHandles::decode_method(target, receiver_limit_oop, flags);
  88   _last_method = methodHandle(THREAD, m);
  89   if ((flags & MethodHandles::_dmf_has_receiver) == 0)
  90     _last_invoke = Bytecodes::_invokestatic;
  91   else if ((flags & MethodHandles::_dmf_does_dispatch) == 0)
  92     _last_invoke = Bytecodes::_invokespecial;
  93   else if ((flags & MethodHandles::_dmf_from_interface) != 0)
  94     _last_invoke = Bytecodes::_invokeinterface;
  95   else
  96     _last_invoke = Bytecodes::_invokevirtual;
  97 }
  98 
  99 
 100 BasicType MethodHandleChain::compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS) {
 101   // There is no direct indication of whether the argument is primitive or not.
 102   // It is implied by the _vmentry code, and by the MethodType of the target.

 103   BasicType arg_type = T_VOID;
 104   if (target != NULL) {
 105     oop mtype = java_dyn_MethodHandle::type(target);
 106     int arg_num = MethodHandles::argument_slot_to_argnum(mtype, arg_slot);
 107     if (arg_num >= 0) {
 108       oop ptype = java_dyn_MethodType::ptype(mtype, arg_num);
 109       arg_type = java_lang_Class::as_BasicType(ptype);
 110     }
 111   } else if (m != NULL) {
 112     // figure out the argument type from the slot
 113     // FIXME: make this explicit in the MH
 114     int cur_slot = m->size_of_parameters();
 115     if (arg_slot >= cur_slot)
 116       return T_VOID;
 117     if (!m->is_static()) {
 118       cur_slot -= type2size[T_OBJECT];
 119       if (cur_slot == arg_slot)
 120         return T_OBJECT;
 121     }
 122     ResourceMark rm(THREAD);


 942 
 943   return make_parameter(type, tk, index, THREAD);
 944 }
 945 
 946 
 947 // -----------------------------------------------------------------------------
 948 // MethodHandleCompiler
 949 //
 950 
 951 static jvalue zero_jvalue;
 952 
 953 // Emit bytecodes for the given invoke instruction.
 954 MethodHandleWalker::ArgToken
 955 MethodHandleCompiler::make_invoke(methodOop m, vmIntrinsics::ID iid,
 956                                   Bytecodes::Code op, bool tailcall,
 957                                   int argc, MethodHandleWalker::ArgToken* argv,
 958                                   TRAPS) {
 959   if (m == NULL) {
 960     // Get the intrinsic methodOop.
 961     m = vmIntrinsics::method_for(iid);
 962     if (m == NULL && iid == vmIntrinsics::_checkSpreadArgument && AllowTransitionalJSR292) {
 963       m = vmIntrinsics::method_for(vmIntrinsics::_checkSpreadArgument_TRANS);
 964     }
 965     if (m == NULL) {
 966       ArgToken zero;
 967       lose(vmIntrinsics::name_at(iid), CHECK_(zero));
 968     }
 969   }
 970 
 971   klassOop  klass   = m->method_holder();
 972   Symbol* name      = m->name();
 973   Symbol* signature = m->signature();
 974 
 975   if (tailcall) {
 976     // Actually, in order to make these methods more recognizable,
 977     // let's put them in holder class MethodHandle.  That way stack
 978     // walkers and compiler heuristics can recognize them.
 979     _target_klass = SystemDictionary::MethodHandle_klass();
 980   }
 981 
 982   // Inline the method.
 983   InvocationCounter* ic = m->invocation_counter();
 984   ic->set_carry_flag();
 985 
 986   for (int i = 0; i < argc; i++) {
 987     ArgToken arg = argv[i];
 988     TokenType tt = arg.token_type();


src/share/vm/prims/methodHandleWalk.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File