Skip to content

Commit

Permalink
Renamings and fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhaeubl committed Aug 20, 2019
1 parent 96eb62e commit 0a9d49d
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ private CollectionInProgressError() {

private static class CollectionVMOperation extends NativeVMOperation {
protected CollectionVMOperation() {
super("Garbage collection", SystemEffect.CAUSES_SAFEPOINT);
super("Garbage collection", SystemEffect.SAFEPOINT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static class ObjectVisitorWalkerOperation extends JavaVMOperation implements Aut
private ObjectVisitor visitor = null;

ObjectVisitorWalkerOperation() {
super("ObjectVisitorWalker", SystemEffect.CAUSES_SAFEPOINT);
super("ObjectVisitorWalker", SystemEffect.SAFEPOINT);
}

ObjectVisitorWalkerOperation open(ObjectVisitor value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected static final class VerifyVMOperation extends JavaVMOperation {
private boolean result;

VerifyVMOperation(String message, HeapVerifierImpl verifier, HeapVerifier.Occasion occasion) {
super("HeapVerification", SystemEffect.CAUSES_SAFEPOINT);
super("HeapVerification", SystemEffect.SAFEPOINT);
this.message = message;
this.verifier = verifier;
this.occasion = occasion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected static final class MemoryWalkerVMOperation extends JavaVMOperation {
private boolean result;

protected MemoryWalkerVMOperation(MemoryWalker.Visitor memoryVisitor) {
super("MemoryWalkerImpl.visitMemory", SystemEffect.CAUSES_SAFEPOINT);
super("MemoryWalkerImpl.visitMemory", SystemEffect.SAFEPOINT);
this.memoryWalkerVisitor = memoryVisitor;
this.result = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import static com.oracle.svm.core.SubstrateOptions.MultiThreaded;
import static com.oracle.svm.core.SubstrateOptions.SpawnIsolates;
import static com.oracle.svm.core.SubstrateOptions.UseDedicatedVMThread;
import static com.oracle.svm.core.SubstrateOptions.UseDedicatedVMOperationThread;
import static com.oracle.svm.core.graal.nodes.WriteCurrentVMThreadNode.writeCurrentVMThread;
import static com.oracle.svm.core.graal.nodes.WriteHeapBaseNode.writeCurrentVMHeapBase;
import static com.oracle.svm.core.util.VMError.shouldNotReachHere;
Expand Down Expand Up @@ -207,8 +207,8 @@ private static int initializeIsolate() {
if (!success) {
return CEntryPointErrors.ISOLATE_INITIALIZATION_FAILED;
}
if (UseDedicatedVMThread.getValue()) {
VMOperationControl.startVmThread();
if (UseDedicatedVMOperationThread.getValue()) {
VMOperationControl.startVMOperationThread();
}
return CEntryPointErrors.NO_ERROR;
}
Expand Down Expand Up @@ -308,8 +308,8 @@ private static int tearDownIsolate() {
if (!JavaThreads.singleton().tearDownVM()) {
return CEntryPointErrors.UNSPECIFIED;
}
if (UseDedicatedVMThread.getValue()) {
VMOperationControl.stopVmThread();
if (UseDedicatedVMOperationThread.getValue()) {
VMOperationControl.stopVMOperationThread();
}
return Isolates.tearDownCurrent();
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
public static final HostedOptionKey<Boolean> EmitStringEncodingSubstitutions = new HostedOptionKey<>(true);

@Option(help = "Determines if VM operations should be executed in a dedicated thread.", type = OptionType.Debug)//
public static final HostedOptionKey<Boolean> UseDedicatedVMThread = new HostedOptionKey<Boolean>(false) {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
if (newValue) {
MultiThreaded.update(values, true);
}
}
};
public static final HostedOptionKey<Boolean> UseDedicatedVMOperationThread = new HostedOptionKey<>(false);

@Platforms(Platform.HOSTED_ONLY.class)
public static Predicate<String> makeFilter(String[] definedFilters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ private static final class DeoptSourceFrameOperation extends JavaVMOperation {
private IsolateThread thread;

DeoptSourceFrameOperation(Deoptimizer receiver, CodePointer pc, boolean ignoreNonDeoptimizable, IsolateThread thread) {
super("DeoptSourceFrameOperation", SystemEffect.CAUSES_SAFEPOINT);
super("DeoptSourceFrameOperation", SystemEffect.SAFEPOINT);
this.receiver = receiver;
this.pc = pc;
this.ignoreNonDeoptimizable = ignoreNonDeoptimizable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public class GCCause {

@Platforms(Platform.HOSTED_ONLY.class)
protected GCCause(String name) {
this.id = HostedGCCauseList.size();
this.name = name;
HostedGCCauseList.add(this);
synchronized (HostedGCCauseList) {
this.id = HostedGCCauseList.size();
this.name = name;
HostedGCCauseList.add(this);
}
}

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ public Object poll() {

@Substitute
public Object remove() throws InterruptedException {
VMOperation.guaranteeNotInProgress("Calling ReferenceQueue.remove() inside a VMOperation could block the VM thread and cause a deadlock.");
VMOperation.guaranteeNotInProgress("Calling ReferenceQueue.remove() inside a VMOperation could block the VM operation thread and cause a deadlock.");
return ReferenceWrapper.unwrap(feeble.remove());
}

@Substitute
public Object remove(long timeoutMillis) throws InterruptedException {
VMOperation.guaranteeNotInProgress("Calling ReferenceQueue.remove(long) inside a VMOperation could block the VM thread and cause a deadlock.");
VMOperation.guaranteeNotInProgress("Calling ReferenceQueue.remove(long) inside a VMOperation could block the VM operation thread and cause a deadlock.");
return ReferenceWrapper.unwrap(feeble.remove(timeoutMillis));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public VMMutex lock() {
* <li>Thread A calls mutex.lockNoTransition() and acquires the mutex</li>
* <li>Thread B calls mutex.lockNoTransition() and is blocked</li>
* <li>Thread A still holds the mutex but needs to trigger a GC. However, the safepoint can't be
* initiated as Thread A is still in the Java state but blocked in native code.</li>
* initiated as Thread B is still in the Java state but blocked in native code.</li>
* </ul>
*/
@Uninterruptible(reason = "Called from uninterruptible code.", callerMustBe = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private static boolean waitForTearDown() {
}

private static boolean isApplicationThread(IsolateThread isolateThread) {
return !VMOperationControl.isDedicatedVmThread(isolateThread);
return !VMOperationControl.isDedicatedVMOperationThread(isolateThread);
}

@SuppressFBWarnings(value = "NN", justification = "notifyAll is necessary for Java semantics, no shared state needs to be modified beforehand")
Expand Down Expand Up @@ -710,7 +710,7 @@ private static class FetchApplicationThreadsOperation extends JavaVMOperation {
private final List<Thread> list;

FetchApplicationThreadsOperation(List<Thread> list) {
super("FetchApplicationThreads", SystemEffect.DOES_NOT_CAUSE_SAFEPOINT);
super("FetchApplicationThreads", SystemEffect.NONE);
this.list = list;
}

Expand Down Expand Up @@ -742,7 +742,7 @@ private static class CountApplicationThreadsOperation extends JavaVMOperation {
private int count;

CountApplicationThreadsOperation(Log trace, AtomicBoolean printLaggards) {
super("VMThreadCounterOperation", SystemEffect.DOES_NOT_CAUSE_SAFEPOINT);
super("VMThreadCounterOperation", SystemEffect.NONE);
this.trace = trace;
this.printLaggards = printLaggards;
this.count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
* VM operation on the Java heap is preferable but not always possible.
*
* <p>
* Do <b>NOT</b> create singleton objects that might get enqueued by multiple threads. If
* {@linkplain SubstrateOptions#UseDedicatedVMThread} is enabled, this can result in race
* conditions.
* {@link JavaVMOperation} objects should be short lived and only enqueued/executed once. It is
* possible to reuse {@link JavaVMOperation} objects for multiple executions but it requires extra
* care: when a VM operation is enqueued, then it must be guaranteed that it is executed before it
* is enqueued again. Otherwise, this could result in various race conditions (especially if
* {@linkplain SubstrateOptions#UseDedicatedVMOperationThread} is enabled).
*/
public abstract class JavaVMOperation extends VMOperation implements VMOperationControl.JavaAllocationFreeQueue.Element<JavaVMOperation> {
protected IsolateThread queuingThread;
Expand Down Expand Up @@ -93,13 +95,13 @@ protected boolean hasWork() {

/** Convenience method for thunks that can be run by allocating a VMOperation. */
public static void enqueueBlockingSafepoint(String name, Thunk thunk) {
ThunkOperation vmOperation = new ThunkOperation(name, SystemEffect.CAUSES_SAFEPOINT, thunk);
ThunkOperation vmOperation = new ThunkOperation(name, SystemEffect.SAFEPOINT, thunk);
vmOperation.enqueue();
}

/** Convenience method for thunks that can be run by allocating a VMOperation. */
public static void enqueueBlockingNoSafepoint(String name, Thunk thunk) {
ThunkOperation vmOperation = new ThunkOperation(name, SystemEffect.DOES_NOT_CAUSE_SAFEPOINT, thunk);
ThunkOperation vmOperation = new ThunkOperation(name, SystemEffect.NONE, thunk);
vmOperation.enqueue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ private Master() {
* Have each of the threads (except myself!) stop at a safepoint.
*
* Locking {@linkplain VMThreads#THREAD_MUTEX} in this method is fine because the method is
* only executed by the VM thread. Therefore, no other thread can initiate a safepoint and
* Java allocations are disabled as well.
* only executed by the VM operation thread. Therefore, no other thread can initiate a
* safepoint and Java allocations are disabled as well.
*/
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, mayBeInlined = true, reason = "The safepoint logic must not allocate.")
protected boolean freeze(String reason) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public final String getName() {
}

public final boolean getCausesSafepoint() {
return systemEffect == SystemEffect.CAUSES_SAFEPOINT;
return systemEffect == SystemEffect.SAFEPOINT;
}

protected final void execute(NativeVMOperationData data) {
Expand Down Expand Up @@ -108,7 +108,11 @@ public static void guaranteeNotInProgress(String message) {
}
}

/** Used to determine if a VMOperation must be executed or if it can be skipped. */
/**
* Used to determine if a VM operation must be executed or if it can be skipped. Regardless of
* the {@linkplain SystemEffect} that was specified for the VM operation, this method might be
* called before or after a safepoint was initiated.
*/
protected boolean hasWork(@SuppressWarnings("unused") NativeVMOperationData data) {
return true;
}
Expand All @@ -125,7 +129,7 @@ protected boolean hasWork(@SuppressWarnings("unused") NativeVMOperationData data
protected abstract void operate(NativeVMOperationData data);

public enum SystemEffect {
DOES_NOT_CAUSE_SAFEPOINT,
CAUSES_SAFEPOINT
NONE,
SAFEPOINT
}
}
Loading

0 comments on commit 0a9d49d

Please sign in to comment.