[armedbear-cvs] r12080 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Fri Jul 31 19:58:55 UTC 2009


Author: ehuelsmann
Date: Fri Jul 31 15:58:50 2009
New Revision: 12080

Log:
Move stack sampling to the scheduling thread.

Note: This commit removes the need for checks in the
      main thread whether or not the sampling interval
      has expired, i.e. a penalty for all those cases
      where we don't actually are profiling.

Modified:
   trunk/abcl/src/org/armedbear/lisp/LispThread.java
   trunk/abcl/src/org/armedbear/lisp/Profiler.java

Modified: trunk/abcl/src/org/armedbear/lisp/LispThread.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispThread.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/LispThread.java	Fri Jul 31 15:58:50 2009
@@ -553,25 +553,16 @@
     {
     }
 
-    private void doProfiling()
-        throws ConditionThrowable
-    {
-        if (sampleNow)
-            Profiler.sample(this);
-    }
-
     public final void pushStackFrame(LispObject operator)
         throws ConditionThrowable
     {
         stack = new StackFrame(operator, stack);
-        doProfiling();
     }
 
     public final void pushStackFrame(LispObject operator, LispObject arg)
         throws ConditionThrowable
     {
         stack = new StackFrame(operator, arg, stack);
-        doProfiling();
     }
 
     public final void pushStackFrame(LispObject operator, LispObject first,
@@ -579,7 +570,6 @@
         throws ConditionThrowable
     {
         stack = new StackFrame(operator, first, second, stack);
-        doProfiling();
     }
 
     public final void pushStackFrame(LispObject operator, LispObject first,
@@ -587,14 +577,12 @@
         throws ConditionThrowable
     {
         stack = new StackFrame(operator, first, second, third, stack);
-        doProfiling();
     }
 
     public final void pushStackFrame(LispObject operator, LispObject... args)
         throws ConditionThrowable
     {
         stack = new StackFrame(operator, args, stack);
-        doProfiling();
     }
 
     public final void popStackFrame()
@@ -619,7 +607,6 @@
             return function.execute();
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }
@@ -636,7 +623,6 @@
             return function.execute(arg);
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }
@@ -654,7 +640,6 @@
             return function.execute(first, second);
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }
@@ -672,7 +657,6 @@
             return function.execute(first, second, third);
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }
@@ -691,7 +675,6 @@
             return function.execute(first, second, third, fourth);
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }
@@ -710,7 +693,6 @@
             return function.execute(first, second, third, fourth, fifth);
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }
@@ -730,7 +712,6 @@
             return function.execute(first, second, third, fourth, fifth, sixth);
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }
@@ -753,7 +734,6 @@
                                     seventh);
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }
@@ -776,7 +756,6 @@
                                     seventh, eighth);
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }
@@ -792,7 +771,6 @@
             return function.execute(args);
         }
         finally {
-            doProfiling();
             popStackFrame();
         }
     }

Modified: trunk/abcl/src/org/armedbear/lisp/Profiler.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Profiler.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Profiler.java	Fri Jul 31 15:58:50 2009
@@ -37,29 +37,6 @@
 {
     private static int sleep = 1;
 
-    public static final void sample(LispThread thread)
-        throws ConditionThrowable
-    {
-        sampleNow = false;
-        thread.incrementCallCounts();
-    }
-
-    private static final Runnable profilerRunnable = new Runnable() {
-        public void run()
-        {
-            profiling = true; // make sure we don't fall through on the first iteration
-            while (profiling) {
-                sampleNow = true;
-                try {
-                    Thread.sleep(sleep);
-                }
-                catch (InterruptedException e) {
-                    Debug.trace(e);
-                }
-            }
-        }
-    };
-
     // ### %start-profiler
     // %start-profiler type granularity
     public static final Primitive _START_PROFILER =
@@ -105,7 +82,24 @@
                 }
                 if (sampling) {
                     sleep = Fixnum.getValue(second);
-                    thread.resetStack();
+                    Runnable profilerRunnable = new Runnable() {
+                        public void run()
+                        {
+                            profiling = true; // make sure we don't fall through on the first iteration
+                            while (profiling) {
+                                try {
+                                    thread.incrementCallCounts();
+                                    Thread.sleep(sleep);
+                                }
+                                catch (InterruptedException e) {
+                                    Debug.trace(e);
+                                }
+                                catch (ConditionThrowable e) {
+                                    break;
+                                }
+                            }
+                        }
+                    };
                     Thread t = new Thread(profilerRunnable);
                     // Maximum priority doesn't hurt:
                     // we're sleeping all the time anyway




More information about the armedbear-cvs mailing list