OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // r4: Callee's JS function. | 111 // r4: Callee's JS function. |
112 // cp: Callee's context. | 112 // cp: Callee's context. |
113 // pp: Callee's constant pool pointer (if enabled) | 113 // pp: Callee's constant pool pointer (if enabled) |
114 // fp: Caller's frame pointer. | 114 // fp: Caller's frame pointer. |
115 // lr: Caller's pc. | 115 // lr: Caller's pc. |
116 // ip: Our own function entry (required by the prologue) | 116 // ip: Our own function entry (required by the prologue) |
117 | 117 |
118 // Sloppy mode functions and builtins need to replace the receiver with the | 118 // Sloppy mode functions and builtins need to replace the receiver with the |
119 // global proxy when called as functions (without an explicit receiver | 119 // global proxy when called as functions (without an explicit receiver |
120 // object). | 120 // object). |
121 if (is_sloppy(info_->language_mode()) && info()->MayUseThis() && | 121 if (is_sloppy(info_->language_mode()) && info_->MayUseThis() && |
122 !info_->is_native()) { | 122 !info_->is_native() && info_->scope()->has_this_declaration()) { |
123 Label ok; | 123 Label ok; |
124 int receiver_offset = info_->scope()->num_parameters() * kPointerSize; | 124 int receiver_offset = info_->scope()->num_parameters() * kPointerSize; |
125 __ LoadP(r5, MemOperand(sp, receiver_offset)); | 125 __ LoadP(r5, MemOperand(sp, receiver_offset)); |
126 __ CompareRoot(r5, Heap::kUndefinedValueRootIndex); | 126 __ CompareRoot(r5, Heap::kUndefinedValueRootIndex); |
127 __ bne(&ok); | 127 __ bne(&ok); |
128 | 128 |
129 __ LoadP(r5, GlobalObjectOperand()); | 129 __ LoadP(r5, GlobalObjectOperand()); |
130 __ LoadP(r5, FieldMemOperand(r5, GlobalObject::kGlobalProxyOffset)); | 130 __ LoadP(r5, FieldMemOperand(r5, GlobalObject::kGlobalProxyOffset)); |
131 | 131 |
132 __ StoreP(r5, MemOperand(sp, receiver_offset)); | 132 __ StoreP(r5, MemOperand(sp, receiver_offset)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 __ push(r4); | 192 __ push(r4); |
193 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 193 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
194 } | 194 } |
195 RecordSafepoint(Safepoint::kNoLazyDeopt); | 195 RecordSafepoint(Safepoint::kNoLazyDeopt); |
196 // Context is returned in both r3 and cp. It replaces the context | 196 // Context is returned in both r3 and cp. It replaces the context |
197 // passed to us. It's saved in the stack and kept live in cp. | 197 // passed to us. It's saved in the stack and kept live in cp. |
198 __ mr(cp, r3); | 198 __ mr(cp, r3); |
199 __ StoreP(r3, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 199 __ StoreP(r3, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
200 // Copy any necessary parameters into the context. | 200 // Copy any necessary parameters into the context. |
201 int num_parameters = scope()->num_parameters(); | 201 int num_parameters = scope()->num_parameters(); |
202 for (int i = 0; i < num_parameters; i++) { | 202 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
203 Variable* var = scope()->parameter(i); | 203 for (int i = first_parameter; i < num_parameters; i++) { |
| 204 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
204 if (var->IsContextSlot()) { | 205 if (var->IsContextSlot()) { |
205 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 206 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
206 (num_parameters - 1 - i) * kPointerSize; | 207 (num_parameters - 1 - i) * kPointerSize; |
207 // Load parameter from stack. | 208 // Load parameter from stack. |
208 __ LoadP(r3, MemOperand(fp, parameter_offset)); | 209 __ LoadP(r3, MemOperand(fp, parameter_offset)); |
209 // Store it in the context. | 210 // Store it in the context. |
210 MemOperand target = ContextOperand(cp, var->index()); | 211 MemOperand target = ContextOperand(cp, var->index()); |
211 __ StoreP(r3, target, r0); | 212 __ StoreP(r3, target, r0); |
212 // Update the write barrier. This clobbers r6 and r3. | 213 // Update the write barrier. This clobbers r6 and r3. |
213 if (need_write_barrier) { | 214 if (need_write_barrier) { |
(...skipping 6065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6279 __ Push(scope_info); | 6280 __ Push(scope_info); |
6280 __ push(ToRegister(instr->function())); | 6281 __ push(ToRegister(instr->function())); |
6281 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6282 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6282 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6283 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6283 } | 6284 } |
6284 | 6285 |
6285 | 6286 |
6286 #undef __ | 6287 #undef __ |
6287 } | 6288 } |
6288 } // namespace v8::internal | 6289 } // namespace v8::internal |
OLD | NEW |