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

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

Issue 1569223002: [runtime] Cleanup runtime support for rest arguments. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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/runtime/runtime.h ('k') | no next file » | 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.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/ast/scopeinfo.h" 9 #include "src/ast/scopeinfo.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 // This runtime function does not materialize the correct arguments when the 634 // This runtime function does not materialize the correct arguments when the
635 // caller has been inlined, better make sure we are not hitting that case. 635 // caller has been inlined, better make sure we are not hitting that case.
636 JavaScriptFrameIterator it(isolate); 636 JavaScriptFrameIterator it(isolate);
637 DCHECK(!it.frame()->HasInlinedFrames()); 637 DCHECK(!it.frame()->HasInlinedFrames());
638 #endif // DEBUG 638 #endif // DEBUG
639 ParameterArguments argument_getter(parameters); 639 ParameterArguments argument_getter(parameters);
640 return *NewStrictArguments(isolate, callee, argument_getter, argument_count); 640 return *NewStrictArguments(isolate, callee, argument_getter, argument_count);
641 } 641 }
642 642
643 643
644 static Handle<JSArray> NewRestParam(Isolate* isolate, Object** parameters,
645 int num_params, int rest_index) {
646 parameters -= rest_index;
647 int num_elements = std::max(0, num_params - rest_index);
648 Handle<FixedArray> elements =
649 isolate->factory()->NewUninitializedFixedArray(num_elements);
650 for (int i = 0; i < num_elements; ++i) {
651 elements->set(i, *--parameters);
652 }
653 return isolate->factory()->NewJSArrayWithElements(elements, FAST_ELEMENTS,
654 num_elements);
655 }
656
657
658 RUNTIME_FUNCTION(Runtime_NewRestParam) { 644 RUNTIME_FUNCTION(Runtime_NewRestParam) {
659 HandleScope scope(isolate); 645 HandleScope scope(isolate);
660 DCHECK(args.length() == 3); 646 DCHECK(args.length() == 3);
661 CONVERT_SMI_ARG_CHECKED(num_params, 0); 647 CONVERT_SMI_ARG_CHECKED(num_params, 0);
662 Object** parameters = reinterpret_cast<Object**>(args[1]); 648 Object** parameters = reinterpret_cast<Object**>(args[1]);
663 CONVERT_SMI_ARG_CHECKED(rest_index, 2); 649 CONVERT_SMI_ARG_CHECKED(rest_index, 2);
664 650 #ifdef DEBUG
665 return *NewRestParam(isolate, parameters, num_params, rest_index); 651 // This runtime function does not materialize the correct arguments when the
652 // caller has been inlined, better make sure we are not hitting that case.
653 JavaScriptFrameIterator it(isolate);
654 DCHECK(!it.frame()->HasInlinedFrames());
655 #endif // DEBUG
656 Handle<JSFunction> callee;
657 ParameterArguments argument_getter(parameters);
658 return *NewRestArguments(isolate, callee, argument_getter, num_params,
659 rest_index);
666 } 660 }
667 661
668 662
669 RUNTIME_FUNCTION(Runtime_NewRestParamSlow) {
670 HandleScope scope(isolate);
671 DCHECK(args.length() == 1);
672 CONVERT_SMI_ARG_CHECKED(rest_index, 0);
673
674 JavaScriptFrameIterator it(isolate);
675
676 // Find the frame that holds the actual arguments passed to the function.
677 it.AdvanceToArgumentsFrame();
678 JavaScriptFrame* frame = it.frame();
679
680 int argument_count = frame->GetArgumentsLength();
681 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1));
682
683 return *NewRestParam(isolate, parameters, argument_count, rest_index);
684 }
685
686
687 RUNTIME_FUNCTION(Runtime_NewClosure) { 663 RUNTIME_FUNCTION(Runtime_NewClosure) {
688 HandleScope scope(isolate); 664 HandleScope scope(isolate);
689 DCHECK_EQ(1, args.length()); 665 DCHECK_EQ(1, args.length());
690 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); 666 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0);
691 Handle<Context> context(isolate->context(), isolate); 667 Handle<Context> context(isolate->context(), isolate);
692 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, 668 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context,
693 NOT_TENURED); 669 NOT_TENURED);
694 } 670 }
695 671
696 672
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1185
1210 // Lookup in the initial Object.prototype object. 1186 // Lookup in the initial Object.prototype object.
1211 Handle<Object> result; 1187 Handle<Object> result;
1212 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1188 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1213 isolate, result, 1189 isolate, result,
1214 Object::GetProperty(isolate->initial_object_prototype(), key)); 1190 Object::GetProperty(isolate->initial_object_prototype(), key));
1215 return *result; 1191 return *result;
1216 } 1192 }
1217 } // namespace internal 1193 } // namespace internal
1218 } // namespace v8 1194 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698