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

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

Issue 816913003: Implement ES6 rest parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove --harmony-arrow-functions from tests 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_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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 __ movp(rsi, rax); 206 __ movp(rsi, rax);
207 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax); 207 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax);
208 208
209 // Copy any necessary parameters into the context. 209 // Copy any necessary parameters into the context.
210 int num_parameters = info->scope()->num_parameters(); 210 int num_parameters = info->scope()->num_parameters();
211 for (int i = 0; i < num_parameters; i++) { 211 for (int i = 0; i < num_parameters; i++) {
212 Variable* var = scope()->parameter(i); 212 Variable* var = scope()->parameter(i);
213 if (var->IsContextSlot()) { 213 if (var->IsContextSlot()) {
214 int parameter_offset = StandardFrameConstants::kCallerSPOffset + 214 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
215 (num_parameters - 1 - i) * kPointerSize; 215 (num_parameters - 1 - i) * kPointerSize;
216
Dmitry Lomov (no reviews) 2015/02/11 00:30:50 Stray edit
caitp (gmail) 2015/02/11 21:05:54 Fixed.
216 // Load parameter from stack. 217 // Load parameter from stack.
217 __ movp(rax, Operand(rbp, parameter_offset)); 218 __ movp(rax, Operand(rbp, parameter_offset));
218 // Store it in the context. 219 // Store it in the context.
219 int context_offset = Context::SlotOffset(var->index()); 220 int context_offset = Context::SlotOffset(var->index());
220 __ movp(Operand(rsi, context_offset), rax); 221 __ movp(Operand(rsi, context_offset), rax);
221 // Update the write barrier. This clobbers rax and rbx. 222 // Update the write barrier. This clobbers rax and rbx.
222 if (need_write_barrier) { 223 if (need_write_barrier) {
223 __ RecordWriteContextSlot( 224 __ RecordWriteContextSlot(
224 rsi, context_offset, rax, rbx, kDontSaveFPRegs); 225 rsi, context_offset, rax, rbx, kDontSaveFPRegs);
225 } else if (FLAG_debug_code) { 226 } else if (FLAG_debug_code) {
226 Label done; 227 Label done;
227 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear); 228 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear);
228 __ Abort(kExpectedNewSpaceObject); 229 __ Abort(kExpectedNewSpaceObject);
229 __ bind(&done); 230 __ bind(&done);
230 } 231 }
231 } 232 }
232 } 233 }
233 } 234 }
234 235
236 // Possibly allocate RestParameters
237 int rest_index;
238 Variable* rest_param = scope()->rest_parameter(&rest_index);
239 if (rest_param) {
240 Comment cmnt(masm_, "[ Allocate rest parameter array");
241
242 int num_parameters = info->scope()->num_parameters();
243 int offset = num_parameters * kPointerSize;
244 __ leap(rdx,
245 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset));
246 __ Push(rdx);
247 __ Push(Smi::FromInt(num_parameters));
248 __ Push(Smi::FromInt(rest_index));
249
250 RestParamAccessStub stub(isolate());
251 __ CallStub(&stub);
252
253 SetVar(rest_param, rax, rbx, rdx);
254 }
255
235 // Possibly allocate an arguments object. 256 // Possibly allocate an arguments object.
236 Variable* arguments = scope()->arguments(); 257 Variable* arguments = scope()->arguments();
237 if (arguments != NULL) { 258 if (arguments != NULL) {
238 // Arguments object must be allocated after the context object, in 259 // Arguments object must be allocated after the context object, in
239 // case the "arguments" or ".arguments" variables are in the context. 260 // case the "arguments" or ".arguments" variables are in the context.
240 Comment cmnt(masm_, "[ Allocate arguments object"); 261 Comment cmnt(masm_, "[ Allocate arguments object");
241 if (function_in_register) { 262 if (function_in_register) {
242 __ Push(rdi); 263 __ Push(rdi);
243 } else { 264 } else {
244 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 265 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
245 } 266 }
246 // The receiver is just before the parameters on the caller's stack. 267 // The receiver is just before the parameters on the caller's stack.
247 int num_parameters = info->scope()->num_parameters(); 268 int num_parameters = info->scope()->num_parameters();
248 int offset = num_parameters * kPointerSize; 269 int offset = num_parameters * kPointerSize;
249 __ leap(rdx, 270 __ leap(rdx,
250 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); 271 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset));
251 __ Push(rdx); 272 __ Push(rdx);
252 __ Push(Smi::FromInt(num_parameters)); 273 __ Push(Smi::FromInt(num_parameters));
253 // Arguments to ArgumentsAccessStub: 274 // Arguments to ArgumentsAccessStub:
254 // function, receiver address, parameter count. 275 // function, receiver address, parameter count.
255 // The stub will rewrite receiver and parameter count if the previous 276 // The stub will rewrite receiver and parameter count if the previous
256 // stack frame was an arguments adapter frame. 277 // stack frame was an arguments adapter frame.
257 ArgumentsAccessStub::Type type; 278 ArgumentsAccessStub::Type type;
258 if (is_strict(language_mode())) { 279 if (is_strict(language_mode()) || !is_simple_parameter_list()) {
259 type = ArgumentsAccessStub::NEW_STRICT; 280 type = ArgumentsAccessStub::NEW_STRICT;
260 } else if (function()->has_duplicate_parameters()) { 281 } else if (function()->has_duplicate_parameters()) {
261 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 282 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
262 } else { 283 } else {
263 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 284 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
264 } 285 }
265 ArgumentsAccessStub stub(isolate(), type); 286 ArgumentsAccessStub stub(isolate(), type);
266 __ CallStub(&stub); 287 __ CallStub(&stub);
267 288
268 SetVar(arguments, rax, rbx, rdx); 289 SetVar(arguments, rax, rbx, rdx);
(...skipping 5046 matching lines...) Expand 10 before | Expand all | Expand 10 after
5315 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5336 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5316 Assembler::target_address_at(call_target_address, 5337 Assembler::target_address_at(call_target_address,
5317 unoptimized_code)); 5338 unoptimized_code));
5318 return OSR_AFTER_STACK_CHECK; 5339 return OSR_AFTER_STACK_CHECK;
5319 } 5340 }
5320 5341
5321 5342
5322 } } // namespace v8::internal 5343 } } // namespace v8::internal
5323 5344
5324 #endif // V8_TARGET_ARCH_X64 5345 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698