diff options
author | Austin Clements <aclements@csail.mit.edu> | 2009-07-29 11:57:46 -0700 |
---|---|---|
committer | Austin Clements <aclements@csail.mit.edu> | 2009-07-29 11:57:46 -0700 |
commit | 6a1530c6ecdc3610889367b75ca275d84604b1c5 (patch) | |
tree | eea7019f7e07a3a6e3f801510489ef285050a586 /usr/austin/eval/func.go | |
parent | 261d6437b8a7a1e7c85f9c83dd4a72446a9234a5 (diff) | |
download | golang-6a1530c6ecdc3610889367b75ca275d84604b1c5.tar.gz |
Flatten the Frame tree. Now each function call produces a
single frame and non-overlapping variables reuse frame slots.
As a result, entering and exiting blocks no longer requires
code execution, which means jumps across block boundaries
should be doable now. Frame slot initialization happens at
definition time now, instead of at frame creation time. As an
added bonus, Scope's are now exclusively compile-time objects
and we no longer need to specially track the function
activation frame for access to out vars.
R=rsc
APPROVED=rsc
DELTA=313 (102 added, 90 deleted, 121 changed)
OCL=32416
CL=32420
Diffstat (limited to 'usr/austin/eval/func.go')
-rw-r--r-- | usr/austin/eval/func.go | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/usr/austin/eval/func.go b/usr/austin/eval/func.go index cc790452b..3fc5e71af 100644 --- a/usr/austin/eval/func.go +++ b/usr/austin/eval/func.go @@ -15,19 +15,15 @@ import ( type vm struct { pc uint; - // The current execution frame. If execution is within a - // block, this may be a child of the original function - // activation frame. + // The execution frame of this function. This remains the + // same throughout a function invocation. f *Frame; - // The original function activation frame. This is used to - // access function out args. - activation *Frame; } type code []func(*vm) func (i code) exec(fr *Frame) { - v := vm{0, fr, fr}; + v := vm{0, fr}; l := uint(len(i)); for v.pc < l { @@ -80,13 +76,13 @@ func (b *codeBuf) get() code { */ type evalFunc struct { - sc *Scope; - fr *Frame; + outer *Frame; + frameSize int; code code; } func (f *evalFunc) NewFrame() *Frame { - return f.sc.NewFrame(f.fr); + return f.outer.child(f.frameSize); } func (f *evalFunc) Call(fr *Frame) { |