diff --git a/modules/lwjgl/core/src/main/java/org/lwjgl/system/Callback.java b/modules/lwjgl/core/src/main/java/org/lwjgl/system/Callback.java index c08d43f693..8e7a2cf053 100644 --- a/modules/lwjgl/core/src/main/java/org/lwjgl/system/Callback.java +++ b/modules/lwjgl/core/src/main/java/org/lwjgl/system/Callback.java @@ -11,6 +11,7 @@ import java.lang.reflect.*; import java.util.concurrent.*; +import static org.lwjgl.system.APIUtil.*; import static org.lwjgl.system.Checks.*; import static org.lwjgl.system.MemoryStack.*; import static org.lwjgl.system.MemoryUtil.*; @@ -45,6 +46,8 @@ private interface ClosureRegistry { } if (code.get(0) == closure.address()) { + apiLog("Closure Registry: simple"); + // When the closure address matches the executable address, we don't have to maintain any mappings. // We can simply cast the executable address to ffi_closure. This is true on many platforms. CLOSURE_REGISTRY = new ClosureRegistry() { @@ -62,6 +65,8 @@ public FFIClosure remove(long executableAddress) { } }; } else { + apiLog("Closure Registry: ConcurrentHashMap"); + CLOSURE_REGISTRY = new ClosureRegistry() { private final ConcurrentHashMap map = new ConcurrentHashMap<>(); @@ -153,10 +158,10 @@ static long create(FFICIF cif, Object instance) { if (closure == null) { throw new OutOfMemoryError(); } + executableAddress = code.get(0); if (DEBUG_ALLOCATOR) { - MemoryManage.DebugAllocator.track(closure.address(), FFIClosure.SIZEOF); + MemoryManage.DebugAllocator.track(executableAddress, FFIClosure.SIZEOF); } - executableAddress = code.get(0); } long user_data = NewGlobalRef(instance);