[vmkit-commits] [PATCH] Refactor AOT into ClassLib-specific components, add support for OpenJDK

Nicolas Geoffray nicolas.geoffray at gmail.com
Tue Nov 8 09:00:14 PST 2011


On Mon, Nov 7, 2011 at 3:55 AM, Will Dietz <wdietz2 at illinois.edu> wrote:

> On Sun, Nov 6, 2011 at 4:38 AM, Nicolas Geoffray
> <nicolas.geoffray at gmail.com> wrote:
> > On Sun, Nov 6, 2011 at 8:32 AM, Will Dietz <wdietz2 at illinois.edu> wrote:
> >>
> >> On Fri, Nov 4, 2011 at 4:57 PM, Nicolas Geoffray
> >> <nicolas.geoffray at gmail.com> wrote:
> >> > Don't you need to fix java.lang.String also?
> >> >
> >>
> >> Hmm, I'd imagine so-- good call.  Strange this didn't break anything
> >> terribly :).
> >
> > I think they are used for debugging and logging in MMTk, so as long as
> you
> > weren't printing things, you may not use the generated strings at all.
> >>
> >> > There is a problem if we don't add the extra fields in LLVM's struct:
> >> > the
> >> > object will be emitted in the executable, and won't be big enough to
> >> > contain
> >> > the two extra fields.
> >>
> >> Bah, okay.  That sort of thing was why my previous (otherwise hacky)
> >> patch for adding extra fields was useful--LLVMInfo would do the right
> >> thing.
> >
> > Indeed. Sorry about not liking this solution :)
> >
>
> No need to be sorry :).
>
> >>
> >> However, I like your idea below of trying to ditch emitting Class in
> >> AOT entirely, I'll give it a go.
> >
> > Thanks!
> > Nicolas
> >
>
> Gave it a go, and the corresponding patch is inlined below.
>
> However, in order for it to work, it also needs the "Don't emit
> methods for primitive classes' VT" patch, which I'm sending in a
> separate thread.
>
> ~Will
>
> From e8eda306e44c270545fdb31b3ba954cfd016c511 Mon Sep 17 00:00:00 2001
> From: Will Dietz <w at wdtz.org>
> Date: Sun, 6 Nov 2011 20:17:02 -0600
> Subject: [PATCH 7/8] Emit NULL for j.l.Class in AOT.
>
> ---
>  include/j3/JavaAOTCompiler.h        |    1 -
>  lib/J3/Compiler/JavaAOTCompiler.cpp |   64
> +----------------------------------
>  2 files changed, 1 insertions(+), 64 deletions(-)
>
> diff --git a/include/j3/JavaAOTCompiler.h b/include/j3/JavaAOTCompiler.h
> index b278a41..483bffb 100644
> --- a/include/j3/JavaAOTCompiler.h
> +++ b/include/j3/JavaAOTCompiler.h
> @@ -94,7 +94,6 @@ private:
>   llvm::Constant* CreateConstantFromJavaMethod(JavaMethod& method);
>   llvm::Constant* CreateConstantFromStaticInstance(Class* cl);
>   llvm::Constant* CreateConstantFromJavaString(JavaString* str);
> -  llvm::Constant* CreateConstantFromJavaClass(CommonClass* cl);
>   llvm::Constant* CreateConstantForBaseObject(CommonClass* cl);
>   llvm::Constant* CreateConstantFromJavaObject(JavaObject* obj);
>   llvm::Constant* CreateConstantFromClassBytes(ClassBytes* bytes);
> diff --git a/lib/J3/Compiler/JavaAOTCompiler.cpp
> b/lib/J3/Compiler/JavaAOTCompiler.cpp
> index 1a4d2e4..2ae8973 100644
> --- a/lib/J3/Compiler/JavaAOTCompiler.cpp
> +++ b/lib/J3/Compiler/JavaAOTCompiler.cpp
> @@ -295,39 +295,7 @@ Constant* JavaAOTCompiler::getStringPtr(JavaString**
> str) {
>  }
>
>  Constant* JavaAOTCompiler::getJavaClass(CommonClass* cl) {
> -  Class* javaClass = cl->classLoader->bootstrapLoader->upcalls->newClass;
> -  LLVMClassInfo* LCI = getClassInfo(javaClass);
> -  llvm::Type* Ty = LCI->getVirtualType();
> -
> -  if (useCooperativeGC()) {
> -    return Constant::getNullValue(JavaIntrinsics.JavaObjectType);
> -  } else {
> -    java_class_iterator End = javaClasses.end();
> -    java_class_iterator I = javaClasses.find(cl);
> -    if (I == End) {
> -      final_object_iterator End = finalObjects.end();
> -      final_object_iterator I = finalObjects.find(cl->delegatee[0]);
> -      if (I == End) {
> -
> -        Module& Mod = *getLLVMModule();
> -
> -        GlobalVariable* varGV =
> -          new GlobalVariable(Mod, Ty->getContainedType(0), false,
> -                             GlobalValue::InternalLinkage, 0, "");
> -
> -        Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV,
> -
>  JavaIntrinsics.JavaObjectType);
> -
> -        javaClasses.insert(std::make_pair(cl, res));
> -        varGV->setInitializer(CreateConstantFromJavaClass(cl));
> -        return res;
> -      } else {
> -        return I->second;
> -      }
> -    } else {
> -      return I->second;
> -    }
> -  }
> +  return Constant::getNullValue(JavaIntrinsics.JavaObjectType);
>

Did you make sure this works with the current setup (mmtk + gnu classpath)?
If you did, then please apply!


>  }
>
>  Constant* JavaAOTCompiler::getJavaClassPtr(CommonClass* cl) {
> @@ -688,36 +656,6 @@ Constant*
> JavaAOTCompiler::CreateConstantForBaseObject(CommonClass* cl) {
>   return ConstantStruct::get(STy, Elmts);
>  }
>
> -Constant* JavaAOTCompiler::CreateConstantFromJavaClass(CommonClass* cl) {
> -  assert(!useCooperativeGC());
> -  Class* javaClass = cl->classLoader->bootstrapLoader->upcalls->newClass;
> -  LLVMClassInfo* LCI = getClassInfo(javaClass);
> -  StructType* STy =
> -    dyn_cast<StructType>(LCI->getVirtualType()->getContainedType(0));
> -
> -  std::vector<Constant*> Elmts;
> -
> -  // JavaObject
> -  Elmts.push_back(CreateConstantForBaseObject(javaClass));
> -
> -  // signers
> -  Elmts.push_back(Constant::getNullValue(JavaIntrinsics.JavaObjectType));
> -
> -  // pd
> -  Elmts.push_back(Constant::getNullValue(JavaIntrinsics.JavaObjectType));
> -
> -  // vmdata
> -  Constant* Cl = getNativeClass(cl);
> -  Cl = ConstantExpr::getCast(Instruction::BitCast, Cl,
> -                             JavaIntrinsics.JavaObjectType);
> -  Elmts.push_back(Cl);
> -
> -  // constructor
> -  Elmts.push_back(Constant::getNullValue(JavaIntrinsics.JavaObjectType));
> -
> -  return ConstantStruct::get(STy, Elmts);
> -}
> -
>  Constant* JavaAOTCompiler::CreateConstantFromJavaObject(JavaObject* obj) {
>   assert(!useCooperativeGC());
>   CommonClass* cl = JavaObject::getClass(obj);
> --
> 1.7.5.1
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/vmkit-commits/attachments/20111108/c9f255be/attachment.html>


More information about the vmkit-commits mailing list