本文整理匯總了Java中jdk.vm.ci.meta.ResolvedJavaMethod類的典型用法代碼示例。如果您正苦於以下問題:Java ResolvedJavaMethod類的具體用法?Java ResolvedJavaMethod怎麽用?Java ResolvedJavaMethod使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ResolvedJavaMethod類屬於jdk.vm.ci.meta包,在下文中一共展示了ResolvedJavaMethod類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tryInline
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
protected LoopScope tryInline(PEMethodScope methodScope, LoopScope loopScope, InvokeData invokeData, MethodCallTargetNode callTarget) {
if (!callTarget.invokeKind().isDirect()) {
return null;
}
ResolvedJavaMethod targetMethod = callTarget.targetMethod();
if (targetMethod.hasNeverInlineDirective()) {
return null;
}
ValueNode[] arguments = callTarget.arguments().toArray(new ValueNode[0]);
GraphBuilderContext graphBuilderContext = new PENonAppendGraphBuilderContext(methodScope, invokeData.invoke);
for (InlineInvokePlugin plugin : inlineInvokePlugins) {
InlineInfo inlineInfo = plugin.shouldInlineInvoke(graphBuilderContext, targetMethod, arguments);
if (inlineInfo != null) {
if (inlineInfo.getMethodToInline() == null) {
return null;
} else {
return doInline(methodScope, loopScope, invokeData, inlineInfo, arguments);
}
}
}
return null;
}
示例2: profile
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
private ProfilingInfo profile(boolean resetProfile, int executions, String methodName, Object... args) {
ResolvedJavaMethod javaMethod = getResolvedJavaMethod(methodName);
Assert.assertTrue(javaMethod.isStatic());
if (resetProfile) {
javaMethod.reprofile();
}
for (int i = 0; i < executions; ++i) {
try {
invoke(javaMethod, null, args);
} catch (Throwable e) {
Assert.fail("method should not throw an exception: " + e.toString());
}
}
ProfilingInfo info = javaMethod.getProfilingInfo();
// The execution counts are low so force maturity
info.setMature();
return info;
}
示例3: testDebugUsageClass
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
@SuppressWarnings("try")
private static void testDebugUsageClass(Class<?> c) {
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
Providers providers = rt.getHostBackend().getProviders();
MetaAccessProvider metaAccess = providers.getMetaAccess();
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
Plugins plugins = new Plugins(new InvocationPlugins());
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
OptionValues options = getInitialOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
for (Method m : c.getDeclaredMethods()) {
if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
graphBuilderSuite.apply(graph, context);
try (DebugCloseable s = debug.disableIntercept()) {
new VerifyDebugUsage().apply(graph, context);
}
}
}
}
示例4: assertEqualMethods
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
static void assertEqualMethods(ResolvedJavaMethod e, ResolvedJavaMethod a) {
if (a != null) {
if (!e.equals(a)) {
if (!e.equals(a)) {
if (!e.getDeclaringClass().equals(a.getDeclaringClass())) {
if (!typesAreRelated(e, a)) {
throw new AssertionError(String.format("%s and %s are unrelated", a.getDeclaringClass().toJavaName(), e.getDeclaringClass().toJavaName()));
}
}
Assert.assertEquals(e.getName(), a.getName());
Assert.assertEquals(e.getSignature(), a.getSignature());
} else {
Assert.assertEquals(e, a);
}
}
}
}
示例5: findMethodTest
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
@Test
public void findMethodTest() {
try {
ResolvedJavaMethod findFoo = metaAccess.lookupJavaType(D.class).findMethod("foo", metaAccess.parseMethodDescriptor("()V"));
ResolvedJavaMethod expectedFoo = metaAccess.lookupJavaMethod(D.class.getDeclaredMethod("foo"));
assertEquals(expectedFoo, findFoo);
ResolvedJavaMethod wrongReturnTypeFoo = metaAccess.lookupJavaType(D.class).findMethod("foo", metaAccess.parseMethodDescriptor("()I"));
assertNull(wrongReturnTypeFoo);
ResolvedJavaMethod wrongArgumentsFoo = metaAccess.lookupJavaType(D.class).findMethod("foo", metaAccess.parseMethodDescriptor("(I)V"));
assertNull(wrongArgumentsFoo);
ResolvedJavaMethod wrongNameFoo = metaAccess.lookupJavaType(D.class).findMethod("bar", metaAccess.parseMethodDescriptor("()V"));
assertNull(wrongNameFoo);
ResolvedJavaMethod wrongClassFoo = metaAccess.lookupJavaType(SubD.class).findMethod("foo", metaAccess.parseMethodDescriptor("()V"));
assertNull(wrongClassFoo);
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(e);
}
}
示例6: checkForRequestedCrash
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
/**
* Checks whether the {@link GraalCompilerOptions#CrashAt} option indicates that the compilation
* of {@code graph} should result in an exception.
*
* @param graph a graph currently being compiled
* @throws RuntimeException if the value of {@link GraalCompilerOptions#CrashAt} matches
* {@code graph.method()} or {@code graph.name}
*/
private static void checkForRequestedCrash(StructuredGraph graph) {
String methodPattern = GraalCompilerOptions.CrashAt.getValue(graph.getOptions());
if (methodPattern != null) {
String crashLabel = null;
if (graph.name != null && graph.name.contains(methodPattern)) {
crashLabel = graph.name;
}
if (crashLabel == null) {
ResolvedJavaMethod method = graph.method();
MethodFilter[] filters = MethodFilter.parse(methodPattern);
for (MethodFilter filter : filters) {
if (filter.matches(method)) {
crashLabel = method.format("%H.%n(%p)");
}
}
}
if (crashLabel != null) {
throw new RuntimeException("Forced crash after compiling " + crashLabel);
}
}
}
示例7: getMethod
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
/**
* Obtain a resolved Java method declared by a given type.
*
* @param type the declaring type
* @param the method's name
*
* Currently, the lookup is based only on the method's name
* but not on the method's signature (i.e., the first method
* with a matching name declared on {@code type} is returned).
*/
private static ResolvedJavaMethod getMethod(ResolvedJavaType type, String methodName) {
if (methodName.equals("<clinit>")) {
return type.getClassInitializer();
}
if (methodName.equals("<init>")) {
ResolvedJavaMethod[] initializers = type.getDeclaredConstructors();
if (initializers.length >= 0) {
return initializers[0];
} else {
throw new IllegalArgumentException();
}
}
for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
if (method.getName().equals(methodName)) {
return method;
}
}
throw new IllegalArgumentException();
}
示例8: setMethods
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
/**
* Sets the methods whose bytecodes were used as input to the compilation.
*
* @param rootMethod the root method of the compilation
* @param inlinedMethods the methods inlined during compilation
*/
public void setMethods(ResolvedJavaMethod rootMethod, Collection<ResolvedJavaMethod> inlinedMethods) {
checkOpen();
assert rootMethod != null;
assert inlinedMethods != null;
if (inlinedMethods.contains(rootMethod)) {
methods = inlinedMethods.toArray(new ResolvedJavaMethod[inlinedMethods.size()]);
for (int i = 0; i < methods.length; i++) {
if (methods[i].equals(rootMethod)) {
if (i != 0) {
ResolvedJavaMethod tmp = methods[0];
methods[0] = methods[i];
methods[i] = tmp;
}
break;
}
}
} else {
methods = new ResolvedJavaMethod[1 + inlinedMethods.size()];
methods[0] = rootMethod;
int i = 1;
for (ResolvedJavaMethod m : inlinedMethods) {
methods[i++] = m;
}
}
}
示例9: getBackedgeBCI
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
/**
* Returns the target BCI of the first bytecode backedge. This is where HotSpot triggers
* on-stack-replacement in case the backedge counter overflows.
*/
private static int getBackedgeBCI(DebugContext debug, ResolvedJavaMethod method) {
Bytecode code = new ResolvedJavaMethodBytecode(method);
BytecodeStream stream = new BytecodeStream(code.getCode());
OptionValues options = debug.getOptions();
BciBlockMapping bciBlockMapping = BciBlockMapping.create(stream, code, options, debug);
for (BciBlock block : bciBlockMapping.getBlocks()) {
if (block.startBci != -1) {
int bci = block.startBci;
for (BciBlock succ : block.getSuccessors()) {
if (succ.startBci != -1) {
int succBci = succ.startBci;
if (succBci < bci) {
// back edge
return succBci;
}
}
}
}
}
TTY.println("Cannot find loop back edge with bytecode loops at:%s", Arrays.toString(bciBlockMapping.getLoopHeaders()));
TTY.println(new BytecodeDisassembler().disassemble(code));
return -1;
}
示例10: registerThreadPlugins
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
private static void registerThreadPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, WordTypes wordTypes, GraalHotSpotVMConfig config, BytecodeProvider bytecodeProvider) {
Registration r = new Registration(plugins, Thread.class, bytecodeProvider);
r.register0("currentThread", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
CurrentJavaThreadNode thread = b.add(new CurrentJavaThreadNode(wordTypes.getWordKind()));
boolean compressible = false;
ValueNode offset = b.add(ConstantNode.forLong(config.threadObjectOffset));
AddressNode address = b.add(new OffsetAddressNode(thread, offset));
ValueNode javaThread = WordOperationPlugin.readOp(b, JavaKind.Object, address, JAVA_THREAD_THREAD_OBJECT_LOCATION, BarrierType.NONE, compressible);
boolean exactType = false;
boolean nonNull = true;
b.addPush(JavaKind.Object, new PiNode(javaThread, metaAccess.lookupJavaType(Thread.class), exactType, nonNull));
return true;
}
});
r.registerMethodSubstitution(ThreadSubstitutions.class, "isInterrupted", Receiver.class, boolean.class);
}
示例11: verify
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
@Override
protected boolean verify(StructuredGraph graph, PhaseContext context) {
final ResolvedJavaType graphType = context.getMetaAccess().lookupJavaType(Graph.class);
final ResolvedJavaType virtualizableType = context.getMetaAccess().lookupJavaType(Virtualizable.class);
final ResolvedJavaType constantNodeType = context.getMetaAccess().lookupJavaType(ConstantNode.class);
if (virtualizableType.isAssignableFrom(graph.method().getDeclaringClass()) && graph.method().getName().equals("virtualize")) {
for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
int bci = t.invoke().bci();
ResolvedJavaMethod callee = t.targetMethod();
String calleeName = callee.getName();
if (callee.getDeclaringClass().equals(graphType)) {
if (calleeName.equals("add") || calleeName.equals("addWithoutUnique") || calleeName.equals("addOrUnique") || calleeName.equals("addWithoutUniqueWithInputs") ||
calleeName.equals("addOrUniqueWithInputs")) {
verifyVirtualizableEffectArguments(constantNodeType, graph.method(), callee, bci, t.arguments(), 1);
}
}
}
}
return true;
}
示例12: testStringEquals
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
private void testStringEquals(String s0, String s1) {
ResolvedJavaMethod method = getResolvedJavaMethod("stringEquals");
StructuredGraph graph = parseForCompile(method);
graph.getParameter(0).replaceAndDelete(asConstant(graph, s0));
graph.getParameter(1).replaceAndDelete(asConstant(graph, s1));
compile(method, graph);
FixedNode firstFixed = graph.start().next();
Assert.assertThat(firstFixed, instanceOf(ReturnNode.class));
ReturnNode ret = (ReturnNode) firstFixed;
JavaConstant result = ret.result().asJavaConstant();
if (result == null) {
Assert.fail("result not constant: " + ret.result());
} else {
int expected = s0.equals(s1) ? 1 : 0;
Assert.assertEquals("result", expected, result.asInt());
}
}
示例13: createNonInlinedInvoke
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
protected Invoke createNonInlinedInvoke(boolean withExceptionEdge, int invokeBci, ValueNode[] invokeArgs, ResolvedJavaMethod targetMethod,
InvokeKind invokeKind, JavaKind resultType, JavaType returnType, JavaTypeProfile profile) {
StampPair returnStamp = graphBuilderConfig.getPlugins().getOverridingStamp(this, returnType, false);
if (returnStamp == null) {
returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false);
}
MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, targetMethod, invokeArgs, returnStamp, profile));
Invoke invoke = createNonInlinedInvoke(withExceptionEdge, invokeBci, callTarget, resultType);
for (InlineInvokePlugin plugin : graphBuilderConfig.getPlugins().getInlineInvokePlugins()) {
plugin.notifyNotInlined(this, targetMethod, invoke);
}
return invoke;
}
示例14: currentMap
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
private OptionValues currentMap(OptionValues initialValues, ResolvedJavaMethod method) {
if (changes.isEmpty() && methodDumps.isEmpty()) {
return initialValues;
}
OptionValues current = cachedOptions;
if (current == null) {
current = new OptionValues(initialValues, changes);
cachedOptions = current;
}
if (method != null) {
for (Dump request : methodDumps) {
final String clazzName = method.getDeclaringClass().getName();
if (method.getName().equals(request.method) && clazzName.equals(request.clazz)) {
current = new OptionValues(current, DebugOptions.Dump, request.filter,
DebugOptions.PrintGraphHost, request.host,
DebugOptions.PrintBinaryGraphPort, request.port);
break;
}
}
}
return current;
}
示例15: createParameterStamps
import jdk.vm.ci.meta.ResolvedJavaMethod; //導入依賴的package包/類
public static Stamp[] createParameterStamps(Assumptions assumptions, ResolvedJavaMethod method) {
Signature sig = method.getSignature();
Stamp[] result = new Stamp[sig.getParameterCount(!method.isStatic())];
int index = 0;
if (!method.isStatic()) {
result[index++] = StampFactory.objectNonNull(TypeReference.create(assumptions, method.getDeclaringClass()));
}
int max = sig.getParameterCount(false);
ResolvedJavaType accessingClass = method.getDeclaringClass();
for (int i = 0; i < max; i++) {
JavaType type = sig.getParameterType(i, accessingClass);
JavaKind kind = type.getJavaKind();
Stamp stamp;
if (kind == JavaKind.Object && type instanceof ResolvedJavaType) {
stamp = StampFactory.object(TypeReference.create(assumptions, (ResolvedJavaType) type));
} else {
stamp = StampFactory.forKind(kind);
}
result[index++] = stamp;
}
return result;
}