< prev index next >

src/hotspot/share/runtime/deoptimization.hpp

Print this page
rev 60137 : 8227745: Enable Escape Analysis for Better Performance in the Presence of JVMTI Agents
Reviewed-by: mdoerr, goetz
rev 60138 : 8227745: delta webrev.5 -> webrev.6


 457                                                Method* compiled_method,
 458                                                //outputs:
 459                                                uint& ret_this_trap_count,
 460                                                bool& ret_maybe_prior_trap,
 461                                                bool& ret_maybe_prior_recompile);
 462   // class loading support for uncommon trap
 463   static void load_class_by_index(const constantPoolHandle& constant_pool, int index, TRAPS);
 464   static void load_class_by_index(const constantPoolHandle& constant_pool, int index);
 465 
 466   static UnrollBlock* fetch_unroll_info_helper(JavaThread* thread, int exec_mode);
 467 
 468   static DeoptAction _unloaded_action; // == Action_reinterpret;
 469   static const char* _trap_reason_name[];
 470   static const char* _trap_action_name[];
 471 
 472   static juint _deoptimization_hist[Reason_LIMIT][1+Action_LIMIT][BC_CASE_LIMIT];
 473   // Note:  Histogram array size is 1-2 Kb.
 474 
 475  public:
 476   static void update_method_data_from_interpreter(MethodData* trap_mdo, int trap_bci, int reason);
 477 
 478 #if defined(ASSERT) && COMPILER2_OR_JVMCI
 479   // Revert optimizations based on escape analysis for all compiled frames of all Java threads.
 480   static void deoptimize_objects_alot_loop();
 481 #endif // defined(ASSERT) && COMPILER2_OR_JVMCI
 482 };
 483 
 484 // EscapeBarriers should be put on execution paths, where JVMTI agents can access object
 485 // references held by java threads.
 486 // They provide means to revert optimizations based on escape analysis in a well synchronized manner
 487 // just before local references escape through JVMTI.
 488 class EscapeBarrier : StackObj {
 489 #if COMPILER2_OR_JVMCI
 490   JavaThread* const _calling_thread;
 491   JavaThread* const _deoptee_thread;
 492   bool        const _barrier_active;
 493 
 494   static bool _deoptimizing_objects_for_all_threads;
 495   static bool _self_deoptimization_in_progress;
 496 
 497   void sync_and_suspend_one();
 498   void sync_and_suspend_all();
 499   void resume_one();
 500   void resume_all();
 501 
 502   // Deoptimize the given frame and deoptimize objects with optimizations based on escape analysis.
 503   bool deoptimize_objects_internal(JavaThread* deoptee, intptr_t* fr_id);
 504 
 505 public:
 506   // Revert ea based optimizations for given deoptee thread
 507   EscapeBarrier(JavaThread* calling_thread, JavaThread* deoptee_thread, bool barrier_active)
 508     : _calling_thread(calling_thread), _deoptee_thread(deoptee_thread), _barrier_active(barrier_active)


 509   {
 510     if (_barrier_active) sync_and_suspend_one();
 511   }
 512 
 513   // Revert ea based optimizations for all java threads
 514   EscapeBarrier(JavaThread* calling_thread, bool barrier_active)
 515     : _calling_thread(calling_thread), _deoptee_thread(NULL), _barrier_active(barrier_active)


 516   {
 517     if (_barrier_active) sync_and_suspend_all();
 518   }
 519 #else
 520 public:
 521   EscapeBarrier(JavaThread* calling_thread, JavaThread* deoptee_thread, bool barrier_active) { }
 522   EscapeBarrier(JavaThread* calling_thread, bool barrier_active) { }

 523 #endif // COMPILER2_OR_JVMCI
 524 
 525   // Deoptimize objects, i.e. reallocate and relock them. The target frames are deoptimized.
 526   // The methods return false iff at least one reallocation failed.
 527   bool deoptimize_objects(intptr_t* fr_id) { return deoptimize_objects_internal(deoptee_thread(), fr_id); }


 528   bool deoptimize_objects(int depth)                           NOT_COMPILER2_OR_JVMCI_RETURN_(true);
 529   // Find and deoptimize non escaping objects and the holding frames on all stacks.
 530   bool deoptimize_objects_all_threads()                        NOT_COMPILER2_OR_JVMCI_RETURN_(true);
 531 
 532   // A java thread was added to the list of threads
 533   static void thread_added(JavaThread* jt)                     NOT_COMPILER2_OR_JVMCI_RETURN;


 534 
 535 #if COMPILER2_OR_JVMCI
 536   // Returns true iff objects were reallocated and relocked because of access through JVMTI
 537   static bool objs_are_deoptimized(JavaThread* thread, intptr_t* fr_id);


 538 
 539   ~EscapeBarrier() {
 540     if (!barrier_active()) return;
 541     if (all_threads()) {
 542       resume_all();
 543     } else {
 544       resume_one();
 545     }
 546   }
 547 
 548 
 549   bool all_threads()    const { return _deoptee_thread == NULL; }            // Should revert optimizations for all threads.
 550   bool self_deopt()     const { return _calling_thread == _deoptee_thread; } // Current thread deoptimizes its own objects.
 551   bool barrier_active() const { return _barrier_active; }                    // Inactive barriers are created if no local objects can escape.
 552 
 553   // accessors
 554   JavaThread* calling_thread() const     { return _calling_thread; }
 555   JavaThread* deoptee_thread() const     { return _deoptee_thread; }
 556 #endif // COMPILER2_OR_JVMCI
 557 };


 457                                                Method* compiled_method,
 458                                                //outputs:
 459                                                uint& ret_this_trap_count,
 460                                                bool& ret_maybe_prior_trap,
 461                                                bool& ret_maybe_prior_recompile);
 462   // class loading support for uncommon trap
 463   static void load_class_by_index(const constantPoolHandle& constant_pool, int index, TRAPS);
 464   static void load_class_by_index(const constantPoolHandle& constant_pool, int index);
 465 
 466   static UnrollBlock* fetch_unroll_info_helper(JavaThread* thread, int exec_mode);
 467 
 468   static DeoptAction _unloaded_action; // == Action_reinterpret;
 469   static const char* _trap_reason_name[];
 470   static const char* _trap_action_name[];
 471 
 472   static juint _deoptimization_hist[Reason_LIMIT][1+Action_LIMIT][BC_CASE_LIMIT];
 473   // Note:  Histogram array size is 1-2 Kb.
 474 
 475  public:
 476   static void update_method_data_from_interpreter(MethodData* trap_mdo, int trap_bci, int reason);





 477 };
 478 
 479 // EscapeBarriers should be put on execution paths, where JVMTI agents can access object
 480 // references held by java threads.
 481 // They provide means to revert optimizations based on escape analysis in a well synchronized manner
 482 // just before local references escape through JVMTI.
 483 class EscapeBarrier : StackObj {
 484 #if COMPILER2_OR_JVMCI
 485   JavaThread* const _calling_thread;
 486   JavaThread* const _deoptee_thread;
 487   bool        const _barrier_active;
 488 
 489   static bool _deoptimizing_objects_for_all_threads;
 490   static bool _self_deoptimization_in_progress;
 491 
 492   void sync_and_suspend_one();
 493   void sync_and_suspend_all();
 494   void resume_one();
 495   void resume_all();
 496 
 497   // Deoptimize the given frame and deoptimize objects with optimizations based on escape analysis.
 498   bool deoptimize_objects_internal(JavaThread* deoptee, intptr_t* fr_id);
 499 
 500 public:
 501   // Revert ea based optimizations for given deoptee thread
 502   EscapeBarrier(JavaThread* calling_thread, JavaThread* deoptee_thread, bool barrier_active)
 503     : _calling_thread(calling_thread), _deoptee_thread(deoptee_thread),
 504       _barrier_active(barrier_active && (JVMCI_ONLY(UseJVMCICompiler) NOT_JVMCI(false)
 505                       COMPILER2_PRESENT(|| DoEscapeAnalysis)))
 506   {
 507     if (_barrier_active) sync_and_suspend_one();
 508   }
 509 
 510   // Revert ea based optimizations for all java threads
 511   EscapeBarrier(JavaThread* calling_thread, bool barrier_active)
 512     : _calling_thread(calling_thread), _deoptee_thread(NULL),
 513       _barrier_active(barrier_active && (JVMCI_ONLY(UseJVMCICompiler) NOT_JVMCI(false)
 514                       COMPILER2_PRESENT(|| DoEscapeAnalysis)))
 515   {
 516     if (_barrier_active) sync_and_suspend_all();
 517   }
 518 #else
 519 public:
 520   EscapeBarrier(JavaThread* calling_thread, JavaThread* deoptee_thread, bool barrier_active) { }
 521   EscapeBarrier(JavaThread* calling_thread, bool barrier_active) { }
 522   static bool deoptimizing_objects_for_all_threads() { return false; }
 523 #endif // COMPILER2_OR_JVMCI
 524 
 525   // Deoptimize objects, i.e. reallocate and relock them. The target frames are deoptimized.
 526   // The methods return false iff at least one reallocation failed.
 527   bool deoptimize_objects(intptr_t* fr_id) {
 528     return true COMPILER2_OR_JVMCI_PRESENT(&& deoptimize_objects_internal(deoptee_thread(), fr_id));
 529   }
 530   bool deoptimize_objects(int depth)                           NOT_COMPILER2_OR_JVMCI_RETURN_(true);
 531   // Find and deoptimize non escaping objects and the holding frames on all stacks.
 532   bool deoptimize_objects_all_threads()                        NOT_COMPILER2_OR_JVMCI_RETURN_(true);
 533 
 534   // A java thread was added to the list of threads
 535   static void thread_added(JavaThread* jt)                     NOT_COMPILER2_OR_JVMCI_RETURN;
 536   // A java thread was removed from the list of threads
 537   static void thread_removed(JavaThread* jt)                   NOT_COMPILER2_OR_JVMCI_RETURN;
 538 
 539 #if COMPILER2_OR_JVMCI
 540   // Returns true iff objects were reallocated and relocked because of access through JVMTI
 541   static bool objs_are_deoptimized(JavaThread* thread, intptr_t* fr_id);
 542 
 543   static bool deoptimizing_objects_for_all_threads() { return _deoptimizing_objects_for_all_threads; }
 544 
 545   ~EscapeBarrier() {
 546     if (!barrier_active()) return;
 547     if (all_threads()) {
 548       resume_all();
 549     } else {
 550       resume_one();
 551     }
 552   }
 553 
 554 
 555   bool all_threads()    const { return _deoptee_thread == NULL; }            // Should revert optimizations for all threads.
 556   bool self_deopt()     const { return _calling_thread == _deoptee_thread; } // Current thread deoptimizes its own objects.
 557   bool barrier_active() const { return _barrier_active; }                    // Inactive barriers are created if no local objects can escape.
 558 
 559   // accessors
 560   JavaThread* calling_thread() const     { return _calling_thread; }
 561   JavaThread* deoptee_thread() const     { return _deoptee_thread; }
 562 #endif // COMPILER2_OR_JVMCI
 563 };
< prev index next >