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

Side by Side Diff: src/messages.js

Issue 1060583008: Port CallSite methods to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 7 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/messages.cc ('k') | src/runtime/runtime.h » ('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 // ------------------------------------------------------------------- 5 // -------------------------------------------------------------------
6 6
7 var $errorToString; 7 var $errorToString;
8 var $formatMessage; 8 var $formatMessage;
9 var $getStackTraceLine; 9 var $getStackTraceLine;
10 var $messageGetPositionInLine; 10 var $messageGetPositionInLine;
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 SET_PRIVATE(this, CallSiteFunctionKey, fun); 730 SET_PRIVATE(this, CallSiteFunctionKey, fun);
731 SET_PRIVATE(this, CallSitePositionKey, pos); 731 SET_PRIVATE(this, CallSitePositionKey, pos);
732 SET_PRIVATE(this, CallSiteStrictModeKey, strict_mode); 732 SET_PRIVATE(this, CallSiteStrictModeKey, strict_mode);
733 } 733 }
734 734
735 function CallSiteGetThis() { 735 function CallSiteGetThis() {
736 return GET_PRIVATE(this, CallSiteStrictModeKey) 736 return GET_PRIVATE(this, CallSiteStrictModeKey)
737 ? UNDEFINED : GET_PRIVATE(this, CallSiteReceiverKey); 737 ? UNDEFINED : GET_PRIVATE(this, CallSiteReceiverKey);
738 } 738 }
739 739
740 function CallSiteGetFunction() {
741 return GET_PRIVATE(this, CallSiteStrictModeKey)
742 ? UNDEFINED : GET_PRIVATE(this, CallSiteFunctionKey);
743 }
744
745 function CallSiteGetPosition() {
746 return GET_PRIVATE(this, CallSitePositionKey);
747 }
748
740 function CallSiteGetTypeName() { 749 function CallSiteGetTypeName() {
741 return GetTypeName(GET_PRIVATE(this, CallSiteReceiverKey), false); 750 return GetTypeName(GET_PRIVATE(this, CallSiteReceiverKey), false);
742 } 751 }
743 752
744 function CallSiteIsToplevel() { 753 function CallSiteIsToplevel() {
745 if (GET_PRIVATE(this, CallSiteReceiverKey) == null) { 754 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
746 return true; 755 var fun = GET_PRIVATE(this, CallSiteFunctionKey);
747 } 756 var pos = GET_PRIVATE(this, CallSitePositionKey);
748 return IS_GLOBAL(GET_PRIVATE(this, CallSiteReceiverKey)); 757 return %CallSiteIsToplevelRT(receiver, fun, pos);
749 } 758 }
750 759
751 function CallSiteIsEval() { 760 function CallSiteIsEval() {
752 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); 761 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
753 return script && script.compilation_type == COMPILATION_TYPE_EVAL; 762 var fun = GET_PRIVATE(this, CallSiteFunctionKey);
763 var pos = GET_PRIVATE(this, CallSitePositionKey);
764 return %CallSiteIsEvalRT(receiver, fun, pos);
754 } 765 }
755 766
756 function CallSiteGetEvalOrigin() { 767 function CallSiteGetEvalOrigin() {
757 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); 768 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey));
758 return FormatEvalOrigin(script); 769 return FormatEvalOrigin(script);
759 } 770 }
760 771
761 function CallSiteGetScriptNameOrSourceURL() { 772 function CallSiteGetScriptNameOrSourceURL() {
762 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); 773 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
763 return script ? script.nameOrSourceURL() : null; 774 var fun = GET_PRIVATE(this, CallSiteFunctionKey);
764 } 775 var pos = GET_PRIVATE(this, CallSitePositionKey);
765 776 return %CallSiteGetScriptNameOrSourceUrlRT(receiver, fun, pos);
766 function CallSiteGetFunction() {
767 return GET_PRIVATE(this, CallSiteStrictModeKey)
768 ? UNDEFINED : GET_PRIVATE(this, CallSiteFunctionKey);
769 } 777 }
770 778
771 function CallSiteGetFunctionName() { 779 function CallSiteGetFunctionName() {
772 // See if the function knows its own name 780 // See if the function knows its own name
781 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
773 var fun = GET_PRIVATE(this, CallSiteFunctionKey); 782 var fun = GET_PRIVATE(this, CallSiteFunctionKey);
774 var name = %FunctionGetDebugName(fun); 783 var pos = GET_PRIVATE(this, CallSitePositionKey);
775 if (name) { 784 return %CallSiteGetFunctionNameRT(receiver, fun, pos);
776 return name;
777 }
778 // Maybe this is an evaluation?
779 var script = %FunctionGetScript(fun);
780 if (script && script.compilation_type == COMPILATION_TYPE_EVAL) {
781 return "eval";
782 }
783 return null;
784 } 785 }
785 786
786 function CallSiteGetMethodName() { 787 function CallSiteGetMethodName() {
787 // See if we can find a unique property on the receiver that holds 788 // See if we can find a unique property on the receiver that holds
788 // this function. 789 // this function.
789 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); 790 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
790 var fun = GET_PRIVATE(this, CallSiteFunctionKey); 791 var fun = GET_PRIVATE(this, CallSiteFunctionKey);
791 var ownName = fun.name; 792 var ownName = fun.name;
792 if (ownName && receiver && 793 if (ownName && receiver &&
793 (%_CallFunction(receiver, ownName, ObjectLookupGetter) === fun || 794 (%_CallFunction(receiver, ownName, ObjectLookupGetter) === fun ||
(...skipping 15 matching lines...) Expand all
809 name = prop; 810 name = prop;
810 } 811 }
811 } 812 }
812 if (name) { 813 if (name) {
813 return name; 814 return name;
814 } 815 }
815 return null; 816 return null;
816 } 817 }
817 818
818 function CallSiteGetFileName() { 819 function CallSiteGetFileName() {
819 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); 820 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
820 return script ? script.name : null; 821 var fun = GET_PRIVATE(this, CallSiteFunctionKey);
822 var pos = GET_PRIVATE(this, CallSitePositionKey);
823 return %CallSiteGetFileNameRT(receiver, fun, pos);
821 } 824 }
822 825
823 function CallSiteGetLineNumber() { 826 function CallSiteGetLineNumber() {
824 if (GET_PRIVATE(this, CallSitePositionKey) == -1) { 827 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
825 return null; 828 var fun = GET_PRIVATE(this, CallSiteFunctionKey);
826 } 829 var pos = GET_PRIVATE(this, CallSitePositionKey);
827 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); 830 return %CallSiteGetLineNumberRT(receiver, fun, pos);
828 var location = null;
829 if (script) {
830 location = script.locationFromPosition(
831 GET_PRIVATE(this, CallSitePositionKey), true);
832 }
833 return location ? location.line + 1 : null;
834 } 831 }
835 832
836 function CallSiteGetColumnNumber() { 833 function CallSiteGetColumnNumber() {
837 if (GET_PRIVATE(this, CallSitePositionKey) == -1) { 834 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
838 return null; 835 var fun = GET_PRIVATE(this, CallSiteFunctionKey);
839 } 836 var pos = GET_PRIVATE(this, CallSitePositionKey);
840 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); 837 return %CallSiteGetColumnNumberRT(receiver, fun, pos);
841 var location = null;
842 if (script) {
843 location = script.locationFromPosition(
844 GET_PRIVATE(this, CallSitePositionKey), true);
845 }
846 return location ? location.column + 1: null;
847 } 838 }
848 839
849 function CallSiteIsNative() { 840 function CallSiteIsNative() {
850 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); 841 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
851 return script ? (script.type == TYPE_NATIVE) : false; 842 var fun = GET_PRIVATE(this, CallSiteFunctionKey);
852 } 843 var pos = GET_PRIVATE(this, CallSitePositionKey);
853 844 return %CallSiteIsNativeRT(receiver, fun, pos);
854 function CallSiteGetPosition() {
855 return GET_PRIVATE(this, CallSitePositionKey);
856 } 845 }
857 846
858 function CallSiteIsConstructor() { 847 function CallSiteIsConstructor() {
859 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); 848 var receiver = GET_PRIVATE(this, CallSiteReceiverKey);
860 var constructor = (receiver != null && IS_OBJECT(receiver)) 849 var constructor = (receiver != null && IS_OBJECT(receiver))
861 ? %GetDataProperty(receiver, "constructor") : null; 850 ? %GetDataProperty(receiver, "constructor") : null;
862 if (!constructor) return false; 851 if (!constructor) return false;
863 return GET_PRIVATE(this, CallSiteFunctionKey) === constructor; 852 return GET_PRIVATE(this, CallSiteFunctionKey) === constructor;
864 } 853 }
865 854
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 return MakeGenericError(GlobalTypeError, type, [arg]); 1293 return MakeGenericError(GlobalTypeError, type, [arg]);
1305 } 1294 }
1306 1295
1307 //Boilerplate for exceptions for stack overflows. Used from 1296 //Boilerplate for exceptions for stack overflows. Used from
1308 //Isolate::StackOverflow(). 1297 //Isolate::StackOverflow().
1309 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow); 1298 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow);
1310 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', 1299 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack',
1311 StackTraceGetter, StackTraceSetter, DONT_ENUM); 1300 StackTraceGetter, StackTraceSetter, DONT_ENUM);
1312 1301
1313 })(); 1302 })();
OLDNEW
« no previous file with comments | « src/messages.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698