[vmkit-commits] [vmkit] r83708 - in /vmkit/trunk: include/mvm/Object.h include/mvm/PrintBuffer.h include/mvm/UTF8.h lib/JnJVM/VMCore/JavaClass.cpp lib/JnJVM/VMCore/Jnjvm.cpp lib/Mvm/Runtime/Object.cpp lib/Mvm/Runtime/UTF8.cpp lib/N3/PNetLib/PNetLib.cpp lib/N3/VMCore/Assembly.cpp lib/N3/VMCore/CLIJit.cpp lib/N3/VMCore/CLISignature.cpp lib/N3/VMCore/N3.cpp lib/N3/VMCore/N3.h lib/N3/VMCore/N3Initialise.cpp lib/N3/VMCore/NativeUtil.cpp lib/N3/VMCore/Opcodes.cpp lib/N3/VMCore/VMArray.cpp lib/N3/VMCore/VMClass.cpp

Gael Thomas gael.thomas at lip6.fr
Sat Oct 10 04:41:27 PDT 2009


Author: gthomas
Date: Sat Oct 10 06:41:26 2009
New Revision: 83708

URL: http://llvm.org/viewvc/llvm-project?rev=83708&view=rev
Log:
Remove definitely printString. Now, a PrintBuffer is used without the gc.
Remark: there is a buf when I launch vmkit without parameter. I do not understand this bug and I don't now if it comes from my modifications...


Modified:
    vmkit/trunk/include/mvm/Object.h
    vmkit/trunk/include/mvm/PrintBuffer.h
    vmkit/trunk/include/mvm/UTF8.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/Mvm/Runtime/Object.cpp
    vmkit/trunk/lib/Mvm/Runtime/UTF8.cpp
    vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp
    vmkit/trunk/lib/N3/VMCore/Assembly.cpp
    vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
    vmkit/trunk/lib/N3/VMCore/CLISignature.cpp
    vmkit/trunk/lib/N3/VMCore/N3.cpp
    vmkit/trunk/lib/N3/VMCore/N3.h
    vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp
    vmkit/trunk/lib/N3/VMCore/NativeUtil.cpp
    vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
    vmkit/trunk/lib/N3/VMCore/VMArray.cpp
    vmkit/trunk/lib/N3/VMCore/VMClass.cpp

