Bug 380469: Followup for the previous check in to remove more no longer used close-on-GC code. r=brendan
authorigor@mir2.org
Sat, 14 Jul 2007 01:28:57 -0700
changeset 3473 53df83a867e3c1c2a74a921aa421e0e6a83efde1
parent 3472 58d529e51853cf44b31091e6d63f97ef78c7e296
child 3474 74c8d5ce3d1d9aaa0672b19dba51380b6fa56ed6
push idunknown
push userunknown
push dateunknown
reviewersbrendan
bugs380469
milestone1.9a7pre
Bug 380469: Followup for the previous check in to remove more no longer used close-on-GC code. r=brendan
js/src/jsfun.c
js/src/jsiter.c
js/src/jsiter.h
--- a/js/src/jsfun.c
+++ b/js/src/jsfun.c
@@ -541,20 +541,18 @@ args_enumerate(JSContext *cx, JSObject *
  * mark its generator object.
  */
 static void
 args_or_call_trace(JSTracer *trc, JSObject *obj)
 {
     JSStackFrame *fp;
 
     fp = (JSStackFrame *) JS_GetPrivate(trc->context, obj);
-    if (fp && (fp->flags & JSFRAME_GENERATOR)) {
-        JS_CALL_OBJECT_TRACER(trc, FRAME_TO_GENERATOR(fp)->obj,
-                              "FRAME_TO_GENERATOR(fp)->obj");
-    }
+    if (fp && (fp->flags & JSFRAME_GENERATOR))
+        js_TraceGenerator(trc, FRAME_TO_GENERATOR(fp));
 }
 #else
 # define args_or_call_trace NULL
 #endif
 
 /*
  * The Arguments class is not initialized via JS_InitClass, and must not be,
  * because its name is "Object".  Per ECMA, that causes instances of it to
--- a/js/src/jsiter.c
+++ b/js/src/jsiter.c
@@ -665,33 +665,39 @@ generator_finalize(JSContext *cx, JSObje
          * the embedding cancels scheduled close hooks.
          */
         JS_ASSERT(gen->state == JSGEN_NEWBORN || gen->state == JSGEN_CLOSED ||
                   gen->state == JSGEN_OPEN);
         JS_free(cx, gen);
     }
 }
 
+void
+js_TraceGenerator(JSTracer *trc, JSGenerator *gen)
+{
+    /*
+     * We must trace argv[-2], as js_TraceStackFrame will not. Note that
+     * js_TraceStackFrame will trace thisp (argv[-1]) and actual arguments,
+     * plus any missing formals and local GC roots.
+     */
+    JS_ASSERT(!JSVAL_IS_PRIMITIVE(gen->frame.argv[-2]));
+    JS_CALL_OBJECT_TRACER(trc, JSVAL_TO_OBJECT(gen->frame.argv[-2]),
+                          "generator");
+    js_TraceStackFrame(trc, &gen->frame);
+}
+
+
 static void
 generator_trace(JSTracer *trc, JSObject *obj)
 {
     JSGenerator *gen;
 
     gen = (JSGenerator *) JS_GetPrivate(trc->context, obj);
-    if (gen) {
-        /*
-         * We must trace argv[-2], as js_TraceStackFrame will not.  Note
-         * that js_TraceStackFrame will trace thisp (argv[-1]) and actual
-         * arguments, plus any missing formals and local GC roots.
-         */
-        JS_ASSERT(!JSVAL_IS_PRIMITIVE(gen->frame.argv[-2]));
-        JS_CALL_OBJECT_TRACER(trc, JSVAL_TO_OBJECT(gen->frame.argv[-2]),
-                              "generator");
-        js_TraceStackFrame(trc, &gen->frame);
-    }
+    if (gen)
+        js_TraceGenerator(trc, gen);
 }
 
 JSClass js_GeneratorClass = {
     js_Generator_str,
     JSCLASS_HAS_PRIVATE | JSCLASS_IS_ANONYMOUS |
     JSCLASS_MARK_IS_TRACE | JSCLASS_HAS_CACHED_PROTO(JSProto_Generator),
     JS_PropertyStub,  JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
     JS_EnumerateStub, JS_ResolveStub,  JS_ConvertStub,  generator_finalize,
@@ -728,18 +734,16 @@ js_NewGenerator(JSContext *cx, JSStackFr
     nslots = 2 + nargs + nvars + 2 * depth;
 
     /* Allocate obj's private data struct. */
     gen = (JSGenerator *)
           JS_malloc(cx, sizeof(JSGenerator) + (nslots - 1) * sizeof(jsval));
     if (!gen)
         goto bad;
 
-    gen->obj = obj;
-
     /* Steal away objects reflecting fp and point them at gen->frame. */
     gen->frame.callobj = fp->callobj;
     if (fp->callobj) {
         JS_SetPrivate(cx, fp->callobj, &gen->frame);
         fp->callobj = NULL;
     }
     gen->frame.argsobj = fp->argsobj;
     if (fp->argsobj) {
--- a/js/src/jsiter.h
+++ b/js/src/jsiter.h
@@ -86,30 +86,31 @@ typedef enum JSGeneratorState {
     JSGEN_NEWBORN,  /* not yet started */
     JSGEN_OPEN,     /* started by a .next() or .send(undefined) call */
     JSGEN_RUNNING,  /* currently executing via .next(), etc., call */
     JSGEN_CLOSING,  /* close method is doing asynchronous return */
     JSGEN_CLOSED    /* closed, cannot be started or closed again */
 } JSGeneratorState;
 
 struct JSGenerator {
-    JSGenerator         *next;
-    JSObject            *obj;
     JSGeneratorState    state;
     JSStackFrame        frame;
     JSArena             arena;
     jsval               stack[1];
 };
 
 #define FRAME_TO_GENERATOR(fp) \
     ((JSGenerator *) ((uint8 *)(fp) - offsetof(JSGenerator, frame)))
 
 extern JSObject *
 js_NewGenerator(JSContext *cx, JSStackFrame *fp);
 
+extern void
+js_TraceGenerator(JSTracer *trc, JSGenerator *gen);
+
 #endif
 
 extern JSClass          js_GeneratorClass;
 extern JSClass          js_IteratorClass;
 extern JSClass          js_StopIterationClass;
 
 extern JSObject *
 js_InitIteratorClasses(JSContext *cx, JSObject *obj);