Skip to content

Commit

Permalink
8306647: Implementation of Structured Concurrency (Preview)
Browse files Browse the repository at this point in the history
8306572: Implementation of Scoped Values (Preview)

Co-authored-by: Alan Bateman <alanb@openjdk.org>
Co-authored-by: Andrew Haley <aph@openjdk.org>
Reviewed-by: psandoz, dfuchs, mchung
  • Loading branch information
Alan Bateman and Andrew Haley committed Jun 7, 2023
1 parent a08c5cb commit f1c7afc
Show file tree
Hide file tree
Showing 36 changed files with 3,515 additions and 2,974 deletions.
1 change: 0 additions & 1 deletion make/conf/docs-modules.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ DOCS_MODULES= \
jdk.hotspot.agent \
jdk.httpserver \
jdk.jpackage \
jdk.incubator.concurrent \
jdk.incubator.vector \
jdk.jartool \
jdk.javadoc \
Expand Down
1 change: 0 additions & 1 deletion make/conf/module-loader-map.conf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ BOOT_MODULES= \
java.rmi \
java.security.sasl \
java.xml \
jdk.incubator.concurrent \
jdk.incubator.vector \
jdk.internal.vm.ci \
jdk.jfr \
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/vmSymbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
template(java_lang_StringBuilder, "java/lang/StringBuilder") \
template(java_lang_CharSequence, "java/lang/CharSequence") \
template(java_lang_SecurityManager, "java/lang/SecurityManager") \
template(java_lang_ScopedValue, "java/lang/ScopedValue") \
template(java_lang_ScopedValue_Carrier, "java/lang/ScopedValue$Carrier") \
template(java_security_AccessControlContext, "java/security/AccessControlContext") \
template(java_security_AccessController, "java/security/AccessController") \
template(executePrivileged_name, "executePrivileged") \
Expand Down Expand Up @@ -157,8 +159,6 @@
template(jdk_internal_loader_BuiltinClassLoader, "jdk/internal/loader/BuiltinClassLoader") \
template(jdk_internal_loader_ClassLoaders_AppClassLoader, "jdk/internal/loader/ClassLoaders$AppClassLoader") \
template(jdk_internal_loader_ClassLoaders_PlatformClassLoader, "jdk/internal/loader/ClassLoaders$PlatformClassLoader") \
template(jdk_incubator_concurrent_ScopedValue, "jdk/incubator/concurrent/ScopedValue") \
template(jdk_incubator_concurrent_ScopedValue_Carrier, "jdk/incubator/concurrent/ScopedValue$Carrier") \
\
/* Java runtime version access */ \
template(java_lang_VersionProps, "java/lang/VersionProps") \
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/prims/jvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ class ScopedValueBindingsResolver {
public:
InstanceKlass* Carrier_klass;
ScopedValueBindingsResolver(JavaThread* THREAD) {
Klass *k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_incubator_concurrent_ScopedValue_Carrier(), true, THREAD);
Klass *k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ScopedValue_Carrier(), true, THREAD);
Carrier_klass = InstanceKlass::cast(k);
}
};
Expand Down Expand Up @@ -1395,7 +1395,7 @@ JVM_ENTRY(jobject, JVM_FindScopedValueBindings(JNIEnv *env, jclass cls))
if (loc != -1) {
javaVFrame *frame = vfst.asJavaVFrame();
StackValueCollection* locals = frame->locals();
StackValue* head_sv = locals->at(loc); // jdk/incubator/concurrent/ScopedValue$Snapshot
StackValue* head_sv = locals->at(loc); // java/lang/ScopedValue$Snapshot
Handle result = head_sv->get_obj();
assert(!head_sv->obj_is_scalar_replaced(), "found scalar-replaced object");
if (result() != nullptr) {
Expand Down

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions src/java.base/share/classes/java/lang/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -2621,19 +2621,6 @@ public Object scopedValueBindings() {
return Thread.scopedValueBindings();
}

public Object findScopedValueBindings() {
return Thread.findScopedValueBindings();
}

public void setScopedValueBindings(Object bindings) {
Thread.setScopedValueBindings(bindings);
}

@ForceInline
public void ensureMaterializedForStackWalk(Object value) {
Thread.ensureMaterializedForStackWalk(value);
}

public Continuation getContinuation(Thread thread) {
return thread.getContinuation();
}
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
import java.util.HashMap;
import java.util.Objects;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.StructureViolationException;
import java.util.concurrent.locks.LockSupport;
import jdk.internal.event.ThreadSleepEvent;
import jdk.internal.misc.StructureViolationExceptions;
import jdk.internal.misc.TerminatingThreadLocal;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
Expand Down Expand Up @@ -321,7 +321,7 @@ void inheritScopedValueBindings(ThreadContainer container) {
// bindings established for running/calling an operation
Object bindings = snapshot.scopedValueBindings();
if (currentThread().scopedValueBindings != bindings) {
StructureViolationExceptions.throwException("Scoped value bindings have changed");
throw new StructureViolationException("Scoped value bindings have changed");
}

this.scopedValueBindings = bindings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -22,15 +22,18 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.incubator.concurrent;
package java.util.concurrent;

import jdk.internal.javac.PreviewFeature;

/**
* Thrown when a structure violation is detected.
*
* @see StructuredTaskScope#close()
*
* @since 19
* @since 21
*/
@PreviewFeature(feature = PreviewFeature.Feature.STRUCTURED_CONCURRENCY)
public final class StructureViolationException extends RuntimeException {
@java.io.Serial
private static final long serialVersionUID = -7705327650798235468L;
Expand Down

1 comment on commit f1c7afc

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.