[vmkit-commits] [vmkit] r59307 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp Jnjvm.cpp JnjvmModule.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Fri Nov 14 08:15:31 PST 2008
Author: geoffray
Date: Fri Nov 14 10:15:18 2008
New Revision: 59307
URL: http://llvm.org/viewvc/llvm-project?rev=59307&view=rev
Log:
There is no virtual machine during intialization of jnjvm, so don't get a JVM
in the resolution of a class.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=59307&r1=59306&r2=59307&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Fri Nov 14 10:15:18 2008
@@ -900,10 +900,6 @@
JnjvmModule *Mod = classLoader->getModule();
Mod->resolveVirtualClass(cl);
Mod->resolveStaticClass(cl);
-#ifndef ISOLATE
- // Allocate now so that compiled code can reference it.
- cl->allocateStaticInstance(JavaThread::get()->getJVM());
-#endif
cl->status = resolved;
}
release();
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=59307&r1=59306&r2=59307&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Fri Nov 14 10:15:18 2008
@@ -117,6 +117,20 @@
// Class object.
setOwnerClass(self);
setInitializationState(inClinit);
+ UserClass* cl = (UserClass*)this;
+#if defined(ISOLATE) || defined(ISOLATE_SHARING)
+ // Isolate environments allocate the static instance on their own, not when
+ // the class is being resolved.
+ JavaObject* val = cl->allocateStaticInstance(vm);
+#else
+ // Single environment allocates the static instance during resolution, so
+ // that compiled code can access it directly (with an initialization
+ // check just before the access)
+ JavaObject* val = cl->getStaticInstance();
+ if (!val) {
+ val = cl->allocateStaticInstance(vm);
+ }
+#endif
release();
@@ -160,19 +174,7 @@
PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", printString());
- UserClass* cl = (UserClass*)this;
-
-#if defined(ISOLATE) || defined(ISOLATE_SHARING)
- // Isolate environments allocate the static instance on their own, not when
- // the class is being resolved.
- JavaObject* val = cl->allocateStaticInstance(vm);
-#else
- // Single environment allocates the static instance during resolution, so
- // that compiled code can access it directly (with an initialization
- // check just before the access)
- JavaObject* val = cl->getStaticInstance();
-#endif
-
+
JavaField* fields = cl->getStaticFields();
for (uint32 i = 0; i < cl->nbStaticFields; ++i) {
fields[i].initField(val, vm);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=59307&r1=59306&r2=59307&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Fri Nov 14 10:15:18 2008
@@ -177,8 +177,17 @@
LLVMClassInfo* LCI = getClassInfo(classDef);
LCI->getStaticType();
JavaObject* obj = ((Class*)classDef)->getStaticInstance();
- assert((obj || isStaticCompiling()) &&
- "Getting static instance before it's created!");
+#ifndef ISOLATE
+ if (!obj && !isStaticCompiling()) {
+ Class* cl = (Class*)classDef;
+ classDef->acquire();
+ if (!(cl->getStaticInstance())) {
+ // Allocate now so that compiled code can reference it.
+ cl->allocateStaticInstance(JavaThread::get()->getJVM());
+ }
+ classDef->release();
+ }
+#endif
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
uint64_t (obj)), JnjvmModule::JavaObjectType);
More information about the vmkit-commits
mailing list