[vmkit-commits] [vmkit] r71651 - in /vmkit/trunk/lib/JnJVM/VMCore: JnjvmClassLoader.cpp JnjvmClassLoader.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed May 13 04:49:10 PDT 2009


Author: geoffray
Date: Wed May 13 06:47:57 2009
New Revision: 71651

URL: http://llvm.org/viewvc/llvm-project?rev=71651&view=rev
Log:
More code to avoid allocating new UTF8s.


Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Wed May 13 06:47:57 2009
@@ -397,7 +397,7 @@
 
 
 const UTF8* JnjvmClassLoader::lookupComponentName(const UTF8* name,
-                                                  bool create,
+                                                  UTF8* holder,
                                                   bool& prim) {
   uint32 len = name->size;
   uint32 start = 0;
@@ -420,9 +420,12 @@
             const uint16* buf = &(name->elements[start + 1]);
             uint32 bufLen = len - 2;
             const UTF8* componentName = hashUTF8->lookupReader(buf, bufLen);
-            if (!componentName && create) {
-              componentName = name->extract(isolate, start + 1,
-                                            start + len - 1);
+            if (!componentName && holder) {
+              holder->size = len - 1;
+              for (uint32 i = 0; i < len - 1; ++i) {
+                holder->elements[i] = name->elements[start + i];
+              }
+              componentName = holder;
             }
             return componentName;
           }
@@ -456,7 +459,7 @@
   
   if (name->elements[0] == I_TAB) {
     bool prim = false;
-    const UTF8* componentName = lookupComponentName(name, false, prim);
+    const UTF8* componentName = lookupComponentName(name, 0, prim);
     if (prim) return constructArray(name);
     if (componentName) {
       UserCommonClass* temp = lookupClass(componentName);
@@ -475,7 +478,10 @@
     return 0;
   } else if (name->elements[0] == I_TAB) {
     bool prim = false;
-    const UTF8* componentName = lookupComponentName(name, true, prim);
+    UTF8* holder = (UTF8*)alloca(sizeof(UTF8) + name->size * sizeof(uint16));
+    if (!holder) return 0;
+    
+    const UTF8* componentName = lookupComponentName(name, holder, prim);
     if (prim) return constructArray(name);
     if (componentName) {
       UserCommonClass* temp = loadName(componentName, doResolve, doThrow);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h Wed May 13 06:47:57 2009
@@ -77,10 +77,10 @@
                    JavaObject* loader, Jnjvm* isolate);
 
   /// lookupComponentName - Try to find the component name of the given array
-  /// name. If the component name is not in the table of UTF8s and create is
-  /// false, the function returns 0.
+  /// name. If the component name is not in the table of UTF8s and holder
+  /// is null, the function returns 0.
   ///
-  const UTF8* lookupComponentName(const UTF8* name, bool create, bool& prim);
+  const UTF8* lookupComponentName(const UTF8* name, UTF8* holder, bool& prim);
 
 protected:
   





More information about the vmkit-commits mailing list