hotspot/src/share/vm/ci/ciMethod.cpp
changeset 14477 95e66ea71f71
parent 14391 df0a1573d5bd
child 14478 1c4a20806af7
equal deleted inserted replaced
14470:f6651390f4e7 14477:95e66ea71f71
    29 #include "ci/ciMethod.hpp"
    29 #include "ci/ciMethod.hpp"
    30 #include "ci/ciMethodBlocks.hpp"
    30 #include "ci/ciMethodBlocks.hpp"
    31 #include "ci/ciMethodData.hpp"
    31 #include "ci/ciMethodData.hpp"
    32 #include "ci/ciStreams.hpp"
    32 #include "ci/ciStreams.hpp"
    33 #include "ci/ciSymbol.hpp"
    33 #include "ci/ciSymbol.hpp"
       
    34 #include "ci/ciReplay.hpp"
    34 #include "ci/ciUtilities.hpp"
    35 #include "ci/ciUtilities.hpp"
    35 #include "classfile/systemDictionary.hpp"
    36 #include "classfile/systemDictionary.hpp"
    36 #include "compiler/abstractCompiler.hpp"
    37 #include "compiler/abstractCompiler.hpp"
    37 #include "compiler/compilerOracle.hpp"
    38 #include "compiler/compilerOracle.hpp"
    38 #include "compiler/methodLiveness.hpp"
    39 #include "compiler/methodLiveness.hpp"
   137     _interpreter_invocation_count = 0;
   138     _interpreter_invocation_count = 0;
   138     _interpreter_throwout_count = 0;
   139     _interpreter_throwout_count = 0;
   139   }
   140   }
   140   if (_interpreter_invocation_count == 0)
   141   if (_interpreter_invocation_count == 0)
   141     _interpreter_invocation_count = 1;
   142     _interpreter_invocation_count = 1;
       
   143   _instructions_size = -1;
       
   144 #ifdef ASSERT
       
   145   if (ReplayCompiles) {
       
   146     ciReplay::initialize(this);
       
   147   }
       
   148 #endif
   142 }
   149 }
   143 
   150 
   144 
   151 
   145 // ------------------------------------------------------------------
   152 // ------------------------------------------------------------------
   146 // ciMethod::ciMethod
   153 // ciMethod::ciMethod
   159   _method_blocks(          NULL),
   166   _method_blocks(          NULL),
   160   _method_data(            NULL)
   167   _method_data(            NULL)
   161 #if defined(COMPILER2) || defined(SHARK)
   168 #if defined(COMPILER2) || defined(SHARK)
   162   ,
   169   ,
   163   _flow(                   NULL),
   170   _flow(                   NULL),
   164   _bcea(                   NULL)
   171   _bcea(                   NULL),
       
   172   _instructions_size(-1)
   165 #endif // COMPILER2 || SHARK
   173 #endif // COMPILER2 || SHARK
   166 {
   174 {
   167   // Usually holder and accessor are the same type but in some cases
   175   // Usually holder and accessor are the same type but in some cases
   168   // the holder has the wrong class loader (e.g. invokedynamic call
   176   // the holder has the wrong class loader (e.g. invokedynamic call
   169   // sites) so we pass the accessor.
   177   // sites) so we pass the accessor.
   998 }
  1006 }
   999 
  1007 
  1000 // ------------------------------------------------------------------
  1008 // ------------------------------------------------------------------
  1001 // ciMethod::has_compiled_code
  1009 // ciMethod::has_compiled_code
  1002 bool ciMethod::has_compiled_code() {
  1010 bool ciMethod::has_compiled_code() {
  1003   VM_ENTRY_MARK;
  1011   return instructions_size() > 0;
  1004   return get_Method()->code() != NULL;
       
  1005 }
  1012 }
  1006 
  1013 
  1007 int ciMethod::comp_level() {
  1014 int ciMethod::comp_level() {
  1008   check_is_loaded();
  1015   check_is_loaded();
  1009   VM_ENTRY_MARK;
  1016   VM_ENTRY_MARK;
  1037 // This is a rough metric for "fat" methods, compared before inlining
  1044 // This is a rough metric for "fat" methods, compared before inlining
  1038 // with InlineSmallCode.  The CodeBlob::code_size accessor includes
  1045 // with InlineSmallCode.  The CodeBlob::code_size accessor includes
  1039 // junk like exception handler, stubs, and constant table, which are
  1046 // junk like exception handler, stubs, and constant table, which are
  1040 // not highly relevant to an inlined method.  So we use the more
  1047 // not highly relevant to an inlined method.  So we use the more
  1041 // specific accessor nmethod::insts_size.
  1048 // specific accessor nmethod::insts_size.
  1042 int ciMethod::instructions_size(int comp_level) {
  1049 int ciMethod::instructions_size() {
  1043   GUARDED_VM_ENTRY(
  1050   if (_instructions_size == -1) {
  1044     nmethod* code = get_Method()->code();
  1051     GUARDED_VM_ENTRY(
  1045     if (code != NULL && (comp_level == CompLevel_any || comp_level == code->comp_level())) {
  1052                      nmethod* code = get_Method()->code();
  1046       return code->insts_end() - code->verified_entry_point();
  1053                      if (code != NULL && (code->comp_level() == CompLevel_full_optimization)) {
  1047     }
  1054                        _instructions_size = code->insts_end() - code->verified_entry_point();
  1048     return 0;
  1055                      } else {
  1049   )
  1056                        _instructions_size = 0;
       
  1057                      }
       
  1058                      );
       
  1059   }
       
  1060   return _instructions_size;
  1050 }
  1061 }
  1051 
  1062 
  1052 // ------------------------------------------------------------------
  1063 // ------------------------------------------------------------------
  1053 // ciMethod::log_nmethod_identity
  1064 // ciMethod::log_nmethod_identity
  1054 void ciMethod::log_nmethod_identity(xmlStream* log) {
  1065 void ciMethod::log_nmethod_identity(xmlStream* log) {
  1164   return _method_blocks;
  1175   return _method_blocks;
  1165 }
  1176 }
  1166 
  1177 
  1167 #undef FETCH_FLAG_FROM_VM
  1178 #undef FETCH_FLAG_FROM_VM
  1168 
  1179 
       
  1180 void ciMethod::dump_replay_data(outputStream* st) {
       
  1181   ASSERT_IN_VM;
       
  1182   Method* method = get_Method();
       
  1183   Klass*  holder = method->method_holder();
       
  1184   st->print_cr("ciMethod %s %s %s %d %d %d %d %d",
       
  1185                holder->name()->as_quoted_ascii(),
       
  1186                method->name()->as_quoted_ascii(),
       
  1187                method->signature()->as_quoted_ascii(),
       
  1188                method->invocation_counter()->raw_counter(),
       
  1189                method->backedge_counter()->raw_counter(),
       
  1190                interpreter_invocation_count(),
       
  1191                interpreter_throwout_count(),
       
  1192                _instructions_size);
       
  1193 }
  1169 
  1194 
  1170 // ------------------------------------------------------------------
  1195 // ------------------------------------------------------------------
  1171 // ciMethod::print_codes
  1196 // ciMethod::print_codes
  1172 //
  1197 //
  1173 // Print a range of the bytecodes for this method.
  1198 // Print a range of the bytecodes for this method.