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

Side by Side Diff: src/runtime.js

Issue 1241533004: Revert of Expose SIMD.Float32x4 type to Javascript. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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/ppc/lithium-codegen-ppc.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 // This files contains runtime support implemented in JavaScript. 5 // This files contains runtime support implemented in JavaScript.
6 6
7 // CAUTION: Some of the functions specified in this file are called 7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in 8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'. 9 // ALL CAPS. The compiled code passes the first argument in 'this'.
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // ECMA-262 Section 11.9.3. 96 // ECMA-262 Section 11.9.3.
97 EQUALS = function EQUALS(y) { 97 EQUALS = function EQUALS(y) {
98 if (IS_STRING(this) && IS_STRING(y)) return %StringEquals(this, y); 98 if (IS_STRING(this) && IS_STRING(y)) return %StringEquals(this, y);
99 var x = this; 99 var x = this;
100 100
101 while (true) { 101 while (true) {
102 if (IS_NUMBER(x)) { 102 if (IS_NUMBER(x)) {
103 while (true) { 103 while (true) {
104 if (IS_NUMBER(y)) return %NumberEquals(x, y); 104 if (IS_NUMBER(y)) return %NumberEquals(x, y);
105 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal 105 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
106 if (IS_SYMBOL(y) || IS_FLOAT32X4(y)) return 1; // not equal 106 if (IS_SYMBOL(y)) return 1; // not equal
107 if (!IS_SPEC_OBJECT(y)) { 107 if (!IS_SPEC_OBJECT(y)) {
108 // String or boolean. 108 // String or boolean.
109 return %NumberEquals(x, %$toNumber(y)); 109 return %NumberEquals(x, %$toNumber(y));
110 } 110 }
111 y = %$toPrimitive(y, NO_HINT); 111 y = %$toPrimitive(y, NO_HINT);
112 } 112 }
113 } else if (IS_STRING(x)) { 113 } else if (IS_STRING(x)) {
114 while (true) { 114 while (true) {
115 if (IS_STRING(y)) return %StringEquals(x, y); 115 if (IS_STRING(y)) return %StringEquals(x, y);
116 if (IS_SYMBOL(y) || IS_FLOAT32X4(y)) return 1; // not equal 116 if (IS_SYMBOL(y)) return 1; // not equal
117 if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y); 117 if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y);
118 if (IS_BOOLEAN(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y)); 118 if (IS_BOOLEAN(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y));
119 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal 119 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
120 y = %$toPrimitive(y, NO_HINT); 120 y = %$toPrimitive(y, NO_HINT);
121 } 121 }
122 } else if (IS_SYMBOL(x)) { 122 } else if (IS_SYMBOL(x)) {
123 if (IS_SYMBOL(y)) return %_ObjectEquals(x, y) ? 0 : 1; 123 if (IS_SYMBOL(y)) return %_ObjectEquals(x, y) ? 0 : 1;
124 return 1; // not equal 124 return 1; // not equal
125 } else if (IS_BOOLEAN(x)) { 125 } else if (IS_BOOLEAN(x)) {
126 if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1; 126 if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1;
127 if (IS_NULL_OR_UNDEFINED(y)) return 1; 127 if (IS_NULL_OR_UNDEFINED(y)) return 1;
128 if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y); 128 if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y);
129 if (IS_STRING(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y)); 129 if (IS_STRING(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y));
130 if (IS_SYMBOL(y) || IS_FLOAT32X4(y)) return 1; // not equal 130 if (IS_SYMBOL(y)) return 1; // not equal
131 // y is object. 131 // y is object.
132 x = %$toNumber(x); 132 x = %$toNumber(x);
133 y = %$toPrimitive(y, NO_HINT); 133 y = %$toPrimitive(y, NO_HINT);
134 } else if (IS_NULL_OR_UNDEFINED(x)) { 134 } else if (IS_NULL_OR_UNDEFINED(x)) {
135 return IS_NULL_OR_UNDEFINED(y) ? 0 : 1; 135 return IS_NULL_OR_UNDEFINED(y) ? 0 : 1;
136 } else if (IS_FLOAT32X4(x)) {
137 if (IS_FLOAT32X4(y))
138 return %Float32x4Equals(x, y);
139 return 1; // not equal
140 } else { 136 } else {
141 // x is an object. 137 // x is an object.
142 if (IS_SPEC_OBJECT(y)) { 138 if (IS_SPEC_OBJECT(y)) {
143 return %_ObjectEquals(x, y) ? 0 : 1; 139 return %_ObjectEquals(x, y) ? 0 : 1;
144 } 140 }
145 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal 141 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
146 if (IS_SYMBOL(y) || IS_FLOAT32X4(y)) return 1; // not equal 142 if (IS_SYMBOL(y)) return 1; // not equal
147 if (IS_BOOLEAN(y)) y = %$toNumber(y); 143 if (IS_BOOLEAN(y)) y = %$toNumber(y);
148 x = %$toPrimitive(x, NO_HINT); 144 x = %$toPrimitive(x, NO_HINT);
149 } 145 }
150 } 146 }
151 } 147 }
152 148
153 // ECMA-262, section 11.9.4, page 56. 149 // ECMA-262, section 11.9.4, page 56.
154 STRICT_EQUALS = function STRICT_EQUALS(x) { 150 STRICT_EQUALS = function STRICT_EQUALS(x) {
155 if (IS_STRING(this)) { 151 if (IS_STRING(this)) {
156 if (!IS_STRING(x)) return 1; // not equal 152 if (!IS_STRING(x)) return 1; // not equal
157 return %StringEquals(this, x); 153 return %StringEquals(this, x);
158 } 154 }
159 155
160 if (IS_NUMBER(this)) { 156 if (IS_NUMBER(this)) {
161 if (!IS_NUMBER(x)) return 1; // not equal 157 if (!IS_NUMBER(x)) return 1; // not equal
162 return %NumberEquals(this, x); 158 return %NumberEquals(this, x);
163 } 159 }
164 160
165 if (IS_FLOAT32X4(this) && IS_FLOAT32X4(x))
166 return %Float32x4Equals(this, x);
167
168 // If anything else gets here, we just do simple identity check. 161 // If anything else gets here, we just do simple identity check.
169 // Objects (including functions), null, undefined and booleans were 162 // Objects (including functions), null, undefined and booleans were
170 // checked in the CompareStub, so there should be nothing left. 163 // checked in the CompareStub, so there should be nothing left.
171 return %_ObjectEquals(this, x) ? 0 : 1; 164 return %_ObjectEquals(this, x) ? 0 : 1;
172 } 165 }
173 166
174 167
175 // ECMA-262, section 11.8.5, page 53. The 'ncr' parameter is used as 168 // ECMA-262, section 11.8.5, page 53. The 'ncr' parameter is used as
176 // the result when either (or both) the operands are NaN. 169 // the result when either (or both) the operands are NaN.
177 COMPARE = function COMPARE(x, ncr) { 170 COMPARE = function COMPARE(x, ncr) {
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 */ 753 */
761 754
762 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, 755 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint,
763 // (1) for number hint, and (2) for string hint. 756 // (1) for number hint, and (2) for string hint.
764 function ToPrimitive(x, hint) { 757 function ToPrimitive(x, hint) {
765 // Fast case check. 758 // Fast case check.
766 if (IS_STRING(x)) return x; 759 if (IS_STRING(x)) return x;
767 // Normal behavior. 760 // Normal behavior.
768 if (!IS_SPEC_OBJECT(x)) return x; 761 if (!IS_SPEC_OBJECT(x)) return x;
769 if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError(kSymbolToPrimitive); 762 if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError(kSymbolToPrimitive);
770 if (IS_FLOAT32X4(x)) return x;
771 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; 763 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT;
772 return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x); 764 return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x);
773 } 765 }
774 766
775 767
776 // ECMA-262, section 9.2, page 30 768 // ECMA-262, section 9.2, page 30
777 function ToBoolean(x) { 769 function ToBoolean(x) {
778 if (IS_BOOLEAN(x)) return x; 770 if (IS_BOOLEAN(x)) return x;
779 if (IS_STRING(x)) return x.length != 0; 771 if (IS_STRING(x)) return x.length != 0;
780 if (x == null) return false; 772 if (x == null) return false;
781 if (IS_NUMBER(x)) return !((x == 0) || NUMBER_IS_NAN(x)); 773 if (IS_NUMBER(x)) return !((x == 0) || NUMBER_IS_NAN(x));
782 return true; 774 return true;
783 } 775 }
784 776
785 777
786 // ECMA-262, section 9.3, page 31. 778 // ECMA-262, section 9.3, page 31.
787 function ToNumber(x) { 779 function ToNumber(x) {
788 if (IS_NUMBER(x)) return x; 780 if (IS_NUMBER(x)) return x;
789 if (IS_STRING(x)) { 781 if (IS_STRING(x)) {
790 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x) 782 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x)
791 : %StringToNumber(x); 783 : %StringToNumber(x);
792 } 784 }
793 if (IS_BOOLEAN(x)) return x ? 1 : 0; 785 if (IS_BOOLEAN(x)) return x ? 1 : 0;
794 if (IS_UNDEFINED(x)) return NAN; 786 if (IS_UNDEFINED(x)) return NAN;
795 if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber); 787 if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber);
796 if (IS_FLOAT32X4(x)) throw MakeTypeError(kSimdToNumber);
797 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); 788 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x));
798 } 789 }
799 790
800 function NonNumberToNumber(x) { 791 function NonNumberToNumber(x) {
801 if (IS_STRING(x)) { 792 if (IS_STRING(x)) {
802 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x) 793 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x)
803 : %StringToNumber(x); 794 : %StringToNumber(x);
804 } 795 }
805 if (IS_BOOLEAN(x)) return x ? 1 : 0; 796 if (IS_BOOLEAN(x)) return x ? 1 : 0;
806 if (IS_UNDEFINED(x)) return NAN; 797 if (IS_UNDEFINED(x)) return NAN;
807 if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber); 798 if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber);
808 if (IS_FLOAT32X4(x)) throw MakeTypeError(kSimdToNumber);
809 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); 799 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x));
810 } 800 }
811 801
812 802
813 // ECMA-262, section 9.8, page 35. 803 // ECMA-262, section 9.8, page 35.
814 function ToString(x) { 804 function ToString(x) {
815 if (IS_STRING(x)) return x; 805 if (IS_STRING(x)) return x;
816 if (IS_NUMBER(x)) return %_NumberToString(x); 806 if (IS_NUMBER(x)) return %_NumberToString(x);
817 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; 807 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
818 if (IS_UNDEFINED(x)) return 'undefined'; 808 if (IS_UNDEFINED(x)) return 'undefined';
(...skipping 15 matching lines...) Expand all
834 return IS_SYMBOL(x) ? x : ToString(x); 824 return IS_SYMBOL(x) ? x : ToString(x);
835 } 825 }
836 826
837 827
838 // ECMA-262, section 9.9, page 36. 828 // ECMA-262, section 9.9, page 36.
839 function ToObject(x) { 829 function ToObject(x) {
840 if (IS_STRING(x)) return new GlobalString(x); 830 if (IS_STRING(x)) return new GlobalString(x);
841 if (IS_NUMBER(x)) return new GlobalNumber(x); 831 if (IS_NUMBER(x)) return new GlobalNumber(x);
842 if (IS_BOOLEAN(x)) return new GlobalBoolean(x); 832 if (IS_BOOLEAN(x)) return new GlobalBoolean(x);
843 if (IS_SYMBOL(x)) return %NewSymbolWrapper(x); 833 if (IS_SYMBOL(x)) return %NewSymbolWrapper(x);
844 if (IS_FLOAT32X4(x)) return %NewFloat32x4Wrapper(x);
845 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { 834 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) {
846 throw MakeTypeError(kUndefinedOrNullToObject); 835 throw MakeTypeError(kUndefinedOrNullToObject);
847 } 836 }
848 return x; 837 return x;
849 } 838 }
850 839
851 840
852 // ECMA-262, section 9.4, page 34. 841 // ECMA-262, section 9.4, page 34.
853 function ToInteger(x) { 842 function ToInteger(x) {
854 if (%_IsSmi(x)) return x; 843 if (%_IsSmi(x)) return x;
(...skipping 27 matching lines...) Expand all
882 // ES5, section 9.12 871 // ES5, section 9.12
883 function SameValue(x, y) { 872 function SameValue(x, y) {
884 if (typeof x != typeof y) return false; 873 if (typeof x != typeof y) return false;
885 if (IS_NUMBER(x)) { 874 if (IS_NUMBER(x)) {
886 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; 875 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
887 // x is +0 and y is -0 or vice versa. 876 // x is +0 and y is -0 or vice versa.
888 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { 877 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
889 return false; 878 return false;
890 } 879 }
891 } 880 }
892 if (IS_FLOAT32X4(x)) {
893 return %Float32x4SameValue(x, y);
894 }
895 return x === y; 881 return x === y;
896 } 882 }
897 883
898 884
899 // ES6, section 7.2.4 885 // ES6, section 7.2.4
900 function SameValueZero(x, y) { 886 function SameValueZero(x, y) {
901 if (typeof x != typeof y) return false; 887 if (typeof x != typeof y) return false;
902 if (IS_NUMBER(x)) { 888 if (IS_NUMBER(x)) {
903 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; 889 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
904 } 890 }
905 if (IS_FLOAT32X4(x)) {
906 return %Float32x4SameValueZero(x, y);
907 }
908 return x === y; 891 return x === y;
909 } 892 }
910 893
911
912 function ConcatIterableToArray(target, iterable) { 894 function ConcatIterableToArray(target, iterable) {
913 var index = target.length; 895 var index = target.length;
914 for (var element of iterable) { 896 for (var element of iterable) {
915 %AddElement(target, index++, element); 897 %AddElement(target, index++, element);
916 } 898 }
917 return target; 899 return target;
918 } 900 }
919 901
920 902
921 /* --------------------------------- 903 /* ---------------------------------
(...skipping 15 matching lines...) Expand all
937 function IsConcatSpreadable(O) { 919 function IsConcatSpreadable(O) {
938 if (!IS_SPEC_OBJECT(O)) return false; 920 if (!IS_SPEC_OBJECT(O)) return false;
939 var spreadable = O[symbolIsConcatSpreadable]; 921 var spreadable = O[symbolIsConcatSpreadable];
940 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O); 922 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O);
941 return ToBoolean(spreadable); 923 return ToBoolean(spreadable);
942 } 924 }
943 925
944 926
945 // ECMA-262, section 8.6.2.6, page 28. 927 // ECMA-262, section 8.6.2.6, page 28.
946 function DefaultNumber(x) { 928 function DefaultNumber(x) {
947 if (!IS_SYMBOL_WRAPPER(x) && !IS_FLOAT32X4_WRAPPER(x)) { 929 if (!IS_SYMBOL_WRAPPER(x)) {
948 var valueOf = x.valueOf; 930 var valueOf = x.valueOf;
949 if (IS_SPEC_FUNCTION(valueOf)) { 931 if (IS_SPEC_FUNCTION(valueOf)) {
950 var v = %_CallFunction(x, valueOf); 932 var v = %_CallFunction(x, valueOf);
951 if (IsPrimitive(v)) return v; 933 if (IsPrimitive(v)) return v;
952 } 934 }
953 935
954 var toString = x.toString; 936 var toString = x.toString;
955 if (IS_SPEC_FUNCTION(toString)) { 937 if (IS_SPEC_FUNCTION(toString)) {
956 var s = %_CallFunction(x, toString); 938 var s = %_CallFunction(x, toString);
957 if (IsPrimitive(s)) return s; 939 if (IsPrimitive(s)) return s;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 $toLength = ToLength; 991 $toLength = ToLength;
1010 $toName = ToName; 992 $toName = ToName;
1011 $toNumber = ToNumber; 993 $toNumber = ToNumber;
1012 $toObject = ToObject; 994 $toObject = ToObject;
1013 $toPositiveInteger = ToPositiveInteger; 995 $toPositiveInteger = ToPositiveInteger;
1014 $toPrimitive = ToPrimitive; 996 $toPrimitive = ToPrimitive;
1015 $toString = ToString; 997 $toString = ToString;
1016 $toUint32 = ToUint32; 998 $toUint32 = ToUint32;
1017 999
1018 }) 1000 })
OLDNEW
« no previous file with comments | « src/ppc/lithium-codegen-ppc.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698