src/hotspot/share/runtime/deoptimization.cpp
changeset 49189 41e570d862b4
parent 49036 bc92debe57e4
child 49324 e6fbaf07192f
equal deleted inserted replaced
49188:e9ba8b40ca6f 49189:41e570d862b4
   602 }
   602 }
   603 
   603 
   604 // Return BasicType of value being returned
   604 // Return BasicType of value being returned
   605 JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_mode))
   605 JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_mode))
   606 
   606 
   607   // We are already active int he special DeoptResourceMark any ResourceObj's we
   607   // We are already active in the special DeoptResourceMark any ResourceObj's we
   608   // allocate will be freed at the end of the routine.
   608   // allocate will be freed at the end of the routine.
   609 
   609 
   610   // It is actually ok to allocate handles in a leaf method. It causes no safepoints,
   610   // It is actually ok to allocate handles in a leaf method. It causes no safepoints,
   611   // but makes the entry a little slower. There is however a little dance we have to
   611   // but makes the entry a little slower. There is however a little dance we have to
   612   // do in debug mode to get around the NoHandleMark code in the JRT_LEAF macro
   612   // do in debug mode to get around the NoHandleMark code in the JRT_LEAF macro
   679       assert(str.bci() < max_bci, "bci in interpreter frame out of bounds");
   679       assert(str.bci() < max_bci, "bci in interpreter frame out of bounds");
   680       // Check to see if we can grab the number of outgoing arguments
   680       // Check to see if we can grab the number of outgoing arguments
   681       // at an uncommon trap for an invoke (where the compiler
   681       // at an uncommon trap for an invoke (where the compiler
   682       // generates debug info before the invoke has executed)
   682       // generates debug info before the invoke has executed)
   683       Bytecodes::Code cur_code = str.next();
   683       Bytecodes::Code cur_code = str.next();
   684       if (cur_code == Bytecodes::_invokevirtual   ||
   684       if (Bytecodes::is_invoke(cur_code)) {
   685           cur_code == Bytecodes::_invokespecial   ||
       
   686           cur_code == Bytecodes::_invokestatic    ||
       
   687           cur_code == Bytecodes::_invokeinterface ||
       
   688           cur_code == Bytecodes::_invokedynamic) {
       
   689         Bytecode_invoke invoke(mh, iframe->interpreter_frame_bci());
   685         Bytecode_invoke invoke(mh, iframe->interpreter_frame_bci());
   690         Symbol* signature = invoke.signature();
   686         cur_invoke_parameter_size = invoke.size_of_parameters();
   691         ArgumentSizeComputer asc(signature);
       
   692         cur_invoke_parameter_size = asc.size();
       
   693         if (invoke.has_receiver()) {
       
   694           // Add in receiver
       
   695           ++cur_invoke_parameter_size;
       
   696         }
       
   697         if (i != 0 && !invoke.is_invokedynamic() && MethodHandles::has_member_arg(invoke.klass(), invoke.name())) {
   687         if (i != 0 && !invoke.is_invokedynamic() && MethodHandles::has_member_arg(invoke.klass(), invoke.name())) {
   698           callee_size_of_parameters++;
   688           callee_size_of_parameters++;
   699         }
   689         }
   700       }
   690       }
   701       if (str.bci() < max_bci) {
   691       if (str.bci() < max_bci) {
   702         Bytecodes::Code bc = str.next();
   692         Bytecodes::Code next_code = str.next();
   703         if (bc >= 0) {
   693         if (next_code >= 0) {
   704           // The interpreter oop map generator reports results before
   694           // The interpreter oop map generator reports results before
   705           // the current bytecode has executed except in the case of
   695           // the current bytecode has executed except in the case of
   706           // calls. It seems to be hard to tell whether the compiler
   696           // calls. It seems to be hard to tell whether the compiler
   707           // has emitted debug information matching the "state before"
   697           // has emitted debug information matching the "state before"
   708           // a given bytecode or the state after, so we try both
   698           // a given bytecode or the state after, so we try both
   709           switch (cur_code) {
   699           if (!Bytecodes::is_invoke(cur_code) && cur_code != Bytecodes::_athrow) {
   710             case Bytecodes::_invokevirtual:
   700             // Get expression stack size for the next bytecode
   711             case Bytecodes::_invokespecial:
   701             if (Bytecodes::is_invoke(next_code)) {
   712             case Bytecodes::_invokestatic:
   702               Bytecode_invoke invoke(mh, str.bci());
   713             case Bytecodes::_invokeinterface:
   703               next_mask_expression_stack_size = invoke.size_of_parameters();
   714             case Bytecodes::_invokedynamic:
   704             } else {
   715             case Bytecodes::_athrow:
       
   716               break;
       
   717             default: {
       
   718               InterpreterOopMap next_mask;
   705               InterpreterOopMap next_mask;
   719               OopMapCache::compute_one_oop_map(mh, str.bci(), &next_mask);
   706               OopMapCache::compute_one_oop_map(mh, str.bci(), &next_mask);
   720               next_mask_expression_stack_size = next_mask.expression_stack_size();
   707               next_mask_expression_stack_size = next_mask.expression_stack_size();
   721               // Need to subtract off the size of the result type of
       
   722               // the bytecode because this is not described in the
       
   723               // debug info but returned to the interpreter in the TOS
       
   724               // caching register
       
   725               BasicType bytecode_result_type = Bytecodes::result_type(cur_code);
       
   726               if (bytecode_result_type != T_ILLEGAL) {
       
   727                 top_frame_expression_stack_adjustment = type2size[bytecode_result_type];
       
   728               }
       
   729               assert(top_frame_expression_stack_adjustment >= 0, "");
       
   730               try_next_mask = true;
       
   731               break;
       
   732             }
   708             }
       
   709             // Need to subtract off the size of the result type of
       
   710             // the bytecode because this is not described in the
       
   711             // debug info but returned to the interpreter in the TOS
       
   712             // caching register
       
   713             BasicType bytecode_result_type = Bytecodes::result_type(cur_code);
       
   714             if (bytecode_result_type != T_ILLEGAL) {
       
   715               top_frame_expression_stack_adjustment = type2size[bytecode_result_type];
       
   716             }
       
   717             assert(top_frame_expression_stack_adjustment >= 0, "stack adjustment must be positive");
       
   718             try_next_mask = true;
   733           }
   719           }
   734         }
   720         }
   735       }
   721       }
   736 
   722 
   737       // Verify stack depth and oops in frame
   723       // Verify stack depth and oops in frame