private static JavaType asJavaType(
     Class<?> type, MetaAccessProvider metaAccess, CodeCacheProvider codeCache) {
   if (WordBase.class.isAssignableFrom(type)) {
     return metaAccess.lookupJavaType(codeCache.getTarget().wordJavaKind.toJavaClass());
   } else {
     return metaAccess.lookupJavaType(type);
   }
 }
Esempio n. 2
0
 public Signature getSignature() {
   ForeignCallDescriptor d = linkage.getDescriptor();
   MetaAccessProvider metaAccess = providers.getMetaAccess();
   Class<?>[] arguments = d.getArgumentTypes();
   ResolvedJavaType[] parameters = new ResolvedJavaType[arguments.length];
   for (int i = 0; i < arguments.length; i++) {
     parameters[i] = metaAccess.lookupJavaType(arguments[i]);
   }
   return new HotSpotSignature(
       jvmciRuntime, metaAccess.lookupJavaType(d.getResultType()), parameters);
 }
 public StackTraceElement getApplySourceLocation(MetaAccessProvider metaAccess) {
   Class<?> c = getClass();
   for (Method m : c.getDeclaredMethods()) {
     if (m.getName().equals("execute")) {
       return metaAccess.lookupJavaMethod(m).asStackTraceElement(0);
     }
   }
   throw new JVMCIError("could not find method named \"execute\" in " + c.getName());
 }
 /**
  * Gets a {@link Classfile} created by parsing the class file bytes for {@code c}.
  *
  * @throws NoClassDefFoundError if the class file cannot be found
  */
 private synchronized Classfile getClassfile(Class<?> c) {
   assert !c.isPrimitive() && !c.isArray() : c;
   Classfile classfile = classfiles.get(c);
   if (classfile == null) {
     try {
       ResolvedJavaType type = metaAccess.lookupJavaType(c);
       InputStream in = getClassfileAsStream(c);
       if (in != null) {
         DataInputStream stream = new DataInputStream(in);
         classfile = new Classfile(type, stream, this);
         classfiles.put(c, classfile);
         return classfile;
       }
       throw new NoClassDefFoundError(c.getName());
     } catch (IOException e) {
       throw (NoClassDefFoundError) new NoClassDefFoundError(c.getName()).initCause(e);
     }
   }
   return classfile;
 }
 /** Gets the substitute method, resolving it first if necessary. */
 public ResolvedJavaMethod getSubstitute(MetaAccessProvider metaAccess) {
   if (cachedSubstitute == null) {
     cachedSubstitute = metaAccess.lookupJavaMethod(getJavaSubstitute());
   }
   return cachedSubstitute;
 }