inlinetest.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 51 行
JAVA
51 行
/*
* $Id: InlineTest.java,v 1.2 2004/01/02 08:41:55 epr Exp $
*/
package org.jnode.test;
import java.io.File;
import org.jnode.vm.VmSystemClassLoader;
import org.jnode.vm.bytecode.BytecodeParser;
import org.jnode.vm.bytecode.BytecodeViewer;
import org.jnode.vm.bytecode.MethodInliner;
import org.jnode.vm.bytecode.SimpleInlineOracle;
import org.jnode.vm.classmgr.VmByteCode;
import org.jnode.vm.classmgr.VmMethod;
import org.jnode.vm.classmgr.VmType;
import org.jnode.vm.x86.VmX86Architecture;
/**
* @author Ewout Prangsma (epr@users.sourceforge.net)
*/
public class InlineTest {
public static void main(String[] args) throws Exception {
final String clsName = InlineTestClass.class.getName();
final VmSystemClassLoader cl = new VmSystemClassLoader(new File(".").toURL(), new VmX86Architecture());
final VmType type = cl.loadClass(clsName, true);
// First show all declared methods
for (int i = 0; i < type.getNoDeclaredMethods(); i++) {
final VmMethod m = type.getDeclaredMethod(i);
System.out.println("\n*** Original " + m.getName() + " ***");
BytecodeParser.parse(m.getBytecode(), new BytecodeViewer());
}
// Now inline the foo method
final VmMethod method = type.getMethod("foo", "()V");
final MethodInliner inliner = new MethodInliner(method.getBytecode());
final SimpleInlineOracle oracle = new SimpleInlineOracle();
final long start = System.currentTimeMillis();
final int count = inliner.inline(oracle, cl);
final VmByteCode result = inliner.toByteCode();
final long end = System.currentTimeMillis();
System.out.println("Inlined " + count + " method call(s) took " + (end - start) + "ms");
// Show the result
System.out.println("\n*** The result ***");
BytecodeParser.parse(result, new BytecodeViewer());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?