Modified: vmkit/trunk/include/mvm/Object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Object.h?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Object.h (original)
+++ vmkit/trunk/include/mvm/Object.h Sat Oct 10 06:41:26 2009
@@ -32,11 +32,6 @@
 ///
 class Object : public gc {
 public:
-  
-  /// printString - Returns a string representation of this object.
-  ///
-  char *printString(void) const;
-
   /// tracer - Default implementation of tracer. Does nothing.
   ///
   virtual void tracer() {}

Modified: vmkit/trunk/include/mvm/PrintBuffer.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/PrintBuffer.h?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/PrintBuffer.h (original)
+++ vmkit/trunk/include/mvm/PrintBuffer.h Sat Oct 10 06:41:26 2009
@@ -15,66 +15,18 @@
 
 #include "types.h"
 #include "mvm/Object.h"
+#include "mvm/UTF8.h"
 
 namespace mvm {
 
-
-/// NativeString - This class is the equivalent of a char*, but allocated
-/// by the GC, hence has a virtual table.
-///
-class NativeString : public gc {
-public:
-  
-  /// VT - The virtual table of this class.
-  ///
-  static VirtualTable VT;
-
-  /// cString - Returns the C equivalent of the NativeString.
-  ///
-  inline char *cString() { return (char *)(this + 1); }
-
-  /// readString - Copies the C string to a newly allocated NativeString.
-  inline static NativeString *readString(char *cStr) {
-    size_t nbb = strlen(cStr);
-    NativeString * res = alloc(nbb + 1);
-    memcpy(res->cString(), cStr, nbb + 1);
-    return res;
-  }
-
-  /// alloc - Allocates a NativeString of size len.
-  ///
-  static inline NativeString *alloc(size_t len) {
-    return (NativeString *)gc::operator new(len + sizeof(VirtualTable*), &VT);
-  }
-
-  /// realloc - Reallocate a native string of size len.
-  ///
-  inline NativeString *realloc(size_t len) {
-    return (NativeString *)gc::realloc(len + sizeof(VirtualTable*));
-  }
-
-  /// setAt - Sets the char c at position pos in the NativeString.
-  ///
-  inline void setAt(int pos, char c) {
-    cString()[pos] = c;
-  }
-
-public:
-  
-  /// print - Just prints the NativeString.
-  ///
-  virtual void print(PrintBuffer *buf) const;
-
-};
-
 /// PrintBuffer - This class is a buffered string.
 ///
-class PrintBuffer : public gc {
-private:
+class PrintBuffer {
+public:
  
-  /// _contents - The buffer.
+  /// contents - The buffer.
   ///
-  NativeString* _contents;
+  char* contents;
 
   /// capacity - The capacity of the current buffer.
   ///
@@ -85,40 +37,64 @@
   ///
   uint32  writePosition;
 
+	void init() {
+		capacity = 256;
+		contents = new char[capacity];
+		writePosition = 0;
+	}
 
 public:
-  
-  /// VT - The virtual table of this class.
-  ///
-  static VirtualTable VT;
-  
-  
-  /// contents - Returns the buffer.
-  ///
-  NativeString* contents() {
-    return _contents;
-  }
+	PrintBuffer() {
+		init();
+	}
 
-  /// setContents - Sets the buffer.
-  ///
-  void setContents(NativeString* n) {
-    _contents = n;
-  }
+	template <class T>
+	PrintBuffer(const T *obj) {
+		init();
+		writeObj(obj);
+	}
 
-  /// write - Writes to this PrintBuffer.
-  ///
-  inline PrintBuffer *write(const char *string) {
-    size_t len= strlen(string);
-    if ((writePosition + len + 1) >= capacity) {
-      while ((writePosition + len + 1) >= capacity)
+	~PrintBuffer() {
+		delete contents;
+	}
+	
+	char *cString() {
+		return contents;
+	}
+
+	void ensureCapacity(uint32 len) {
+		uint32 size = writePosition + len + 1;
+    if (size >= capacity) {
+      while (size >= capacity)
         capacity*= 4;
-      setContents(contents()->realloc(capacity));
+			char *newContents = new char[capacity];
+			memcpy(newContents, contents, writePosition);
+			delete[] contents;
+			contents = newContents;
     }
-    strcpy(contents()->cString() + writePosition, string);
+	}
+
+  /// write - Writes to this PrintBuffer.
+  ///
+  virtual PrintBuffer *write(const char *string) {
+    uint32 len= strlen(string);
+		ensureCapacity(len);
+    strcpy(cString() + writePosition, string);
     writePosition+= len;
     return this;
   }
-  
+
+  /// writeChar - Writes a char.
+  inline PrintBuffer *writeUTF8(const UTF8 *utf8) {
+		uint32 len = utf8->size;
+		ensureCapacity(len);
+		for(uint32 i=0; i<len; i++) {
+			//			printf("%d/%d: '%c (%d)'\n", i, len, utf8->elements[i], utf8->elements[i]);
+			contents[writePosition + i] = utf8->elements[i];
+		}
+		contents[writePosition += len] = 0;
+		return this;
+  }
 
   /// writeChar - Writes a char.
   inline PrintBuffer *writeChar(char v) {
@@ -126,7 +102,6 @@
     sprintf(buf, "%c", v);
     return write(buf);
   }
-  
 
   /// writeChar - Writes a int32.
   inline PrintBuffer *writeS4(int v) {
@@ -172,32 +147,11 @@
 
   /// writeObj - Writes an Object to the buffer.
   ///
-  PrintBuffer *writeObj(const Object *);
-
-public:
-  
-  /// alloc - Allocates a default PrintBuffer.
-  ///
-  static PrintBuffer *alloc(void) {
-    PrintBuffer* pbf = (PrintBuffer*)gc::operator new(sizeof(PrintBuffer), &VT);
-    pbf->capacity= 32;
-    pbf->writePosition= 0;
-    pbf->setContents(NativeString::alloc(pbf->capacity));
-    return pbf;
-  }
-
-	template <typename T> 
-	static char *objectToString(T *obj) {
-		PrintBuffer *buf = alloc();
-		obj->print(buf);
-		return buf->contents()->cString();
+	template <class T>
+  inline PrintBuffer *writeObj(const T *obj) {
+		obj->print(this);
+		return this;
 	}
-
-  /// tracer - Traces this PrintBuffer.
-  ///
-  static void staticTracer(PrintBuffer* obj) {
-    obj->contents()->markAndTrace();
-  }
 };
 
 } // end namespace mvm

Modified: vmkit/trunk/include/mvm/UTF8.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/UTF8.h?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/UTF8.h (original)
+++ vmkit/trunk/include/mvm/UTF8.h Sat Oct 10 06:41:26 2009
@@ -6,6 +6,7 @@
 
 namespace mvm {
 
+class PrintBuffer;
 class UTF8Map;
 
 class UTF8 {
@@ -14,8 +15,8 @@
   
   /// operator new - Redefines the new operator of this class to allocate
   /// its objects in permanent memory, not with the garbage collector.
-  void* operator new(size_t sz, mvm::BumpPtrAllocator& allocator, sint32 size) {
-    return allocator.Allocate(sizeof(ssize_t) + size * sizeof(uint16), "UTF8");
+  void* operator new(size_t sz, mvm::BumpPtrAllocator& allocator, sint32 n) {
+    return allocator.Allocate(sizeof(UTF8) + (n - 1) * sizeof(uint16), "UTF8");
   }
   
   UTF8(sint32 n) {
@@ -54,7 +55,8 @@
     else return memcmp((const char*)elements, (const char*)other->elements, 
                        size * sizeof(uint16)) < 0;
   }
-  
+
+	virtual void print(PrintBuffer *pb) const;
 };
 
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Sat Oct 10 06:41:26 2009
@@ -819,7 +819,7 @@
   
   PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "; ", 0);
   PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "reading ", 0);
-  PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", printString());
+  PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", mvm::PrintBuffer(this).cString());
 
   Reader reader(&bytes);
   uint32 magic = reader.readU4();

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Sat Oct 10 06:41:26 2009
@@ -174,7 +174,7 @@
     
     PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "; ", 0);
     PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "clinit ", 0);
-    PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", printString());
+    PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", mvm::PrintString(this).cString());
 
 
 

Modified: vmkit/trunk/lib/Mvm/Runtime/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/Object.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/Object.cpp Sat Oct 10 06:41:26 2009
@@ -20,10 +20,6 @@
 
 using namespace mvm;
 
-
-VirtualTable NativeString::VT(0, 0, (uintptr_t)VirtualTable::emptyTracer);
-VirtualTable PrintBuffer::VT(0, 0, (uintptr_t)PrintBuffer::staticTracer);
-
 extern "C" void printFloat(float f) {
   fprintf(stderr, "%f\n", f);
 }
@@ -40,32 +36,6 @@
   fprintf(stderr, "%d\n", i);
 }
 
-extern "C" void printObject(mvm::Object* obj) {
-  fprintf(stderr, "%s\n", obj->printString());
-}
-
-
-PrintBuffer *PrintBuffer::writeObj(const Object *obj) {
-  Object *beg = (Object*)Collector::begOf(obj);
-  
-  if(beg) {
-    if(beg == obj) {
-      obj->print((mvm::PrintBuffer*)this);
-    } else {
-      write("<In Object [");
-      beg->print(this);
-      write("] -- offset ");
-      writeS4((intptr_t)obj - (intptr_t)beg);
-      write(">");
-    }
-  } else {
-    write("<DirectValue: ");
-    writeS4((intptr_t)obj);
-    write(">");
-  }
-  return this;
-}
-
 extern "C" void write_ptr(PrintBuffer* buf, void* obj) {
   buf->writePtr(obj);
 }
@@ -78,43 +48,12 @@
   buf->write(a);
 }
 
-char *Object::printString(void) const {
-  PrintBuffer *buf= PrintBuffer::alloc();
-  buf->writeObj(this);
-  return buf->contents()->cString();
-}
-
 void Object::print(PrintBuffer *buf) const {
   buf->write("<Object@");
   buf->writePtr((void*)this);
   buf->write(">");
 }
 
-void NativeString::print(PrintBuffer *buf) const {
-  NativeString *const self= (NativeString *)this;
-  buf->write("\"");
-  for (size_t i= 0; i < strlen(self->cString()); ++i) {
-    int c= self->cString()[i];
-    switch (c) {
-      case '\b': buf->write("\\b"); break;
-      case '\f': buf->write("\\f"); break;
-      case '\n': buf->write("\\n"); break;
-      case '\r': buf->write("\\r"); break;
-      case '\t': buf->write("\\t"); break;
-      case '"':  buf->write("\\\""); break;
-      default: {
-        char esc[32];
-        if (c < 32)
-          sprintf(esc, "\\x%02x", c);
-        else
-          sprintf(esc, "%c", c);
-        buf->write(esc);
-      }
-    }
-  }
-  buf->write("\"");
-}
-
 typedef void (*destructor_t)(void*);
 
 

Modified: vmkit/trunk/lib/Mvm/Runtime/UTF8.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/UTF8.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/UTF8.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/UTF8.cpp Sat Oct 10 06:41:26 2009
@@ -1,7 +1,13 @@
 #include "mvm/UTF8.h"
+#include "mvm/PrintBuffer.h"
 
 using namespace mvm;
 
+void UTF8::print(PrintBuffer *pb) const {
+	pb->writeUTF8(this);
+}
+
+
 const UTF8* UTF8::extract(UTF8Map* map, uint32 start, uint32 end) const {
   uint32 len = end - start;
   uint16* buf = (uint16*)alloca(sizeof(uint16) * len);

Modified: vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp (original)
+++ vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp Sat Oct 10 06:41:26 2009
@@ -523,7 +523,7 @@
 extern "C" VMObject* System_Reflection_Assembly_LoadFromName(PNetString* str, sint32 & error, VMObject* parent) {
   N3* vm = (N3*)(VMThread::get()->vm);
   Assembly* ass = vm->loadAssembly(vm->arrayToUTF8(str->value), "dll");
-  if (!ass) vm->error("unfound assembly %s\n", str->value->printString());
+  if (!ass) vm->error("unfound assembly %s\n", mvm::PrintBuffer(str->value).cString());
   error = 0;
   return ass->getAssemblyDelegatee();
 }
@@ -620,7 +620,8 @@
 extern "C" VMObject* System_Reflection_Assembly_GetType(VMObject* obj, PNetString* str, bool onError, bool ignoreCase) {
   Assembly* ass = ASSEMBLY_VALUE(obj);
   const ArrayUInt16* array = str->value;
-  char* asciiz = ass->vm->arrayToAsciiz(array);
+	mvm::PrintBuffer pb(array);
+  char* asciiz = pb.cString();
   char* index = (char*)sys_memrchr(asciiz, '.', strlen(asciiz));
   N3* vm = ass->vm;
   
@@ -758,7 +759,7 @@
 
   if ((obj != 0) && virt) {
     if (!(obj->classOf->isAssignableFrom(type))) {
-      VMThread::get()->vm->illegalArgumentException(meth->name->printString());
+      VMThread::get()->vm->illegalArgumentException(mvm::PrintBuffer(meth->name).cString());
     }
     verifyNull(obj);
   }

Modified: vmkit/trunk/lib/N3/VMCore/Assembly.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Assembly.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Assembly.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Assembly.cpp Sat Oct 10 06:41:26 2009
@@ -374,7 +374,7 @@
   }
   buf[i] = '>';
   const UTF8* genName = UTF8::readerConstruct(VMThread::get()->vm, buf, size);
-  //printf("%s\n", genName->printString());
+  //printf("%s\n", mvm::PrintBuffer(genName).cString());
   
   ClassNameCmp CC(genName, nameSpace);
   VMGenericClass* cl = (VMGenericClass*) loadedNameClasses->lookupOrCreate(CC, this, genClassDup);
@@ -825,8 +825,8 @@
 
 void Assembly::read() {
   Reader* reader = newReader(bytes);
-  PRINT_DEBUG(DEBUG_LOAD, 1, LIGHT_GREEN, "Reading %s::%s", vm->printString(),
-              this->printString());
+  PRINT_DEBUG(DEBUG_LOAD, 1, LIGHT_GREEN, "Reading %s::%s", mvm::PrintBuffer(vm).cString(),
+              mvm::PrintBuffer(this).cString());
 
   textSection =  new(allocator, "Section") Section();
   rsrcSection =  new(allocator, "Section") Section();

Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Sat Oct 10 06:41:26 2009
@@ -485,7 +485,7 @@
     } else if (meth->name == vm->asciizToUTF8("Address")) {
       func = 2;
     } else {
-      vm->error("implement me %s", meth->name->printString());
+      vm->error("implement me %s", mvm::PrintBuffer(meth->name).cString());
     }
       
     VMClassArray* type = (VMClassArray*)meth->classDef;
@@ -607,7 +607,7 @@
     
   Value* obj = 0;
   if (type->isPointer) {
-    VMThread::get()->vm->error("implement me %s", mvm::PrintBuffer::objectToString(type));
+    VMThread::get()->vm->error("implement me %s", mvm::PrintBuffer(type).cString());
   } else if (type->isArray) {
     VMClassArray* arrayType = (VMClassArray*)type;
     Value* valCl = new LoadInst(arrayType->llvmVar(), "", currentBlock);
@@ -911,7 +911,7 @@
 
 Function* CLIJit::compileIntern() {
   PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "intern compile %s\n",
-              compilingMethod->printString());
+              mvm::PrintBuffer(compilingMethod).cString());
 
   if (compilingClass->subclassOf(MSCorlib::pDelegate)) {
     const UTF8* name = compilingMethod->name;
@@ -919,14 +919,14 @@
     else if (name == N3::invokeName) return invokeDelegate();
     else VMThread::get()->vm->error("implement me");
   } else {
-    VMThread::get()->vm->error("implement me %s", mvm::PrintBuffer::objectToString(compilingClass));
+    VMThread::get()->vm->error("implement me %s", mvm::PrintBuffer(compilingClass).cString());
   }
   return 0;
 }
 
 Function* CLIJit::compileNative(VMGenericMethod* genMethod) {
   PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "native compile %s\n",
-              compilingMethod->printString());
+              mvm::PrintBuffer(compilingMethod));
     
   const FunctionType *funcType = compilingMethod->getSignature(genMethod);
   
@@ -1148,7 +1148,7 @@
 
 Function* CLIJit::compileFatOrTiny(VMGenericClass* genClass, VMGenericMethod* genMethod) {
   PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "tiny or fat compile %s\n",
-              compilingMethod->printString());
+              mvm::PrintBuffer(compilingMethod).cString());
   uint32 offset = compilingMethod->offset;
   ArrayUInt8* bytes = compilingClass->assembly->bytes;
   uint8 header = READ_U1(bytes, offset);
