hotspot/src/share/vm/opto/callGenerator.cpp
changeset 24002 4e6a72032a99
parent 23846 490ace57944d
child 24479 20eb4c752fb5
equal deleted inserted replaced
24001:d0eea05381dd 24002:4e6a72032a99
   264   return new VirtualCallGenerator(m, vtable_index);
   264   return new VirtualCallGenerator(m, vtable_index);
   265 }
   265 }
   266 
   266 
   267 // Allow inlining decisions to be delayed
   267 // Allow inlining decisions to be delayed
   268 class LateInlineCallGenerator : public DirectCallGenerator {
   268 class LateInlineCallGenerator : public DirectCallGenerator {
       
   269  private:
       
   270   // unique id for log compilation
       
   271   jlong _unique_id;
       
   272 
   269  protected:
   273  protected:
   270   CallGenerator* _inline_cg;
   274   CallGenerator* _inline_cg;
   271 
       
   272   virtual bool do_late_inline_check(JVMState* jvms) { return true; }
   275   virtual bool do_late_inline_check(JVMState* jvms) { return true; }
   273 
   276 
   274  public:
   277  public:
   275   LateInlineCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
   278   LateInlineCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
   276     DirectCallGenerator(method, true), _inline_cg(inline_cg) {}
   279     DirectCallGenerator(method, true), _inline_cg(inline_cg), _unique_id(0) {}
   277 
   280 
   278   virtual bool is_late_inline() const { return true; }
   281   virtual bool is_late_inline() const { return true; }
   279 
   282 
   280   // Convert the CallStaticJava into an inline
   283   // Convert the CallStaticJava into an inline
   281   virtual void do_late_inline();
   284   virtual void do_late_inline();
   282 
   285 
   283   virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
   286   virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
   284     Compile *C = Compile::current();
   287     Compile *C = Compile::current();
       
   288 
       
   289     C->log_inline_id(this);
   285 
   290 
   286     // Record that this call site should be revisited once the main
   291     // Record that this call site should be revisited once the main
   287     // parse is finished.
   292     // parse is finished.
   288     if (!is_mh_late_inline()) {
   293     if (!is_mh_late_inline()) {
   289       C->add_late_inline(this);
   294       C->add_late_inline(this);
   302     C->print_inlining_assert_ready();
   307     C->print_inlining_assert_ready();
   303     C->print_inlining(method(), call->jvms()->depth()-1, call->jvms()->bci(), msg);
   308     C->print_inlining(method(), call->jvms()->depth()-1, call->jvms()->bci(), msg);
   304     C->print_inlining_move_to(this);
   309     C->print_inlining_move_to(this);
   305     C->print_inlining_update_delayed(this);
   310     C->print_inlining_update_delayed(this);
   306   }
   311   }
       
   312 
       
   313   virtual void set_unique_id(jlong id) {
       
   314     _unique_id = id;
       
   315   }
       
   316 
       
   317   virtual jlong unique_id() const {
       
   318     return _unique_id;
       
   319   }
   307 };
   320 };
   308 
   321 
   309 void LateInlineCallGenerator::do_late_inline() {
   322 void LateInlineCallGenerator::do_late_inline() {
   310   // Can't inline it
   323   // Can't inline it
   311   CallStaticJavaNode* call = call_node();
   324   CallStaticJavaNode* call = call_node();
   366 
   379 
   367   C->print_inlining_assert_ready();
   380   C->print_inlining_assert_ready();
   368 
   381 
   369   C->print_inlining_move_to(this);
   382   C->print_inlining_move_to(this);
   370 
   383 
       
   384   C->log_late_inline(this);
       
   385 
   371   // This check is done here because for_method_handle_inline() method
   386   // This check is done here because for_method_handle_inline() method
   372   // needs jvms for inlined state.
   387   // needs jvms for inlined state.
   373   if (!do_late_inline_check(jvms)) {
   388   if (!do_late_inline_check(jvms)) {
   374     map->disconnect_inputs(NULL, C);
   389     map->disconnect_inputs(NULL, C);
   375     return;
   390     return;
   376   }
       
   377 
       
   378   CompileLog* log = C->log();
       
   379   if (log != NULL) {
       
   380     log->head("late_inline method='%d'", log->identify(method()));
       
   381     JVMState* p = jvms;
       
   382     while (p != NULL) {
       
   383       log->elem("jvms bci='%d' method='%d'", p->bci(), log->identify(p->method()));
       
   384       p = p->caller();
       
   385     }
       
   386     log->tail("late_inline");
       
   387   }
   391   }
   388 
   392 
   389   // Setup default node notes to be picked up by the inlining
   393   // Setup default node notes to be picked up by the inlining
   390   Node_Notes* old_nn = C->default_node_notes();
   394   Node_Notes* old_nn = C->default_node_notes();
   391   if (old_nn != NULL) {
   395   if (old_nn != NULL) {
   436   virtual bool is_mh_late_inline() const { return true; }
   440   virtual bool is_mh_late_inline() const { return true; }
   437 
   441 
   438   virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
   442   virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
   439     JVMState* new_jvms = LateInlineCallGenerator::generate(jvms, parent_parser);
   443     JVMState* new_jvms = LateInlineCallGenerator::generate(jvms, parent_parser);
   440 
   444 
       
   445     Compile* C = Compile::current();
   441     if (_input_not_const) {
   446     if (_input_not_const) {
   442       // inlining won't be possible so no need to enqueue right now.
   447       // inlining won't be possible so no need to enqueue right now.
   443       call_node()->set_generator(this);
   448       call_node()->set_generator(this);
   444     } else {
   449     } else {
   445       Compile::current()->add_late_inline(this);
   450       C->add_late_inline(this);
   446     }
   451     }
   447     return new_jvms;
   452     return new_jvms;
   448   }
   453   }
   449 };
   454 };
   450 
   455 
   481   LateInlineStringCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
   486   LateInlineStringCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
   482     LateInlineCallGenerator(method, inline_cg) {}
   487     LateInlineCallGenerator(method, inline_cg) {}
   483 
   488 
   484   virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
   489   virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
   485     Compile *C = Compile::current();
   490     Compile *C = Compile::current();
       
   491 
       
   492     C->log_inline_id(this);
       
   493 
   486     C->add_string_late_inline(this);
   494     C->add_string_late_inline(this);
   487 
   495 
   488     JVMState* new_jvms =  DirectCallGenerator::generate(jvms, parent_parser);
   496     JVMState* new_jvms =  DirectCallGenerator::generate(jvms, parent_parser);
   489     return new_jvms;
   497     return new_jvms;
   490   }
   498   }
   502   LateInlineBoxingCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
   510   LateInlineBoxingCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
   503     LateInlineCallGenerator(method, inline_cg) {}
   511     LateInlineCallGenerator(method, inline_cg) {}
   504 
   512 
   505   virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
   513   virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
   506     Compile *C = Compile::current();
   514     Compile *C = Compile::current();
       
   515 
       
   516     C->log_inline_id(this);
   507 
   517 
   508     C->add_boxing_late_inline(this);
   518     C->add_boxing_late_inline(this);
   509 
   519 
   510     JVMState* new_jvms =  DirectCallGenerator::generate(jvms, parent_parser);
   520     JVMState* new_jvms =  DirectCallGenerator::generate(jvms, parent_parser);
   511     return new_jvms;
   521     return new_jvms;
   784         if (cg != NULL && cg->is_inline())
   794         if (cg != NULL && cg->is_inline())
   785           return cg;
   795           return cg;
   786       } else {
   796       } else {
   787         const char* msg = "receiver not constant";
   797         const char* msg = "receiver not constant";
   788         if (PrintInlining)  C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
   798         if (PrintInlining)  C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
       
   799         C->log_inline_failure(msg);
   789       }
   800       }
   790     }
   801     }
   791     break;
   802     break;
   792 
   803 
   793   case vmIntrinsics::_linkToVirtual:
   804   case vmIntrinsics::_linkToVirtual:
   856         if (cg != NULL && cg->is_inline())
   867         if (cg != NULL && cg->is_inline())
   857           return cg;
   868           return cg;
   858       } else {
   869       } else {
   859         const char* msg = "member_name not constant";
   870         const char* msg = "member_name not constant";
   860         if (PrintInlining)  C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
   871         if (PrintInlining)  C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
       
   872         C->log_inline_failure(msg);
   861       }
   873       }
   862     }
   874     }
   863     break;
   875     break;
   864 
   876 
   865   default:
   877   default: