Ruby Forum Ruby-dev > useless external functions

Posted by SASADA Koichi (Guest)
on 04.09.2008 12:17
(Received via mailing list)
Hi,

I counted references of external functions in MRI/trunk.

 http://www.atdot.net/sp/readonly/yr0o6k

  [Function name, Reference count, Object file name]

(sorted by refcount, funcname).

It will be help for refactoring (some functions which have few
reference count should be review).


How to make it:

$ ./ruby -v
ruby 1.9.0 (2008-09-04 revision 19114) [i686-linux]

$ objdump -t libruby-static.a .ext/i686-linux/*.so
.ext/i686-linux/**/*.so > syms

$ cat t.rb

global_syms = {}
local_syms = {}
und_syms = Hash.new(0)
file = nil

File.read('syms').each{|line|
  info = line.split(/\s+/)
  if info[3] == '.text'
    if info[1] == 'g'
      global_syms[info[5]] = file
    elsif info[1] == 'l'
      local_syms[info[5]] = file
    else
      #
    end
  elsif info[1] == '*UND*'
    und_syms[info[3]] += 1
  elsif /^(.+\.(so|o)):/ =~ info[0]
    file = $1
  else
    # p line
  end
}

st = Hash.new(0)
global_syms.each{|m, f|
  st[m] = und_syms[m]
}

st.to_a.sort_by{|(m, c)| [c, m]}.each{|(m, c)|
  p [m, c, global_syms[m]]
}


Regards,
Posted by Michal Suchanek (Guest)
on 04.09.2008 14:12
(Received via mailing list)
Hello

While you are looking at this - are the visible symbols in libruby
prefixed with something like ruby_ or rb_?

There seem to be a few random functions here and there, the st_, vm_
iseq_ and insn_ stuff.
Also oniguruma has many symbols in that list. As I understand it Ruby
uses a modified Oniguruma so people who would like to use Ruby and
Oniguruma might have a hard time putting it together.

With 1.8 I had some trouble linking a program using a standalone regex
library with libruby as there was something like regex_start in both.

Thanks

Michal
Posted by SASADA Koichi (Guest)
on 04.09.2008 14:46
(Received via mailing list)
SASADA Koichi wrote:
> I counted references of external functions in MRI/trunk.
> 
>  http://www.atdot.net/sp/readonly/yr0o6k
> 

Here is a variable version:
  http://www.atdot.net/sp/readonly/4p8o6k
Posted by Charles Oliver Nutter (Guest)
on 06.09.2008 20:45
(Received via mailing list)
Michal Suchanek wrote:
> 
> With 1.8 I had some trouble linking a program using a standalone regex
> library with libruby as there was something like regex_start in both.

The oniguruma thing should definitely be addressed. The version
incorporated into 1.9 would conflict if an application wanted to link
both 1.9 and Oniguruma.

I suppose it's also worth asking why Oniguruma was imported and directly
modified too. Why?

- Charlie
Posted by Michal Suchanek (Guest)
on 07.09.2008 11:02
(Received via mailing list)
On 06/09/2008, Charles Oliver Nutter <charles.nutter@sun.com> wrote:
> > uses a modified Oniguruma so people who would like to use Ruby and
> > Oniguruma might have a hard time putting it together.
> >
> > With 1.8 I had some trouble linking a program using a standalone regex
> > library with libruby as there was something like regex_start in both.
> >
>
>  The oniguruma thing should definitely be addressed. The version
> incorporated into 1.9 would conflict if an application wanted to link both
> 1.9 and Oniguruma.

I do not see how onigiruma is different from the other symbols that
are not prefixed. Any other language interpreter (and even other
programs) can have insn_ vm_  iseq_ or any of the other symbols.

Thanks

Michal