@@ -1314,7 +1314,7 @@
   
   if (nbe == 0 && codeLen < 50) {
     PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "%s can be inlined\n",
-                compilingMethod->printString());
+                mvm::PrintBuffer(compilingMethod).cString());
     compilingMethod->canBeInlined = true;
   }
   
@@ -1326,7 +1326,7 @@
                                    std::vector<Value*>& args, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   
   PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "tiny or fat inline compile %s\n",
-              compilingMethod->printString());
+              mvm::PrintBuffer(compilingMethod).cString());
   uint32 offset = compilingMethod->offset;
   ArrayUInt8* bytes = compilingClass->assembly->bytes;
   uint8 header = READ_U1(bytes, offset);
@@ -1439,7 +1439,7 @@
   
   PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL,
               "end tiny or fat inline compile %s\n",
-              compilingMethod->printString());
+              mvm::PrintBuffer(compilingMethod).cString());
   
   return endNode;
 }
@@ -1471,7 +1471,7 @@
     classDef->aquire();
     if (methPtr == 0) {
       methPtr = Function::Create(getSignature(genMethod), GlobalValue::GhostLinkage,
-                                 mvm::PrintBuffer::objectToString(this), classDef->vm->getLLVMModule());
+                                 mvm::PrintBuffer(this).cString(), classDef->vm->getLLVMModule());
       classDef->vm->functions->hash(methPtr, this);
     }
     classDef->release();

