Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Mar 25, 2024
1 parent 8da1df4 commit 06e76c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/main/java/org/truffleruby/cext/ValueWrapperManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public final class ValueWrapperManager {

private volatile HandleBlockWeakReference[] blockMap = new HandleBlockWeakReference[0];

public static HandleBlockHolder getBlockHolder(RubyContext context, RubyLanguage language) {
public static HandleBlockHolder getBlockHolder(RubyLanguage language) {
return language.getCurrentFiber().handleData;
}

@TruffleBoundary
public synchronized HandleBlock addToBlockMap(RubyContext context, RubyLanguage language) {
HandleBlock block = new HandleBlock(context, language, this);
public synchronized HandleBlock addToBlockMap(RubyLanguage language) {
HandleBlock block = new HandleBlock(language, this);
int blockIndex = block.getIndex();
HandleBlockWeakReference[] map = growMapIfRequired(blockMap, blockIndex);
blockMap = map;
Expand All @@ -80,9 +80,9 @@ public synchronized HandleBlock addToBlockMap(RubyContext context, RubyLanguage
}

@TruffleBoundary
public HandleBlock addToSharedBlockMap(RubyContext context, RubyLanguage language) {
public HandleBlock addToSharedBlockMap(RubyLanguage language) {
synchronized (language) {
HandleBlock block = new HandleBlock(context, language, this);
HandleBlock block = new HandleBlock(language, this);
int blockIndex = block.getIndex();
HandleBlockWeakReference[] map = growMapIfRequired(language.handleBlockSharedMap, blockIndex);
language.handleBlockSharedMap = map;
Expand Down Expand Up @@ -143,7 +143,7 @@ public void freeAllBlocksInMap() {
}
}

public void cleanup(RubyContext context, HandleBlockHolder holder) {
public void cleanup(HandleBlockHolder holder) {
holder.handleBlock = null;
}

Expand Down Expand Up @@ -205,7 +205,7 @@ public static final class HandleBlock {

@SuppressWarnings("unused") private Cleanable cleanable;

public HandleBlock(RubyContext context, RubyLanguage language, ValueWrapperManager manager) {
public HandleBlock(RubyLanguage language, ValueWrapperManager manager) {
HandleBlockAllocator allocator = language.handleBlockAllocator;
long base = allocator.getFreeBlock();
this.base = base;
Expand Down Expand Up @@ -287,7 +287,7 @@ static long allocateHandleOnKnownThread(Node node, ValueWrapper wrapper) {
wrapper,
getContext(node),
getLanguage(node),
getBlockHolder(getContext(node), getLanguage(node)),
getBlockHolder(getLanguage(node)),
false);
}

Expand All @@ -301,7 +301,7 @@ static long allocateSharedHandleOnKnownThread(Node node, ValueWrapper wrapper) {
wrapper,
getContext(node),
getLanguage(node),
getBlockHolder(getContext(node), getLanguage(node)),
getBlockHolder(getLanguage(node)),
true);
}

Expand Down Expand Up @@ -329,10 +329,10 @@ protected static long allocateHandle(Node node, ValueWrapper wrapper, RubyContex

if (block == null || block.isFull()) {
if (shared) {
block = context.getValueWrapperManager().addToSharedBlockMap(context, language);
block = context.getValueWrapperManager().addToSharedBlockMap(language);
holder.sharedHandleBlock = block;
} else {
block = context.getValueWrapperManager().addToBlockMap(context, language);
block = context.getValueWrapperManager().addToBlockMap(language);
holder.handleBlock = block;
}

Expand All @@ -346,8 +346,8 @@ protected static boolean isSharedObject(ValueWrapper wrapper) {
}

public static HandleBlock allocateNewBlock(RubyContext context, RubyLanguage language) {
HandleBlockHolder holder = getBlockHolder(context, language);
HandleBlock block = context.getValueWrapperManager().addToBlockMap(context, language);
HandleBlockHolder holder = getBlockHolder(language);
HandleBlock block = context.getValueWrapperManager().addToBlockMap(language);

holder.handleBlock = block;
return block;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/truffleruby/core/fiber/FiberManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public void start(RubyFiber fiber, Thread javaThread) {
}

public void cleanup(RubyFiber fiber, Thread javaThread) {
context.getValueWrapperManager().cleanup(context, fiber.handleData);
context.getValueWrapperManager().cleanup(fiber.handleData);

fiber.status = FiberStatus.TERMINATED;

Expand Down

0 comments on commit 06e76c6

Please sign in to comment.