Skip to content

Commit

Permalink
Merge PR #389: Remember object slot being allocated, and use onSpinWa…
Browse files Browse the repository at this point in the history
…it to resolve old todo
  • Loading branch information
smarr committed Oct 12, 2022
2 parents 17014c8 + b4ef8df commit 591172d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/som/interpreter/nodes/dispatch/ClassSlotAccessNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;

import som.compiler.MixinDefinition;
import som.compiler.MixinDefinition.SlotDefinition;
import som.interpreter.Invokable;
import som.interpreter.SArguments;
import som.interpreter.nodes.InstantiationNode.ClassInstantiationNode;
import som.interpreter.nodes.InstantiationNodeFactory.ClassInstantiationNodeGen;
import som.interpreter.objectstorage.ObjectTransitionSafepoint;
import som.vm.VmSettings;
import som.vm.constants.Nil;
import som.vmobjects.SClass;
import som.vmobjects.SObject;
Expand All @@ -30,7 +34,8 @@
public final class ClassSlotAccessNode extends CachedSlotRead {
private final MixinDefinition mixinDef;
private final SlotDefinition slotDef;
private final boolean objectSlotIsAllocated;

@CompilationFinal private boolean objectSlotIsAllocated;

@Child protected DirectCallNode superclassAndMixinResolver;
@Child protected ClassInstantiationNode instantiation;
Expand Down Expand Up @@ -70,6 +75,7 @@ public SClass read(final SObject rcvr) {
if (!objectSlotIsAllocated) {
CompilerDirectives.transferToInterpreterAndInvalidate();
ObjectTransitionSafepoint.INSTANCE.ensureSlotAllocatedToAvoidDeadlock(rcvr, slotDef);
objectSlotIsAllocated = true;
}

synchronized (rcvr) {
Expand Down
2 changes: 1 addition & 1 deletion src/som/vmobjects/SClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public ObjectLayout getLayoutForInstancesToUpdateObject() {
// Class loading can take considerable time and might be problematic here.
// But seems better than running into a stack overflow in other places.
while (!layout.isValid()) {
// TODO(JDK9): add call to Thread.onSpinWait() once moving to JDK9 support
Thread.onSpinWait();
layout = instanceClassGroup.getInstanceLayout();
}

Expand Down

1 comment on commit 591172d

@rebenchdb
Copy link

@rebenchdb rebenchdb bot commented on 591172d Oct 12, 2022

Choose a reason for hiding this comment

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

Performance changes for 17014c8...591172d

Summary Over All Benchmarks
Summary Over All Benchmarks

Full Report

Please sign in to comment.