[vmkit-commits] [vmkit] r71977 - in /vmkit/trunk/lib/JnJVM: Compiler/JITInfo.cpp Compiler/JavaAOTCompiler.cpp Compiler/JnjvmModuleProvider.cpp VMCore/JavaArray.cpp VMCore/JavaArray.h VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JavaTypes.cpp VMCore/JavaTypes.h VMCore/JnjvmClassLoader.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun May 17 05:37:15 PDT 2009


Author: geoffray
Date: Sun May 17 07:36:53 2009
New Revision: 71977

URL: http://llvm.org/viewvc/llvm-project?rev=71977&view=rev
Log:
Code cleanup. No functionality changes.


Modified:
    vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp

Modified: vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp?rev=71977&r1=71976&r2=71977&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp Sun May 17 07:36:53 2009
@@ -373,10 +373,10 @@
   
   JavaLLVMCompiler* Mod = 
     (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
-  const char* name = 0;
+  std::string name;
   if (Mod->isStaticCompiling()) {
-    name = virt ? signature->printString("virtual_ap") :
-                  signature->printString("static_ap");
+    name += signature->printString();
+    name += virt ? "virtual_ap" : "static_ap";
   } else {
     name = "";
   }

Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp?rev=71977&r1=71976&r2=71977&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp Sun May 17 07:36:53 2009
@@ -18,6 +18,7 @@
 
 #include "jnjvm/JnjvmModule.h"
 
+#include "JavaArray.h"
 #include "JavaCache.h"
 #include "JavaConstantPool.h"
 #include "JavaString.h"
@@ -276,9 +277,11 @@
     LLVMClassInfo* LCI = getClassInfo(classDef);
     const Type* Ty = LCI->getStaticType();
     Ty = Ty->getContainedType(0);
+    std::string name(classDef->printString());
+    name += "_static";
     GlobalVariable* varGV = 
       new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage,
-                         0, classDef->printString("<static>"), getLLVMModule());
+                         0, name, getLLVMModule());
 
     Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV,
                                           JnjvmModule::ptrType);
@@ -314,13 +317,13 @@
       dyn_cast<ArrayType>(JnjvmModule::VTType->getContainedType(0));
     const PointerType* PTy = dyn_cast<PointerType>(ATy->getContainedType(0));
     ATy = ArrayType::get(PTy, size);
+    std::string name(classDef->printString());
+    name += "_VT";
     // Do not set a virtual table as a constant, because the runtime may
     // modify it.
     GlobalVariable* varGV = new GlobalVariable(ATy, false,
                                                GlobalValue::ExternalLinkage,
-                                               0, 
-                                               classDef->printString("<VT>"),
-                                               getLLVMModule());
+                                               0, name, getLLVMModule());
   
     res = ConstantExpr::getCast(Instruction::BitCast, varGV,
                                 JnjvmModule::VTType);

Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp?rev=71977&r1=71976&r2=71977&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Sun May 17 07:36:53 2009
@@ -70,9 +70,11 @@
   Function* func = 0;
   LLVMSignatureInfo* LSI = getSignatureInfo(sign);
   
-  const char* name = cl->printString();
-  char* key = (char*)alloca(strlen(name) + 16);
-  sprintf(key, "%s%d", name, index);
+  const UTF8* name = cl->name;
+  char* key = (char*)alloca(name->size + 16);
+  for (sint32 i = 0; i < name->size; ++i)
+    key[i] = name->elements[i];
+  sprintf(key + name->size, "%d", index);
   Function* F = TheModule->getFunction(key);
   if (F) return F;
   

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp Sun May 17 07:36:53 2009
@@ -35,15 +35,6 @@
 const unsigned int JavaArray::T_INT = 10;
 const unsigned int JavaArray::T_LONG = 11;
 
-void UTF8::printUTF8(mvm::PrintBuffer* buf) const {
-  for (int i = 0; i < size; i++)
-    buf->writeChar((char)elements[i]);
-}
-
-void UTF8::print(mvm::PrintBuffer* buf) const {
-  return printUTF8(buf);
-}
-
 const UTF8* UTF8::extract(UTF8Map* map, uint32 start, uint32 end) const {
   uint32 len = end - start;
   uint16* buf = (uint16*)alloca(sizeof(uint16) * len);
@@ -55,7 +46,7 @@
   return map->lookupOrCreateReader(buf, len);
 }
 
-char* UTF8::UTF8ToAsciiz() const {
+char* UTF8::printString() const {
 #ifndef DEBUG
   mvm::NativeString* buf = mvm::NativeString::alloc(size + 1);
   for (sint32 i = 0; i < size; ++i) {

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h Sun May 17 07:36:53 2009
@@ -128,13 +128,8 @@
   const UTF8* extract(UTF8Map* map, uint32 start, uint32 len) const;
 
   
-  /// UTF8ToAsciiz - Allocates a C string with the contents of this UTF8.
-  char* UTF8ToAsciiz() const;
-  
   /// printString - Allocates a C string with the contents of this UTF8.
-  char* printString() const {
-    return UTF8ToAsciiz();
-  }
+  char* printString() const;
 
   /// equals - Are the two UTF8s equal?
   bool equals(const UTF8* other) const {
@@ -157,12 +152,6 @@
                        size * sizeof(uint16)) < 0;
   }
   
-  /// print - Prints the UTF8 for debugging purposes.
-  virtual void print(mvm::PrintBuffer* buf) const;
-  
-  /// printUTF8 - Prints the UTF8 for debugging purposes.
-  void printUTF8(mvm::PrintBuffer* buf) const;
-
 };
 
 } // end namespace jnjvm

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Sun May 17 07:36:53 2009
@@ -150,40 +150,6 @@
   }
 }
 
