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() && info_->scope()->has_this_declaration()) { | 122 !info_->is_native()) { |
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 int first_parameter = scope()->has_this_declaration() ? -1 : 0; | 202 for (int i = 0; i < num_parameters; i++) { |
203 for (int i = first_parameter; i < num_parameters; i++) { | 203 Variable* var = scope()->parameter(i); |
204 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); | |
205 if (var->IsContextSlot()) { | 204 if (var->IsContextSlot()) { |
206 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 205 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
207 (num_parameters - 1 - i) * kPointerSize; | 206 (num_parameters - 1 - i) * kPointerSize; |
208 // Load parameter from stack. | 207 // Load parameter from stack. |
209 __ LoadP(r3, MemOperand(fp, parameter_offset)); | 208 __ LoadP(r3, MemOperand(fp, parameter_offset)); |
210 // Store it in the context. | 209 // Store it in the context. |
211 MemOperand target = ContextOperand(cp, var->index()); | 210 MemOperand target = ContextOperand(cp, var->index()); |
212 __ StoreP(r3, target, r0); | 211 __ StoreP(r3, target, r0); |
213 // Update the write barrier. This clobbers r6 and r3. | 212 // Update the write barrier. This clobbers r6 and r3. |
214 if (need_write_barrier) { | 213 if (need_write_barrier) { |
(...skipping 6093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6308 __ Push(scope_info); | 6307 __ Push(scope_info); |
6309 __ push(ToRegister(instr->function())); | 6308 __ push(ToRegister(instr->function())); |
6310 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6309 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6311 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6310 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6312 } | 6311 } |
6313 | 6312 |
6314 | 6313 |
6315 #undef __ | 6314 #undef __ |
6316 } | 6315 } |
6317 } // namespace v8::internal | 6316 } // namespace v8::internal |
OLD | NEW |