src/share/vm/runtime/safepoint.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File

## src/share/vm/runtime/safepoint.cpp

Print this page

      34 #include "interpreter/interpreter.hpp"
      35 #include "memory/resourceArea.hpp"
      36 #include "memory/universe.inline.hpp"
      37 #include "oops/oop.inline.hpp"
      38 #include "oops/symbol.hpp"
      39 #include "runtime/compilationPolicy.hpp"
      40 #include "runtime/deoptimization.hpp"
      41 #include "runtime/frame.inline.hpp"
      42 #include "runtime/interfaceSupport.hpp"
      43 #include "runtime/mutexLocker.hpp"
      44 #include "runtime/orderAccess.inline.hpp"
      45 #include "runtime/osThread.hpp"
      46 #include "runtime/safepoint.hpp"
      47 #include "runtime/signature.hpp"
      48 #include "runtime/stubCodeGenerator.hpp"
      49 #include "runtime/stubRoutines.hpp"
      50 #include "runtime/sweeper.hpp"
      51 #include "runtime/synchronizer.hpp"
      52 #include "runtime/thread.inline.hpp"
      53 #include "services/runtimeService.hpp"

      54 #include "utilities/events.hpp"
      55 #include "utilities/macros.hpp"
      56 #ifdef TARGET_ARCH_x86
      57 # include "nativeInst_x86.hpp"
      58 # include "vmreg_x86.inline.hpp"
      59 #endif
      60 #ifdef TARGET_ARCH_sparc
      61 # include "nativeInst_sparc.hpp"
      62 # include "vmreg_sparc.inline.hpp"
      63 #endif
      64 #ifdef TARGET_ARCH_zero
      65 # include "nativeInst_zero.hpp"
      66 # include "vmreg_zero.inline.hpp"
      67 #endif
      68 #ifdef TARGET_ARCH_arm
      69 # include "nativeInst_arm.hpp"
      70 # include "vmreg_arm.inline.hpp"
      71 #endif
      72 #ifdef TARGET_ARCH_ppc
      73 # include "nativeInst_ppc.hpp"
     485   }
     486 #if INCLUDE_ALL_GCS
     487   // If there are any concurrent GC threads resume them.
     488   if (UseConcMarkSweepGC) {
     489     ConcurrentMarkSweepThread::desynchronize(false);
     490   } else if (UseG1GC) {
     491     SuspendibleThreadSet::desynchronize();
     492   }
     493 #endif // INCLUDE_ALL_GCS
     494   // record this time so VMThread can keep track how much time has elasped
     495   // since last safepoint.
     496   _end_of_last_safepoint = os::javaTimeMillis();
     497 }
     498
     499 bool SafepointSynchronize::is_cleanup_needed() {
     500   // Need a safepoint if some inline cache buffers is non-empty
     501   if (!InlineCacheBuffer::is_empty()) return true;
     502   return false;
     503 }
     504
     505
     506
     507 // Various cleaning tasks that should be done periodically at safepoints
     508 void SafepointSynchronize::do_cleanup_tasks() {
     509   {
     510     TraceTime t1("deflating idle monitors", TraceSafepointCleanupTime);
     511     ObjectSynchronizer::deflate_idle_monitors();
     512   }
     513
     514   {
     515     TraceTime t2("updating inline caches", TraceSafepointCleanupTime);
     516     InlineCacheBuffer::update_inline_caches();
     517   }

     518   {
     519     TraceTime t3("compilation policy safepoint handler", TraceSafepointCleanupTime);
     520     CompilationPolicy::policy()->do_safepoint_work();
     521   }
     522
     523   {
     524     TraceTime t4("mark nmethods", TraceSafepointCleanupTime);
     525     NMethodSweeper::mark_active_nmethods();
     526   }
     527

     528   if (SymbolTable::needs_rehashing()) {
     529     TraceTime t5("rehashing symbol table", TraceSafepointCleanupTime);
     530     SymbolTable::rehash_table();
     531   }
     532
     533   if (StringTable::needs_rehashing()) {
     534     TraceTime t6("rehashing string table", TraceSafepointCleanupTime);
     535     StringTable::rehash_table();
     536   }
     537
     538   // rotate log files?
     539   if (UseGCLogFileRotation) {
     540     gclog_or_tty->rotate_log(false);
     541   }
     542
     543   {
     544     // CMS delays purging the CLDG until the beginning of the next safepoint and to
     545     // make sure concurrent sweep is done
     546     TraceTime t7("purging class loader data graph", TraceSafepointCleanupTime);
     547     ClassLoaderDataGraph::purge_if_needed();
     548   }
     549 }
     550
     551
     552 bool SafepointSynchronize::safepoint_safe(JavaThread *thread, JavaThreadState state) {
     553   switch(state) {
     554   case _thread_in_native:
      34 #include "interpreter/interpreter.hpp"
      35 #include "memory/resourceArea.hpp"
      36 #include "memory/universe.inline.hpp"
      37 #include "oops/oop.inline.hpp"
      38 #include "oops/symbol.hpp"
      39 #include "runtime/compilationPolicy.hpp"
      40 #include "runtime/deoptimization.hpp"
      41 #include "runtime/frame.inline.hpp"
      42 #include "runtime/interfaceSupport.hpp"
      43 #include "runtime/mutexLocker.hpp"
      44 #include "runtime/orderAccess.inline.hpp"
      45 #include "runtime/osThread.hpp"
      46 #include "runtime/safepoint.hpp"
      47 #include "runtime/signature.hpp"
      48 #include "runtime/stubCodeGenerator.hpp"
      49 #include "runtime/stubRoutines.hpp"
      50 #include "runtime/sweeper.hpp"
      51 #include "runtime/synchronizer.hpp"
      52 #include "runtime/thread.inline.hpp"
      53 #include "services/runtimeService.hpp"
      54 #include "trace/tracing.hpp"
      55 #include "utilities/events.hpp"
      56 #include "utilities/macros.hpp"
      57 #ifdef TARGET_ARCH_x86
      58 # include "nativeInst_x86.hpp"
      59 # include "vmreg_x86.inline.hpp"
      60 #endif
      61 #ifdef TARGET_ARCH_sparc
      62 # include "nativeInst_sparc.hpp"
      63 # include "vmreg_sparc.inline.hpp"
      64 #endif
      65 #ifdef TARGET_ARCH_zero
      66 # include "nativeInst_zero.hpp"
      67 # include "vmreg_zero.inline.hpp"
      68 #endif
      69 #ifdef TARGET_ARCH_arm
      70 # include "nativeInst_arm.hpp"
      71 # include "vmreg_arm.inline.hpp"
      72 #endif
      73 #ifdef TARGET_ARCH_ppc
      74 # include "nativeInst_ppc.hpp"
     486   }
     487 #if INCLUDE_ALL_GCS
     488   // If there are any concurrent GC threads resume them.
     489   if (UseConcMarkSweepGC) {
     490     ConcurrentMarkSweepThread::desynchronize(false);
     491   } else if (UseG1GC) {
     492     SuspendibleThreadSet::desynchronize();
     493   }
     494 #endif // INCLUDE_ALL_GCS
     495   // record this time so VMThread can keep track how much time has elasped
     496   // since last safepoint.
     497   _end_of_last_safepoint = os::javaTimeMillis();
     498 }
     499
     500 bool SafepointSynchronize::is_cleanup_needed() {
     501   // Need a safepoint if some inline cache buffers is non-empty
     502   if (!InlineCacheBuffer::is_empty()) return true;
     503   return false;
     504 }
     505

     506 // Various cleaning tasks that should be done periodically at safepoints
     507 void SafepointSynchronize::do_cleanup_tasks() {
     508   {
     509     TraceTime t1("deflating idle monitors", TraceSafepointCleanupTime);
     510     ObjectSynchronizer::deflate_idle_monitors();
     511   }
     512
     513   {
     514     TraceTime t2("updating inline caches", TraceSafepointCleanupTime);
     515     InlineCacheBuffer::update_inline_caches();
     516   }
     517
     518   {
     519     TraceTime t3("compilation policy safepoint handler", TraceSafepointCleanupTime);
     520     CompilationPolicy::policy()->do_safepoint_work();
     521   }
     522
     523   {
     524     TraceTime t4("mark nmethods", TraceSafepointCleanupTime);
     525     NMethodSweeper::mark_active_nmethods();
     526   }
     527
     528 //#define PRINT_RESIZE
     529
     530   if (HashtablesResizeSymbolTable == true) {
     531     ResizeHashtableStats stats;
     532     {
     533       TraceTime t5("resize_table for SymbolTable", TraceSafepointCleanupTime);
     534       EventSymbolTableResize event;
     535       stats = SymbolTable::the_table()->resize_table(SymbolTable_lock,
     536                                                       HashtablesResizeSymbolTableTriggerLoadFactor,
     537                                                         HashtablesResizeSymbolTableDesiredLoadFactor);
     538       if (stats.resized == true) {
     539         if (PrintSymbolTableStatisticsTimeline == true) {
     540           tty->print("-------------------------------------------------------------------------------\n");
     541           tty->print("SymbolTable resized from %d to %d\n", stats.old_size, stats.new_size);
     542           tty->print("-------------------------------------------------------------------------------\n");
     543         }
     544         if (event.should_commit() == true) {
     545           event.set_oldSize(stats.old_size);
     546           event.set_newSize(stats.new_size);
     547           event.commit();
     548         }
     549       }
     550     }
     551   }
     552
     553   if (HashtablesResizeStringTable == true) {
     554     ResizeHashtableStats stats;
     555     {
     556       TraceTime t6("resize_table for StringTable", TraceSafepointCleanupTime);
     557       EventStringTableResize event;
     558       stats = StringTable::the_table()->resize_table(StringTable_lock,
     559                                                       HashtablesResizeStringTableTriggerLoadFactor,
     560                                                         HashtablesResizeStringTableDesiredLoadFactor);
     561       if (stats.resized == true) {
     562         if (PrintStringTableStatisticsTimeline == true) {
     563           tty->print("-------------------------------------------------------------------------------\n");
     564           tty->print("StringTable resized from %d to %d\n", stats.old_size, stats.new_size);
     565           tty->print("-------------------------------------------------------------------------------\n");
     566         }
     567         if (event.should_commit() == true) {
     568           event.set_oldSize(stats.old_size);
     569           event.set_newSize(stats.new_size);
     570           event.commit();
     571         }
     572       }
     573     }
     574   }
     575
     576   if (HashtablesResizeSystemDictionary == true) {
     577     ResizeHashtableStats stats;
     578     {
     579       TraceTime t6("resize_table for SystemDictionary", TraceSafepointCleanupTime);
     580       EventSystemDictionaryResize event;
     581       stats = SystemDictionary::the_table()->resize_table(SystemDictionary_lock,
     582                                                             HashtablesResizeSystemDictionaryTriggerLoadFactor,
     583                                                               HashtablesResizeSystemDictionaryDesiredLoadFactor);
     584       if (stats.resized == true) {
     585         if (PrintStringTableStatisticsTimeline == true) {
     586           tty->print("-------------------------------------------------------------------------------\n");
     587           tty->print("SystemDictionary resized from %d to %d\n", stats.old_size, stats.new_size);
     588           tty->print("-------------------------------------------------------------------------------\n");
     589         }
     590         if (event.should_commit() == true) {
     591           event.set_oldSize(stats.old_size);
     592           event.set_newSize(stats.new_size);
     593           event.commit();
     594         }
     595       }
     596     }
     597   }
     598
     599   {
     600     bool wants = false;
     601     bool reported = false;
     602     static int skip = 1000;
     603     if (PrintSymbolTableStatisticsTimeline == true) {
     604       wants = true;
     605       static int number_of_entries = 0;
     606       if (SymbolTable::the_table()->number_of_entries() > (skip+number_of_entries)) {
     607         number_of_entries = SymbolTable::the_table()->number_of_entries();
     608         tty->print("SymbolTable      %9d:%6.3f:%lld\n", number_of_entries, (float)number_of_entries/(float)SymbolTable::the_table()->table_size(), os::javaTimeNanos());
     609         reported = true;
     610       }
     611     }
     612     if (PrintStringTableStatisticsTimeline == true) {
     613       wants = true;
     614       static int number_of_entries = 0;
     615       if (StringTable::the_table()->number_of_entries() > (skip+number_of_entries)) {
     616         number_of_entries = StringTable::the_table()->number_of_entries();
     617         tty->print("StringTable      %9d:%6.3f:%lld\n", number_of_entries, (float)number_of_entries/(float)SymbolTable::the_table()->table_size(), os::javaTimeNanos());
     618         reported = true;
     619       }
     620     }
     621     if (PrintSystemDictionaryStatisticsTimeline == true) {
     622       wants = true;
     623       static int number_of_entries = 0;
     624       if (SystemDictionary::the_table()->number_of_entries() > (skip+number_of_entries)) {
     625         number_of_entries = SystemDictionary::the_table()->number_of_entries();
     626         tty->print("SystemDictionary %9d:%6.3f:%lld\n", number_of_entries, (float)number_of_entries/(float)SymbolTable::the_table()->table_size(), os::javaTimeNanos());
     627         reported = true;
     628       }
     629     }
     630     if ((wants == true) && (reported == false)) {
     631       tty->print(".\n");
     632     }
     633   }
     634
     635   if (SymbolTable::needs_rehashing()) {
     636     TraceTime t8("rehashing symbol table", TraceSafepointCleanupTime);
     637     SymbolTable::rehash_table();
     638   }
     639
     640   if (StringTable::needs_rehashing()) {
     641     TraceTime t9("rehashing string table", TraceSafepointCleanupTime);
     642     StringTable::rehash_table();
     643   }
     644
     645   // rotate log files?
     646   if (UseGCLogFileRotation) {
     647     gclog_or_tty->rotate_log(false);
     648   }
     649
     650   {
     651     // CMS delays purging the CLDG until the beginning of the next safepoint and to
     652     // make sure concurrent sweep is done
     653     TraceTime t7("purging class loader data graph", TraceSafepointCleanupTime);
     654     ClassLoaderDataGraph::purge_if_needed();
     655   }
     656 }
     657
     658
     659 bool SafepointSynchronize::safepoint_safe(JavaThread *thread, JavaThreadState state) {
     660   switch(state) {
     661   case _thread_in_native:

src/share/vm/runtime/safepoint.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File