Index: src/x87/lithium-codegen-x87.cc |
diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc |
index cee37cf1c24f1a974d3a0da878e7712bfbfb4a1e..57c1d39ac997babee7f9d7c66e8632b0c804c1af 100644 |
--- a/src/x87/lithium-codegen-x87.cc |
+++ b/src/x87/lithium-codegen-x87.cc |
@@ -110,8 +110,8 @@ bool LCodeGen::GeneratePrologue() { |
// 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()->MayUseThis() && |
- !info_->is_native()) { |
+ if (is_sloppy(info()->language_mode()) && info()->MayUseThis() && |
+ !info()->is_native() && info()->scope()->has_this_declaration()) { |
Label ok; |
// +1 for return address. |
int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; |
@@ -242,8 +242,9 @@ bool LCodeGen::GeneratePrologue() { |
// Copy parameters into context if necessary. |
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; |