OLD | NEW |
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 kMessages = { | 7 var kMessages = { |
8 // Error | 8 // Error |
9 constructor_is_generator: ["Class constructor may not be a generator"], | 9 constructor_is_generator: ["Class constructor may not be a generator"], |
10 constructor_is_accessor: ["Class constructor may not be an accessor"], | 10 constructor_is_accessor: ["Class constructor may not be an accessor"], |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 SET_PRIVATE(this, CallSiteFunctionKey, fun); | 738 SET_PRIVATE(this, CallSiteFunctionKey, fun); |
739 SET_PRIVATE(this, CallSitePositionKey, pos); | 739 SET_PRIVATE(this, CallSitePositionKey, pos); |
740 SET_PRIVATE(this, CallSiteStrictModeKey, strict_mode); | 740 SET_PRIVATE(this, CallSiteStrictModeKey, strict_mode); |
741 } | 741 } |
742 | 742 |
743 function CallSiteGetThis() { | 743 function CallSiteGetThis() { |
744 return GET_PRIVATE(this, CallSiteStrictModeKey) | 744 return GET_PRIVATE(this, CallSiteStrictModeKey) |
745 ? UNDEFINED : GET_PRIVATE(this, CallSiteReceiverKey); | 745 ? UNDEFINED : GET_PRIVATE(this, CallSiteReceiverKey); |
746 } | 746 } |
747 | 747 |
| 748 function CallSiteGetFunction() { |
| 749 return GET_PRIVATE(this, CallSiteStrictModeKey) |
| 750 ? UNDEFINED : GET_PRIVATE(this, CallSiteFunctionKey); |
| 751 } |
| 752 |
| 753 function CallSiteGetPosition() { |
| 754 return GET_PRIVATE(this, CallSitePositionKey); |
| 755 } |
| 756 |
748 function CallSiteGetTypeName() { | 757 function CallSiteGetTypeName() { |
749 return GetTypeName(GET_PRIVATE(this, CallSiteReceiverKey), false); | 758 return GetTypeName(GET_PRIVATE(this, CallSiteReceiverKey), false); |
750 } | 759 } |
751 | 760 |
752 function CallSiteIsToplevel() { | 761 function CallSiteIsToplevel() { |
753 if (GET_PRIVATE(this, CallSiteReceiverKey) == null) { | 762 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
754 return true; | 763 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
755 } | 764 var pos = GET_PRIVATE(this, CallSitePositionKey); |
756 return IS_GLOBAL(GET_PRIVATE(this, CallSiteReceiverKey)); | 765 return %CallSiteIsToplevelRT(receiver, fun, pos); |
757 } | 766 } |
758 | 767 |
759 function CallSiteIsEval() { | 768 function CallSiteIsEval() { |
760 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); | 769 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
761 return script && script.compilation_type == COMPILATION_TYPE_EVAL; | 770 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
| 771 var pos = GET_PRIVATE(this, CallSitePositionKey); |
| 772 return %CallSiteIsEvalRT(receiver, fun, pos); |
762 } | 773 } |
763 | 774 |
764 function CallSiteGetEvalOrigin() { | 775 function CallSiteGetEvalOrigin() { |
765 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); | 776 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); |
766 return FormatEvalOrigin(script); | 777 return FormatEvalOrigin(script); |
767 } | 778 } |
768 | 779 |
769 function CallSiteGetScriptNameOrSourceURL() { | 780 function CallSiteGetScriptNameOrSourceURL() { |
770 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); | 781 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
771 return script ? script.nameOrSourceURL() : null; | 782 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
772 } | 783 var pos = GET_PRIVATE(this, CallSitePositionKey); |
773 | 784 return %CallSiteGetScriptNameOrSourceUrlRT(receiver, fun, pos); |
774 function CallSiteGetFunction() { | |
775 return GET_PRIVATE(this, CallSiteStrictModeKey) | |
776 ? UNDEFINED : GET_PRIVATE(this, CallSiteFunctionKey); | |
777 } | 785 } |
778 | 786 |
779 function CallSiteGetFunctionName() { | 787 function CallSiteGetFunctionName() { |
780 // See if the function knows its own name | 788 // See if the function knows its own name |
| 789 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
781 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 790 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
782 var name = %FunctionGetDebugName(fun); | 791 var pos = GET_PRIVATE(this, CallSitePositionKey); |
783 if (name) { | 792 return %CallSiteGetFunctionNameRT(receiver, fun, pos); |
784 return name; | |
785 } | |
786 // Maybe this is an evaluation? | |
787 var script = %FunctionGetScript(fun); | |
788 if (script && script.compilation_type == COMPILATION_TYPE_EVAL) { | |
789 return "eval"; | |
790 } | |
791 return null; | |
792 } | 793 } |
793 | 794 |
794 function CallSiteGetMethodName() { | 795 function CallSiteGetMethodName() { |
795 // See if we can find a unique property on the receiver that holds | 796 // See if we can find a unique property on the receiver that holds |
796 // this function. | 797 // this function. |
797 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 798 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
798 var fun = GET_PRIVATE(this, CallSiteFunctionKey); | 799 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
799 var ownName = fun.name; | 800 var ownName = fun.name; |
800 if (ownName && receiver && | 801 if (ownName && receiver && |
801 (%_CallFunction(receiver, ownName, ObjectLookupGetter) === fun || | 802 (%_CallFunction(receiver, ownName, ObjectLookupGetter) === fun || |
(...skipping 15 matching lines...) Expand all Loading... |
817 name = prop; | 818 name = prop; |
818 } | 819 } |
819 } | 820 } |
820 if (name) { | 821 if (name) { |
821 return name; | 822 return name; |
822 } | 823 } |
823 return null; | 824 return null; |
824 } | 825 } |
825 | 826 |
826 function CallSiteGetFileName() { | 827 function CallSiteGetFileName() { |
827 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); | 828 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
828 return script ? script.name : null; | 829 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
| 830 var pos = GET_PRIVATE(this, CallSitePositionKey); |
| 831 return %CallSiteGetFileNameRT(receiver, fun, pos); |
829 } | 832 } |
830 | 833 |
831 function CallSiteGetLineNumber() { | 834 function CallSiteGetLineNumber() { |
832 if (GET_PRIVATE(this, CallSitePositionKey) == -1) { | 835 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
833 return null; | 836 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
834 } | 837 var pos = GET_PRIVATE(this, CallSitePositionKey); |
835 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); | 838 return %CallSiteGetLineNumberRT(receiver, fun, pos); |
836 var location = null; | |
837 if (script) { | |
838 location = script.locationFromPosition( | |
839 GET_PRIVATE(this, CallSitePositionKey), true); | |
840 } | |
841 return location ? location.line + 1 : null; | |
842 } | 839 } |
843 | 840 |
844 function CallSiteGetColumnNumber() { | 841 function CallSiteGetColumnNumber() { |
845 if (GET_PRIVATE(this, CallSitePositionKey) == -1) { | 842 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
846 return null; | 843 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
847 } | 844 var pos = GET_PRIVATE(this, CallSitePositionKey); |
848 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); | 845 return %CallSiteGetColumnNumberRT(receiver, fun, pos); |
849 var location = null; | |
850 if (script) { | |
851 location = script.locationFromPosition( | |
852 GET_PRIVATE(this, CallSitePositionKey), true); | |
853 } | |
854 return location ? location.column + 1: null; | |
855 } | 846 } |
856 | 847 |
857 function CallSiteIsNative() { | 848 function CallSiteIsNative() { |
858 var script = %FunctionGetScript(GET_PRIVATE(this, CallSiteFunctionKey)); | 849 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
859 return script ? (script.type == TYPE_NATIVE) : false; | 850 var fun = GET_PRIVATE(this, CallSiteFunctionKey); |
860 } | 851 var pos = GET_PRIVATE(this, CallSitePositionKey); |
861 | 852 return %CallSiteIsNativeRT(receiver, fun, pos); |
862 function CallSiteGetPosition() { | |
863 return GET_PRIVATE(this, CallSitePositionKey); | |
864 } | 853 } |
865 | 854 |
866 function CallSiteIsConstructor() { | 855 function CallSiteIsConstructor() { |
867 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); | 856 var receiver = GET_PRIVATE(this, CallSiteReceiverKey); |
868 var constructor = (receiver != null && IS_OBJECT(receiver)) | 857 var constructor = (receiver != null && IS_OBJECT(receiver)) |
869 ? %GetDataProperty(receiver, "constructor") : null; | 858 ? %GetDataProperty(receiver, "constructor") : null; |
870 if (!constructor) return false; | 859 if (!constructor) return false; |
871 return GET_PRIVATE(this, CallSiteFunctionKey) === constructor; | 860 return GET_PRIVATE(this, CallSiteFunctionKey) === constructor; |
872 } | 861 } |
873 | 862 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 function SetUpStackOverflowBoilerplate() { | 1255 function SetUpStackOverflowBoilerplate() { |
1267 var boilerplate = MakeRangeError(kStackOverflow); | 1256 var boilerplate = MakeRangeError(kStackOverflow); |
1268 | 1257 |
1269 %DefineAccessorPropertyUnchecked( | 1258 %DefineAccessorPropertyUnchecked( |
1270 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1259 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
1271 | 1260 |
1272 return boilerplate; | 1261 return boilerplate; |
1273 } | 1262 } |
1274 | 1263 |
1275 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1264 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
OLD | NEW |