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

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

Issue 1018043003: [es6] generate rest parameters correctly for subclass constructors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test that rest params have same elements as arguments object, too Created 5 years, 9 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/ia32/full-codegen-ia32.cc ('k') | test/mjsunit/harmony/rest-params.js » ('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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } else if (FLAG_debug_code) { 225 } else if (FLAG_debug_code) {
226 Label done; 226 Label done;
227 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear); 227 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear);
228 __ Abort(kExpectedNewSpaceObject); 228 __ Abort(kExpectedNewSpaceObject);
229 __ bind(&done); 229 __ bind(&done);
230 } 230 }
231 } 231 }
232 } 232 }
233 } 233 }
234 234
235 ArgumentsAccessStub::HasNewTarget has_new_target =
236 IsSubclassConstructor(info->function()->kind())
237 ? ArgumentsAccessStub::HAS_NEW_TARGET
238 : ArgumentsAccessStub::NO_NEW_TARGET;
239
235 // Possibly allocate RestParameters 240 // Possibly allocate RestParameters
236 int rest_index; 241 int rest_index;
237 Variable* rest_param = scope()->rest_parameter(&rest_index); 242 Variable* rest_param = scope()->rest_parameter(&rest_index);
238 if (rest_param) { 243 if (rest_param) {
239 Comment cmnt(masm_, "[ Allocate rest parameter array"); 244 Comment cmnt(masm_, "[ Allocate rest parameter array");
240 245
241 int num_parameters = info->scope()->num_parameters(); 246 int num_parameters = info->scope()->num_parameters();
242 int offset = num_parameters * kPointerSize; 247 int offset = num_parameters * kPointerSize;
248 if (has_new_target == ArgumentsAccessStub::HAS_NEW_TARGET) {
249 --num_parameters;
250 ++rest_index;
251 }
252
243 __ leap(rdx, 253 __ leap(rdx,
244 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); 254 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset));
245 __ Push(rdx); 255 __ Push(rdx);
246 __ Push(Smi::FromInt(num_parameters)); 256 __ Push(Smi::FromInt(num_parameters));
247 __ Push(Smi::FromInt(rest_index)); 257 __ Push(Smi::FromInt(rest_index));
248 258
249 RestParamAccessStub stub(isolate()); 259 RestParamAccessStub stub(isolate());
250 __ CallStub(&stub); 260 __ CallStub(&stub);
251 261
252 SetVar(rest_param, rax, rbx, rdx); 262 SetVar(rest_param, rax, rbx, rdx);
(...skipping 15 matching lines...) Expand all
268 int offset = num_parameters * kPointerSize; 278 int offset = num_parameters * kPointerSize;
269 __ leap(rdx, 279 __ leap(rdx,
270 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); 280 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset));
271 __ Push(rdx); 281 __ Push(rdx);
272 __ Push(Smi::FromInt(num_parameters)); 282 __ Push(Smi::FromInt(num_parameters));
273 // Arguments to ArgumentsAccessStub: 283 // Arguments to ArgumentsAccessStub:
274 // function, receiver address, parameter count. 284 // function, receiver address, parameter count.
275 // The stub will rewrite receiver and parameter count if the previous 285 // The stub will rewrite receiver and parameter count if the previous
276 // stack frame was an arguments adapter frame. 286 // stack frame was an arguments adapter frame.
277 287
278 ArgumentsAccessStub::HasNewTarget has_new_target =
279 IsSubclassConstructor(info->function()->kind())
280 ? ArgumentsAccessStub::HAS_NEW_TARGET
281 : ArgumentsAccessStub::NO_NEW_TARGET;
282 ArgumentsAccessStub::Type type; 288 ArgumentsAccessStub::Type type;
283 if (is_strict(language_mode()) || !is_simple_parameter_list()) { 289 if (is_strict(language_mode()) || !is_simple_parameter_list()) {
284 type = ArgumentsAccessStub::NEW_STRICT; 290 type = ArgumentsAccessStub::NEW_STRICT;
285 } else if (function()->has_duplicate_parameters()) { 291 } else if (function()->has_duplicate_parameters()) {
286 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 292 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
287 } else { 293 } else {
288 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 294 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
289 } 295 }
290 ArgumentsAccessStub stub(isolate(), type, has_new_target); 296 ArgumentsAccessStub stub(isolate(), type, has_new_target);
291 __ CallStub(&stub); 297 __ CallStub(&stub);
(...skipping 5108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5400 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5406 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5401 Assembler::target_address_at(call_target_address, 5407 Assembler::target_address_at(call_target_address,
5402 unoptimized_code)); 5408 unoptimized_code));
5403 return OSR_AFTER_STACK_CHECK; 5409 return OSR_AFTER_STACK_CHECK;
5404 } 5410 }
5405 5411
5406 5412
5407 } } // namespace v8::internal 5413 } } // namespace v8::internal
5408 5414
5409 #endif // V8_TARGET_ARCH_X64 5415 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | test/mjsunit/harmony/rest-params.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698