Modified: vmkit/trunk/lib/N3/VMCore/CLISignature.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLISignature.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLISignature.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLISignature.cpp Sat Oct 10 06:41:26 2009
@@ -182,7 +182,7 @@
   uint32 numSizes = ass->uncompressSignature(offset);
 
   if (numSizes != 0) {
-    printf("type = %s\n", mvm::PrintBuffer::objectToString(cl));
+    printf("type = %s\n", mvm::PrintBuffer(cl).cString());
     VMThread::get()->vm->error("implement me");
   }
 

Modified: vmkit/trunk/lib/N3/VMCore/N3.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3.cpp Sat Oct 10 06:41:26 2009
@@ -370,7 +370,7 @@
     vm->executeAssembly(info.assembly, args);
   }catch(...) {
     VMObject* exc = th->pendingException;
-    printf("N3 caught %s\n", exc->printString());
+    printf("N3 caught %s\n", mvm::PrintBuffer(exc).cString());
   }
 
   vm->threadSystem->nonDaemonLock->lock();
@@ -416,14 +416,4 @@
   return (CLIString*)CLIString::stringDup(array, this);
 }
 
-char* N3::arrayToAsciiz(const ArrayUInt16 *array) {
-	int size = array->size;
-  mvm::NativeString* buf = mvm::NativeString::alloc(size + 1);
-  for (sint32 i = 0; i < size; ++i) {
-    buf->setAt(i, array->elements[i]);
-  }
-  buf->setAt(size, 0);
-  return buf->cString();
-}
-
 #include "MSCorlib.inc"

