Chromium Code Reviews| Index: src/x64/lithium-codegen-x64.cc |
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
| index fe71ff53d6796c6eeab380d4f44222aea8c3852d..d6f05eff18a5b5ebdbe9fbc3d73f1e6b3d032415 100644 |
| --- a/src/x64/lithium-codegen-x64.cc |
| +++ b/src/x64/lithium-codegen-x64.cc |
| @@ -2608,12 +2608,27 @@ void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
| ASSERT(function.is(rdi)); // Required by InvokeFunction. |
| ASSERT(ToRegister(instr->result()).is(rax)); |
| - // TODO(1412): This is not correct if the called function is a |
| - // strict mode function or a native. |
| - // |
| - // If the receiver is null or undefined, we have to pass the global object |
| - // as a receiver. |
| + // If the receiver is null or undefined, we have to pass the global |
| + // object as a receiver to normal functions. Values have to be |
| + // passed unchanged to builtins and strict-mode functions. |
| Label global_object, receiver_ok; |
| + |
| + // Do not transform the receiver to object for strict mode |
| + // functions. |
| + __ movq(kScratchRegister, |
| + FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
| + __ testb(FieldOperand(kScratchRegister, |
| + SharedFunctionInfo::kStrictModeByteOffset), |
| + Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); |
| + __ j(not_equal, &receiver_ok, Label::kNear); |
| + |
| + // Do not transform the receiver to object for builtins. |
| + __ testb(FieldOperand(kScratchRegister, |
| + SharedFunctionInfo::kNativeByteOffset), |
| + Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); |
| + __ j(not_zero, &receiver_ok, Label::kNear); |
|
Rico
2011/05/31 10:31:15
__ j(not_equal to be consistent (I wonder who orig
Mads Ager (chromium)
2011/05/31 10:33:22
Done. Also in builtins-x64.cc.
|
| + |
| + // Normal function. Replace undefined or null with global receiver. |
| __ CompareRoot(receiver, Heap::kNullValueRootIndex); |
| __ j(equal, &global_object, Label::kNear); |
| __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex); |