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

Side by Side Diff: src/x87/lithium-codegen-x87.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, 10 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 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
8 8
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 info_->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { 104 info_->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) {
105 __ int3(); 105 __ int3();
106 } 106 }
107 #endif 107 #endif
108 108
109 // Sloppy mode functions and builtins need to replace the receiver with the 109 // Sloppy mode functions and builtins need to replace the receiver with the
110 // global proxy when called as functions (without an explicit receiver 110 // global proxy when called as functions (without an explicit receiver
111 // object). 111 // object).
112 if (info_->this_has_uses() && 112 if (info_->this_has_uses() &&
113 info_->strict_mode() == SLOPPY && 113 info_->strict_mode() == SLOPPY &&
114 !info_->is_native()) { 114 !info_->is_native() &&
115 info_->scope->has_this_declaration()) {
115 Label ok; 116 Label ok;
116 // +1 for return address. 117 // +1 for return address.
117 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; 118 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize;
118 __ mov(ecx, Operand(esp, receiver_offset)); 119 __ mov(ecx, Operand(esp, receiver_offset));
119 120
120 __ cmp(ecx, isolate()->factory()->undefined_value()); 121 __ cmp(ecx, isolate()->factory()->undefined_value());
121 __ j(not_equal, &ok, Label::kNear); 122 __ j(not_equal, &ok, Label::kNear);
122 123
123 __ mov(ecx, GlobalObjectOperand()); 124 __ mov(ecx, GlobalObjectOperand());
124 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalProxyOffset)); 125 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalProxyOffset));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 __ CallRuntime(Runtime::kNewFunctionContext, 1); 235 __ CallRuntime(Runtime::kNewFunctionContext, 1);
235 } 236 }
236 RecordSafepoint(Safepoint::kNoLazyDeopt); 237 RecordSafepoint(Safepoint::kNoLazyDeopt);
237 // Context is returned in eax. It replaces the context passed to us. 238 // Context is returned in eax. It replaces the context passed to us.
238 // It's saved in the stack and kept live in esi. 239 // It's saved in the stack and kept live in esi.
239 __ mov(esi, eax); 240 __ mov(esi, eax);
240 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); 241 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax);
241 242
242 // Copy parameters into context if necessary. 243 // Copy parameters into context if necessary.
243 int num_parameters = scope()->num_parameters(); 244 int num_parameters = scope()->num_parameters();
244 for (int i = 0; i < num_parameters; i++) { 245 int first_parameter = scope()->has_this_declaration() ? -1 : 0;
245 Variable* var = scope()->parameter(i); 246 for (int i = first_parameter; i < num_parameters; i++) {
247 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i);
246 if (var->IsContextSlot()) { 248 if (var->IsContextSlot()) {
247 int parameter_offset = StandardFrameConstants::kCallerSPOffset + 249 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
248 (num_parameters - 1 - i) * kPointerSize; 250 (num_parameters - 1 - i) * kPointerSize;
249 // Load parameter from stack. 251 // Load parameter from stack.
250 __ mov(eax, Operand(ebp, parameter_offset)); 252 __ mov(eax, Operand(ebp, parameter_offset));
251 // Store it in the context. 253 // Store it in the context.
252 int context_offset = Context::SlotOffset(var->index()); 254 int context_offset = Context::SlotOffset(var->index());
253 __ mov(Operand(esi, context_offset), eax); 255 __ mov(Operand(esi, context_offset), eax);
254 // Update the write barrier. This clobbers eax and ebx. 256 // Update the write barrier. This clobbers eax and ebx.
255 if (need_write_barrier) { 257 if (need_write_barrier) {
(...skipping 6074 matching lines...) Expand 10 before | Expand all | Expand 10 after
6330 CallRuntime(Runtime::kPushBlockContext, 2, instr); 6332 CallRuntime(Runtime::kPushBlockContext, 2, instr);
6331 RecordSafepoint(Safepoint::kNoLazyDeopt); 6333 RecordSafepoint(Safepoint::kNoLazyDeopt);
6332 } 6334 }
6333 6335
6334 6336
6335 #undef __ 6337 #undef __
6336 6338
6337 } } // namespace v8::internal 6339 } } // namespace v8::internal
6338 6340
6339 #endif // V8_TARGET_ARCH_X87 6341 #endif // V8_TARGET_ARCH_X87
OLDNEW
« src/scopes.cc ('K') | « src/x87/full-codegen-x87.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698