Modified: vmkit/trunk/lib/N3/VMCore/N3.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.h?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3.h (original)
+++ vmkit/trunk/lib/N3/VMCore/N3.h Sat Oct 10 06:41:26 2009
@@ -129,7 +129,6 @@
 
 	// usefull string, uint16 and utf8 functions
 
-	char*            arrayToAsciiz(const ArrayUInt16 *array);
 	ArrayUInt16*     asciizToArray(const char *asciiz);          // done
 	ArrayUInt16*     bufToArray(const uint16 *buf, uint32 len);  // done
 	ArrayUInt16*     UTF8ToArray(const UTF8 *utf8);              // done

Modified: vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp Sat Oct 10 06:41:26 2009
@@ -189,6 +189,9 @@
 	{
 		UTF8 fake(0);																				
 		UTF8::VT = ((VirtualTable**)(void*)(&fake))[0];	
+#if !defined(WITHOUT_FINALIZER)
+		((void**)UTF8::VT)[0] = 0;
+#endif
 	}
 
   INIT(VMCond);

Modified: vmkit/trunk/lib/N3/VMCore/NativeUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/NativeUtil.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/NativeUtil.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/NativeUtil.cpp Sat Oct 10 06:41:26 2009
@@ -30,7 +30,11 @@
 
 static void* makeFull(VMCommonClass* cl, VMMethod* meth) {
   char* buf = (char*)alloca(4096);
-  sprintf(buf, "%s_%s_%s", cl->nameSpace->printString(), cl->name->printString(), meth->name->printString());
+  sprintf(buf, 
+					"%s_%s_%s", 
+					mvm::PrintBuffer(cl->nameSpace).cString(), 
+					mvm::PrintBuffer(cl->name).cString(),
+					mvm::PrintBuffer(meth->name).cString());
 
   std::vector<VMCommonClass*>::iterator i = meth->parameters.begin(),
                                         e = meth->parameters.end();
@@ -39,7 +43,7 @@
   ++i;
   for ( ; i!= e; ++i) {
     VMCommonClass* cl = *i;
-    sprintf(buf, "%s_%s_%s", buf, cl->nameSpace->printString(), cl->name->printString());
+    sprintf(buf, "%s_%s_%s", buf, mvm::PrintBuffer(cl->nameSpace).cString(), mvm::PrintBuffer(cl->name).cString());
   }
 
   cliToInternal(buf);
@@ -47,16 +51,19 @@
   
   if (!res) {
     VMThread::get()->vm->error("unable to find native method %s",
-                               mvm::PrintBuffer::objectToString(meth));
+                               mvm::PrintBuffer(meth).cString());
   }
 
   return res;
 }
 
 void* NativeUtil::nativeLookup(VMCommonClass* cl, VMMethod* meth) {
-  char* name = cl->name->printString();
-  char* nameSpace = cl->nameSpace->printString();
-  char* methName = meth->name->printString();
+	mvm::PrintBuffer _name(cl->name);
+	mvm::PrintBuffer _nameSpace(cl->nameSpace);
+	mvm::PrintBuffer _methName(meth->name);
+  char* name = _name.cString();
+  char* nameSpace = _nameSpace.cString();
+  char* methName = _methName.cString();
 
   char* buf = (char*)alloca(6 + strlen(name) + strlen(nameSpace) +
                             strlen(methName));

Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Sat Oct 10 06:41:26 2009
@@ -107,7 +107,7 @@
 
 
 extern "C" void n3PrintExecution(char* opcode, VMMethod* meth) {
-  fprintf(stderr, "executing %s %s\n", mvm::PrintBuffer::objectToString(meth), opcode);
+  fprintf(stderr, "executing %s %s\n", mvm::PrintBuffer(meth).cString(), opcode);
 }
 
 
@@ -208,7 +208,7 @@
     if (bytecodes[i] != 0xFE) {
       PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5x] %-5d ", i,
                   bytecodes[i]);
