Permalink
Browse files

removing gc thing by object id

  • Loading branch information...
1 parent eb003e5 commit a84310caa88e754d6b6e73cf9d310073892eb4d0 @tenderlove tenderlove committed Jul 21, 2008
Showing with 6 additions and 13 deletions.
  1. +1 −8 ext/spidermonkey/context.c
  2. +3 −3 ext/spidermonkey/js_land_proxy.c
  3. +2 −2 lib/johnson/spidermonkey/runtime.rb
@@ -89,17 +89,10 @@ initialize_native(VALUE self, VALUE rb_runtime, VALUE UNUSED(options))
//// INFRASTRUCTURE BELOW HERE ////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-static void deallocate(JohnsonContext* context)
-{
- JS_SetContextPrivate(context->js, 0);
- JS_DestroyContext(context->js);
- free(context);
-}
-
static VALUE allocate(VALUE klass)
{
JohnsonContext* context = calloc(1, sizeof(JohnsonContext));
- return Data_Wrap_Struct(klass, 0, deallocate, context);
+ return Data_Wrap_Struct(klass, 0, 0, context);
}
void init_Johnson_SpiderMonkey_Context(VALUE spidermonkey)
@@ -550,10 +550,10 @@ static void finalize(JSContext* js_context, JSObject* obj)
// remove the proxy OID from the id map
JS_HashTableRemove(runtime->rbids, (void *)self);
-
+
// free up the ruby value for GC
- call_ruby_from_js(runtime, NULL, ruby_runtime, rb_intern("remove_gcthing"), 1, self);
- }
+ rb_funcall(ruby_runtime, rb_intern("remove_gcthing"), 1, rb_obj_id(self));
+ }
}
JSBool make_js_land_proxy(JohnsonRuntime* runtime, VALUE value, jsval* retval)
@@ -17,8 +17,8 @@ def add_gcthing(thing)
end
# called from js_land_proxy.c:finalize
- def remove_gcthing(thing)
- @gcthings.delete(thing.object_id)
+ def remove_gcthing(object_id)
+ @gcthings.delete(object_id) if @gcthings
end

0 comments on commit a84310c

Please sign in to comment.