changeset 64:6a7e87cd1588

Fixed a TODO; executing the whole code now works, though we get GC root leak warnings.
author Atul Varma <varmaa@toolness.com>
date Thu, 25 Jun 2009 11:46:43 -0700
parents 4910bc49a182
children 109d9927c805
files spidermonkey-playground.cpp tcb.js
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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();