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

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

Issue 1693513002: [runtime] Introduce FastNewStrictArgumentsStub to optimize strict arguments. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix mips and mips64. Created 4 years, 10 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') | src/x64/builtins-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 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 result->set_elements(*elements); 561 result->set_elements(*elements);
562 for (int i = 0; i < argument_count; ++i) { 562 for (int i = 0; i < argument_count; ++i) {
563 elements->set(i, parameters[i]); 563 elements->set(i, parameters[i]);
564 } 564 }
565 } 565 }
566 } 566 }
567 return result; 567 return result;
568 } 568 }
569 569
570 570
571 template <typename T>
572 Handle<JSObject> NewStrictArguments(Isolate* isolate, Handle<JSFunction> callee,
573 T parameters, int argument_count) {
574 Handle<JSObject> result =
575 isolate->factory()->NewArgumentsObject(callee, argument_count);
576
577 if (argument_count > 0) {
578 Handle<FixedArray> array =
579 isolate->factory()->NewUninitializedFixedArray(argument_count);
580 DisallowHeapAllocation no_gc;
581 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
582 for (int i = 0; i < argument_count; i++) {
583 array->set(i, parameters[i], mode);
584 }
585 result->set_elements(*array);
586 }
587 return result;
588 }
589
590
591 class HandleArguments BASE_EMBEDDED { 571 class HandleArguments BASE_EMBEDDED {
592 public: 572 public:
593 explicit HandleArguments(Handle<Object>* array) : array_(array) {} 573 explicit HandleArguments(Handle<Object>* array) : array_(array) {}
594 Object* operator[](int index) { return *array_[index]; } 574 Object* operator[](int index) { return *array_[index]; }
595 575
596 private: 576 private:
597 Handle<Object>* array_; 577 Handle<Object>* array_;
598 }; 578 };
599 579
600 580
(...skipping 16 matching lines...) Expand all
617 // This generic runtime function can also be used when the caller has been 597 // This generic runtime function can also be used when the caller has been
618 // inlined, we use the slow but accurate {GetCallerArguments}. 598 // inlined, we use the slow but accurate {GetCallerArguments}.
619 int argument_count = 0; 599 int argument_count = 0;
620 base::SmartArrayPointer<Handle<Object>> arguments = 600 base::SmartArrayPointer<Handle<Object>> arguments =
621 GetCallerArguments(isolate, &argument_count); 601 GetCallerArguments(isolate, &argument_count);
622 HandleArguments argument_getter(arguments.get()); 602 HandleArguments argument_getter(arguments.get());
623 return *NewSloppyArguments(isolate, callee, argument_getter, argument_count); 603 return *NewSloppyArguments(isolate, callee, argument_getter, argument_count);
624 } 604 }
625 605
626 606
627 RUNTIME_FUNCTION(Runtime_NewStrictArguments_Generic) { 607 RUNTIME_FUNCTION(Runtime_NewStrictArguments) {
628 HandleScope scope(isolate); 608 HandleScope scope(isolate);
629 DCHECK(args.length() == 1); 609 DCHECK_EQ(1, args.length());
630 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); 610 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0);
631 // This generic runtime function can also be used when the caller has been 611 // This generic runtime function can also be used when the caller has been
632 // inlined, we use the slow but accurate {GetCallerArguments}. 612 // inlined, we use the slow but accurate {GetCallerArguments}.
633 int argument_count = 0; 613 int argument_count = 0;
634 base::SmartArrayPointer<Handle<Object>> arguments = 614 base::SmartArrayPointer<Handle<Object>> arguments =
635 GetCallerArguments(isolate, &argument_count); 615 GetCallerArguments(isolate, &argument_count);
636 HandleArguments argument_getter(arguments.get()); 616 Handle<JSObject> result =
637 return *NewStrictArguments(isolate, callee, argument_getter, argument_count); 617 isolate->factory()->NewArgumentsObject(callee, argument_count);
618 if (argument_count) {
619 Handle<FixedArray> array =
620 isolate->factory()->NewUninitializedFixedArray(argument_count);
621 DisallowHeapAllocation no_gc;
622 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
623 for (int i = 0; i < argument_count; i++) {
624 array->set(i, *arguments[i], mode);
625 }
626 result->set_elements(*array);
627 }
628 return *result;
638 } 629 }
639 630
640 631
641 RUNTIME_FUNCTION(Runtime_NewRestParameter) { 632 RUNTIME_FUNCTION(Runtime_NewRestParameter) {
642 HandleScope scope(isolate); 633 HandleScope scope(isolate);
643 DCHECK_EQ(1, args.length()); 634 DCHECK_EQ(1, args.length());
644 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) 635 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0)
645 int start_index = callee->shared()->internal_formal_parameter_count(); 636 int start_index = callee->shared()->internal_formal_parameter_count();
646 // This generic runtime function can also be used when the caller has been 637 // This generic runtime function can also be used when the caller has been
647 // inlined, we use the slow but accurate {GetCallerArguments}. 638 // inlined, we use the slow but accurate {GetCallerArguments}.
(...skipping 26 matching lines...) Expand all
674 // This runtime function does not materialize the correct arguments when the 665 // This runtime function does not materialize the correct arguments when the
675 // caller has been inlined, better make sure we are not hitting that case. 666 // caller has been inlined, better make sure we are not hitting that case.
676 JavaScriptFrameIterator it(isolate); 667 JavaScriptFrameIterator it(isolate);
677 DCHECK(!it.frame()->HasInlinedFrames()); 668 DCHECK(!it.frame()->HasInlinedFrames());
678 #endif // DEBUG 669 #endif // DEBUG
679 ParameterArguments argument_getter(parameters); 670 ParameterArguments argument_getter(parameters);
680 return *NewSloppyArguments(isolate, callee, argument_getter, argument_count); 671 return *NewSloppyArguments(isolate, callee, argument_getter, argument_count);
681 } 672 }
682 673
683 674
684 RUNTIME_FUNCTION(Runtime_NewStrictArguments) {
685 HandleScope scope(isolate);
686 DCHECK(args.length() == 3);
687 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0)
688 Object** parameters = reinterpret_cast<Object**>(args[1]);
689 CONVERT_SMI_ARG_CHECKED(argument_count, 2);
690 #ifdef DEBUG
691 // This runtime function does not materialize the correct arguments when the
692 // caller has been inlined, better make sure we are not hitting that case.
693 JavaScriptFrameIterator it(isolate);
694 DCHECK(!it.frame()->HasInlinedFrames());
695 #endif // DEBUG
696 ParameterArguments argument_getter(parameters);
697 return *NewStrictArguments(isolate, callee, argument_getter, argument_count);
698 }
699
700
701 RUNTIME_FUNCTION(Runtime_NewClosure) { 675 RUNTIME_FUNCTION(Runtime_NewClosure) {
702 HandleScope scope(isolate); 676 HandleScope scope(isolate);
703 DCHECK_EQ(1, args.length()); 677 DCHECK_EQ(1, args.length());
704 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); 678 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0);
705 Handle<Context> context(isolate->context(), isolate); 679 Handle<Context> context(isolate->context(), isolate);
706 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, 680 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context,
707 NOT_TENURED); 681 NOT_TENURED);
708 } 682 }
709 683
710 684
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 1215
1242 // Lookup in the initial Object.prototype object. 1216 // Lookup in the initial Object.prototype object.
1243 Handle<Object> result; 1217 Handle<Object> result;
1244 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1218 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1245 isolate, result, 1219 isolate, result,
1246 Object::GetProperty(isolate->initial_object_prototype(), key)); 1220 Object::GetProperty(isolate->initial_object_prototype(), key));
1247 return *result; 1221 return *result;
1248 } 1222 }
1249 } // namespace internal 1223 } // namespace internal
1250 } // namespace v8 1224 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698