< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.cpp

Print this page

  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "c1/c1_Compilation.hpp"
  27 #include "c1/c1_Defs.hpp"
  28 #include "c1/c1_FrameMap.hpp"
  29 #include "c1/c1_Instruction.hpp"
  30 #include "c1/c1_LIRAssembler.hpp"
  31 #include "c1/c1_LIRGenerator.hpp"
  32 #include "c1/c1_ValueStack.hpp"
  33 #include "ci/ciArrayKlass.hpp"
  34 #include "ci/ciInstance.hpp"
  35 #include "ci/ciObjArray.hpp"
  36 #include "ci/ciUtilities.hpp"

  37 #include "compiler/compilerDefinitions.inline.hpp"
  38 #include "compiler/compilerOracle.hpp"
  39 #include "gc/shared/barrierSet.hpp"
  40 #include "gc/shared/c1/barrierSetC1.hpp"
  41 #include "oops/klass.inline.hpp"
  42 #include "oops/methodCounters.hpp"
  43 #include "runtime/sharedRuntime.hpp"
  44 #include "runtime/stubRoutines.hpp"
  45 #include "runtime/vm_version.hpp"
  46 #include "utilities/bitMap.inline.hpp"
  47 #include "utilities/macros.hpp"
  48 #include "utilities/powerOfTwo.hpp"
  49 
  50 #ifdef ASSERT
  51 #define __ gen()->lir(__FILE__, __LINE__)->
  52 #else
  53 #define __ gen()->lir()->
  54 #endif
  55 
  56 #ifndef PATCHED_ADDR

3263     freq_log = CompilerConfig::scaled_freq_log(freq_log, scale);
3264   }
3265   increment_event_counter_impl(info, info->scope()->method(), step, right_n_bits(freq_log), bci, backedge, true);
3266 }
3267 
3268 void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info,
3269                                                 ciMethod *method, LIR_Opr step, int frequency,
3270                                                 int bci, bool backedge, bool notify) {
3271   assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0");
3272   int level = _compilation->env()->comp_level();
3273   assert(level > CompLevel_simple, "Shouldn't be here");
3274 
3275   int offset = -1;
3276   LIR_Opr counter_holder;
3277   if (level == CompLevel_limited_profile) {
3278     MethodCounters* counters_adr = method->ensure_method_counters();
3279     if (counters_adr == nullptr) {
3280       bailout("method counters allocation failed");
3281       return;
3282     }




3283     counter_holder = new_pointer_register();
3284     __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);

3285     offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
3286                                  MethodCounters::invocation_counter_offset());
3287   } else if (level == CompLevel_full_profile) {
3288     counter_holder = new_register(T_METADATA);
3289     offset = in_bytes(backedge ? MethodData::backedge_counter_offset() :
3290                                  MethodData::invocation_counter_offset());
3291     ciMethodData* md = method->method_data_or_null();
3292     assert(md != nullptr, "Sanity");
3293     __ metadata2reg(md->constant_encoding(), counter_holder);
3294   } else {
3295     ShouldNotReachHere();
3296   }
3297   LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT);
3298   LIR_Opr result = new_register(T_INT);
3299   __ load(counter, result);
3300   __ add(result, step, result);
3301   __ store(result, counter);
3302   if (notify && (!backedge || UseOnStackReplacement)) {
3303     LIR_Opr meth = LIR_OprFact::metadataConst(method->constant_encoding());
3304     // The bci for info can point to cmp for if's we want the if bci

  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "c1/c1_Compilation.hpp"
  27 #include "c1/c1_Defs.hpp"
  28 #include "c1/c1_FrameMap.hpp"
  29 #include "c1/c1_Instruction.hpp"
  30 #include "c1/c1_LIRAssembler.hpp"
  31 #include "c1/c1_LIRGenerator.hpp"
  32 #include "c1/c1_ValueStack.hpp"
  33 #include "ci/ciArrayKlass.hpp"
  34 #include "ci/ciInstance.hpp"
  35 #include "ci/ciObjArray.hpp"
  36 #include "ci/ciUtilities.hpp"
  37 #include "code/SCCache.hpp"
  38 #include "compiler/compilerDefinitions.inline.hpp"
  39 #include "compiler/compilerOracle.hpp"
  40 #include "gc/shared/barrierSet.hpp"
  41 #include "gc/shared/c1/barrierSetC1.hpp"
  42 #include "oops/klass.inline.hpp"
  43 #include "oops/methodCounters.hpp"
  44 #include "runtime/sharedRuntime.hpp"
  45 #include "runtime/stubRoutines.hpp"
  46 #include "runtime/vm_version.hpp"
  47 #include "utilities/bitMap.inline.hpp"
  48 #include "utilities/macros.hpp"
  49 #include "utilities/powerOfTwo.hpp"
  50 
  51 #ifdef ASSERT
  52 #define __ gen()->lir(__FILE__, __LINE__)->
  53 #else
  54 #define __ gen()->lir()->
  55 #endif
  56 
  57 #ifndef PATCHED_ADDR

3264     freq_log = CompilerConfig::scaled_freq_log(freq_log, scale);
3265   }
3266   increment_event_counter_impl(info, info->scope()->method(), step, right_n_bits(freq_log), bci, backedge, true);
3267 }
3268 
3269 void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info,
3270                                                 ciMethod *method, LIR_Opr step, int frequency,
3271                                                 int bci, bool backedge, bool notify) {
3272   assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0");
3273   int level = _compilation->env()->comp_level();
3274   assert(level > CompLevel_simple, "Shouldn't be here");
3275 
3276   int offset = -1;
3277   LIR_Opr counter_holder;
3278   if (level == CompLevel_limited_profile) {
3279     MethodCounters* counters_adr = method->ensure_method_counters();
3280     if (counters_adr == nullptr) {
3281       bailout("method counters allocation failed");
3282       return;
3283     }
3284 if (SCCache::is_on()) {
3285     counter_holder = new_register(T_METADATA);
3286     __ metadata2reg(counters_adr, counter_holder);
3287 } else {
3288     counter_holder = new_pointer_register();
3289     __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);
3290 }
3291     offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
3292                                  MethodCounters::invocation_counter_offset());
3293   } else if (level == CompLevel_full_profile) {
3294     counter_holder = new_register(T_METADATA);
3295     offset = in_bytes(backedge ? MethodData::backedge_counter_offset() :
3296                                  MethodData::invocation_counter_offset());
3297     ciMethodData* md = method->method_data_or_null();
3298     assert(md != nullptr, "Sanity");
3299     __ metadata2reg(md->constant_encoding(), counter_holder);
3300   } else {
3301     ShouldNotReachHere();
3302   }
3303   LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT);
3304   LIR_Opr result = new_register(T_INT);
3305   __ load(counter, result);
3306   __ add(result, step, result);
3307   __ store(result, counter);
3308   if (notify && (!backedge || UseOnStackReplacement)) {
3309     LIR_Opr meth = LIR_OprFact::metadataConst(method->constant_encoding());
3310     // The bci for info can point to cmp for if's we want the if bci
< prev index next >