Thanks Will for the simplified patch! It almost looks good, with the exception of the forgotten write barrier. Feel free to commit once that is fixed.<br><br><div class="gmail_quote">On Mon, Oct 31, 2011 at 9:44 PM, Will Dietz <span dir="ltr"><<a href="mailto:wdietz2@illinois.edu">wdietz2@illinois.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Fri, Oct 28, 2011 at 5:31 PM, Nicolas Geoffray<br>
<<a href="mailto:nicolas.geoffray@gmail.com">nicolas.geoffray@gmail.com</a>> wrote:<br>
> Hi Will!<br>
> I think this patch could work, but I would definitely try a more 'localized'<br>
> approach before doing it this way.<br>
> I think that in the bootstrap process of OpenJDK, you should update the<br>
> Class::virtualSize field for java.lang.Class to include these two new<br>
> fields, and that would be it. No need to extend the JavaField array (the<br>
> Java side of things does not have to know we added new fields).<br>
> Of course, you need to make sure no java.lang.Class objects are allocated<br>
> *before* you change the size.<br>
> Thanks, and let me know if that worked!<br>
> Nicolas<br>
<br>
</div>I was playing nice with the JavaFields not so that anything from Java<br>
could see the fields (I actually intentionally tried to hide them from<br>
Java code), but so that the created LLVM types (LLVMInfo) for<br>
java.lang.Class matched up.  Not knowing better, that seemed like<br>
something to ensure was correct.<br>
<br>
However, what you suggested is much simpler and seems to work equally<br>
well, thanks for the good suggestion.<br>
<br>
Updated patch inlined below :)<br>
<br>
~Will<br>
<br>
>From f57fed146de2962a5e3c1306515ab9374862647e Mon Sep 17 00:00:00 2001<br>
From: Will Dietz <<a href="mailto:w@wdtz.org">w@wdtz.org</a>><br>
Date: Mon, 31 Oct 2011 15:23:24 -0500<br>
Subject: [PATCH] Add extra fields to JavaObjectClass to hold CommonClass and<br>
 protection domain.<br>
<br>
---<br>
 lib/J3/ClassLib/OpenJDK/ClasspathReflect.h |   13 +++++++------<br>
 lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp    |    2 ++<br>
 2 files changed, 9 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/lib/J3/ClassLib/OpenJDK/ClasspathReflect.h<br>
b/lib/J3/ClassLib/OpenJDK/ClasspathReflect.h<br>
index 75d35a7..4075a5f 100644<br>
<div class="im">--- a/lib/J3/ClassLib/OpenJDK/ClasspathReflect.h<br>
+++ b/lib/J3/ClassLib/OpenJDK/ClasspathReflect.h<br>
@@ -38,30 +38,31 @@ private:<br>
   JavaObject* annotations;<br>
   JavaObject* declaredAnnotations;<br>
   JavaObject* annotationType;<br>
+  // Extra fields added by VM<br>
+  UserCommonClass * internalClass;<br>
</div>+  JavaObject * pd;<br>
<div class="im"><br>
 public:<br>
<br>
   static UserCommonClass* getClass(JavaObjectClass* cl) {<br>
     llvm_gcroot(cl, 0);<br>
-    UNIMPLEMENTED();<br>
-    return NULL;<br>
+    return cl->internalClass;<br>
   }<br>
<br>
   static void setClass(JavaObjectClass* cl, UserCommonClass* vmdata) {<br>
     llvm_gcroot(cl, 0);<br>
-    UNIMPLEMENTED();<br>
+    cl->internalClass = vmdata;<br>
   }<br>
<br>
   static void setProtectionDomain(JavaObjectClass* cl, JavaObject* pd) {<br>
     llvm_gcroot(cl, 0);<br>
     llvm_gcroot(pd, 0);<br>
-    UNIMPLEMENTED();<br>
+    cl->pd = pd;<br></div></blockquote><div><br></div><div>This should be a write barrier.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">

   }<br>
<br>
   static JavaObject* getProtectionDomain(JavaObjectClass* cl) {<br>
     llvm_gcroot(cl, 0);<br>
-    UNIMPLEMENTED();<br>
-    return NULL;<br>
+    return cl->pd;<br>
   }<br>
<br>
   static void staticTracer(JavaObjectClass* obj, word_t closure) {<br>
</div>diff --git a/lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp<br>
b/lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp<br>
index a4a48c8..476b6e3 100644<br>
--- a/lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp<br>
+++ b/lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp<br>
@@ -468,6 +468,8 @@ void<br>
Classpath::initialiseClasspath(JnjvmClassLoader* loader) {<br>
<br>
   newClass =<br>
     UPCALL_CLASS(loader, "java/lang/Class");<br>
+  // Add space for extra fields, see ClasspathReflect.h<br>
+  newClass->virtualSize += 2*sizeof(void*);<br></blockquote><div><br></div><div>Did you actually make sure no java.lang.Class  objects were created before executing that line? I'm not sure how you could ensure that with an assert. But you could just trace allocations (printf in Class::doNew) manually and see if it holds today.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
   newThrowable =<br>
     UPCALL_CLASS(loader, "java/lang/Throwable");<br>
<font color="#888888">--<br>
1.7.5.1<br>
</font></blockquote></div><br>