-static void printClassNameIntern(const UTF8* name, unsigned int start,
-                                 unsigned int end,  mvm::PrintBuffer* buf) {
-  
-  uint16 first = name->elements[start];
-  if (first == I_TAB) {
-    unsigned int stepsEnd = start;
-    while (name->elements[stepsEnd] == I_TAB) stepsEnd++;
-    if (name->elements[stepsEnd] == I_REF) {
-      printClassNameIntern(name, (stepsEnd + 1),(end - 1), buf);
-    } else {
-      name->printUTF8(buf);
-    }
-    buf->write(" ");
-    for (uint32 i = start; i < stepsEnd; i++)
-      buf->write("[]");
-  } else {
-    char* tmp = (char*)(alloca(1 + (end - start)));
-    for (uint32 i = start; i < end; i++) {
-      short int cur = name->elements[i];
-      tmp[i - start] = (cur == '/' ? '.' : cur);
-    }
-    tmp[end - start] = 0;
-    buf->write(tmp);
-  }
-}
-
-void CommonClass::printClassName(const UTF8* name, mvm::PrintBuffer* buf) {
-  printClassNameIntern(name, 0, name->size, buf);
-}
-
-void CommonClass::print(mvm::PrintBuffer* buf) const {
-  printClassName(name, buf);
-}
-
 UserClassPrimitive* CommonClass::toPrimitive(Jnjvm* vm) const {
   if (this == vm->upcalls->voidClass) {
     return vm->upcalls->OfVoid;
@@ -366,30 +332,6 @@
   cl->classLoader->getCompiler()->setDestructor(this, ptr, name);
 }
 
-const char* JavaMethod::printString() const {
-  mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc();
-  buf->write("JavaMethod<");
-  ((JavaMethod*)this)->getSignature()->printWithSign(classDef, name, buf);
-  buf->write(">");
-  return buf->contents()->cString();
-}
-
-const char* JavaField::printString() const {
-  mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc();
-  buf->write("JavaField<");
-  if (isStatic(access))
-    buf->write("static ");
-  else
-    buf->write("virtual ");
-  ((JavaField*)this)->getSignature()->tPrintBuf(buf);
-  buf->write(" ");
-  classDef->print(buf);
-  buf->write("::");
-  name->printUTF8(buf);
-  buf->write(">");
-  return buf->contents()->cString();
-}
-
 JavaMethod* Class::lookupInterfaceMethodDontThrow(const UTF8* name,
                                                   const UTF8* type) {
   JavaMethod* cur = lookupMethodDontThrow(name, type, false, false, 0);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Sun May 17 07:36:53 2009
@@ -20,6 +20,7 @@
 #include "mvm/Threads/Locks.h"
 
 #include "JavaAccess.h"
+#include "JavaArray.h"
 #include "JnjvmClassLoader.h"
 #include "JnjvmConfig.h"
 
@@ -415,26 +416,14 @@
     return 0;
   }
 
-  /// printClassName - Adds a string representation of this class in the
-  /// given buffer.
-  ///
-  static void printClassName(const UTF8* name, mvm::PrintBuffer* buf);
-   
-  /// print - Print the class for debugging purposes.
-  ///
-  void print(mvm::PrintBuffer *buf) const;
-  
   /// tracer - The tracer of this GC-allocated class.
   ///
   void TRACER;
   
   /// printString - Prints the class.
   ///
-  const char *printString(const char* ext = "") const {
-    mvm::PrintBuffer *buf = mvm::PrintBuffer::alloc();
-    print(buf);
-    buf->write(ext);
-    return buf->contents()->cString();
+  const char *printString() const {
+    return name->printString();
   }
 
   /// inheritName - Does this class in its class hierarchy inherits
@@ -1168,7 +1157,9 @@
   
   /// printString - Output a string representation of the method.
   ///
-  const char* printString() const;
+  const char* printString() const {
+    return name->printString();
+  }
  
   /// toString - Return an array of chars, suitable for creating a string.
   ///
@@ -1422,7 +1413,9 @@
 
   /// printString - Output a string representation of the field.
   ///
-  const char* printString() const;
+  const char* printString() const {
+    return name->printString();
+  }
 
   /// getVritual*Field - Get a virtual field of an object.
   ///

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp Sun May 17 07:36:53 2009
@@ -16,26 +16,6 @@
 
 using namespace jnjvm;
 
-void PrimitiveTypedef::tPrintBuf(mvm::PrintBuffer* buf) const {
-  prim->name->printUTF8(buf);
-}
-
-void ArrayTypedef::tPrintBuf(mvm::PrintBuffer* buf) const {
-  UserCommonClass::printClassName(keyName, buf);
-}
-
-void ObjectTypedef::tPrintBuf(mvm::PrintBuffer* buf) const {
-  UserCommonClass::printClassName(pseudoAssocClassName, buf);
-}
-
-const char* Typedef::printString() const {
-  mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc();
-  buf->write("Type<");
-  tPrintBuf(buf);
-  buf->write(">");
-  return buf->contents()->cString();
-}
-
 UserCommonClass* ArrayTypedef::assocClass(JnjvmClassLoader* loader) const {
   return loader->constructArray(keyName);
 }
@@ -44,39 +24,6 @@
   return loader->loadName(pseudoAssocClassName, false, true);
 }
 
-void Signdef::humanPrintArgs(mvm::PrintBuffer* buf) const {
-  buf->write("(");
-  Typedef* const* arguments = getArgumentsType();
-  for (uint32 i = 0; i < nbArguments; i++) {
-    arguments[i]->tPrintBuf(buf);
-    if (i != nbArguments - 1) {
-      buf->write(", ");
-    }
-  }
-  buf->write(")");
-}
-
-const char* Signdef::printString(const char* ext) const {
-  mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc();
-  buf->write("Signature<");
-  getReturnType()->tPrintBuf(buf);
-  buf->write("...");
-  humanPrintArgs(buf);
-  buf->write(ext);
-  buf->write(">");
-  return buf->contents()->cString();
-}
-
-void Signdef::printWithSign(UserCommonClass* cl, const UTF8* name,
-                            mvm::PrintBuffer* buf) const {
-  getReturnType()->tPrintBuf(buf);
-  buf->write(" ");
-  UserCommonClass::printClassName(cl->name, buf);
-  buf->write("::");
-  name->printUTF8(buf);
-  humanPrintArgs(buf);
-}
-
 Signdef::Signdef(const UTF8* name, JnjvmClassLoader* loader,
                  std::vector<Typedef*>& args, Typedef* ret) {
   

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Sun May 17 07:36:53 2009
@@ -65,13 +65,12 @@
   ///
   const UTF8* keyName;
   
-  /// tPrintBuf - Prints the name of the class this Typedef represents.
-  ///
-  virtual void tPrintBuf(mvm::PrintBuffer* buf) const = 0;
-  
   /// printString - Print the Typedef for debugging purposes.
   ///
-  const char* printString() const;
+  const char* printString() const {
+    assert(keyName && "No key name");
+    return keyName->printString();
+  }
   
   /// assocClass - Given the loaded, try to load the class represented by this
   /// Typedef.
@@ -123,11 +122,6 @@
   
 public:
   
-  /// tPrintBuf - Prints the name of the class this Typedef represents.
-  ///
-  virtual void tPrintBuf(mvm::PrintBuffer* buf) const;
-  
-
   virtual bool trace() const {
     return false;
   }
@@ -195,10 +189,6 @@
 
 class ArrayTypedef : public Typedef {
 public:
-  /// tPrintBuf - Prints the name of the class this Typedef represents.
-  ///
-  virtual void tPrintBuf(mvm::PrintBuffer* buf) const;
-
   
   virtual bool trace() const {
     return true;
@@ -219,10 +209,6 @@
   const UTF8* pseudoAssocClassName;
 
 public:
-  /// tPrintBuf - Prints the name of the class this Typedef represents.
-  ///
-  virtual void tPrintBuf(mvm::PrintBuffer* buf) const;
-  
   virtual bool trace() const {
     return true;
   }
@@ -285,18 +271,14 @@
   
   /// printString - Print the signature with the following extension.
   ///
-  const char* printString(const char* ext = "") const;
+  const char* printString() const {
+    return keyName->printString();
+  }
   
   /// nativeName - Get a native name for callbacks emitted AOT.
   ///
   void nativeName(char* buf, const char* ext) const;
 
-  /// printWithSign - Print the signature of a method with the method's class
-  /// and name.
-  ///
-  void printWithSign(UserCommonClass* cl, const UTF8* name,
-                     mvm::PrintBuffer* buf) const;
-  
   /// Signdef - Create a new Signdef.
   ///
   Signdef(const UTF8* name, JnjvmClassLoader* loader,
@@ -394,9 +376,6 @@
   }
 
 private:
-  /// humanPrintArgs - Prints the list of typedef in a human readable form.
-  ///
-  void humanPrintArgs(mvm::PrintBuffer* buf) const;
   
   /// arguments - The list of arguments of the signature. First is the return
   /// type.

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Sun May 17 07:36:53 2009
@@ -294,7 +294,7 @@
 }
 
 ArrayUInt8* JnjvmBootstrapLoader::openName(const UTF8* utf8) {
-  char* asciiz = utf8->UTF8ToAsciiz();
+  char* asciiz = utf8->printString();
   uint32 alen = strlen(asciiz);
   ArrayUInt8* res = 0;
   





More information about the vmkit-commits mailing list