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

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 883823002: Implement proper scoping for "this" in arrow functions Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased against master, plus fixes. Only 4 tests failing (+2 in TurboFan) 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
« no previous file with comments | « src/variables.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 #ifdef DEBUG 107 #ifdef DEBUG
108 if (strlen(FLAG_stop_at) > 0 && 108 if (strlen(FLAG_stop_at) > 0 &&
109 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { 109 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) {
110 __ int3(); 110 __ int3();
111 } 111 }
112 #endif 112 #endif
113 113
114 // Sloppy mode functions and builtins need to replace the receiver with the 114 // Sloppy mode functions and builtins need to replace the receiver with the
115 // global proxy when called as functions (without an explicit receiver 115 // global proxy when called as functions (without an explicit receiver
116 // object). 116 // object).
117 if (is_sloppy(info->language_mode()) && !info->is_native()) { 117 if (is_sloppy(info->language_mode()) && !info->is_native() &&
118 info->scope()->has_this_declaration()) {
118 Label ok; 119 Label ok;
119 // +1 for return address. 120 // +1 for return address.
120 StackArgumentsAccessor args(rsp, info->scope()->num_parameters()); 121 StackArgumentsAccessor args(rsp, info->scope()->num_parameters());
121 __ movp(rcx, args.GetReceiverOperand()); 122 __ movp(rcx, args.GetReceiverOperand());
122 123
123 __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex); 124 __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex);
124 __ j(not_equal, &ok, Label::kNear); 125 __ j(not_equal, &ok, Label::kNear);
125 126
126 __ movp(rcx, GlobalObjectOperand()); 127 __ movp(rcx, GlobalObjectOperand());
127 __ movp(rcx, FieldOperand(rcx, GlobalObject::kGlobalProxyOffset)); 128 __ movp(rcx, FieldOperand(rcx, GlobalObject::kGlobalProxyOffset));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 __ CallRuntime(Runtime::kNewFunctionContext, 1); 202 __ CallRuntime(Runtime::kNewFunctionContext, 1);
202 } 203 }
203 function_in_register = false; 204 function_in_register = false;
204 // Context is returned in rax. It replaces the context passed to us. 205 // Context is returned in rax. It replaces the context passed to us.
205 // It's saved in the stack and kept live in rsi. 206 // It's saved in the stack and kept live in rsi.
206 __ movp(rsi, rax); 207 __ movp(rsi, rax);
207 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax); 208 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax);
208 209
209 // Copy any necessary parameters into the context. 210 // Copy any necessary parameters into the context.
210 int num_parameters = info->scope()->num_parameters(); 211 int num_parameters = info->scope()->num_parameters();
211 for (int i = 0; i < num_parameters; i++) { 212 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0;
212 Variable* var = scope()->parameter(i); 213 for (int i = first_parameter; i < num_parameters; i++) {
214 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i);
213 if (var->IsContextSlot()) { 215 if (var->IsContextSlot()) {
214 int parameter_offset = StandardFrameConstants::kCallerSPOffset + 216 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
215 (num_parameters - 1 - i) * kPointerSize; 217 (num_parameters - 1 - i) * kPointerSize;
216 // Load parameter from stack. 218 // Load parameter from stack.
217 __ movp(rax, Operand(rbp, parameter_offset)); 219 __ movp(rax, Operand(rbp, parameter_offset));
218 // Store it in the context. 220 // Store it in the context.
219 int context_offset = Context::SlotOffset(var->index()); 221 int context_offset = Context::SlotOffset(var->index());
220 __ movp(Operand(rsi, context_offset), rax); 222 __ movp(Operand(rsi, context_offset), rax);
221 // Update the write barrier. This clobbers rax and rbx. 223 // Update the write barrier. This clobbers rax and rbx.
222 if (need_write_barrier) { 224 if (need_write_barrier) {
(...skipping 5164 matching lines...) Expand 10 before | Expand all | Expand 10 after
5387 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5389 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5388 Assembler::target_address_at(call_target_address, 5390 Assembler::target_address_at(call_target_address,
5389 unoptimized_code)); 5391 unoptimized_code));
5390 return OSR_AFTER_STACK_CHECK; 5392 return OSR_AFTER_STACK_CHECK;
5391 } 5393 }
5392 5394
5393 5395
5394 } } // namespace v8::internal 5396 } } // namespace v8::internal
5395 5397
5396 #endif // V8_TARGET_ARCH_X64 5398 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/variables.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698