Subj : Re: The new changes to atom safety in garbage collection To : netscape.public.mozilla.jseng From : Brendan Eich Date : Wed Jul 30 2003 06:52 pm This is a multi-part message in MIME format. --------------070905060804000503090802 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Brendan Eich wrote: > Steven C. Cole wrote: > >> Here's my question: Is the "keep atoms" flag also set in other places >> where it's not safe to GC them? In other words, can we go back to >> calling the "official" api JS_GC() call from our out-of-memory hooks >> (which can happen in resolve hooks or any of the other object hooks), >> and remove the "restricted GC" routine that I wrote? > > That's a great idea -- thanks. We just need the resolve code in > js_LookupProperty to farble rt->gcKeepAtoms. I'm hopeful that's the > last place, but I haven't checked. If you know of other cases where > JSClass or JSObjectOps callbacks might be unable to trigger a GC > without collecting an atom in use, hit me. Try this patch. /be --------------070905060804000503090802 Content-Type: text/plain; name="od" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="od" Index: jsobj.c =================================================================== RCS file: /cvsroot/mozilla/js/src/jsobj.c,v retrieving revision 3.148 diff -p -u -8 -u -r3.148 jsobj.c --- jsobj.c 26 Jul 2003 22:37:09 -0000 3.148 +++ jsobj.c 31 Jul 2003 00:47:59 -0000 @@ -2313,19 +2313,24 @@ js_LookupProperty(JSContext *cx, JSObjec (cx->fp->flags & JSFRAME_ASSIGNING)) { flags |= JSRESOLVE_ASSIGNING; } } obj2 = (clasp->flags & JSCLASS_NEW_RESOLVE_GETS_START) ? start : NULL; JS_UNLOCK_OBJ(cx, obj); + + /* Protect id and all atoms from a GC nested in resolve. */ + JS_KEEP_ATOMS(cx->runtime); ok = newresolve(cx, obj, ID_TO_VALUE(id), flags, &obj2); + JS_UNKEEP_ATOMS(cx->runtime); if (!ok) goto cleanup; + JS_LOCK_OBJ(cx, obj); SET_OBJ_INFO(obj, file, line); if (obj2) { /* Resolved: juggle locks and lookup id again. */ if (obj2 != obj) { JS_UNLOCK_OBJ(cx, obj); JS_LOCK_OBJ(cx, obj2); } --------------070905060804000503090802-- .