Index: src/runtime.js |
diff --git a/src/runtime.js b/src/runtime.js |
index dd776dbc8c354722c692c3580914398e5de26d30..87e5b23ce0a80cb65418d3cdd54827631c4b5399 100644 |
--- a/src/runtime.js |
+++ b/src/runtime.js |
@@ -103,8 +103,8 @@ EQUALS = function EQUALS(y) { |
while (true) { |
if (IS_NUMBER(y)) return %NumberEquals(x, y); |
if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal |
- if (IS_SYMBOL(y) || IS_FLOAT32X4(y)) return 1; // not equal |
if (!IS_SPEC_OBJECT(y)) { |
+ if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1; // not equal |
// String or boolean. |
return %NumberEquals(x, %$toNumber(y)); |
} |
@@ -113,10 +113,10 @@ EQUALS = function EQUALS(y) { |
} else if (IS_STRING(x)) { |
while (true) { |
if (IS_STRING(y)) return %StringEquals(x, y); |
- if (IS_SYMBOL(y) || IS_FLOAT32X4(y)) return 1; // not equal |
if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y); |
if (IS_BOOLEAN(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y)); |
if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal |
+ if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1; // not equal |
y = %$toPrimitive(y, NO_HINT); |
} |
} else if (IS_SYMBOL(x)) { |
@@ -127,24 +127,23 @@ EQUALS = function EQUALS(y) { |
if (IS_NULL_OR_UNDEFINED(y)) return 1; |
if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y); |
if (IS_STRING(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y)); |
- if (IS_SYMBOL(y) || IS_FLOAT32X4(y)) return 1; // not equal |
+ if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) return 1; // not equal |
// y is object. |
x = %$toNumber(x); |
y = %$toPrimitive(y, NO_HINT); |
} else if (IS_NULL_OR_UNDEFINED(x)) { |
return IS_NULL_OR_UNDEFINED(y) ? 0 : 1; |
- } else if (IS_FLOAT32X4(x)) { |
- if (IS_FLOAT32X4(y)) |
- return %Float32x4Equals(x, y); |
- return 1; // not equal |
+ } else if (IS_SIMD_VALUE(x)) { |
+ return %SimdEquals(x, y); |
} else { |
// x is an object. |
- if (IS_SPEC_OBJECT(y)) { |
- return %_ObjectEquals(x, y) ? 0 : 1; |
- } |
+ if (IS_SPEC_OBJECT(y)) return %_ObjectEquals(x, y) ? 0 : 1; |
if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal |
- if (IS_SYMBOL(y) || IS_FLOAT32X4(y)) return 1; // not equal |
- if (IS_BOOLEAN(y)) y = %$toNumber(y); |
+ if (IS_BOOLEAN(y)) { |
+ y = %$toNumber(y); |
+ } else if (IS_SYMBOL(y) || IS_SIMD_VALUE(y)) { |
+ return 1; // not equal |
+ } |
x = %$toPrimitive(x, NO_HINT); |
} |
} |
@@ -162,8 +161,7 @@ STRICT_EQUALS = function STRICT_EQUALS(x) { |
return %NumberEquals(this, x); |
} |
- if (IS_FLOAT32X4(this) && IS_FLOAT32X4(x)) |
- return %Float32x4Equals(this, x); |
+ if (IS_SIMD_VALUE(this)) return %SimdEquals(this, x); |
// If anything else gets here, we just do simple identity check. |
// Objects (including functions), null, undefined and booleans were |
@@ -766,8 +764,7 @@ function ToPrimitive(x, hint) { |
if (IS_STRING(x)) return x; |
// Normal behavior. |
if (!IS_SPEC_OBJECT(x)) return x; |
- if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError(kSymbolToPrimitive); |
- if (IS_FLOAT32X4(x)) return x; |
+ if (IS_SIMD_VALUE(x)) return x; |
if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; |
return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x); |
} |
@@ -792,8 +789,7 @@ function ToNumber(x) { |
} |
if (IS_BOOLEAN(x)) return x ? 1 : 0; |
if (IS_UNDEFINED(x)) return NAN; |
- if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber); |
- if (IS_FLOAT32X4(x)) throw MakeTypeError(kSimdToNumber); |
+ // Types that can't be converted to number are caught in DefaultNumber. |
return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); |
} |
@@ -804,8 +800,7 @@ function NonNumberToNumber(x) { |
} |
if (IS_BOOLEAN(x)) return x ? 1 : 0; |
if (IS_UNDEFINED(x)) return NAN; |
- if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber); |
- if (IS_FLOAT32X4(x)) throw MakeTypeError(kSimdToNumber); |
+ // Types that can't be converted to number are caught in DefaultNumber. |
return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); |
} |
@@ -816,7 +811,7 @@ function ToString(x) { |
if (IS_NUMBER(x)) return %_NumberToString(x); |
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; |
if (IS_UNDEFINED(x)) return 'undefined'; |
- if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString); |
+ // Types that can't be converted to string are caught in DefaultString. |
return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x)); |
} |
@@ -824,7 +819,7 @@ function NonStringToString(x) { |
if (IS_NUMBER(x)) return %_NumberToString(x); |
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; |
if (IS_UNDEFINED(x)) return 'undefined'; |
- if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString); |
+ // Types that can't be converted to string are caught in DefaultString. |
return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x)); |
} |
@@ -841,7 +836,7 @@ function ToObject(x) { |
if (IS_NUMBER(x)) return new GlobalNumber(x); |
if (IS_BOOLEAN(x)) return new GlobalBoolean(x); |
if (IS_SYMBOL(x)) return %NewSymbolWrapper(x); |
- if (IS_FLOAT32X4(x)) return %NewFloat32x4Wrapper(x); |
+ if (IS_SIMD_VALUE(x)) return %SimdToObject(x); |
if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { |
throw MakeTypeError(kUndefinedOrNullToObject); |
} |
@@ -889,9 +884,7 @@ function SameValue(x, y) { |
return false; |
} |
} |
- if (IS_FLOAT32X4(x)) { |
- return %Float32x4SameValue(x, y); |
- } |
+ if (IS_SIMD_VALUE(x)) return %SimdSameValue(x, y); |
return x === y; |
} |
@@ -902,9 +895,7 @@ function SameValueZero(x, y) { |
if (IS_NUMBER(x)) { |
if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
} |
- if (IS_FLOAT32X4(x)) { |
- return %Float32x4SameValueZero(x, y); |
- } |
+ if (IS_SIMD_VALUE(x)) return %SimdSameValueZero(x, y); |
return x === y; |
} |
@@ -944,18 +935,17 @@ function IsConcatSpreadable(O) { |
// ECMA-262, section 8.6.2.6, page 28. |
function DefaultNumber(x) { |
- if (!IS_SYMBOL_WRAPPER(x) && !IS_FLOAT32X4_WRAPPER(x)) { |
- var valueOf = x.valueOf; |
- if (IS_SPEC_FUNCTION(valueOf)) { |
- var v = %_CallFunction(x, valueOf); |
- if (IsPrimitive(v)) return v; |
- } |
- |
- var toString = x.toString; |
- if (IS_SPEC_FUNCTION(toString)) { |
- var s = %_CallFunction(x, toString); |
- if (IsPrimitive(s)) return s; |
- } |
+ var valueOf = x.valueOf; |
+ if (IS_SPEC_FUNCTION(valueOf)) { |
+ var v = %_CallFunction(x, valueOf); |
+ if (IS_SYMBOL(v)) throw MakeTypeError(kSymbolToNumber); |
+ if (IS_SIMD_VALUE(x)) throw MakeTypeError(kSimdToNumber); |
+ if (IsPrimitive(v)) return v; |
+ } |
+ var toString = x.toString; |
+ if (IS_SPEC_FUNCTION(toString)) { |
+ var s = %_CallFunction(x, toString); |
+ if (IsPrimitive(s)) return s; |
} |
throw MakeTypeError(kCannotConvertToPrimitive); |
} |
@@ -963,6 +953,7 @@ function DefaultNumber(x) { |
// ECMA-262, section 8.6.2.6, page 28. |
function DefaultString(x) { |
if (!IS_SYMBOL_WRAPPER(x)) { |
+ if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString); |
var toString = x.toString; |
if (IS_SPEC_FUNCTION(toString)) { |
var s = %_CallFunction(x, toString); |