use of jdk.vm.ci.meta.JavaMethod in project graal by oracle.
the class ArrayCopyIntrinsificationTest method getCode.
@Override
protected InstalledCode getCode(ResolvedJavaMethod method, StructuredGraph g, boolean forceCompile, boolean installAsDefault, OptionValues options) {
StructuredGraph graph = g == null ? parseForCompile(method) : g;
int nodeCount = graph.getNodeCount();
InstalledCode result = super.getCode(method, graph, forceCompile, installAsDefault, options);
boolean graphWasProcessed = nodeCount != graph.getNodeCount();
if (graphWasProcessed) {
if (mustIntrinsify) {
for (Node node : graph.getNodes()) {
if (node instanceof Invoke) {
Invoke invoke = (Invoke) node;
Assert.assertTrue(invoke.callTarget() instanceof DirectCallTargetNode);
LoweredCallTargetNode directCall = (LoweredCallTargetNode) invoke.callTarget();
JavaMethod callee = directCall.targetMethod();
if (callee.getDeclaringClass().equals(getMetaAccess().lookupJavaType(System.class)) && callee.getName().equals("arraycopy")) {
// A partial snippet (e.g., ArrayCopySnippets.checkcastArraycopy) may
// call the original arraycopy method
} else {
Assert.assertTrue(callee.toString(), callee.getName().equals("<init>"));
Assert.assertTrue(getMetaAccess().lookupJavaType(ArrayIndexOutOfBoundsException.class).equals(callee.getDeclaringClass()) || getMetaAccess().lookupJavaType(NullPointerException.class).equals(callee.getDeclaringClass()));
}
}
}
} else {
boolean found = false;
for (Node node : graph.getNodes()) {
if (node instanceof Invoke) {
Invoke invoke = (Invoke) node;
LoweredCallTargetNode directCall = (LoweredCallTargetNode) invoke.callTarget();
JavaMethod callee = directCall.targetMethod();
if (callee.getDeclaringClass().equals(getMetaAccess().lookupJavaType(System.class)) && callee.getName().equals("arraycopy")) {
found = true;
} else {
fail("found invoke to some method other than arraycopy: " + callee);
}
}
}
Assert.assertTrue("did not find invoke to arraycopy", found);
}
}
return result;
}
use of jdk.vm.ci.meta.JavaMethod in project graal by oracle.
the class BytecodeDisassembler method getInvokedMethodAt.
public static JavaMethod getInvokedMethodAt(ResolvedJavaMethod method, int invokeBci) {
if (method.getCode() == null) {
return null;
}
ConstantPool cp = method.getConstantPool();
BytecodeStream stream = new BytecodeStream(method.getCode());
int opcode = stream.currentBC();
while (opcode != Bytecodes.END) {
int bci = stream.currentBCI();
if (bci == invokeBci) {
if (stream.nextBCI() > bci + 1) {
switch(opcode) {
case INVOKEVIRTUAL:
case INVOKESPECIAL:
case INVOKESTATIC:
{
int cpi = stream.readCPI();
JavaMethod callee = cp.lookupMethod(cpi, opcode);
return callee;
}
case INVOKEINTERFACE:
{
int cpi = stream.readCPI();
JavaMethod callee = cp.lookupMethod(cpi, opcode);
return callee;
}
case INVOKEDYNAMIC:
{
int cpi = stream.readCPI4();
JavaMethod callee = cp.lookupMethod(cpi, opcode);
return callee;
}
default:
throw new InternalError(BytecodeDisassembler.disassembleOne(method, invokeBci));
}
}
}
stream.next();
opcode = stream.currentBC();
}
return null;
}
use of jdk.vm.ci.meta.JavaMethod in project graal by oracle.
the class BytecodeParser method genInvokeDynamic.
protected void genInvokeDynamic(int cpi, int opcode) {
JavaMethod target = lookupMethod(cpi, opcode);
genInvokeDynamic(target);
}
use of jdk.vm.ci.meta.JavaMethod in project graal by oracle.
the class BytecodeParser method genInvokeSpecial.
protected void genInvokeSpecial(int cpi, int opcode) {
JavaMethod target = lookupMethod(cpi, opcode);
genInvokeSpecial(target);
}
use of jdk.vm.ci.meta.JavaMethod in project graal by oracle.
the class HotSpotGraalCompiler method fmt.
/**
* Wraps {@code obj} in a {@link Formatter} that standardizes formatting for certain objects.
*/
static Formattable fmt(Object obj) {
return new Formattable() {
@Override
public void formatTo(Formatter buf, int flags, int width, int precision) {
if (obj instanceof Throwable) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
((Throwable) obj).printStackTrace(new PrintStream(baos));
buf.format("%s", baos.toString());
} else if (obj instanceof StackTraceElement[]) {
for (StackTraceElement e : (StackTraceElement[]) obj) {
buf.format("\t%s%n", e);
}
} else if (obj instanceof JavaMethod) {
buf.format("%s", str((JavaMethod) obj));
} else {
buf.format("%s", obj);
}
}
};
}
Aggregations