Skip to content

Commit 8c1feaa

Browse files
committed
Be more aggressive preserving objects converted to native pointers.
1 parent 764a777 commit 8c1feaa

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/java/org/truffleruby/cext/ValueWrapperManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public synchronized long createNativeHandle(ValueWrapper wrapper) {
104104
}
105105
wrapper.setHandle(handleAddress);
106106
addToHandleMap(handleAddress, wrapper);
107-
context.getMarkingService().keepObject(wrapper);
108107
addFinalizer(wrapper, handlePointer);
109108
return handleAddress;
110109
}

src/main/java/org/truffleruby/cext/ValueWrapperMessageResolution.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,18 @@ public static abstract class ForeignAsPointerNode extends Node {
5353

5454
@CompilationFinal private RubyContext context;
5555
private final BranchProfile createHandleProfile = BranchProfile.create();
56+
private final BranchProfile taggedObjectProfile = BranchProfile.create();
5657

5758
protected long access(VirtualFrame frame, ValueWrapper wrapper) {
5859
long handle = wrapper.getHandle();
5960
if (handle == ValueWrapperManager.UNSET_HANDLE) {
6061
createHandleProfile.enter();
6162
handle = getContext().getValueWrapperManager().createNativeHandle(wrapper);
6263
}
64+
if (ValueWrapperManager.isTaggedObject(handle)) {
65+
taggedObjectProfile.enter();
66+
getContext().getMarkingService().keepObject(wrapper);
67+
}
6368
return handle;
6469
}
6570

0 commit comments

Comments
 (0)