[Swfdec] 3 commits - libswfdec/js libswfdec/swfdec_script.c

Benjamin Otte company at kemper.freedesktop.org
Tue Mar 13 13:44:31 PDT 2007


 libswfdec/js/jsgc.c       |    7 ++++---
 libswfdec/js/jsinterp.h   |    6 ++++++
 libswfdec/swfdec_script.c |    8 ++++----
 3 files changed, 14 insertions(+), 7 deletions(-)

New commits:
diff-tree 467707141d1d5daa08fe9ebff8bcdfb7ed0abac1 (from 2cb65b20ea0ecae2b718fa01f80b0098965e5703)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Mar 13 21:34:31 2007 +0100

    use js_Free/AllocRawStack instead of js_Free/AllocStack
    
    This fixes the GC (yay!)

diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
index e261d61..210235e 100644
--- a/libswfdec/swfdec_script.c
+++ b/libswfdec/swfdec_script.c
@@ -2843,7 +2843,7 @@ swfdec_script_interpret (SwfdecScript *s
   endpc = startpc + script->buffer->length;
   fp->pc = pc;
   /* set up stack */
-  startsp = js_AllocStack (cx, STACKSIZE, &mark);
+  startsp = js_AllocRawStack (cx, STACKSIZE, &mark);
   if (!startsp) {
     ok = JS_FALSE;
     goto out;
@@ -2987,7 +2987,7 @@ no_catch:
   /* Reset sp before freeing stack slots, because our caller may GC soon. */
   fp->sp = fp->spbase;
   fp->spbase = NULL;
-  js_FreeStack(cx, mark);
+  js_FreeRawStack(cx, mark);
   cx->interpLevel--;
   swfdec_script_unref (script);
   return ok;
@@ -3068,7 +3068,7 @@ swfdec_script_execute (SwfdecScript *scr
   frame.varobj = obj;
   /* allocate stack for variables */
   frame.nvars = 4;
-  frame.vars = js_AllocStack (cx, frame.nvars, &mark);
+  frame.vars = js_AllocRawStack (cx, frame.nvars, &mark);
   if (frame.vars == NULL) {
     return JS_FALSE;
   }
@@ -3087,7 +3087,7 @@ swfdec_script_execute (SwfdecScript *scr
    */
   ok = swfdec_script_interpret (script, cx, &frame.rval);
 
-  js_FreeStack (cx, mark);
+  js_FreeRawStack (cx, mark);
   if (frame.constant_pool)
     swfdec_constant_pool_free (frame.constant_pool);
 
diff-tree 2cb65b20ea0ecae2b718fa01f80b0098965e5703 (from 77b9d003d542b050ec3c536bf7b33d551395df78)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Mar 13 21:32:17 2007 +0100

    export js_AllocRawStack and js_FreeRawStack

diff --git a/libswfdec/js/jsinterp.h b/libswfdec/js/jsinterp.h
index 32bb3a1..1a9e39d 100644
--- a/libswfdec/js/jsinterp.h
+++ b/libswfdec/js/jsinterp.h
@@ -238,6 +238,12 @@ js_AllocStack(JSContext *cx, uintN nslot
 extern JS_FRIEND_API(void)
 js_FreeStack(JSContext *cx, void *mark);
 
+extern JS_FRIEND_API(jsval *)
+js_AllocRawStack(JSContext *cx, uintN nslots, void **markp);
+
+extern JS_FRIEND_API(void)
+js_FreeRawStack(JSContext *cx, void *mark);
+
 extern JSBool
 js_GetArgument(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
 
diff-tree 77b9d003d542b050ec3c536bf7b33d551395df78 (from 20ece7c7093cd5d405f791db433249f8f62c7ad6)
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Mar 13 21:31:34 2007 +0100

    compute number of stack slots correctly
    
    also dump stats to stderr automatically if GC_MARK_DEBUG is defined

diff --git a/libswfdec/js/jsgc.c b/libswfdec/js/jsgc.c
index 88d64ca..fb463f0 100644
--- a/libswfdec/js/jsgc.c
+++ b/libswfdec/js/jsgc.c
@@ -847,8 +847,9 @@ js_MarkGCThing(JSContext *cx, void *thin
               rt->gcStats.maxdepth = rt->gcStats.depth);
 
 #ifdef GC_MARK_DEBUG
-    if (js_DumpGCHeap)
-        gc_dump_thing(thing, flags, arg, js_DumpGCHeap);
+    if (!js_DumpGCHeap)
+      js_DumpGCHeap = stderr;
+    gc_dump_thing(thing, flags, arg, js_DumpGCHeap);
 #endif
 
     switch (flags & GCF_TYPEMASK) {
@@ -1228,7 +1229,7 @@ restart:
 			       ? (uintN)(fp->sp - fp->spbase)
 			       : depth;
 		    } else {
-		      nslots = JS_UPTRDIFF(fp->sp, fp->spbase);
+		      nslots = (uintN) (fp->sp - fp->spbase);
 		    }
                     GC_MARK_JSVALS(cx, nslots, fp->spbase, "operand");
                 }


More information about the Swfdec mailing list