Forum: Ruby-core ID_ALLOCATOR ?

Posted by Roger Pack (Guest)
on 2012-11-08 18:38
(Received via mailing list)
Hello.

Ruby 2.0 is all about "non breaking backward compatibility" right? <wink
wink>.
Anyway, I used to use this code in the ruby-prof gem to see a method is 
the
allocator:

if (method_id == ID_ALLOCATOR)

        result = rb_str_new2("allocate");


This fails to compile with 2.0 however:

rp_method.c:101: error: ID_ALLOCATOR undeclared (first use in this 
function)

Any help/work arounds available?

Thanks.

-r
Posted by Yusuke Endoh (Guest)
on 2012-11-09 04:41
(Received via mailing list)
Hello Roger,

2012/11/9, Roger Pack <rogerdpack2@gmail.com>:
> rp_method.c:101: error: ID_ALLOCATOR undeclared (first use in this
> function)

It looks deleted at r36925, for a refactoring (?) of #6993.

It is easy to add the macro ID_ALLOCATOR, but the commit may affect
ruby-prof in more essential way.  For example, set_trace_func does
not hook a call to #allocate method. (Note that I could be wrong;
I just read #6993 and I don't read that commit itself.)  Is this a
matter for ruby-prof?

Anyway I'll reopen #6993 and ask ko1 and nobu.  Thank you,
Posted by Roger Pack (Guest)
on 2012-11-09 16:28
(Received via mailing list)
On Thu, Nov 8, 2012 at 8:40 PM, Yusuke Endoh <mame@tsg.ne.jp> wrote:

> >
> not hook a call to #allocate method. (Note that I could be wrong;
> I just read #6993 and I don't read that commit itself.)  Is this a
> matter for ruby-prof?
>

It does seem that it is useful in today's ruby-prof for 1.9.x


>
> Anyway I'll reopen #6993 and ask ko1 and nobu.  Thank you,
>

Thanks!
-roger-
Posted by SASADA Koichi (Guest)
on 2012-11-09 19:14
(Received via mailing list)
Can I see ruby-prof code?

Are there any reason that we can not modify ruby-prof code?
Posted by Roger Pack (Guest)
on 2012-11-09 19:33
(Received via mailing list)
On Fri, Nov 9, 2012 at 11:14 AM, SASADA Koichi <ko1@atdot.net> wrote:

> Can I see ruby-prof code?
>
> Are there any reason that we can not modify ruby-prof code?
>


https://github.com/rdp/ruby-prof/blob/master/ext/r...

Should I define ID_ALLOCATOR myself?
That would work.
-r
Posted by SASADA Koichi (Guest)
on 2012-11-09 20:04
(Received via mailing list)
(2012/11/10 3:26), Roger Pack wrote:
>
> https://github.com/rdp/ruby-prof/blob/master/ext/r...

Thanks.

> Should I define ID_ALLOCATOR myself?
> That would work.

If there is no problem, please patch it.

Thoughts:

(1) ID_ALLOCATOR is common or not?

  if ID_ALLOCATOR is used in many gems then
    we need to consider about adding ID_ALLOCATOR
  elsif
    it is easy to modify ruby-prof directly
  end

(2) My recommendation

#ifdef ID_ALLOCATOR
    if (mid == ID_ALLOCATOR)
        result = rb_str_new2("allocate");
    else
#endif
    if (mid == 0)
        result = rb_str_new2("[No method]");
    else
        result = rb_String(ID2SYM(mid));
Posted by Roger Pack (Guest)
on 2012-11-09 21:14
(Received via mailing list)
>         result = rb_String(ID2SYM(mid));
>


Good idea.  Or should I assume that ID_ALLOCATOR=1 will also apply for 
2.0,
so I can just assume it works?
Posted by SASADA Koichi (Guest)
on 2012-11-09 21:25
(Received via mailing list)
(2012/11/10 5:14), Roger Pack wrote:
>
> Good idea.  Or should I assume that ID_ALLOCATOR=1 will also apply for
> 2.0, so I can just assume it works?

Nobu, what do you think about it?

I think id==1 can be used by another purpose.
Posted by Nobuyoshi Nakada (nobu)
on 2012-11-20 03:59
(Received via mailing list)
(12/11/10 5:25), SASADA Koichi wrote:
> (2012/11/10 5:14), Roger Pack wrote:

As for ruby-prof, ID_ALLOCATOR code seems useless.

>> Good idea.  Or should I assume that ID_ALLOCATOR=1 will also apply for
>> 2.0, so I can just assume it works?

I'm not sure what you'll assume about an undefined symbol.

> Nobu, what do you think about it?
>
> I think id==1 can be used by another purpose.

Possibly.
Posted by Yusuke Endoh (Guest)
on 2012-11-24 02:28
(Received via mailing list)
Roger, Ko1, Nobu, did you agree?


2012/11/20 Nobuyoshi Nakada <nobu@ruby-lang.org>:
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.