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

Side by Side Diff: src/runtime/runtime-scopes.cc

Issue 1278783002: [es6] Use strict arguments objects for destructured parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Doh Created 5 years, 4 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/parser.cc ('k') | src/scopeinfo.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 return *value; 391 return *value;
392 } 392 }
393 393
394 394
395 static Handle<JSObject> NewSloppyArguments(Isolate* isolate, 395 static Handle<JSObject> NewSloppyArguments(Isolate* isolate,
396 Handle<JSFunction> callee, 396 Handle<JSFunction> callee,
397 Object** parameters, 397 Object** parameters,
398 int argument_count) { 398 int argument_count) {
399 CHECK(!IsSubclassConstructor(callee->shared()->kind())); 399 CHECK(!IsSubclassConstructor(callee->shared()->kind()));
400 DCHECK(callee->is_simple_parameter_list()); 400 DCHECK(callee->has_simple_parameters());
401 Handle<JSObject> result = 401 Handle<JSObject> result =
402 isolate->factory()->NewArgumentsObject(callee, argument_count); 402 isolate->factory()->NewArgumentsObject(callee, argument_count);
403 403
404 // Allocate the elements if needed. 404 // Allocate the elements if needed.
405 int parameter_count = callee->shared()->internal_formal_parameter_count(); 405 int parameter_count = callee->shared()->internal_formal_parameter_count();
406 if (argument_count > 0) { 406 if (argument_count > 0) {
407 if (parameter_count > 0) { 407 if (parameter_count > 0) {
408 int mapped_count = Min(argument_count, parameter_count); 408 int mapped_count = Min(argument_count, parameter_count);
409 Handle<FixedArray> parameter_map = 409 Handle<FixedArray> parameter_map =
410 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED); 410 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 511
512 // Find the frame that holds the actual arguments passed to the function. 512 // Find the frame that holds the actual arguments passed to the function.
513 it.AdvanceToArgumentsFrame(); 513 it.AdvanceToArgumentsFrame();
514 JavaScriptFrame* frame = it.frame(); 514 JavaScriptFrame* frame = it.frame();
515 515
516 // Determine parameter location on the stack and dispatch on language mode. 516 // Determine parameter location on the stack and dispatch on language mode.
517 int argument_count = frame->GetArgumentsLength(); 517 int argument_count = frame->GetArgumentsLength();
518 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); 518 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1));
519 519
520 return (is_strict(callee->shared()->language_mode()) || 520 return (is_strict(callee->shared()->language_mode()) ||
521 !callee->is_simple_parameter_list()) 521 !callee->has_simple_parameters())
522 ? *NewStrictArguments(isolate, callee, parameters, argument_count) 522 ? *NewStrictArguments(isolate, callee, parameters, argument_count)
523 : *NewSloppyArguments(isolate, callee, parameters, argument_count); 523 : *NewSloppyArguments(isolate, callee, parameters, argument_count);
524 } 524 }
525 525
526 526
527 RUNTIME_FUNCTION(Runtime_NewSloppyArguments) { 527 RUNTIME_FUNCTION(Runtime_NewSloppyArguments) {
528 HandleScope scope(isolate); 528 HandleScope scope(isolate);
529 DCHECK(args.length() == 3); 529 DCHECK(args.length() == 3);
530 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); 530 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0);
531 Object** parameters = reinterpret_cast<Object**>(args[1]); 531 Object** parameters = reinterpret_cast<Object**>(args[1]);
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 1161
1162 // Lookup in the initial Object.prototype object. 1162 // Lookup in the initial Object.prototype object.
1163 Handle<Object> result; 1163 Handle<Object> result;
1164 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1164 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1165 isolate, result, 1165 isolate, result,
1166 Object::GetProperty(isolate->initial_object_prototype(), key)); 1166 Object::GetProperty(isolate->initial_object_prototype(), key));
1167 return *result; 1167 return *result;
1168 } 1168 }
1169 } // namespace internal 1169 } // namespace internal
1170 } // namespace v8 1170 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698