Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index 0f0d136b91d78abeef55792e200c6461fbfe7820..b8d3dff80a8bd77bf60e0b42135872d6a6293e60 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -130,7 +130,7 @@ bool LCodeGen::GeneratePrologue() { |
// Sloppy mode functions need to replace the receiver with the global proxy |
// when called as functions (without an explicit receiver object). |
if (info_->this_has_uses() && is_sloppy(info_->language_mode()) && |
- !info_->is_native()) { |
+ !info_->is_native() && info_->scope()->has_this_declaration()) { |
Label ok; |
StackArgumentsAccessor args(rsp, scope()->num_parameters()); |
__ movp(rcx, args.GetReceiverOperand()); |
@@ -212,8 +212,9 @@ bool LCodeGen::GeneratePrologue() { |
// Copy any necessary parameters into the context. |
int num_parameters = scope()->num_parameters(); |
- for (int i = 0; i < num_parameters; i++) { |
- Variable* var = scope()->parameter(i); |
+ int first_parameter = 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; |