Hi,

2010/7/10 Magnus Holm <judofyr / gmail.com>:
> Could someone enlighten me about rb_control_frame_t's lfp and dfp?
> They both seem to be related to local variables, and they seem to
> "overlap" each other in some way=85 I don't quite get how they work
> together=85


YARV distinguishes dynamic variables from local ones.

YARV's local variables (specified by lfp) means only local variables
defined at top level of method.  YARV's dynamic variables (specified
by dfp) means local variables defined at current scope.

  def foo(a)
    b =3D 1
    bar do |p|
      q =3D 1
      baz do |r|
        s =3D 1
        # (1)
      end
    end
  end

If YARV is executing at (1), YARV's local variables are a and b, and
YARV's dynamic ones are r and s.
dfp[0] has a special pointer to its previous dynamic scope which has
p and q, which is used to access p and q.


I didn't hear directly from ko1 why local variables and dynamic ones
are distinguished, but I guess a performance reason; we empirically
know that top-level local variables are frequently accessed from the
whole of method, so lfp provides short-cut of access to top-level
variables.

--=20
Yusuke Endoh <mame / tsg.ne.jp>