Chromium Code Reviews| Index: src/runtime.js |
| diff --git a/src/runtime.js b/src/runtime.js |
| index dd776dbc8c354722c692c3580914398e5de26d30..ab25340246d70648692c213e802ff15336c80676 100644 |
| --- a/src/runtime.js |
| +++ b/src/runtime.js |
| @@ -103,7 +103,7 @@ 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_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.
|
| if (!IS_SPEC_OBJECT(y)) { |
| // String or boolean. |
| return %NumberEquals(x, %$toNumber(y)); |
| @@ -113,7 +113,7 @@ 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_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
|
| 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 |
| @@ -127,7 +127,7 @@ 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); |
| @@ -137,13 +137,37 @@ EQUALS = function EQUALS(y) { |
| if (IS_FLOAT32X4(y)) |
| return %Float32x4Equals(x, y); |
| return 1; // not equal |
| + } else if (IS_INT32X4(x)) { |
| + if (IS_INT32X4(y)) |
| + return %Int32x4Equals(x, y); |
| + return 1; // not equal |
| + } else if (IS_BOOL32X4(x)) { |
| + if (IS_BOOL32X4(y)) |
| + return %Bool32x4Equals(x, y); |
| + return 1; // not equal |
| + } else if (IS_INT16X8(x)) { |
| + if (IS_INT16X8(y)) |
| + return %Int16x8Equals(x, y); |
| + return 1; // not equal |
| + } else if (IS_BOOL16X8(x)) { |
| + if (IS_BOOL16X8(y)) |
| + return %Bool16x8Equals(x, y); |
| + return 1; // not equal |
| + } else if (IS_INT8X16(x)) { |
| + if (IS_INT8X16(y)) |
| + return %Int8x16Equals(x, y); |
| + return 1; // not equal |
| + } else if (IS_BOOL8X16(x)) { |
| + if (IS_BOOL8X16(y)) |
| + return %Bool8x16Equals(x, y); |
| + return 1; // not equal |
| } else { |
| // x is an object. |
| 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_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.
|
| if (IS_BOOLEAN(y)) y = %$toNumber(y); |
| x = %$toPrimitive(x, NO_HINT); |
| } |
| @@ -164,6 +188,18 @@ STRICT_EQUALS = function STRICT_EQUALS(x) { |
| if (IS_FLOAT32X4(this) && IS_FLOAT32X4(x)) |
|
rossberg
2015/07/29 14:37:55
Same here.
bbudge
2015/07/30 13:46:58
Done.
|
| return %Float32x4Equals(this, x); |
| + if (IS_INT32X4(this) && IS_INT32X4(x)) |
| + return %Int32x4Equals(this, x); |
| + if (IS_BOOL32X4(this) && IS_BOOL32X4(x)) |
| + return %Bool32x4Equals(this, x); |
| + if (IS_INT16X8(this) && IS_INT16X8(x)) |
| + return %Int16x8Equals(this, x); |
| + if (IS_BOOL16X8(this) && IS_BOOL16X8(x)) |
| + return %Bool16x8Equals(this, x); |
| + if (IS_INT8X16(this) && IS_INT8X16(x)) |
| + return %Int8x16Equals(this, x); |
| + if (IS_BOOL8X16(this) && IS_BOOL8X16(x)) |
| + return %Bool8x16Equals(this, x); |
| // If anything else gets here, we just do simple identity check. |
| // Objects (including functions), null, undefined and booleans were |
| @@ -767,7 +803,7 @@ function ToPrimitive(x, hint) { |
| // 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 +828,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 +839,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)); |
| } |
| @@ -842,6 +876,12 @@ function ToObject(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_INT32X4(x)) return %NewInt32x4Wrapper(x); |
| + if (IS_BOOL32X4(x)) return %NewBool32x4Wrapper(x); |
| + if (IS_INT16X8(x)) return %NewInt16x8Wrapper(x); |
| + if (IS_BOOL16X8(x)) return %NewBool16x8Wrapper(x); |
| + if (IS_INT8X16(x)) return %NewInt8x16Wrapper(x); |
| + if (IS_BOOL8X16(x)) return %NewBool8x16Wrapper(x); |
|
bbudge
2015/07/30 13:46:58
Did the same thing here too, with the %IsSimdValue
|
| if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { |
| throw MakeTypeError(kUndefinedOrNullToObject); |
| } |
| @@ -889,9 +929,13 @@ function SameValue(x, y) { |
| return false; |
| } |
| } |
| - if (IS_FLOAT32X4(x)) { |
| - return %Float32x4SameValue(x, y); |
| - } |
| + 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.
|
| + if (IS_INT32X4(x)) return %Int32x4SameValue(x, y); |
| + if (IS_BOOL32X4(x)) return %Bool32x4SameValue(x, y); |
| + if (IS_INT16X8(x)) return %Int16x8SameValue(x, y); |
| + if (IS_BOOL16X8(x)) return %Bool16x8SameValue(x, y); |
| + if (IS_INT8X16(x)) return %Int8x16SameValue(x, y); |
| + if (IS_BOOL8X16(x)) return %Bool8x16SameValue(x, y); |
| return x === y; |
| } |
| @@ -902,9 +946,13 @@ 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_FLOAT32X4(x)) return %Float32x4SameValueZero(x, y); |
|
rossberg
2015/07/29 14:37:56
And here.
bbudge
2015/07/30 13:46:58
Done.
|
| + if (IS_INT32X4(x)) return %Int32x4SameValueZero(x, y); |
| + if (IS_BOOL32X4(x)) return %Bool32x4SameValueZero(x, y); |
| + if (IS_INT16X8(x)) return %Int16x8SameValueZero(x, y); |
| + if (IS_BOOL16X8(x)) return %Bool16x8SameValueZero(x, y); |
| + if (IS_INT8X16(x)) return %Int8x16SameValueZero(x, y); |
| + if (IS_BOOL8X16(x)) return %Bool8x16SameValueZero(x, y); |
| return x === y; |
| } |
| @@ -944,18 +992,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); |
| } |