Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) || IS_SIMD_VALUE(y)) return 1; // not equal |
|
bbudge
2015/07/30 13:46:58
I moved these primitive checks which always return
rossberg
2015/07/30 15:12:24
Fine with me.
| |
| 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) || IS_SIMD_VALUE(y)) return 1; // not equal |
|
bbudge
2015/07/30 13:46:58
Made this %IsSimdValue call and moved it to the en
| |
| 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) || IS_SIMD_VALUE(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)) { | 136 } else if (IS_FLOAT32X4(x)) { |
|
rossberg
2015/07/29 14:37:55
Guard these by a (cheaper) IS_SIMD_VALUE test.
bbudge
2015/07/30 13:46:58
Done. Using %IsSimdValue intrinsic. Also, moved al
| |
| 137 if (IS_FLOAT32X4(y)) | 137 if (IS_FLOAT32X4(y)) |
| 138 return %Float32x4Equals(x, y); | 138 return %Float32x4Equals(x, y); |
| 139 return 1; // not equal | 139 return 1; // not equal |
| 140 } else if (IS_INT32X4(x)) { | |
| 141 if (IS_INT32X4(y)) | |
| 142 return %Int32x4Equals(x, y); | |
| 143 return 1; // not equal | |
| 144 } else if (IS_BOOL32X4(x)) { | |
| 145 if (IS_BOOL32X4(y)) | |
| 146 return %Bool32x4Equals(x, y); | |
| 147 return 1; // not equal | |
| 148 } else if (IS_INT16X8(x)) { | |
| 149 if (IS_INT16X8(y)) | |
| 150 return %Int16x8Equals(x, y); | |
| 151 return 1; // not equal | |
| 152 } else if (IS_BOOL16X8(x)) { | |
| 153 if (IS_BOOL16X8(y)) | |
| 154 return %Bool16x8Equals(x, y); | |
| 155 return 1; // not equal | |
| 156 } else if (IS_INT8X16(x)) { | |
| 157 if (IS_INT8X16(y)) | |
| 158 return %Int8x16Equals(x, y); | |
| 159 return 1; // not equal | |
| 160 } else if (IS_BOOL8X16(x)) { | |
| 161 if (IS_BOOL8X16(y)) | |
| 162 return %Bool8x16Equals(x, y); | |
| 163 return 1; // not equal | |
| 140 } else { | 164 } else { |
| 141 // x is an object. | 165 // x is an object. |
| 142 if (IS_SPEC_OBJECT(y)) { | 166 if (IS_SPEC_OBJECT(y)) { |
| 143 return %_ObjectEquals(x, y) ? 0 : 1; | 167 return %_ObjectEquals(x, y) ? 0 : 1; |
| 144 } | 168 } |
| 145 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal | 169 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal |
| 146 if (IS_SYMBOL(y) || IS_FLOAT32X4(y)) return 1; // not equal | 170 if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1; // not equal |
|
bbudge
2015/07/30 13:46:58
Moved this to after the IS_BOOLEAN case.
| |
| 147 if (IS_BOOLEAN(y)) y = %$toNumber(y); | 171 if (IS_BOOLEAN(y)) y = %$toNumber(y); |
| 148 x = %$toPrimitive(x, NO_HINT); | 172 x = %$toPrimitive(x, NO_HINT); |
| 149 } | 173 } |
| 150 } | 174 } |
| 151 } | 175 } |
| 152 | 176 |
| 153 // ECMA-262, section 11.9.4, page 56. | 177 // ECMA-262, section 11.9.4, page 56. |
| 154 STRICT_EQUALS = function STRICT_EQUALS(x) { | 178 STRICT_EQUALS = function STRICT_EQUALS(x) { |
| 155 if (IS_STRING(this)) { | 179 if (IS_STRING(this)) { |
| 156 if (!IS_STRING(x)) return 1; // not equal | 180 if (!IS_STRING(x)) return 1; // not equal |
| 157 return %StringEquals(this, x); | 181 return %StringEquals(this, x); |
| 158 } | 182 } |
| 159 | 183 |
| 160 if (IS_NUMBER(this)) { | 184 if (IS_NUMBER(this)) { |
| 161 if (!IS_NUMBER(x)) return 1; // not equal | 185 if (!IS_NUMBER(x)) return 1; // not equal |
| 162 return %NumberEquals(this, x); | 186 return %NumberEquals(this, x); |
| 163 } | 187 } |
| 164 | 188 |
| 165 if (IS_FLOAT32X4(this) && IS_FLOAT32X4(x)) | 189 if (IS_FLOAT32X4(this) && IS_FLOAT32X4(x)) |
|
rossberg
2015/07/29 14:37:55
Same here.
bbudge
2015/07/30 13:46:58
Done.
| |
| 166 return %Float32x4Equals(this, x); | 190 return %Float32x4Equals(this, x); |
| 191 if (IS_INT32X4(this) && IS_INT32X4(x)) | |
| 192 return %Int32x4Equals(this, x); | |
| 193 if (IS_BOOL32X4(this) && IS_BOOL32X4(x)) | |
| 194 return %Bool32x4Equals(this, x); | |
| 195 if (IS_INT16X8(this) && IS_INT16X8(x)) | |
| 196 return %Int16x8Equals(this, x); | |
| 197 if (IS_BOOL16X8(this) && IS_BOOL16X8(x)) | |
| 198 return %Bool16x8Equals(this, x); | |
| 199 if (IS_INT8X16(this) && IS_INT8X16(x)) | |
| 200 return %Int8x16Equals(this, x); | |
| 201 if (IS_BOOL8X16(this) && IS_BOOL8X16(x)) | |
| 202 return %Bool8x16Equals(this, x); | |
| 167 | 203 |
| 168 // If anything else gets here, we just do simple identity check. | 204 // If anything else gets here, we just do simple identity check. |
| 169 // Objects (including functions), null, undefined and booleans were | 205 // Objects (including functions), null, undefined and booleans were |
| 170 // checked in the CompareStub, so there should be nothing left. | 206 // checked in the CompareStub, so there should be nothing left. |
| 171 return %_ObjectEquals(this, x) ? 0 : 1; | 207 return %_ObjectEquals(this, x) ? 0 : 1; |
| 172 } | 208 } |
| 173 | 209 |
| 174 | 210 |
| 175 // ECMA-262, section 11.8.5, page 53. The 'ncr' parameter is used as | 211 // 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. | 212 // the result when either (or both) the operands are NaN. |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 760 */ | 796 */ |
| 761 | 797 |
| 762 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, | 798 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, |
| 763 // (1) for number hint, and (2) for string hint. | 799 // (1) for number hint, and (2) for string hint. |
| 764 function ToPrimitive(x, hint) { | 800 function ToPrimitive(x, hint) { |
| 765 // Fast case check. | 801 // Fast case check. |
| 766 if (IS_STRING(x)) return x; | 802 if (IS_STRING(x)) return x; |
| 767 // Normal behavior. | 803 // Normal behavior. |
| 768 if (!IS_SPEC_OBJECT(x)) return x; | 804 if (!IS_SPEC_OBJECT(x)) return x; |
| 769 if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError(kSymbolToPrimitive); | 805 if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError(kSymbolToPrimitive); |
| 770 if (IS_FLOAT32X4(x)) return x; | 806 if (IS_SIMD_VALUE(x)) return x; |
| 771 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; | 807 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; |
| 772 return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x); | 808 return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x); |
| 773 } | 809 } |
| 774 | 810 |
| 775 | 811 |
| 776 // ECMA-262, section 9.2, page 30 | 812 // ECMA-262, section 9.2, page 30 |
| 777 function ToBoolean(x) { | 813 function ToBoolean(x) { |
| 778 if (IS_BOOLEAN(x)) return x; | 814 if (IS_BOOLEAN(x)) return x; |
| 779 if (IS_STRING(x)) return x.length != 0; | 815 if (IS_STRING(x)) return x.length != 0; |
| 780 if (x == null) return false; | 816 if (x == null) return false; |
| 781 if (IS_NUMBER(x)) return !((x == 0) || NUMBER_IS_NAN(x)); | 817 if (IS_NUMBER(x)) return !((x == 0) || NUMBER_IS_NAN(x)); |
| 782 return true; | 818 return true; |
| 783 } | 819 } |
| 784 | 820 |
| 785 | 821 |
| 786 // ECMA-262, section 9.3, page 31. | 822 // ECMA-262, section 9.3, page 31. |
| 787 function ToNumber(x) { | 823 function ToNumber(x) { |
| 788 if (IS_NUMBER(x)) return x; | 824 if (IS_NUMBER(x)) return x; |
| 789 if (IS_STRING(x)) { | 825 if (IS_STRING(x)) { |
| 790 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x) | 826 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x) |
| 791 : %StringToNumber(x); | 827 : %StringToNumber(x); |
| 792 } | 828 } |
| 793 if (IS_BOOLEAN(x)) return x ? 1 : 0; | 829 if (IS_BOOLEAN(x)) return x ? 1 : 0; |
| 794 if (IS_UNDEFINED(x)) return NAN; | 830 if (IS_UNDEFINED(x)) return NAN; |
| 795 if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber); | 831 // Types that can't be converted to number are caught in DefaultNumber. |
| 796 if (IS_FLOAT32X4(x)) throw MakeTypeError(kSimdToNumber); | |
| 797 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); | 832 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); |
| 798 } | 833 } |
| 799 | 834 |
| 800 function NonNumberToNumber(x) { | 835 function NonNumberToNumber(x) { |
| 801 if (IS_STRING(x)) { | 836 if (IS_STRING(x)) { |
| 802 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x) | 837 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x) |
| 803 : %StringToNumber(x); | 838 : %StringToNumber(x); |
| 804 } | 839 } |
| 805 if (IS_BOOLEAN(x)) return x ? 1 : 0; | 840 if (IS_BOOLEAN(x)) return x ? 1 : 0; |
| 806 if (IS_UNDEFINED(x)) return NAN; | 841 if (IS_UNDEFINED(x)) return NAN; |
| 807 if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber); | 842 // Types that can't be converted to number are caught in DefaultNumber. |
| 808 if (IS_FLOAT32X4(x)) throw MakeTypeError(kSimdToNumber); | |
| 809 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); | 843 return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); |
| 810 } | 844 } |
| 811 | 845 |
| 812 | 846 |
| 813 // ECMA-262, section 9.8, page 35. | 847 // ECMA-262, section 9.8, page 35. |
| 814 function ToString(x) { | 848 function ToString(x) { |
| 815 if (IS_STRING(x)) return x; | 849 if (IS_STRING(x)) return x; |
| 816 if (IS_NUMBER(x)) return %_NumberToString(x); | 850 if (IS_NUMBER(x)) return %_NumberToString(x); |
| 817 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; | 851 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; |
| 818 if (IS_UNDEFINED(x)) return 'undefined'; | 852 if (IS_UNDEFINED(x)) return 'undefined'; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 835 } | 869 } |
| 836 | 870 |
| 837 | 871 |
| 838 // ECMA-262, section 9.9, page 36. | 872 // ECMA-262, section 9.9, page 36. |
| 839 function ToObject(x) { | 873 function ToObject(x) { |
| 840 if (IS_STRING(x)) return new GlobalString(x); | 874 if (IS_STRING(x)) return new GlobalString(x); |
| 841 if (IS_NUMBER(x)) return new GlobalNumber(x); | 875 if (IS_NUMBER(x)) return new GlobalNumber(x); |
| 842 if (IS_BOOLEAN(x)) return new GlobalBoolean(x); | 876 if (IS_BOOLEAN(x)) return new GlobalBoolean(x); |
| 843 if (IS_SYMBOL(x)) return %NewSymbolWrapper(x); | 877 if (IS_SYMBOL(x)) return %NewSymbolWrapper(x); |
| 844 if (IS_FLOAT32X4(x)) return %NewFloat32x4Wrapper(x); | 878 if (IS_FLOAT32X4(x)) return %NewFloat32x4Wrapper(x); |
| 879 if (IS_INT32X4(x)) return %NewInt32x4Wrapper(x); | |
| 880 if (IS_BOOL32X4(x)) return %NewBool32x4Wrapper(x); | |
| 881 if (IS_INT16X8(x)) return %NewInt16x8Wrapper(x); | |
| 882 if (IS_BOOL16X8(x)) return %NewBool16x8Wrapper(x); | |
| 883 if (IS_INT8X16(x)) return %NewInt8x16Wrapper(x); | |
| 884 if (IS_BOOL8X16(x)) return %NewBool8x16Wrapper(x); | |
|
bbudge
2015/07/30 13:46:58
Did the same thing here too, with the %IsSimdValue
| |
| 845 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { | 885 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { |
| 846 throw MakeTypeError(kUndefinedOrNullToObject); | 886 throw MakeTypeError(kUndefinedOrNullToObject); |
| 847 } | 887 } |
| 848 return x; | 888 return x; |
| 849 } | 889 } |
| 850 | 890 |
| 851 | 891 |
| 852 // ECMA-262, section 9.4, page 34. | 892 // ECMA-262, section 9.4, page 34. |
| 853 function ToInteger(x) { | 893 function ToInteger(x) { |
| 854 if (%_IsSmi(x)) return x; | 894 if (%_IsSmi(x)) return x; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 882 // ES5, section 9.12 | 922 // ES5, section 9.12 |
| 883 function SameValue(x, y) { | 923 function SameValue(x, y) { |
| 884 if (typeof x != typeof y) return false; | 924 if (typeof x != typeof y) return false; |
| 885 if (IS_NUMBER(x)) { | 925 if (IS_NUMBER(x)) { |
| 886 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; | 926 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
| 887 // x is +0 and y is -0 or vice versa. | 927 // x is +0 and y is -0 or vice versa. |
| 888 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { | 928 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { |
| 889 return false; | 929 return false; |
| 890 } | 930 } |
| 891 } | 931 } |
| 892 if (IS_FLOAT32X4(x)) { | 932 if (IS_FLOAT32X4(x)) return %Float32x4SameValue(x, y); |
|
rossberg
2015/07/29 14:37:55
And here.
bbudge
2015/07/30 13:46:58
Done.
| |
| 893 return %Float32x4SameValue(x, y); | 933 if (IS_INT32X4(x)) return %Int32x4SameValue(x, y); |
| 894 } | 934 if (IS_BOOL32X4(x)) return %Bool32x4SameValue(x, y); |
| 935 if (IS_INT16X8(x)) return %Int16x8SameValue(x, y); | |
| 936 if (IS_BOOL16X8(x)) return %Bool16x8SameValue(x, y); | |
| 937 if (IS_INT8X16(x)) return %Int8x16SameValue(x, y); | |
| 938 if (IS_BOOL8X16(x)) return %Bool8x16SameValue(x, y); | |
| 895 return x === y; | 939 return x === y; |
| 896 } | 940 } |
| 897 | 941 |
| 898 | 942 |
| 899 // ES6, section 7.2.4 | 943 // ES6, section 7.2.4 |
| 900 function SameValueZero(x, y) { | 944 function SameValueZero(x, y) { |
| 901 if (typeof x != typeof y) return false; | 945 if (typeof x != typeof y) return false; |
| 902 if (IS_NUMBER(x)) { | 946 if (IS_NUMBER(x)) { |
| 903 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; | 947 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
| 904 } | 948 } |
| 905 if (IS_FLOAT32X4(x)) { | 949 if (IS_FLOAT32X4(x)) return %Float32x4SameValueZero(x, y); |
|
rossberg
2015/07/29 14:37:56
And here.
bbudge
2015/07/30 13:46:58
Done.
| |
| 906 return %Float32x4SameValueZero(x, y); | 950 if (IS_INT32X4(x)) return %Int32x4SameValueZero(x, y); |
| 907 } | 951 if (IS_BOOL32X4(x)) return %Bool32x4SameValueZero(x, y); |
| 952 if (IS_INT16X8(x)) return %Int16x8SameValueZero(x, y); | |
| 953 if (IS_BOOL16X8(x)) return %Bool16x8SameValueZero(x, y); | |
| 954 if (IS_INT8X16(x)) return %Int8x16SameValueZero(x, y); | |
| 955 if (IS_BOOL8X16(x)) return %Bool8x16SameValueZero(x, y); | |
| 908 return x === y; | 956 return x === y; |
| 909 } | 957 } |
| 910 | 958 |
| 911 | 959 |
| 912 function ConcatIterableToArray(target, iterable) { | 960 function ConcatIterableToArray(target, iterable) { |
| 913 var index = target.length; | 961 var index = target.length; |
| 914 for (var element of iterable) { | 962 for (var element of iterable) { |
| 915 %AddElement(target, index++, element); | 963 %AddElement(target, index++, element); |
| 916 } | 964 } |
| 917 return target; | 965 return target; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 937 function IsConcatSpreadable(O) { | 985 function IsConcatSpreadable(O) { |
| 938 if (!IS_SPEC_OBJECT(O)) return false; | 986 if (!IS_SPEC_OBJECT(O)) return false; |
| 939 var spreadable = O[symbolIsConcatSpreadable]; | 987 var spreadable = O[symbolIsConcatSpreadable]; |
| 940 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O); | 988 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O); |
| 941 return ToBoolean(spreadable); | 989 return ToBoolean(spreadable); |
| 942 } | 990 } |
| 943 | 991 |
| 944 | 992 |
| 945 // ECMA-262, section 8.6.2.6, page 28. | 993 // ECMA-262, section 8.6.2.6, page 28. |
| 946 function DefaultNumber(x) { | 994 function DefaultNumber(x) { |
| 947 if (!IS_SYMBOL_WRAPPER(x) && !IS_FLOAT32X4_WRAPPER(x)) { | 995 var valueOf = x.valueOf; |
| 948 var valueOf = x.valueOf; | 996 if (IS_SPEC_FUNCTION(valueOf)) { |
| 949 if (IS_SPEC_FUNCTION(valueOf)) { | 997 var v = %_CallFunction(x, valueOf); |
| 950 var v = %_CallFunction(x, valueOf); | 998 if (IS_SYMBOL(v)) throw MakeTypeError(kSymbolToNumber); |
| 951 if (IsPrimitive(v)) return v; | 999 if (IS_SIMD_VALUE(x)) throw MakeTypeError(kSimdToNumber); |
| 952 } | 1000 if (IsPrimitive(v)) return v; |
| 953 | 1001 } |
| 954 var toString = x.toString; | 1002 var toString = x.toString; |
| 955 if (IS_SPEC_FUNCTION(toString)) { | 1003 if (IS_SPEC_FUNCTION(toString)) { |
| 956 var s = %_CallFunction(x, toString); | 1004 var s = %_CallFunction(x, toString); |
| 957 if (IsPrimitive(s)) return s; | 1005 if (IsPrimitive(s)) return s; |
| 958 } | |
| 959 } | 1006 } |
| 960 throw MakeTypeError(kCannotConvertToPrimitive); | 1007 throw MakeTypeError(kCannotConvertToPrimitive); |
| 961 } | 1008 } |
| 962 | 1009 |
| 963 // ECMA-262, section 8.6.2.6, page 28. | 1010 // ECMA-262, section 8.6.2.6, page 28. |
| 964 function DefaultString(x) { | 1011 function DefaultString(x) { |
| 965 if (!IS_SYMBOL_WRAPPER(x)) { | 1012 if (!IS_SYMBOL_WRAPPER(x)) { |
| 966 var toString = x.toString; | 1013 var toString = x.toString; |
| 967 if (IS_SPEC_FUNCTION(toString)) { | 1014 if (IS_SPEC_FUNCTION(toString)) { |
| 968 var s = %_CallFunction(x, toString); | 1015 var s = %_CallFunction(x, toString); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1009 $toLength = ToLength; | 1056 $toLength = ToLength; |
| 1010 $toName = ToName; | 1057 $toName = ToName; |
| 1011 $toNumber = ToNumber; | 1058 $toNumber = ToNumber; |
| 1012 $toObject = ToObject; | 1059 $toObject = ToObject; |
| 1013 $toPositiveInteger = ToPositiveInteger; | 1060 $toPositiveInteger = ToPositiveInteger; |
| 1014 $toPrimitive = ToPrimitive; | 1061 $toPrimitive = ToPrimitive; |
| 1015 $toString = ToString; | 1062 $toString = ToString; |
| 1016 $toUint32 = ToUint32; | 1063 $toUint32 = ToUint32; |
| 1017 | 1064 |
| 1018 }) | 1065 }) |
| OLD | NEW |