harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r595379 - in /harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363: base/ver_utils.h java5/context_5.h
Date Thu, 15 Nov 2007 18:06:02 GMT
Author: mloenko
Date: Thu Nov 15 10:05:56 2007
New Revision: 595379

URL: http://svn.apache.org/viewvc?rev=595379&view=rev
Log:
templatizing util classes to extend their usage

Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver_utils.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver_utils.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver_utils.h?rev=595379&r1=595378&r2=595379&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver_utils.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver_utils.h Thu Nov 15 10:05:56
2007
@@ -72,10 +72,11 @@
         vf_HashEntry_t *next;       // next hash entry
     };
 
+    template<typename T>
     class Stack {
     protected:
         int max_depth;
-        Address* stack;
+        T* stack;
         int depth;
 
     public:
@@ -88,16 +89,17 @@
               tc_free(stack);
           }
 
-          void push(Address value) {
+          void push(T value) {
               if( depth == max_depth ) {
-                  max_depth += max_depth/2 + 32;
-                  stack = (Address*) tc_realloc(stack, sizeof(Address) * max_depth);
+                  assert(sizeof(T) < 4096);
+                  max_depth += 4096/sizeof(T);
+                  stack = (T*) tc_realloc(stack, sizeof(T) * max_depth);
               }
 
               stack[depth++] = value;
           }
 
-          Address pop() {
+          T pop() {
               assert(depth > 0);
               return stack[--depth];
           }
@@ -111,22 +113,23 @@
           }
     };
 
-    class FastStack : Stack {
+    template<typename T>
+    class FastStack : Stack<T> {
     public:
         FastStack() : fdepth(0) 
         {}
 
-        void push(Address value) {
+        void push(T value) {
             if( fdepth < BUFSIZE ) {
                 buffer[fdepth++] = value;
             } else {
-                Stack::push(value);
+                Stack<T>::push(value);
             }
         }
 
-        Address pop() {
+        T pop() {
             assert(fdepth > 0);
-            return Stack::is_empty() ? buffer[--fdepth] : Stack::pop();
+            return Stack<T>::is_empty() ? buffer[--fdepth] : Stack<T>::pop();
         }
 
         bool is_empty() {
@@ -135,16 +138,35 @@
 
         void init() {
             fdepth = 0;
-            Stack::init();
+            Stack<T>::init();
+        }
+
+        int get_depth() {
+            return fdepth < BUFSIZE ? fdepth : BUFSIZE + Stack<T>::depth;
+        }
+
+        T at(int d) {
+            assert(d < get_depth());
+            return d < BUFSIZE ? buffer[d] : Stack<T>::stack[d - BUFSIZE];
+        }
+
+        int instack(T other) {
+            for( int i = 0; i < fdepth; i++ ) {
+                if( buffer[i] == other ) return true;
+            }
+            for( int i = 0; i < Stack<T>::depth; i++ ) {
+                if( Stack<T>::stack[i] == other ) return true;
+            }
+            return false;
         }
 
     private:
         static const int BUFSIZE = 100;
         int fdepth;
-        Address buffer[BUFSIZE];
+        T buffer[BUFSIZE];
     };
 
-    class MarkableStack : public FastStack {
+    class MarkableStack : public FastStack<Address> {
         // contains the following entries:
         // <address, mark> no mask means zero mark
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h?rev=595379&r1=595378&r2=595379&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h Thu Nov 15
10:05:56 2007
@@ -49,7 +49,7 @@
         // stack to push instructions like branch targets, etc to go thru the method. the
stack is method-wide.
         MarkableStack stack;
 
-        FastStack dead_code_stack;
+        FastStack<Address> dead_code_stack;
         bool      dead_code_parsing;
 
         //we would like to flush StackMapTable attribute from this method



Mime
View raw message