Skip to content

Commit

Permalink
No longer using method data to avoid memory leak (it was too complicated
Browse files Browse the repository at this point in the history
and did not work on Rubinius or on 1.9.3).  Now we just leak memory
instead.
  • Loading branch information
Paul Brannan committed May 9, 2012
1 parent cbe101d commit fb7c602
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 341 deletions.
1 change: 0 additions & 1 deletion ext/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Makefile
insns.inc
method_data.c
mkmf.log
9 changes: 0 additions & 9 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@
have_func('fmemopen')
have_func("rb_ensure", "ruby.h")

if have_header('ruby/node.h') then
# ruby.h defines HAVE_RUBY_NODE_H, even though it is not there
$defs.push("-DREALLY_HAVE_RUBY_NODE_H")
elsif have_header('node.h') then
# okay
else
$defs.push("-DNEED_MINIMAL_NODE")
end

have_header('env.h')

checking_for("whether VALUE is a pointer") do
Expand Down
26 changes: 14 additions & 12 deletions ext/jit_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
#include <jit/jit-dump.h>

#include "rubyjit.h"
#include "method_data.h"

#ifdef NEED_MINIMAL_NODE
#include "minimal_node.h"
#endif

#ifndef RARRAY_LEN
#define RARRAY_LEN(a) RARRAY(a)->len
Expand All @@ -38,6 +33,8 @@ static VALUE rb_cLabel;
static VALUE rb_mCall;
static VALUE rb_cClosure;

static VALUE closures;

jit_type_t jit_type_VALUE;
jit_type_t jit_type_ID;
jit_type_t jit_type_Function_Ptr;
Expand Down Expand Up @@ -1446,9 +1443,15 @@ static VALUE module_define_jit_method(VALUE klass, VALUE name_v, VALUE function_

closure_v = function_to_closure(function_v);
Data_Get_Struct(closure_v, struct Closure, closure);
define_method_with_data(
klass, rb_intern(name), RUBY_METHOD_FUNC(closure->function_ptr),
arity, closure_v);

/* TODO: This will leak the closure if the method is ever redefined.
* I had a solution to this problem, but it became too convoluted to
* maintain.
*/
rb_ary_push(closures, closure_v);
rb_define_method(
klass, name, RUBY_METHOD_FUNC(closure->function_ptr), arity);

return Qnil;
}

Expand All @@ -1461,6 +1464,9 @@ void Init_jit_ext()
{
jit_init();

closures = rb_ary_new();
rb_gc_register_address(&closures);

rb_mJIT = rb_define_module("JIT");

rb_cContext = rb_define_class_under(rb_mJIT, "Context", rb_cObject);
Expand Down Expand Up @@ -1576,9 +1582,5 @@ void Init_jit_ext()

/* VALUE rb_cModule = rb_define_module(); */
rb_define_method(rb_cModule, "define_jit_method", module_define_jit_method, 2);

#ifdef NEED_MINIMAL_NODE
Init_minimal_node();
#endif
}

308 changes: 0 additions & 308 deletions ext/method_data.c.rpp

This file was deleted.

Loading

0 comments on commit fb7c602

Please sign in to comment.