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

Side by Side Diff: src/ia32/full-codegen-ia32.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/arm64/full-codegen-arm64.cc ('k') | src/x64/full-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_IA32 7 #if V8_TARGET_ARCH_IA32
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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } else if (FLAG_debug_code) { 229 } else if (FLAG_debug_code) {
230 Label done; 230 Label done;
231 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear); 231 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear);
232 __ Abort(kExpectedNewSpaceObject); 232 __ Abort(kExpectedNewSpaceObject);
233 __ bind(&done); 233 __ bind(&done);
234 } 234 }
235 } 235 }
236 } 236 }
237 } 237 }
238 238
239 ArgumentsAccessStub::HasNewTarget has_new_target =
240 IsSubclassConstructor(info->function()->kind())
241 ? ArgumentsAccessStub::HAS_NEW_TARGET
242 : ArgumentsAccessStub::NO_NEW_TARGET;
243
239 // Possibly allocate RestParameters 244 // Possibly allocate RestParameters
240 int rest_index; 245 int rest_index;
241 Variable* rest_param = scope()->rest_parameter(&rest_index); 246 Variable* rest_param = scope()->rest_parameter(&rest_index);
242 if (rest_param) { 247 if (rest_param) {
243 Comment cmnt(masm_, "[ Allocate rest parameter array"); 248 Comment cmnt(masm_, "[ Allocate rest parameter array");
244 249
245 int num_parameters = info->scope()->num_parameters(); 250 int num_parameters = info->scope()->num_parameters();
246 int offset = num_parameters * kPointerSize; 251 int offset = num_parameters * kPointerSize;
252 if (has_new_target == ArgumentsAccessStub::HAS_NEW_TARGET) {
253 --num_parameters;
254 ++rest_index;
255 }
256
247 __ lea(edx, 257 __ lea(edx,
248 Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset)); 258 Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset));
249 __ push(edx); 259 __ push(edx);
250 __ push(Immediate(Smi::FromInt(num_parameters))); 260 __ push(Immediate(Smi::FromInt(num_parameters)));
251 __ push(Immediate(Smi::FromInt(rest_index))); 261 __ push(Immediate(Smi::FromInt(rest_index)));
252 262
253 RestParamAccessStub stub(isolate()); 263 RestParamAccessStub stub(isolate());
254 __ CallStub(&stub); 264 __ CallStub(&stub);
255 265
256 SetVar(rest_param, eax, ebx, edx); 266 SetVar(rest_param, eax, ebx, edx);
(...skipping 20 matching lines...) Expand all
277 // The stub will rewrite receiver and parameter count if the previous 287 // The stub will rewrite receiver and parameter count if the previous
278 // stack frame was an arguments adapter frame. 288 // stack frame was an arguments adapter frame.
279 ArgumentsAccessStub::Type type; 289 ArgumentsAccessStub::Type type;
280 if (is_strict(language_mode()) || !is_simple_parameter_list()) { 290 if (is_strict(language_mode()) || !is_simple_parameter_list()) {
281 type = ArgumentsAccessStub::NEW_STRICT; 291 type = ArgumentsAccessStub::NEW_STRICT;
282 } else if (function()->has_duplicate_parameters()) { 292 } else if (function()->has_duplicate_parameters()) {
283 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 293 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
284 } else { 294 } else {
285 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 295 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
286 } 296 }
287 ArgumentsAccessStub::HasNewTarget has_new_target = 297
288 IsSubclassConstructor(info->function()->kind())
289 ? ArgumentsAccessStub::HAS_NEW_TARGET
290 : ArgumentsAccessStub::NO_NEW_TARGET;
291 ArgumentsAccessStub stub(isolate(), type, has_new_target); 298 ArgumentsAccessStub stub(isolate(), type, has_new_target);
292 __ CallStub(&stub); 299 __ CallStub(&stub);
293 300
294 SetVar(arguments, eax, ebx, edx); 301 SetVar(arguments, eax, ebx, edx);
295 } 302 }
296 303
297 if (FLAG_trace) { 304 if (FLAG_trace) {
298 __ CallRuntime(Runtime::kTraceEnter, 0); 305 __ CallRuntime(Runtime::kTraceEnter, 0);
299 } 306 }
300 307
(...skipping 5076 matching lines...) Expand 10 before | Expand all | Expand 10 after
5377 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5384 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5378 Assembler::target_address_at(call_target_address, 5385 Assembler::target_address_at(call_target_address,
5379 unoptimized_code)); 5386 unoptimized_code));
5380 return OSR_AFTER_STACK_CHECK; 5387 return OSR_AFTER_STACK_CHECK;
5381 } 5388 }
5382 5389
5383 5390
5384 } } // namespace v8::internal 5391 } } // namespace v8::internal
5385 5392
5386 #endif // V8_TARGET_ARCH_IA32 5393 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm64/full-codegen-arm64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698