Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1116)

Side by Side Diff: src/mips64/lithium-codegen-mips64.cc

Issue 883823002: Implement proper scoping for "this" in arrow functions Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make sure an unresolved VariableProxy for "this" is not considered a valid LHS Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/hydrogen-osr.h" 9 #include "src/hydrogen-osr.h"
10 #include "src/ic/ic.h" 10 #include "src/ic/ic.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // a1: Callee's JS function. 112 // a1: Callee's JS function.
113 // cp: Callee's context. 113 // cp: Callee's context.
114 // fp: Caller's frame pointer. 114 // fp: Caller's frame pointer.
115 // lr: Caller's pc. 115 // lr: Caller's pc.
116 116
117 // Sloppy mode functions and builtins need to replace the receiver with the 117 // Sloppy mode functions and builtins need to replace the receiver with the
118 // global proxy when called as functions (without an explicit receiver 118 // global proxy when called as functions (without an explicit receiver
119 // object). 119 // object).
120 if (info_->this_has_uses() && 120 if (info_->this_has_uses() &&
121 info_->strict_mode() == SLOPPY && 121 info_->strict_mode() == SLOPPY &&
122 !info_->is_native()) { 122 !info_->is_native() &&
123 info_->scope()->has_this_declaration()) {
123 Label ok; 124 Label ok;
124 int receiver_offset = info_->scope()->num_parameters() * kPointerSize; 125 int receiver_offset = info_->scope()->num_parameters() * kPointerSize;
125 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); 126 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
126 __ ld(a2, MemOperand(sp, receiver_offset)); 127 __ ld(a2, MemOperand(sp, receiver_offset));
127 __ Branch(&ok, ne, a2, Operand(at)); 128 __ Branch(&ok, ne, a2, Operand(at));
128 129
129 __ ld(a2, GlobalObjectOperand()); 130 __ ld(a2, GlobalObjectOperand());
130 __ ld(a2, FieldMemOperand(a2, GlobalObject::kGlobalProxyOffset)); 131 __ ld(a2, FieldMemOperand(a2, GlobalObject::kGlobalProxyOffset));
131 132
132 __ sd(a2, MemOperand(sp, receiver_offset)); 133 __ sd(a2, MemOperand(sp, receiver_offset));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 __ push(a1); 185 __ push(a1);
185 __ CallRuntime(Runtime::kNewFunctionContext, 1); 186 __ CallRuntime(Runtime::kNewFunctionContext, 1);
186 } 187 }
187 RecordSafepoint(Safepoint::kNoLazyDeopt); 188 RecordSafepoint(Safepoint::kNoLazyDeopt);
188 // Context is returned in both v0. It replaces the context passed to us. 189 // Context is returned in both v0. It replaces the context passed to us.
189 // It's saved in the stack and kept live in cp. 190 // It's saved in the stack and kept live in cp.
190 __ mov(cp, v0); 191 __ mov(cp, v0);
191 __ sd(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); 192 __ sd(v0, MemOperand(fp, StandardFrameConstants::kContextOffset));
192 // Copy any necessary parameters into the context. 193 // Copy any necessary parameters into the context.
193 int num_parameters = scope()->num_parameters(); 194 int num_parameters = scope()->num_parameters();
194 for (int i = 0; i < num_parameters; i++) { 195 int first_parameter = scope()->has_this_declaration() ? -1 : 0;
195 Variable* var = scope()->parameter(i); 196 for (int i = first_parameter; i < num_parameters; i++) {
197 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i);
196 if (var->IsContextSlot()) { 198 if (var->IsContextSlot()) {
197 int parameter_offset = StandardFrameConstants::kCallerSPOffset + 199 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
198 (num_parameters - 1 - i) * kPointerSize; 200 (num_parameters - 1 - i) * kPointerSize;
199 // Load parameter from stack. 201 // Load parameter from stack.
200 __ ld(a0, MemOperand(fp, parameter_offset)); 202 __ ld(a0, MemOperand(fp, parameter_offset));
201 // Store it in the context. 203 // Store it in the context.
202 MemOperand target = ContextOperand(cp, var->index()); 204 MemOperand target = ContextOperand(cp, var->index());
203 __ sd(a0, target); 205 __ sd(a0, target);
204 // Update the write barrier. This clobbers a3 and a0. 206 // Update the write barrier. This clobbers a3 and a0.
205 if (need_write_barrier) { 207 if (need_write_barrier) {
(...skipping 5778 matching lines...) Expand 10 before | Expand all | Expand 10 after
5984 __ li(at, scope_info); 5986 __ li(at, scope_info);
5985 __ Push(at, ToRegister(instr->function())); 5987 __ Push(at, ToRegister(instr->function()));
5986 CallRuntime(Runtime::kPushBlockContext, 2, instr); 5988 CallRuntime(Runtime::kPushBlockContext, 2, instr);
5987 RecordSafepoint(Safepoint::kNoLazyDeopt); 5989 RecordSafepoint(Safepoint::kNoLazyDeopt);
5988 } 5990 }
5989 5991
5990 5992
5991 #undef __ 5993 #undef __
5992 5994
5993 } } // namespace v8::internal 5995 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698