< prev index next >

src/share/vm/c1/c1_GraphBuilder.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_CFGPrinter.hpp"
  27 #include "c1/c1_Canonicalizer.hpp"
  28 #include "c1/c1_Compilation.hpp"
  29 #include "c1/c1_GraphBuilder.hpp"
  30 #include "c1/c1_InstructionPrinter.hpp"
  31 #include "ci/ciCallSite.hpp"
  32 #include "ci/ciField.hpp"
  33 #include "ci/ciKlass.hpp"
  34 #include "ci/ciMemberName.hpp"
  35 #include "compiler/compileBroker.hpp"
  36 #include "interpreter/bytecode.hpp"

  37 #include "runtime/sharedRuntime.hpp"
  38 #include "runtime/compilationPolicy.hpp"
  39 #include "utilities/bitMap.inline.hpp"
  40 
  41 class BlockListBuilder VALUE_OBJ_CLASS_SPEC {
  42  private:
  43   Compilation* _compilation;
  44   IRScope*     _scope;
  45 
  46   BlockList    _blocks;                // internal list of all blocks
  47   BlockList*   _bci2block;             // mapping from bci to blocks for GraphBuilder
  48 
  49   // fields used by mark_loops
  50   BitMap       _active;                // for iteration of control flow graph
  51   BitMap       _visited;               // for iteration of control flow graph
  52   intArray     _loop_map;              // caches the information if a block is contained in a loop
  53   int          _next_loop_index;       // next free loop number
  54   int          _next_block_number;     // for reverse postorder numbering of blocks
  55 
  56   // accessors


3443 bool GraphBuilder::try_inline_intrinsics(ciMethod* callee) {
3444   if (callee->is_synchronized()) {
3445     // We don't currently support any synchronized intrinsics
3446     return false;
3447   }
3448 
3449   // callee seems like a good candidate
3450   // determine id
3451   vmIntrinsics::ID id = callee->intrinsic_id();
3452   if (!InlineNatives && id != vmIntrinsics::_Reference_get) {
3453     // InlineNatives does not control Reference.get
3454     INLINE_BAILOUT("intrinsic method inlining disabled");
3455   }
3456   bool preserves_state = false;
3457   bool cantrap = true;
3458   switch (id) {
3459     case vmIntrinsics::_arraycopy:
3460       if (!InlineArrayCopy) return false;
3461       break;
3462 
3463 #ifdef TRACE_HAVE_INTRINSICS
3464     case vmIntrinsics::_classID:
3465     case vmIntrinsics::_threadID:
3466       preserves_state = true;






3467       cantrap = true;
3468       break;
3469 
3470     case vmIntrinsics::_counterTime:
3471       preserves_state = true;
3472       cantrap = false;
3473       break;
3474 #endif
3475 
3476     case vmIntrinsics::_currentTimeMillis:
3477     case vmIntrinsics::_nanoTime:
3478       preserves_state = true;
3479       cantrap = false;
3480       break;
3481 
3482     case vmIntrinsics::_floatToRawIntBits   :
3483     case vmIntrinsics::_intBitsToFloat      :
3484     case vmIntrinsics::_doubleToRawLongBits :
3485     case vmIntrinsics::_longBitsToDouble    :
3486       if (!InlineMathNatives) return false;


4379 #ifndef _LP64
4380   offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
4381 #endif
4382 
4383   args->push(src);
4384   args->push(offset);
4385   args->push(cmpval);
4386   args->push(newval);
4387 
4388   // An unsafe CAS can alias with other field accesses, but we don't
4389   // know which ones so mark the state as no preserved.  This will
4390   // cause CSE to invalidate memory across it.
4391   bool preserves_state = false;
4392   Intrinsic* result = new Intrinsic(result_type, callee->intrinsic_id(), args, false, state_before, preserves_state);
4393   append_split(result);
4394   push(result_type, result);
4395   compilation()->set_has_unsafe_access(true);
4396 }
4397 
4398 
























4399 void GraphBuilder::print_inlining(ciMethod* callee, const char* msg, bool success) {
4400   CompileLog* log = compilation()->log();
4401   if (log != NULL) {
4402     if (success) {
4403       if (msg != NULL)
4404         log->inline_success(msg);
4405       else
4406         log->inline_success("receiver is statically known");
4407     } else {
4408       if (msg != NULL)
4409         log->inline_fail(msg);
4410       else
4411         log->inline_fail("reason unknown");
4412     }





4413   }
4414 
4415   if (!PrintInlining && !compilation()->method()->has_option("PrintInlining")) {
4416     return;
4417   }
4418   CompileTask::print_inlining(callee, scope()->level(), bci(), msg);
4419   if (success && CIPrintMethodCodes) {
4420     callee->print_codes();
4421   }
4422 }
4423 
4424 bool GraphBuilder::append_unsafe_get_and_set_obj(ciMethod* callee, bool is_add) {
4425   if (InlineUnsafeOps) {
4426     Values* args = state()->pop_arguments(callee->arg_size());
4427     BasicType t = callee->return_type()->basic_type();
4428     null_check(args->at(0));
4429     Instruction* offset = args->at(2);
4430 #ifndef _LP64
4431     offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
4432 #endif




  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_CFGPrinter.hpp"
  27 #include "c1/c1_Canonicalizer.hpp"
  28 #include "c1/c1_Compilation.hpp"
  29 #include "c1/c1_GraphBuilder.hpp"
  30 #include "c1/c1_InstructionPrinter.hpp"
  31 #include "ci/ciCallSite.hpp"
  32 #include "ci/ciField.hpp"
  33 #include "ci/ciKlass.hpp"
  34 #include "ci/ciMemberName.hpp"
  35 #include "compiler/compileBroker.hpp"
  36 #include "interpreter/bytecode.hpp"
  37 #include "jfr/jfrEvents.hpp"
  38 #include "runtime/sharedRuntime.hpp"
  39 #include "runtime/compilationPolicy.hpp"
  40 #include "utilities/bitMap.inline.hpp"
  41 
  42 class BlockListBuilder VALUE_OBJ_CLASS_SPEC {
  43  private:
  44   Compilation* _compilation;
  45   IRScope*     _scope;
  46 
  47   BlockList    _blocks;                // internal list of all blocks
  48   BlockList*   _bci2block;             // mapping from bci to blocks for GraphBuilder
  49 
  50   // fields used by mark_loops
  51   BitMap       _active;                // for iteration of control flow graph
  52   BitMap       _visited;               // for iteration of control flow graph
  53   intArray     _loop_map;              // caches the information if a block is contained in a loop
  54   int          _next_loop_index;       // next free loop number
  55   int          _next_block_number;     // for reverse postorder numbering of blocks
  56 
  57   // accessors


3444 bool GraphBuilder::try_inline_intrinsics(ciMethod* callee) {
3445   if (callee->is_synchronized()) {
3446     // We don't currently support any synchronized intrinsics
3447     return false;
3448   }
3449 
3450   // callee seems like a good candidate
3451   // determine id
3452   vmIntrinsics::ID id = callee->intrinsic_id();
3453   if (!InlineNatives && id != vmIntrinsics::_Reference_get) {
3454     // InlineNatives does not control Reference.get
3455     INLINE_BAILOUT("intrinsic method inlining disabled");
3456   }
3457   bool preserves_state = false;
3458   bool cantrap = true;
3459   switch (id) {
3460     case vmIntrinsics::_arraycopy:
3461       if (!InlineArrayCopy) return false;
3462       break;
3463 
3464 #ifdef JFR_HAVE_INTRINSICS
3465 #if defined(_LP64) || !defined(TRACE_ID_CLASS_SHIFT)
3466     case vmIntrinsics::_getClassId:
3467       preserves_state = false;
3468       cantrap = false;
3469       break;
3470 #endif
3471 
3472     case vmIntrinsics::_getEventWriter:
3473       preserves_state = false;
3474       cantrap = true;
3475       break;
3476 
3477     case vmIntrinsics::_counterTime:
3478       preserves_state = true;
3479       cantrap = false;
3480       break;
3481 #endif
3482 
3483     case vmIntrinsics::_currentTimeMillis:
3484     case vmIntrinsics::_nanoTime:
3485       preserves_state = true;
3486       cantrap = false;
3487       break;
3488 
3489     case vmIntrinsics::_floatToRawIntBits   :
3490     case vmIntrinsics::_intBitsToFloat      :
3491     case vmIntrinsics::_doubleToRawLongBits :
3492     case vmIntrinsics::_longBitsToDouble    :
3493       if (!InlineMathNatives) return false;


4386 #ifndef _LP64
4387   offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
4388 #endif
4389 
4390   args->push(src);
4391   args->push(offset);
4392   args->push(cmpval);
4393   args->push(newval);
4394 
4395   // An unsafe CAS can alias with other field accesses, but we don't
4396   // know which ones so mark the state as no preserved.  This will
4397   // cause CSE to invalidate memory across it.
4398   bool preserves_state = false;
4399   Intrinsic* result = new Intrinsic(result_type, callee->intrinsic_id(), args, false, state_before, preserves_state);
4400   append_split(result);
4401   push(result_type, result);
4402   compilation()->set_has_unsafe_access(true);
4403 }
4404 
4405 
4406 static void post_inlining_event(EventCompilerInlining* event,
4407                                 int compile_id,
4408                                 const char* msg,
4409                                 bool success,
4410                                 int bci,
4411                                 ciMethod* caller,
4412                                 ciMethod* callee) {
4413   assert(caller != NULL, "invariant");
4414   assert(callee != NULL, "invariant");
4415   assert(event != NULL, "invariant");
4416   assert(event->should_commit(), "invariant");
4417   JfrStructCalleeMethod callee_struct;
4418   callee_struct.set_type(callee->holder()->name()->as_utf8());
4419   callee_struct.set_name(callee->name()->as_utf8());
4420   callee_struct.set_descriptor(callee->signature()->as_symbol()->as_utf8());
4421   event->set_compileId(compile_id);
4422   event->set_message(msg);
4423   event->set_succeeded(success);
4424   event->set_bci(bci);
4425   event->set_caller(caller->get_Method());
4426   event->set_callee(callee_struct);
4427   event->commit();
4428 }
4429 
4430 void GraphBuilder::print_inlining(ciMethod* callee, const char* msg, bool success) {
4431   CompileLog* log = compilation()->log();
4432   if (log != NULL) {
4433     if (success) {
4434       if (msg != NULL)
4435         log->inline_success(msg);
4436       else
4437         log->inline_success("receiver is statically known");
4438     } else {
4439       if (msg != NULL)
4440         log->inline_fail(msg);
4441       else
4442         log->inline_fail("reason unknown");
4443     }
4444   }
4445 
4446   EventCompilerInlining event;
4447   if (event.should_commit()) {
4448     post_inlining_event(&event, compilation()->env()->task()->compile_id(), msg, success, bci(), method(), callee);
4449   }
4450 
4451   if (!PrintInlining && !compilation()->method()->has_option("PrintInlining")) {
4452     return;
4453   }
4454   CompileTask::print_inlining(callee, scope()->level(), bci(), msg);
4455   if (success && CIPrintMethodCodes) {
4456     callee->print_codes();
4457   }
4458 }
4459 
4460 bool GraphBuilder::append_unsafe_get_and_set_obj(ciMethod* callee, bool is_add) {
4461   if (InlineUnsafeOps) {
4462     Values* args = state()->pop_arguments(callee->arg_size());
4463     BasicType t = callee->return_type()->basic_type();
4464     null_check(args->at(0));
4465     Instruction* offset = args->at(2);
4466 #ifndef _LP64
4467     offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
4468 #endif


< prev index next >