OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // a1: Callee's JS function. | 137 // a1: Callee's JS function. |
138 // cp: Callee's context. | 138 // cp: Callee's context. |
139 // fp: Caller's frame pointer. | 139 // fp: Caller's frame pointer. |
140 // lr: Caller's pc. | 140 // lr: Caller's pc. |
141 | 141 |
142 // Sloppy mode functions and builtins need to replace the receiver with the | 142 // Sloppy mode functions and builtins need to replace the receiver with the |
143 // global proxy when called as functions (without an explicit receiver | 143 // global proxy when called as functions (without an explicit receiver |
144 // object). | 144 // object). |
145 if (info_->this_has_uses() && | 145 if (info_->this_has_uses() && |
146 info_->strict_mode() == SLOPPY && | 146 info_->strict_mode() == SLOPPY && |
147 !info_->is_native()) { | 147 !info_->is_native() && |
| 148 info_->scope()->has_this_declaration()) { |
148 Label ok; | 149 Label ok; |
149 int receiver_offset = info_->scope()->num_parameters() * kPointerSize; | 150 int receiver_offset = info_->scope()->num_parameters() * kPointerSize; |
150 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 151 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
151 __ lw(a2, MemOperand(sp, receiver_offset)); | 152 __ lw(a2, MemOperand(sp, receiver_offset)); |
152 __ Branch(&ok, ne, a2, Operand(at)); | 153 __ Branch(&ok, ne, a2, Operand(at)); |
153 | 154 |
154 __ lw(a2, GlobalObjectOperand()); | 155 __ lw(a2, GlobalObjectOperand()); |
155 __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalProxyOffset)); | 156 __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalProxyOffset)); |
156 | 157 |
157 __ sw(a2, MemOperand(sp, receiver_offset)); | 158 __ sw(a2, MemOperand(sp, receiver_offset)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 __ push(a1); | 210 __ push(a1); |
210 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 211 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
211 } | 212 } |
212 RecordSafepoint(Safepoint::kNoLazyDeopt); | 213 RecordSafepoint(Safepoint::kNoLazyDeopt); |
213 // Context is returned in both v0. It replaces the context passed to us. | 214 // Context is returned in both v0. It replaces the context passed to us. |
214 // It's saved in the stack and kept live in cp. | 215 // It's saved in the stack and kept live in cp. |
215 __ mov(cp, v0); | 216 __ mov(cp, v0); |
216 __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 217 __ sw(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
217 // Copy any necessary parameters into the context. | 218 // Copy any necessary parameters into the context. |
218 int num_parameters = scope()->num_parameters(); | 219 int num_parameters = scope()->num_parameters(); |
219 for (int i = 0; i < num_parameters; i++) { | 220 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
220 Variable* var = scope()->parameter(i); | 221 for (int i = first_parameter; i < num_parameters; i++) { |
| 222 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
221 if (var->IsContextSlot()) { | 223 if (var->IsContextSlot()) { |
222 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 224 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
223 (num_parameters - 1 - i) * kPointerSize; | 225 (num_parameters - 1 - i) * kPointerSize; |
224 // Load parameter from stack. | 226 // Load parameter from stack. |
225 __ lw(a0, MemOperand(fp, parameter_offset)); | 227 __ lw(a0, MemOperand(fp, parameter_offset)); |
226 // Store it in the context. | 228 // Store it in the context. |
227 MemOperand target = ContextOperand(cp, var->index()); | 229 MemOperand target = ContextOperand(cp, var->index()); |
228 __ sw(a0, target); | 230 __ sw(a0, target); |
229 // Update the write barrier. This clobbers a3 and a0. | 231 // Update the write barrier. This clobbers a3 and a0. |
230 if (need_write_barrier) { | 232 if (need_write_barrier) { |
(...skipping 5737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5968 __ li(at, scope_info); | 5970 __ li(at, scope_info); |
5969 __ Push(at, ToRegister(instr->function())); | 5971 __ Push(at, ToRegister(instr->function())); |
5970 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5972 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5971 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5973 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5972 } | 5974 } |
5973 | 5975 |
5974 | 5976 |
5975 #undef __ | 5977 #undef __ |
5976 | 5978 |
5977 } } // namespace v8::internal | 5979 } } // namespace v8::internal |
OLD | NEW |