# HG changeset patch # User Atul Varma # Date 1245955603 25200 # Node ID 6a7e87cd15889f8eb3b9b58186b10968857a3e4f # Parent 4910bc49a182b98371b853c7e1d112743635396a Fixed a TODO; executing the whole code now works, though we get GC root leak warnings. diff -r 4910bc49a182 -r 6a7e87cd1588 spidermonkey-playground.cpp --- a/spidermonkey-playground.cpp Thu Jun 25 11:39:32 2009 -0700 +++ b/spidermonkey-playground.cpp Thu Jun 25 11:46:43 2009 -0700 @@ -124,6 +124,7 @@ // TODO: Check for return values here. JSContext *module_cx = JS_NewContext(JS_GetRuntime(cx), 8192); + JS_BeginRequest(module_cx); JSObject *module_global = JS_NewObject(module_cx, &global_class, NULL, NULL); JS_InitStandardClasses(module_cx, module_global); @@ -137,12 +138,14 @@ jsval module_rval; if (!JS_EvaluateScript(module_cx, module_global, source, strlen(source), filename, 1, &module_rval)) { + JS_EndRequest(module_cx); JS_DestroyContext(module_cx); return JS_FALSE; } *rval = OBJECT_TO_JSVAL(module_exports); + JS_EndRequest(module_cx); JS_DestroyContext(module_cx); return JS_TRUE; diff -r 4910bc49a182 -r 6a7e87cd1588 tcb.js --- a/tcb.js Thu Jun 25 11:39:32 2009 -0700 +++ b/tcb.js Thu Jun 25 11:46:43 2009 -0700 @@ -73,13 +73,6 @@ print(" " + name + ": " + scopeChain[name]); } -profileMemory(); - -// TODO: If we continue from here, we crash, ever since we added -// the TCB global as a named root. Probably a GC-related bug in some of the -// wrapper code. -throw new Error("TODO: Remove this throw!"); - // Load a sample SecurableModule and run some code in it. function SafeWrapper(object) { @@ -245,3 +238,5 @@ var boop = {bind: socket.bind}; boop.bind("127.0.0.1", 8080); } catch (e) {} + +profileMemory();