< prev index next >

src/hotspot/share/runtime/continuationFreezeThaw.cpp

Print this page

  57 #include "runtime/interfaceSupport.inline.hpp"
  58 #include "runtime/javaThread.inline.hpp"
  59 #include "runtime/jniHandles.inline.hpp"
  60 #include "runtime/keepStackGCProcessed.hpp"
  61 #include "runtime/mountUnmountDisabler.hpp"
  62 #include "runtime/objectMonitor.inline.hpp"
  63 #include "runtime/orderAccess.hpp"
  64 #include "runtime/prefetch.inline.hpp"
  65 #include "runtime/sharedRuntime.hpp"
  66 #include "runtime/smallRegisterMap.inline.hpp"
  67 #include "runtime/stackChunkFrameStream.inline.hpp"
  68 #include "runtime/stackFrameStream.inline.hpp"
  69 #include "runtime/stackOverflow.hpp"
  70 #include "runtime/stackWatermarkSet.inline.hpp"
  71 #include "runtime/vframe.inline.hpp"
  72 #include "runtime/vframe_hp.hpp"
  73 #include "utilities/debug.hpp"
  74 #include "utilities/exceptions.hpp"
  75 #include "utilities/macros.hpp"
  76 #include "utilities/vmError.hpp"



  77 #if INCLUDE_ZGC
  78 #include "gc/z/zStackChunkGCData.inline.hpp"
  79 #endif
  80 #if INCLUDE_JFR
  81 #include "jfr/jfr.inline.hpp"
  82 #endif
  83 #ifdef COMPILER1
  84 #include "c1/c1_Runtime1.hpp"
  85 #endif
  86 #ifdef COMPILER2
  87 #include "opto/runtime.hpp"
  88 #endif
  89 
  90 /*
  91  * This file contains the implementation of continuation freezing (yield) and thawing (run).
  92  *
  93  * This code is very latency-critical and very hot. An ordinary and well-behaved server application
  94  * would likely call these operations many thousands of times per second second, on every core.
  95  *
  96  * Freeze might be called every time the application performs any I/O operation, every time it

1597   assert(chunk->max_thawing_size() == 0, "");
1598   assert(chunk->pc() == nullptr, "");
1599   assert(chunk->is_empty(), "");
1600   assert(chunk->flags() == 0, "");
1601   assert(chunk->is_gc_mode() == false, "");
1602   assert(chunk->lockstack_size() == 0, "");
1603 
1604   // fields are uninitialized
1605   chunk->set_parent_access<IS_DEST_UNINITIALIZED>(_cont.last_nonempty_chunk());
1606   chunk->set_cont_access<IS_DEST_UNINITIALIZED>(_cont.continuation());
1607 
1608 #if INCLUDE_ZGC
1609   if (UseZGC) {
1610     ZStackChunkGCData::initialize(chunk);
1611     assert(!chunk->requires_barriers(), "ZGC always allocates in the young generation");
1612     _barriers = false;
1613   } else
1614 #endif
1615 #if INCLUDE_SHENANDOAHGC
1616   if (UseShenandoahGC) {

1617     _barriers = chunk->requires_barriers();
1618   } else
1619 #endif
1620   {
1621     if (!allocator.took_slow_path()) {
1622       // Guaranteed to be in young gen / newly allocated memory
1623       assert(!chunk->requires_barriers(), "Unfamiliar GC requires barriers on TLAB allocation");
1624       _barriers = false;
1625     } else {
1626       // Some GCs could put direct allocations in old gen for slow-path
1627       // allocations; need to explicitly check if that was the case.
1628       _barriers = chunk->requires_barriers();
1629     }
1630   }
1631 
1632   if (_barriers) {
1633     log_develop_trace(continuations)("allocation requires barriers");
1634   }
1635 
1636   assert(chunk->parent() == nullptr || chunk->parent()->is_stackChunk(), "");

  57 #include "runtime/interfaceSupport.inline.hpp"
  58 #include "runtime/javaThread.inline.hpp"
  59 #include "runtime/jniHandles.inline.hpp"
  60 #include "runtime/keepStackGCProcessed.hpp"
  61 #include "runtime/mountUnmountDisabler.hpp"
  62 #include "runtime/objectMonitor.inline.hpp"
  63 #include "runtime/orderAccess.hpp"
  64 #include "runtime/prefetch.inline.hpp"
  65 #include "runtime/sharedRuntime.hpp"
  66 #include "runtime/smallRegisterMap.inline.hpp"
  67 #include "runtime/stackChunkFrameStream.inline.hpp"
  68 #include "runtime/stackFrameStream.inline.hpp"
  69 #include "runtime/stackOverflow.hpp"
  70 #include "runtime/stackWatermarkSet.inline.hpp"
  71 #include "runtime/vframe.inline.hpp"
  72 #include "runtime/vframe_hp.hpp"
  73 #include "utilities/debug.hpp"
  74 #include "utilities/exceptions.hpp"
  75 #include "utilities/macros.hpp"
  76 #include "utilities/vmError.hpp"
  77 #if INCLUDE_SHENANDOAHGC
  78 #include "gc/shenandoah/shenandoahStackChunkGCData.inline.hpp"
  79 #endif
  80 #if INCLUDE_ZGC
  81 #include "gc/z/zStackChunkGCData.inline.hpp"
  82 #endif
  83 #if INCLUDE_JFR
  84 #include "jfr/jfr.inline.hpp"
  85 #endif
  86 #ifdef COMPILER1
  87 #include "c1/c1_Runtime1.hpp"
  88 #endif
  89 #ifdef COMPILER2
  90 #include "opto/runtime.hpp"
  91 #endif
  92 
  93 /*
  94  * This file contains the implementation of continuation freezing (yield) and thawing (run).
  95  *
  96  * This code is very latency-critical and very hot. An ordinary and well-behaved server application
  97  * would likely call these operations many thousands of times per second second, on every core.
  98  *
  99  * Freeze might be called every time the application performs any I/O operation, every time it

1600   assert(chunk->max_thawing_size() == 0, "");
1601   assert(chunk->pc() == nullptr, "");
1602   assert(chunk->is_empty(), "");
1603   assert(chunk->flags() == 0, "");
1604   assert(chunk->is_gc_mode() == false, "");
1605   assert(chunk->lockstack_size() == 0, "");
1606 
1607   // fields are uninitialized
1608   chunk->set_parent_access<IS_DEST_UNINITIALIZED>(_cont.last_nonempty_chunk());
1609   chunk->set_cont_access<IS_DEST_UNINITIALIZED>(_cont.continuation());
1610 
1611 #if INCLUDE_ZGC
1612   if (UseZGC) {
1613     ZStackChunkGCData::initialize(chunk);
1614     assert(!chunk->requires_barriers(), "ZGC always allocates in the young generation");
1615     _barriers = false;
1616   } else
1617 #endif
1618 #if INCLUDE_SHENANDOAHGC
1619   if (UseShenandoahGC) {
1620     ShenandoahStackChunkGCData::initialize(chunk);
1621     _barriers = chunk->requires_barriers();
1622   } else
1623 #endif
1624   {
1625     if (!allocator.took_slow_path()) {
1626       // Guaranteed to be in young gen / newly allocated memory
1627       assert(!chunk->requires_barriers(), "Unfamiliar GC requires barriers on TLAB allocation");
1628       _barriers = false;
1629     } else {
1630       // Some GCs could put direct allocations in old gen for slow-path
1631       // allocations; need to explicitly check if that was the case.
1632       _barriers = chunk->requires_barriers();
1633     }
1634   }
1635 
1636   if (_barriers) {
1637     log_develop_trace(continuations)("allocation requires barriers");
1638   }
1639 
1640   assert(chunk->parent() == nullptr || chunk->parent()->is_stackChunk(), "");
< prev index next >