Skip to content

Commit

Permalink
Improve TCO
Browse files Browse the repository at this point in the history
Instead of checking for self-recursion check that the thing we're
calling is a function and not a closure, therefore the new frame will
have the same env as the current frame.
  • Loading branch information
nicowilliams committed Jun 24, 2014
1 parent 4b7c701 commit beb0d08
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ jv jq_next(jq_state *jq) {
uint16_t* retaddr;
struct frame* new_frame;
struct closure cl = make_closure(jq, pc);
if (nclosures == 0 && *(pc + 2) == RET && frame_current(jq)->bc == cl.bc) {
if (nclosures == 0 && *(pc + 2) == RET && *pc == 1) {
// TCO
retaddr = frame_current(jq)->retaddr;
stack_ptr retdata = frame_current(jq)->retdata;
Expand Down

0 comments on commit beb0d08

Please sign in to comment.