Index: src/arm/full-codegen-arm.cc |
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc |
index 2522b09a68886257be64c5843fd77cb02a36ba94..da385b62f699a43e92401c49b0c57f529800baeb 100644 |
--- a/src/arm/full-codegen-arm.cc |
+++ b/src/arm/full-codegen-arm.cc |
@@ -127,7 +127,7 @@ void FullCodeGenerator::Generate() { |
// global proxy when called as functions (without an explicit receiver |
// object). |
if (is_sloppy(info->language_mode()) && !info->is_native() && |
- info->MayUseThis()) { |
+ info->MayUseThis() && info->scope()->has_this_declaration()) { |
Label ok; |
int receiver_offset = info->scope()->num_parameters() * kPointerSize; |
__ ldr(r2, MemOperand(sp, receiver_offset)); |
@@ -216,8 +216,9 @@ void FullCodeGenerator::Generate() { |
__ str(r0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
// 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; |
@@ -3066,8 +3067,9 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
__ ldr(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
// r3: the receiver of the enclosing function. |
- int receiver_offset = 2 + info_->scope()->num_parameters(); |
- __ ldr(r3, MemOperand(fp, receiver_offset * kPointerSize)); |
+ Variable* this_var = scope()->LookupThis(); |
+ DCHECK_NOT_NULL(this_var); |
+ __ ldr(r3, VarOperand(this_var, r3)); |
// r2: language mode. |
__ mov(r2, Operand(Smi::FromInt(language_mode()))); |