[vmkit-commits] [vmkit] r64913 - in /vmkit/trunk/lib/JnJVM: LLVMRuntime/runtime-default.ll VMCore/JavaClass.h VMCore/JnjvmModule.cpp VMCore/JnjvmModule.h VMCore/LowerConstantCalls.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Feb 18 01:34:33 PST 2009


Author: geoffray
Date: Wed Feb 18 03:34:24 2009
New Revision: 64913

URL: http://llvm.org/viewvc/llvm-project?rev=64913&view=rev
Log:
Save one compare instruction in the initialization check by
storing the info as a bool in the per-task class information.


Modified:
    vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
    vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp

Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=64913&r1=64912&r2=64913&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Wed Feb 18 03:34:24 2009
@@ -30,8 +30,9 @@
 
 ;;; The task class mirror.
 ;;; Field 1: The class state
-;;; Field 2: The static instance
-%TaskClassMirror = type { i32, i8* }
+;;; Field 2: The initialization state
+;;; Field 3: The static instance
+%TaskClassMirror = type { i8, i1, i8* }
 
 ;;; Field 0: the VT of threads
 ;;; Field 1: next

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=64913&r1=64912&r2=64913&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Wed Feb 18 03:34:24 2009
@@ -47,16 +47,13 @@
 /// used (i.e allocating instances of the class, calling methods of the class
 /// and accessing static fields of the class) when it is in the ready state.
 ///
-typedef enum JavaState {
-  loaded = 0,       /// The .class file has been found.
-  classRead = 1,    /// The .class file has been read.
-  resolved = 2,     /// The class has been resolved.
-  vmjc = 3,         /// The class is defined in a shared library.
-  inClinit = 4,     /// The class is cliniting.
-  ready = 5,        /// The class is ready to be used.
-  erroneous = 6,    /// The class is in an erroneous state.
-  dontuseenums = 0xffffffff /// dummy value to force the enum to be int32
-} JavaState;
+#define loaded 0       /// The .class file has been found.
+#define classRead 1    /// The .class file has been read.
+#define resolved 2     /// The class has been resolved.
+#define vmjc 3         /// The class is defined in a shared library.
+#define inClinit 4     /// The class is cliniting.
+#define ready 5        /// The class is ready to be used.
+#define erroneous 6    /// The class is in an erroneous state.
 
 
 /// Attribut - This class represents JVM attributes to Java class, methods and
@@ -124,9 +121,12 @@
 class TaskClassMirror {
 public:
   
-  /// status - The initialization state.
+  /// status - The state.
   ///
-  JavaState status;
+  uint8 status;
+
+  /// initialized - Is the class initialized?
+  bool initialized;
 
   /// staticInstance - Memory that holds the static variables of the class.
   ///
@@ -745,14 +745,15 @@
   
   /// getInitializationState - Get the state of the class.
   ///
-  JavaState getInitializationState() {
+  uint8 getInitializationState() {
     return IsolateInfo[0].status;
   }
 
   /// setInitializationState - Set the state of the class.
   ///
-  void setInitializationState(JavaState st) {
+  void setInitializationState(uint8 st) {
     IsolateInfo[0].status = st;
+    if (st == ready) IsolateInfo[0].initialized = true;
   }
   
   /// isReady - Has this class been initialized?
@@ -824,11 +825,11 @@
     getCurrentTaskClassMirror().staticInstance = val;
   }
 
-  JavaState getInitializationState() {
+  uint8 getInitializationState() {
     return getCurrentTaskClassMirror().status;
   }
   
-  void setInitializationState(JavaState st) {
+  void setInitializationState(uint8 st) {
     getCurrentTaskClassMirror().status = st;
   }
   

Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=64913&r1=64912&r2=64913&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Wed Feb 18 03:34:24 2009
@@ -92,6 +92,7 @@
 llvm::ConstantInt*  JnjvmModule::OffsetTaskClassMirrorInClassConstant;
 llvm::ConstantInt*  JnjvmModule::OffsetStaticInstanceInTaskClassMirrorConstant;
 llvm::ConstantInt*  JnjvmModule::OffsetStatusInTaskClassMirrorConstant;
+llvm::ConstantInt*  JnjvmModule::OffsetInitializedInTaskClassMirrorConstant;
 llvm::ConstantInt*  JnjvmModule::OffsetJavaExceptionInThreadConstant;
 llvm::ConstantInt*  JnjvmModule::OffsetCXXExceptionInThreadConstant;
 llvm::ConstantInt*  JnjvmModule::ClassReadyConstant;
@@ -2019,13 +2020,14 @@
   OffsetObjectSizeInClassConstant = mvm::MvmModule::constantOne;
   OffsetVTInClassConstant = mvm::MvmModule::constantTwo;
   OffsetTaskClassMirrorInClassConstant = mvm::MvmModule::constantThree;
-  OffsetStaticInstanceInTaskClassMirrorConstant = mvm::MvmModule::constantOne;
+  OffsetStaticInstanceInTaskClassMirrorConstant = mvm::MvmModule::constantTwo;
   OffsetStatusInTaskClassMirrorConstant = mvm::MvmModule::constantZero;
+  OffsetInitializedInTaskClassMirrorConstant = mvm::MvmModule::constantOne;
   
   OffsetJavaExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 9);
   OffsetCXXExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 10);
   
-  ClassReadyConstant = ConstantInt::get(Type::Int32Ty, ready);
+  ClassReadyConstant = ConstantInt::get(Type::Int8Ty, ready);
  
 
   if (staticCompilation) {

Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h?rev=64913&r1=64912&r2=64913&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Wed Feb 18 03:34:24 2009
@@ -365,6 +365,7 @@
   static llvm::ConstantInt* OffsetDisplayInClassConstant;
   static llvm::ConstantInt* OffsetTaskClassMirrorInClassConstant;
   static llvm::ConstantInt* OffsetStaticInstanceInTaskClassMirrorConstant;
+  static llvm::ConstantInt* OffsetInitializedInTaskClassMirrorConstant;
   static llvm::ConstantInt* OffsetStatusInTaskClassMirrorConstant;
   
   static llvm::ConstantInt* OffsetJavaExceptionInThreadConstant;

Modified: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=64913&r1=64912&r2=64913&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Wed Feb 18 03:34:24 2009
@@ -280,15 +280,13 @@
          
           Value* Cl = Call.getArgument(0); 
           Value* TCM = getTCM(module, Call.getArgument(0), CI);
-          Value* GEP[2] = { module->constantZero,
-                            module->OffsetStatusInTaskClassMirrorConstant };
+          Value* GEP[2] = 
+            { module->constantZero,
+              module->OffsetInitializedInTaskClassMirrorConstant };
           Value* StatusPtr = GetElementPtrInst::Create(TCM, GEP, GEP + 2, "",
                                                        CI);
           
-          Value* Status = new LoadInst(StatusPtr, "", CI);
-          Value* test = new ICmpInst(ICmpInst::ICMP_EQ, Status,
-                                     module->ClassReadyConstant,
-                                     "", CI);
+          Value* test = new LoadInst(StatusPtr, "", CI);
           
           BasicBlock* trueCl = BasicBlock::Create("Initialized", &F);
           BasicBlock* falseCl = BasicBlock::Create("Uninitialized", &F);





More information about the vmkit-commits mailing list