-      PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "compiling %s::", compilingMethod->printString());
+      PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "compiling %s::", mvm::PrintBuffer(compilingMethod).cString());
       PRINT_DEBUG(N3_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecodes[i]]);
       PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "\n");
     }
@@ -1827,7 +1827,7 @@
       case 0xFE : {
         PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5x] %-5d ", i,
                     bytecodes[i + 1]);
-        PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "compiling %s::", compilingMethod->printString());
+        PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "compiling %s::", mvm::PrintBuffer(compilingMethod).cString());
         PRINT_DEBUG(N3_COMPILE, 1, LIGHT_CYAN, OpcodeNamesFE[bytecodes[i + 1]]);
         PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "\n");
 
@@ -2023,7 +2023,7 @@
     if (bytecodes[i] != 0xFE) {
       PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5x] %-5d ", i,
                   bytecodes[i]);
-      PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "exploring %s::", compilingMethod->printString());
+      PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "exploring %s::", mvm::PrintBuffer(compilingMethod).cString());
       PRINT_DEBUG(N3_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecodes[i]]);
       PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "\n");
     }
@@ -2467,7 +2467,7 @@
       
         PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5x] %-5d ", i,
                     bytecodes[i + 1]);
-        PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "exploring %s::", compilingMethod->printString());
+        PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "exploring %s::", mvm::PrintBuffer(compilingMethod).cString());
         PRINT_DEBUG(N3_COMPILE, 1, LIGHT_CYAN, OpcodeNamesFE[bytecodes[i + 1]]);
         PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "\n");
       

