sun.hotspot.code.CodeBlob Java Examples

The following examples show how to use sun.hotspot.code.CodeBlob. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GetCodeHeapEntriesTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void test() {
    System.out.printf("type %s%n", type);
    long addr = WHITE_BOX.allocateCodeBlob(SIZE, type.id);
    Asserts.assertNE(0, addr, "allocation failed");
    CodeBlob[] blobs = CodeBlob.getCodeBlobs(type);
    Asserts.assertNotNull(blobs);
    CodeBlob blob = Arrays.stream(blobs)
                          .filter(GetCodeHeapEntriesTest::filter)
                          .findAny()
                          .get();
    Asserts.assertNotNull(blob);
    Asserts.assertEQ(blob.code_blob_type, type);
    Asserts.assertGTE(blob.size, SIZE);

    WHITE_BOX.freeCodeBlob(addr);
    blobs = CodeBlob.getCodeBlobs(type);
    long count = Arrays.stream(blobs)
                       .filter(GetCodeHeapEntriesTest::filter)
                       .count();
    Asserts.assertEQ(0L, count);
}
 
Example #2
Source File: OverflowCodeCacheTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void test() {
    System.out.printf("type %s%n", type);
    System.out.println("allocating till possible...");
    ArrayList<Long> blobs = new ArrayList<>();
    int compilationActivityMode = -1;
    try {
        long addr;
        int size = (int) (getHeapSize() >> 7);
        while ((addr = WHITE_BOX.allocateCodeBlob(size, type.id)) != 0) {
            blobs.add(addr);

            BlobType actualType = CodeBlob.getCodeBlob(addr).code_blob_type;
            if (actualType != type) {
                // check we got allowed overflow handling
                Asserts.assertTrue(type.allowTypeWhenOverflow(actualType),
                        type + " doesn't allow using " + actualType + " when overflow");
            }
        }
        /* now, remember compilationActivityMode to check it later, after freeing, since we
           possibly have no free cache for futher work */
        compilationActivityMode = WHITE_BOX.getCompilationActivityMode();
    } finally {
        for (Long blob : blobs) {
            WHITE_BOX.freeCodeBlob(blob);
        }
    }
    Asserts.assertNotEquals(compilationActivityMode, 1 /* run_compilation*/,
            "Compilation must be disabled when CodeCache(CodeHeap) overflows");
}
 
Example #3
Source File: TestCodeSweeper.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static final long getHeaderSize(BlobType btype) {
    long addr = WHITE_BOX.allocateCodeBlob(0, btype.id);
    int size = CodeBlob.getCodeBlob(addr).size;
    WHITE_BOX.freeCodeBlob(addr);
    return size;
}
 
Example #4
Source File: TestCodeSweeper.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static final long getHeaderSize(BlobType btype) {
    long addr = WHITE_BOX.allocateCodeBlob(0, btype.id);
    int size = CodeBlob.getCodeBlob(addr).size;
    WHITE_BOX.freeCodeBlob(addr);
    return size;
}
 
Example #5
Source File: GetCodeHeapEntriesTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static boolean filter(CodeBlob blob) {
    if (blob == null) {
        return false;
    }
    return DUMMY_NAME.equals(blob.name);
}
 
Example #6
Source File: CodeCacheUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static final long getHeaderSize(BlobType btype) {
    long addr = WB.allocateCodeBlob(0, btype.id);
    int size = CodeBlob.getCodeBlob(addr).size;
    WB.freeCodeBlob(addr);
    return size;
}