This commit is contained in:
2026-07-07 00:22:32 +08:00
parent 620afef715
commit 74e4360d71
89 changed files with 1986 additions and 3374 deletions
@@ -20,7 +20,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.kne.debug.TimeDebugger;
import org.kne.membandboost.MembandBoost;
import jdk.internal.misc.Unsafe;
public class ByteBufferAllocator {
public ByteBufferAllocator(boolean isDirect) {
@@ -43,31 +42,8 @@ public class ByteBufferAllocator {
throw new InternalError();
return buf;
}
private static jdk.internal.misc.Unsafe usf;
private static Method meth;
static {
Class<?> name;
try {
name = Class.forName("jdk.internal.misc.Unsafe");
Field field = name.getDeclaredField("theUnsafe");
field.setAccessible(true);
usf= (Unsafe) field.get(null);
meth=name.getMethod("allocateUninitializedArray", Class.class,int.class);
} catch (java.lang.reflect.InaccessibleObjectException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
public static byte[] allocateUninitializedArray(int capacity) {
if(usf!=null) {
return (byte[]) usf.allocateUninitializedArray(byte.class, capacity);
}else {
return new byte[capacity];
}
}
public static ByteBuffer allocateHeap(int capacity) {
/*if(capacity<=2048) {
return MembandBoost.allocateUninitializedHeapBufferBlocked(capacity);
@@ -75,10 +51,6 @@ public class ByteBufferAllocator {
return MembandBoost.allocateUninitializedHeapBuffer(capacity);
//}
}
public static ByteBuffer allocateHeap0(int capacity) {
return ByteBuffer.wrap((byte[])allocateUninitializedArray(capacity)) ;
}
}