Skip to content

Commit

Permalink
Prevent clobbering of %ebx on evaluating arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
vidarh committed Jul 17, 2013
1 parent 6918bf8 commit 6901567
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ def handle_splat(scope,args)
reg = compile_eval_arg(scope,:numargs)
@e.sall(2,reg)
@e.subl(reg,:esp)
@e.movl(reg,:edx)
reg = compile_eval_arg(scope,args.last.last)
@e.movl(reg,:edx)
reg = compile_eval_arg(scope,args.last.last)
@e.addl(reg,:edx)
@e.movl(:esp,:ecx)
l = @e.local
Expand All @@ -484,17 +484,25 @@ def compile_callm_args(scope, ob, args)
if splat
@e.addl(:ecx,:ebx)
end

# we're for now going to assume that %ebx is likely
# to get clobbered later, so in the case of a splat,
# we so we store it here until it's time to call the method.
@e.pushl(:ebx)

ret = compile_eval_arg(scope, ob)
@e.save_to_stack(ret, 0)
@e.save_to_stack(ret, 1)
args.each_with_index do |a,i|
param = compile_eval_arg(scope, a)
@e.save_to_stack(param, i+1)
@e.save_to_stack(param, i+2)
end

# This is where the actual call gets done
# This differs depending on whether it's a normal
# method call or a closure call.

# But first we pull the number of arguments off the stack.
@e.popl(:ebx)
yield
end

Expand Down

0 comments on commit 6901567

Please sign in to comment.