Modified: vmkit/trunk/lib/N3/VMCore/VMArray.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMArray.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMArray.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMArray.cpp Sat Oct 10 06:41:26 2009
@@ -159,7 +159,7 @@
 void ArrayObject::print(mvm::PrintBuffer *buf) const {
   buf->write("Array<");
   for (int i = 0; i < size; i++) {
-    buf->writeObj(elements[i]);
+		elements[i]->print(buf);
     buf->write(" ");
   }
   buf->write(">");

Modified: vmkit/trunk/lib/N3/VMCore/VMClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.cpp?rev=83708&r1=83707&r2=83708&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Sat Oct 10 06:41:26 2009
@@ -246,8 +246,8 @@
       
       PRINT_DEBUG(N3_LOAD, 0, COLOR_NORMAL, "%s", "; ");
       PRINT_DEBUG(N3_LOAD, 0, LIGHT_GREEN, "%s", "clinit ");
-      PRINT_DEBUG(N3_LOAD, 0, COLOR_NORMAL, "%s::%s\n", printString(),
-                  cl->printString());
+      PRINT_DEBUG(N3_LOAD, 0, COLOR_NORMAL, "%s::%s\n", mvm::PrintBuffer(this).cString(),
+                  mvm::PrintBuffer(cl).cString());
       
       if (meth) {
         llvm::Function* pred = meth->compiledPtr(genMethod);
@@ -570,7 +570,7 @@
   if (!res) {
     VMThread::get()->vm->error(N3::MissingMethodException, 
                                "unable to find %s in %s",
-                               mvm::PrintBuffer::objectToString(name), mvm::PrintBuffer::objectToString(this));
+                               mvm::PrintBuffer(name).cString(), mvm::PrintBuffer(this).cString());
   }
   return res;
 }
@@ -617,7 +617,7 @@
   if (!res) {
     VMThread::get()->vm->error(N3::MissingFieldException, 
                                "unable to find %s in %s",
-                               mvm::PrintBuffer::objectToString(name), mvm::PrintBuffer::objectToString(this));
+                               mvm::PrintBuffer(name).cString(), mvm::PrintBuffer(this).cString());
   }
   return res;
 }





More information about the vmkit-commits mailing list