< prev index next >

src/java.base/share/classes/jdk/internal/vm/Continuation.java

Print this page
*** 44,20 ***
  /**
   * A one-shot delimited continuation.
   */
  public class Continuation {
      private static final Unsafe U = Unsafe.getUnsafe();
!     private static final boolean PRESERVE_EXTENT_LOCAL_CACHE;
      private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
      static {
          ContinuationSupport.ensureSupported();
          PreviewFeatures.ensureEnabled();
  
          StackChunk.init(); // ensure StackChunk class is initialized
  
!         String value = GetPropertyAction.privilegedGetProperty("jdk.preserveExtentLocalCache");
!         PRESERVE_EXTENT_LOCAL_CACHE = (value == null) || Boolean.parseBoolean(value);
      }
  
      private static final VarHandle MOUNTED;
  
      /** Reason for pinning */
--- 44,20 ---
  /**
   * A one-shot delimited continuation.
   */
  public class Continuation {
      private static final Unsafe U = Unsafe.getUnsafe();
!     private static final boolean PRESERVE_SCOPED_VALUE_CACHE;
      private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
      static {
          ContinuationSupport.ensureSupported();
          PreviewFeatures.ensureEnabled();
  
          StackChunk.init(); // ensure StackChunk class is initialized
  
!         String value = GetPropertyAction.privilegedGetProperty("jdk.preserveScopedValueCache");
!         PRESERVE_SCOPED_VALUE_CACHE = (value == null) || Boolean.parseBoolean(value);
      }
  
      private static final VarHandle MOUNTED;
  
      /** Reason for pinning */

*** 127,11 ***
      private boolean done;
      private volatile boolean mounted = false;
      private Object yieldInfo;
      private boolean preempted;
  
!     private Object[] extentLocalCache;
  
      /**
       * Constructs a continuation
       * @param scope the continuation's scope, used in yield
       * @param target the continuation's body
--- 127,11 ---
      private boolean done;
      private volatile boolean mounted = false;
      private Object yieldInfo;
      private boolean preempted;
  
!     private Object[] scopedValueCache;
  
      /**
       * Constructs a continuation
       * @param scope the continuation's scope, used in yield
       * @param target the continuation's body

*** 236,11 ***
       * Mounts and runs the continuation body. If suspended, continues it from the last suspend point.
       */
      public final void run() {
          while (true) {
              mount();
!             JLA.setExtentLocalCache(extentLocalCache);
  
              if (done)
                  throw new IllegalStateException("Continuation terminated");
  
              Thread t = currentCarrierThread();
--- 236,11 ---
       * Mounts and runs the continuation body. If suspended, continues it from the last suspend point.
       */
      public final void run() {
          while (true) {
              mount();
!             JLA.setScopedValueCache(scopedValueCache);
  
              if (done)
                  throw new IllegalStateException("Continuation terminated");
  
              Thread t = currentCarrierThread();

*** 268,16 ***
                          parent.child = null;
  
                      postYieldCleanup();
  
                      unmount();
!                     if (PRESERVE_EXTENT_LOCAL_CACHE) {
!                         extentLocalCache = JLA.extentLocalCache();
                      } else {
!                         extentLocalCache = null;
                      }
!                     JLA.setExtentLocalCache(null);
                  } catch (Throwable e) { e.printStackTrace(); System.exit(1); }
              }
              // we're now in the parent continuation
  
              assert yieldInfo == null || yieldInfo instanceof ContinuationScope;
--- 268,16 ---
                          parent.child = null;
  
                      postYieldCleanup();
  
                      unmount();
!                     if (PRESERVE_SCOPED_VALUE_CACHE) {
!                         scopedValueCache = JLA.scopedValueCache();
                      } else {
!                         scopedValueCache = null;
                      }
!                     JLA.setScopedValueCache(null);
                  } catch (Throwable e) { e.printStackTrace(); System.exit(1); }
              }
              // we're now in the parent continuation
  
              assert yieldInfo == null || yieldInfo instanceof ContinuationScope;
< prev index next >