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

Side by Side Diff: src/arm/full-codegen-arm.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 | « no previous file | src/arm64/full-codegen-arm64.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_ARM 7 #if V8_TARGET_ARCH_ARM
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } else if (FLAG_debug_code) { 233 } else if (FLAG_debug_code) {
234 Label done; 234 Label done;
235 __ JumpIfInNewSpace(cp, r0, &done); 235 __ JumpIfInNewSpace(cp, r0, &done);
236 __ Abort(kExpectedNewSpaceObject); 236 __ Abort(kExpectedNewSpaceObject);
237 __ bind(&done); 237 __ bind(&done);
238 } 238 }
239 } 239 }
240 } 240 }
241 } 241 }
242 242
243 ArgumentsAccessStub::HasNewTarget has_new_target =
244 IsSubclassConstructor(info->function()->kind())
245 ? ArgumentsAccessStub::HAS_NEW_TARGET
246 : ArgumentsAccessStub::NO_NEW_TARGET;
247
243 // Possibly allocate RestParameters 248 // Possibly allocate RestParameters
244 int rest_index; 249 int rest_index;
245 Variable* rest_param = scope()->rest_parameter(&rest_index); 250 Variable* rest_param = scope()->rest_parameter(&rest_index);
246 if (rest_param) { 251 if (rest_param) {
247 Comment cmnt(masm_, "[ Allocate rest parameter array"); 252 Comment cmnt(masm_, "[ Allocate rest parameter array");
248 253
249 int num_parameters = info->scope()->num_parameters(); 254 int num_parameters = info->scope()->num_parameters();
250 int offset = num_parameters * kPointerSize; 255 int offset = num_parameters * kPointerSize;
256 if (has_new_target == ArgumentsAccessStub::HAS_NEW_TARGET) {
257 --num_parameters;
258 ++rest_index;
259 }
260
251 __ add(r3, fp, Operand(StandardFrameConstants::kCallerSPOffset + offset)); 261 __ add(r3, fp, Operand(StandardFrameConstants::kCallerSPOffset + offset));
252 __ mov(r2, Operand(Smi::FromInt(num_parameters))); 262 __ mov(r2, Operand(Smi::FromInt(num_parameters)));
253 __ mov(r1, Operand(Smi::FromInt(rest_index))); 263 __ mov(r1, Operand(Smi::FromInt(rest_index)));
254 __ Push(r3, r2, r1); 264 __ Push(r3, r2, r1);
255 265
256 RestParamAccessStub stub(isolate()); 266 RestParamAccessStub stub(isolate());
257 __ CallStub(&stub); 267 __ CallStub(&stub);
258 268
259 SetVar(rest_param, r0, r1, r2); 269 SetVar(rest_param, r0, r1, r2);
260 } 270 }
(...skipping 13 matching lines...) Expand all
274 int offset = num_parameters * kPointerSize; 284 int offset = num_parameters * kPointerSize;
275 __ add(r2, fp, 285 __ add(r2, fp,
276 Operand(StandardFrameConstants::kCallerSPOffset + offset)); 286 Operand(StandardFrameConstants::kCallerSPOffset + offset));
277 __ mov(r1, Operand(Smi::FromInt(num_parameters))); 287 __ mov(r1, Operand(Smi::FromInt(num_parameters)));
278 __ Push(r3, r2, r1); 288 __ Push(r3, r2, r1);
279 289
280 // Arguments to ArgumentsAccessStub: 290 // Arguments to ArgumentsAccessStub:
281 // function, receiver address, parameter count. 291 // function, receiver address, parameter count.
282 // The stub will rewrite receiever and parameter count if the previous 292 // The stub will rewrite receiever and parameter count if the previous
283 // stack frame was an arguments adapter frame. 293 // stack frame was an arguments adapter frame.
284 ArgumentsAccessStub::HasNewTarget has_new_target =
285 IsSubclassConstructor(info->function()->kind())
286 ? ArgumentsAccessStub::HAS_NEW_TARGET
287 : ArgumentsAccessStub::NO_NEW_TARGET;
288 ArgumentsAccessStub::Type type; 294 ArgumentsAccessStub::Type type;
289 if (is_strict(language_mode()) || !is_simple_parameter_list()) { 295 if (is_strict(language_mode()) || !is_simple_parameter_list()) {
290 type = ArgumentsAccessStub::NEW_STRICT; 296 type = ArgumentsAccessStub::NEW_STRICT;
291 } else if (function()->has_duplicate_parameters()) { 297 } else if (function()->has_duplicate_parameters()) {
292 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 298 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
293 } else { 299 } else {
294 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 300 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
295 } 301 }
296 ArgumentsAccessStub stub(isolate(), type, has_new_target); 302 ArgumentsAccessStub stub(isolate(), type, has_new_target);
297 __ CallStub(&stub); 303 __ CallStub(&stub);
(...skipping 5214 matching lines...) Expand 10 before | Expand all | Expand 10 after
5512 5518
5513 DCHECK(interrupt_address == 5519 DCHECK(interrupt_address ==
5514 isolate->builtins()->OsrAfterStackCheck()->entry()); 5520 isolate->builtins()->OsrAfterStackCheck()->entry());
5515 return OSR_AFTER_STACK_CHECK; 5521 return OSR_AFTER_STACK_CHECK;
5516 } 5522 }
5517 5523
5518 5524
5519 } } // namespace v8::internal 5525 } } // namespace v8::internal
5520 5526
5521 #endif // V8_TARGET_ARCH_ARM 5527 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698