當前位置: 首頁>>代碼示例>>Java>>正文


Java ResolvedJavaMethod.getCode方法代碼示例

本文整理匯總了Java中jdk.vm.ci.meta.ResolvedJavaMethod.getCode方法的典型用法代碼示例。如果您正苦於以下問題:Java ResolvedJavaMethod.getCode方法的具體用法?Java ResolvedJavaMethod.getCode怎麽用?Java ResolvedJavaMethod.getCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jdk.vm.ci.meta.ResolvedJavaMethod的用法示例。


在下文中一共展示了ResolvedJavaMethod.getCode方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: beginGroup

import jdk.vm.ci.meta.ResolvedJavaMethod; //導入方法依賴的package包/類
/**
 * Starts a new group of graphs with the given name, short name and method byte code index (BCI)
 * as properties.
 */
@Override
public void beginGroup(DebugContext debug, String name, String shortName, ResolvedJavaMethod method, int bci, Map<Object, Object> properties) {
    beginGroup();
    beginProperties();
    printProperty("name", name);
    if (properties != null) {
        for (Entry<Object, Object> entry : properties.entrySet()) {
            printProperty(entry.getKey().toString(), entry.getValue().toString());
        }
    }
    endProperties();
    beginMethod(name, shortName, bci);
    if (method != null && method.getCode() != null) {
        printBytecodes(new BytecodeDisassembler(false).disassemble(method));
    }
    endMethod();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:IdealGraphPrinter.java

示例2: tryFastInlineAccessor

import jdk.vm.ci.meta.ResolvedJavaMethod; //導入方法依賴的package包/類
/**
 * Tries to inline {@code targetMethod} if it is an instance field accessor. This avoids the
 * overhead of creating and using a nested {@link BytecodeParser} object.
 */
private boolean tryFastInlineAccessor(ValueNode[] args, ResolvedJavaMethod targetMethod) {
    byte[] bytecode = targetMethod.getCode();
    if (bytecode != null && bytecode.length == ACCESSOR_BYTECODE_LENGTH &&
                    Bytes.beU1(bytecode, 0) == ALOAD_0 &&
                    Bytes.beU1(bytecode, 1) == GETFIELD) {
        int b4 = Bytes.beU1(bytecode, 4);
        if (b4 >= IRETURN && b4 <= ARETURN) {
            int cpi = Bytes.beU2(bytecode, 2);
            JavaField field = targetMethod.getConstantPool().lookupField(cpi, targetMethod, GETFIELD);
            if (field instanceof ResolvedJavaField) {
                ValueNode receiver = invocationPluginReceiver.init(targetMethod, args).get();
                ResolvedJavaField resolvedField = (ResolvedJavaField) field;
                genGetField(resolvedField, receiver);
                notifyBeforeInline(targetMethod);
                printInlining(targetMethod, targetMethod, true, "inline accessor method (bytecode parsing)");
                notifyAfterInline(targetMethod);
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:BytecodeParser.java

示例3: getCodeTest

import jdk.vm.ci.meta.ResolvedJavaMethod; //導入方法依賴的package包/類
/**
 * @see ResolvedJavaMethod#getCode()
 */
@Test
public void getCodeTest() {
    for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) {
        ResolvedJavaMethod m = e.getValue();
        byte[] code = m.getCode();
        if (code == null) {
            assertTrue(m.getCodeSize() == 0);
        } else {
            if (m.isAbstract()) {
                assertTrue(code.length == 0);
            } else if (!m.isNative()) {
                assertTrue(code.length > 0);
            }
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:TestResolvedJavaMethod.java

示例4: checkSize

import jdk.vm.ci.meta.ResolvedJavaMethod; //導入方法依賴的package包/類
private static boolean checkSize(ResolvedJavaMethod method, ValueNode[] args, StructuredGraph graph) {
    int bonus = 1;
    for (ValueNode v : args) {
        if (v.isConstant()) {
            bonus++;
        }
    }
    return method.getCode().length <= TrivialInliningSize.getValue(graph.getOptions()) * bonus;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:InlineDuringParsingPlugin.java

示例5: testGetBytecodes

import jdk.vm.ci.meta.ResolvedJavaMethod; //導入方法依賴的package包/類
@Test
public void testGetBytecodes() throws NoSuchMethodException {
    Method reflectionMethod = String.class.getDeclaredMethod("hashCode");
    ResolvedJavaMethod method = metaAccess.lookupJavaMethod(reflectionMethod);

    /*
     * ResolvedJavaMethod provides all information that you want about a method, for example,
     * the bytecodes.
     */
    byte[] bytecodes = method.getCode();

    /*
     * BytecodeDisassembler shows you how to iterate bytecodes, how to access type information,
     * and more.
     */
    String disassembly = new BytecodeDisassembler().disassemble(method);

    /*
     * We don't want test cases to print any output, so we check the validity of the output
     * instead.
     */
    Pattern disassemblyLineRE = Pattern.compile(" *\\d+: [a-z][\\w_]+");
    for (String line : disassembly.split("\\n")) {
        Assert.assertTrue(line, disassemblyLineRE.matcher(line).find());
    }
    Assert.assertTrue(bytecodes.length > 0);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:GraalTutorial.java

示例6: getByteCode

import jdk.vm.ci.meta.ResolvedJavaMethod; //導入方法依賴的package包/類
private static byte getByteCode(Call call) {
    ResolvedJavaMethod m = call.debugInfo.getBytecodePosition().getMethod();
    int callPosition = call.debugInfo.getBytecodePosition().getBCI();
    byte[] code = m.getCode();
    return code[callPosition];
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:CallInfo.java

示例7: methodCode

import jdk.vm.ci.meta.ResolvedJavaMethod; //導入方法依賴的package包/類
@Override
public byte[] methodCode(ResolvedJavaMethod method) {
    return method.getCode();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:BinaryGraphPrinter.java


注:本文中的jdk.vm.ci.meta.ResolvedJavaMethod.getCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。