Index: src/x64/full-codegen-x64.cc |
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc |
index faf9e74dcf3a66e4be499e655ef6915ab816ff91..42f7ecae0c3eb77a0fca75d09f4b78f72b6201f5 100644 |
--- a/src/x64/full-codegen-x64.cc |
+++ b/src/x64/full-codegen-x64.cc |
@@ -114,7 +114,8 @@ void FullCodeGenerator::Generate() { |
// Sloppy mode functions and builtins need to replace the receiver with the |
// global proxy when called as functions (without an explicit receiver |
// object). |
- if (is_sloppy(info->language_mode()) && !info->is_native()) { |
+ if (is_sloppy(info->language_mode()) && !info->is_native() && |
+ info->scope()->has_this_declaration()) { |
Label ok; |
// +1 for return address. |
StackArgumentsAccessor args(rsp, info->scope()->num_parameters()); |
@@ -208,8 +209,9 @@ void FullCodeGenerator::Generate() { |
// Copy any necessary parameters into the context. |
int num_parameters = info->scope()->num_parameters(); |
- for (int i = 0; i < num_parameters; i++) { |
- Variable* var = scope()->parameter(i); |
+ int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; |
+ for (int i = first_parameter; i < num_parameters; i++) { |
+ Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
if (var->IsContextSlot()) { |
int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
(num_parameters - 1 - i) * kPointerSize; |