Index: src/builtins-arm.cc |
=================================================================== |
--- src/builtins-arm.cc (revision 311) |
+++ src/builtins-arm.cc (working copy) |
@@ -40,12 +40,21 @@ |
void Builtins::Generate_Adaptor(MacroAssembler* masm, |
int argc, |
CFunctionId id) { |
- // r0 contains the number of arguments excluding the receiver. |
- // JumpToBuiltin expects r0 to contains the number of arguments |
- // including the receiver. |
- __ mov(r0, Operand(argc + 1)); |
+ // TODO(1238487): Don't pass the function in a static variable. |
__ mov(ip, Operand(ExternalReference::builtin_passed_function())); |
__ str(r1, MemOperand(ip, 0)); |
+ |
+ if (argc == -1) { |
+ // The actual argument count has already been loaded into register |
+ // r0, but JumpToBuiltin expects r0 to contain the number of |
+ // arguments including the receiver. |
+ __ add(r0, r0, Operand(1)); |
+ } else { |
+ // The number passed in argc excludes the receiver, but |
+ // JumpToBuiltin expects r0 to contain the number of arguments |
+ // including the receiver. |
+ __ mov(r0, Operand(argc + 1)); |
+ } |
__ JumpToBuiltin(ExternalReference(id)); |
} |