[vmkit-commits] [PATCH] Update OpenJDK's classpath reflect--fix field layout and class mapping

Nicolas Geoffray nicolas.geoffray at gmail.com
Thu Oct 27 14:08:20 PDT 2011


On Thu, Oct 27, 2011 at 10:02 PM, Will Dietz <wdietz2 at illinois.edu> wrote:

> Nevermind.  From what you said about the VMThread tracing I think
> things on that front clicked, and this is all wrong now :).
>
> Still need to tackle mapping various objects to their internal
> representation, but for example realizing that the
> Object/Class/Method/Constructor are explicitly not GC-allocated makes
> that easier.
>

What do you mean? Java objects are always GC-allocated. VMKit internal
structures like j3::JavaMethod or j3::JavaField are malloced.


> However the field layout is wrong, and the protection domain is wrong...
>
> I'll get back to you :).
>
>
OK. Note that I understand the problem and have a few ideas we could
discuss. But please do as you think would be best, and we can then talk :)

Nicolas


> ~Will
>
> On Wed, Oct 26, 2011 at 9:17 PM, Will Dietz <wdietz2 at illinois.edu> wrote:
> > Inlined below.
> >
> > This raises a question that I'm not sure I have a good answer to in
> > general: how to replace the various 'vmdata' mappings that GNU
> > Classpath so nicely provides?
> >
> > Here I stash things in a static map, and it seems to work fine.  However:
> > a)where does the map really belong? The Jnjvm?
> > b)seems like a bad idea to put GC'd pointers in a stl container, but I
> > could be wrong.
> >
> > Is there a general way to map /from/ a JavaObject?
> >
> > We have this issue with java.lang.Thread -> JavaThread, and
> > java.lang.ClassLoader -> JnjvmClassLoader (don't bother with
> > VMClassLoader intermediate in OpenJDK port, maybe that's a mistake),
> > so this is worth discussing/solving.
> >
> > However those instances I'm able to abuse existing fields ('eetop' for
> > JavaThread, and 'classes' for ClassLoader), and the biggest issues
> > there seems to be ensuring that plays nice with GC stuff.
> >
> > Anyway, thoughts welcome :).
> >
> > ~Will
> >
> >
> > From 4e25b2c950aff018261054ca13baeeadb72d6df1 Mon Sep 17 00:00:00 2001
> > From: Will Dietz <w at wdtz.org>
> > Date: Wed, 26 Oct 2011 18:23:38 -0500
> > Subject: [PATCH 1/2] Update classpathreflect--field layout, class
> mapping.
> >
> > ---
> >  lib/J3/ClassLib/OpenJDK/ClasspathReflect.cpp |    1 +
> >  lib/J3/ClassLib/OpenJDK/ClasspathReflect.h   |   47
> ++++++++-----------------
> >  2 files changed, 16 insertions(+), 32 deletions(-)
> >
> > diff --git a/lib/J3/ClassLib/OpenJDK/ClasspathReflect.cpp
> > b/lib/J3/ClassLib/OpenJDK/ClasspathReflect.cpp
> > index 3d69fa4..31dd417 100644
> > --- a/lib/J3/ClassLib/OpenJDK/ClasspathReflect.cpp
> > +++ b/lib/J3/ClassLib/OpenJDK/ClasspathReflect.cpp
> > @@ -14,6 +14,7 @@
> >
> >  namespace j3 {
> >
> > +std::map<JavaObjectClass*, UserCommonClass*> JavaObjectClass::ClassMap;
> >  JavaMethod*
> JavaObjectConstructor::getInternalMethod(JavaObjectConstructor*
> > self) {
> >   llvm_gcroot(self, 0);
> >   UserCommonClass* cls = JavaObjectClass::getClass(self->declaringClass);
> > diff --git a/lib/J3/ClassLib/OpenJDK/ClasspathReflect.h
> > b/lib/J3/ClassLib/OpenJDK/ClasspathReflect.h
> > index 08042b3..101e726 100644
> > --- a/lib/J3/ClassLib/OpenJDK/ClasspathReflect.h
> > +++ b/lib/J3/ClassLib/OpenJDK/ClasspathReflect.h
> > @@ -16,25 +16,27 @@
> >  #include "JavaObject.h"
> >  #include "JavaThread.h"
> >
> > +#include <map>
> >  namespace j3 {
> >
> >  class JavaObjectClass : public JavaObject {
> >  private:
> > -  JavaObject* signers;
> > -  JavaObject* pd;
> > -  UserCommonClass* vmdata;
> > +  static std::map<JavaObjectClass*, UserCommonClass*> ClassMap;
> >   JavaObject* constructor;
> > +  JavaObject* newInstanceCallerCache;
> > +  JavaObject* name;
> > +  JavaObject* pd;
> >
> >  public:
> >
> >   static UserCommonClass* getClass(JavaObjectClass* cl) {
> >     llvm_gcroot(cl, 0);
> > -    return cl->vmdata;
> > +    return ClassMap[cl];
> >   }
> >
> >   static void setClass(JavaObjectClass* cl, UserCommonClass* vmdata) {
> >     llvm_gcroot(cl, 0);
> > -    cl->vmdata = vmdata;
> > +    ClassMap[cl] = vmdata;
> >   }
> >
> >   static void setProtectionDomain(JavaObjectClass* cl, JavaObject* pd) {
> > @@ -50,11 +52,12 @@ public:
> >   }
> >
> >   static void staticTracer(JavaObjectClass* obj, word_t closure) {
> > -    mvm::Collector::markAndTrace(obj, &obj->pd, closure);
> > -    mvm::Collector::markAndTrace(obj, &obj->signers, closure);
> >     mvm::Collector::markAndTrace(obj, &obj->constructor, closure);
> > -    if (obj->vmdata) {
> > -      JavaObject** Obj =
> obj->vmdata->classLoader->getJavaClassLoaderPtr();
> > +    mvm::Collector::markAndTrace(obj, &obj->newInstanceCallerCache,
> closure);
> > +    mvm::Collector::markAndTrace(obj, &obj->name, closure);
> > +    mvm::Collector::markAndTrace(obj, &obj->pd, closure);
> > +    if (ClassMap[obj]) {
> > +      JavaObject** Obj =
> ClassMap[obj]->classLoader->getJavaClassLoaderPtr();
> >       if (*Obj) mvm::Collector::markAndTraceRoot(Obj, closure);
> >     }
> >   }
> > @@ -64,8 +67,8 @@ class JavaObjectField : public JavaObject {
> >  private:
> >   uint8 flag;
> >   JavaObjectClass* declaringClass;
> > -  JavaObject* name;
> >   uint32 slot;
> > +  JavaObject* name;
> >
> >  public:
> >
> > @@ -92,8 +95,8 @@ class JavaObjectMethod : public JavaObject {
> >  private:
> >   uint8 flag;
> >   JavaObjectClass* declaringClass;
> > -  JavaObject* name;
> >   uint32 slot;
> > +  JavaObject* name;
> >
> >  public:
> >
> > @@ -133,32 +136,12 @@ public:
> >
> >  };
> >
> > -class JavaObjectVMThread : public JavaObject {
> > -private:
> > -  JavaObject* thread;
> > -  bool running;
> > -  JavaThread* vmdata;
> > -
> > -public:
> > -  static void staticTracer(JavaObjectVMThread* obj, word_t closure) {
> > -    mvm::Collector::markAndTrace(obj, &obj->thread, closure);
> > -  }
> > -
> > -  static void setVmdata(JavaObjectVMThread* vmthread,
> > -                        JavaThread* internal_thread) {
> > -    llvm_gcroot(vmthread, 0);
> > -    vmthread->vmdata = internal_thread;
> > -  }
> > -
> > -};
> > -
> > -
> >  class JavaObjectThrowable : public JavaObject {
> >  private:
> > +  JavaObject* backtrace;
> >   JavaObject* detailedMessage;
> >   JavaObject* cause;
> >   JavaObject* stackTrace;
> > -  JavaObject* vmState;
> >
> >  public:
> >
> > --
> > 1.7.5.1
> >
>
> _______________________________________________
> vmkit-commits mailing list
> vmkit-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/vmkit-commits/attachments/20111027/eed48794/attachment.html>


More information about the vmkit-commits mailing list