OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arm/lithium-codegen-arm.h" | 7 #include "src/arm/lithium-codegen-arm.h" |
8 #include "src/arm/lithium-gap-resolver-arm.h" | 8 #include "src/arm/lithium-gap-resolver-arm.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // cp: Callee's context. | 114 // cp: Callee's context. |
115 // pp: Callee's constant pool pointer (if FLAG_enable_ool_constant_pool) | 115 // pp: Callee's constant pool pointer (if FLAG_enable_ool_constant_pool) |
116 // fp: Caller's frame pointer. | 116 // fp: Caller's frame pointer. |
117 // lr: Caller's pc. | 117 // lr: Caller's pc. |
118 | 118 |
119 // Sloppy mode functions and builtins need to replace the receiver with the | 119 // Sloppy mode functions and builtins need to replace the receiver with the |
120 // global proxy when called as functions (without an explicit receiver | 120 // global proxy when called as functions (without an explicit receiver |
121 // object). | 121 // object). |
122 if (info_->this_has_uses() && | 122 if (info_->this_has_uses() && |
123 info_->strict_mode() == SLOPPY && | 123 info_->strict_mode() == SLOPPY && |
124 !info_->is_native()) { | 124 !info_->is_native() && |
| 125 info_->scope()->has_this_declaration()) { |
125 Label ok; | 126 Label ok; |
126 int receiver_offset = info_->scope()->num_parameters() * kPointerSize; | 127 int receiver_offset = info_->scope()->num_parameters() * kPointerSize; |
127 __ ldr(r2, MemOperand(sp, receiver_offset)); | 128 __ ldr(r2, MemOperand(sp, receiver_offset)); |
128 __ CompareRoot(r2, Heap::kUndefinedValueRootIndex); | 129 __ CompareRoot(r2, Heap::kUndefinedValueRootIndex); |
129 __ b(ne, &ok); | 130 __ b(ne, &ok); |
130 | 131 |
131 __ ldr(r2, GlobalObjectOperand()); | 132 __ ldr(r2, GlobalObjectOperand()); |
132 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalProxyOffset)); | 133 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalProxyOffset)); |
133 | 134 |
134 __ str(r2, MemOperand(sp, receiver_offset)); | 135 __ str(r2, MemOperand(sp, receiver_offset)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 __ push(r1); | 190 __ push(r1); |
190 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 191 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
191 } | 192 } |
192 RecordSafepoint(Safepoint::kNoLazyDeopt); | 193 RecordSafepoint(Safepoint::kNoLazyDeopt); |
193 // Context is returned in both r0 and cp. It replaces the context | 194 // Context is returned in both r0 and cp. It replaces the context |
194 // passed to us. It's saved in the stack and kept live in cp. | 195 // passed to us. It's saved in the stack and kept live in cp. |
195 __ mov(cp, r0); | 196 __ mov(cp, r0); |
196 __ str(r0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 197 __ str(r0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
197 // Copy any necessary parameters into the context. | 198 // Copy any necessary parameters into the context. |
198 int num_parameters = scope()->num_parameters(); | 199 int num_parameters = scope()->num_parameters(); |
199 for (int i = 0; i < num_parameters; i++) { | 200 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
200 Variable* var = scope()->parameter(i); | 201 for (int i = first_parameter; i < num_parameters; i++) { |
| 202 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
201 if (var->IsContextSlot()) { | 203 if (var->IsContextSlot()) { |
202 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 204 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
203 (num_parameters - 1 - i) * kPointerSize; | 205 (num_parameters - 1 - i) * kPointerSize; |
204 // Load parameter from stack. | 206 // Load parameter from stack. |
205 __ ldr(r0, MemOperand(fp, parameter_offset)); | 207 __ ldr(r0, MemOperand(fp, parameter_offset)); |
206 // Store it in the context. | 208 // Store it in the context. |
207 MemOperand target = ContextOperand(cp, var->index()); | 209 MemOperand target = ContextOperand(cp, var->index()); |
208 __ str(r0, target); | 210 __ str(r0, target); |
209 // Update the write barrier. This clobbers r3 and r0. | 211 // Update the write barrier. This clobbers r3 and r0. |
210 if (need_write_barrier) { | 212 if (need_write_barrier) { |
(...skipping 5745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5956 __ Push(scope_info); | 5958 __ Push(scope_info); |
5957 __ push(ToRegister(instr->function())); | 5959 __ push(ToRegister(instr->function())); |
5958 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5960 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5959 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5961 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5960 } | 5962 } |
5961 | 5963 |
5962 | 5964 |
5963 #undef __ | 5965 #undef __ |
5964 | 5966 |
5965 } } // namespace v8::internal | 5967 } } // namespace v8::internal |
OLD | NEW |