31
31
import com .sun .max .ve .error .VEError ;
32
32
import com .sun .max .vm .actor .holder .ClassActor ;
33
33
import com .sun .max .vm .heap .Heap ;
34
-
34
+ import static com . sun . max . vm . intrinsics . MaxineIntrinsicIDs .*;
35
35
import static com .sun .cri .bytecode .Bytecodes .*;
36
36
37
- import com .sun .cri .bytecode .INTRINSIC ;
38
37
39
38
/**
40
39
* A {@link PageDirectByteBuffer} is a custom variant of {@link DirectByteBuffer} for use
41
40
* in VE for buffers that are multiples of the page size and have a lifetime that matches the VM.
42
41
* They are allocated from virtual memory, whereas {@link DirectByteBuffer} uses malloc
43
42
* memory and over-allocates in order to guarantee page alignment, resulting
44
- * in 3 pages allocated when 1 is requested.
45
- *
43
+ * in 3 pages allocated when 1 is requested.
44
+ *
46
45
* We invoke the private constructor provided for JNI_NewDirectByteBuffer using
47
46
* Maxine's {@link ALIAS} mechanism. No "cleaner" is set up for such buffers
48
47
* so they cannot be reclaimed.
49
- *
50
- *
48
+ *
49
+ *
51
50
* @author Mick Jordan
52
51
*
53
52
*/
@@ -56,12 +55,12 @@ public class PageDirectByteBuffer {
56
55
57
56
@ ALIAS (declaringClassName ="java.nio.DirectByteBuffer" , name ="<init>" )
58
57
private native void init (long addr , int cap );
59
-
58
+
60
59
@ INTRINSIC (UNSAFE_CAST ) static native PageDirectByteBuffer asPageDirectByteBuffer (Object obj );
61
60
@ INTRINSIC (UNSAFE_CAST ) public static native ByteBuffer asByteBuffer (Object obj );
62
-
61
+
63
62
private static ClassActor directByteBufferActor ;
64
-
63
+
65
64
static {
66
65
try {
67
66
directByteBufferActor = ClassActor .fromJava (Class .forName ("java.nio.DirectByteBuffer" ));
@@ -70,7 +69,7 @@ public class PageDirectByteBuffer {
70
69
ProgramError .unexpected ("can't load DirectByteBuffer" , ex );
71
70
}
72
71
}
73
-
72
+
74
73
public static ByteBuffer allocateDirect (int cap ) {
75
74
final ByteBuffer byteBuffer = asByteBuffer (Heap .createTuple (directByteBufferActor .dynamicHub ()));
76
75
PageDirectByteBuffer thisByteBuffer = asPageDirectByteBuffer (byteBuffer );
0 commit comments