Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / v8 / src / runtime.js
index 706b99d..d9e1fe5 100644 (file)
@@ -36,6 +36,7 @@ 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)) return 1;  // not equal
         if (!IS_SPEC_OBJECT(y)) {
           // String or boolean.
           return %NumberEquals(x, %ToNumber(y));
@@ -49,57 +50,17 @@ function EQUALS(y) {
         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 (IsFloat32x4(y) || IsFloat64x2(y) || IsInt32x4(y)) {
-          return %StringEquals(x, %ToString(y));
-        }
         y = %ToPrimitive(y, NO_HINT);
       }
     } else if (IS_SYMBOL(x)) {
       if (IS_SYMBOL(y)) return %_ObjectEquals(x, y) ? 0 : 1;
       return 1; // not equal
-    } else if (IsFloat32x4(x)) {
-      while (true) {
-        if (IsFloat32x4(y) || IsInt32x4(y)) {
-          return (x.x == y.x && x.y == y.y && x.z == y.z && x.w == y.w) ? 0 : 1;
-        }
-        if (IS_STRING(y)) return %StringEquals(%ToString(x), y);
-        if (IS_NUMBER(y)) return 1;  // not equal
-        if (IS_SYMBOL(y)) return 1;  // not equal
-        if (IS_BOOLEAN(y)) return y ? 0 : 1;
-        if (IS_NULL_OR_UNDEFINED(y)) return 1;  // not equal
-        y = %ToPrimitive(y, NO_HINT);
-      }
-    } else if (IsFloat64x2(x)) {
-      while (true) {
-        if (IsFloat64x2(y)) {
-          return (x.x == y.x && x.y == y.y) ? 0 : 1;
-        }
-        if (IS_STRING(y)) return %StringEquals(%ToString(x), y);
-        if (IS_NUMBER(y)) return 1;  // not equal
-        if (IS_SYMBOL(y)) return 1;  // not equal
-        if (IS_BOOLEAN(y)) return y ? 0 : 1;
-        if (IS_NULL_OR_UNDEFINED(y)) return 1;  // not equal
-        y = %ToPrimitive(y, NO_HINT);
-      }
-    } else if (IsInt32x4(x)) {
-      while (true) {
-        if (IsFloat32x4(y) || IsInt32x4(y)) {
-          return (x.x == y.x && x.y == y.y && x.z == y.z && x.w == y.w) ? 0 : 1;
-        }
-        if (IS_STRING(y)) return %StringEquals(%ToString(x), y);
-        if (IS_NUMBER(y)) return 1;  // not equal
-        if (IS_SYMBOL(y)) return 1;  // not equal
-        if (IS_BOOLEAN(y)) return y ? 0 : 1;
-        if (IS_NULL_OR_UNDEFINED(y)) return 1;  // not equal
-        y = %ToPrimitive(y, NO_HINT);
-      }
     } else if (IS_BOOLEAN(x)) {
       if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1;
       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)) return 1;  // not equal
-      if (IsFloat32x4(y) || IsFloat64x2(y) || IsInt32x4(y)) return x ? 0 : 1;
       // y is object.
       x = %ToNumber(x);
       y = %ToPrimitive(y, NO_HINT);
@@ -130,23 +91,6 @@ function STRICT_EQUALS(x) {
     return %NumberEquals(this, x);
   }
 
-  if (IsFloat32x4(this)) {
-    if (!IsFloat32x4(x)) return 1;  // not equal
-    return (this.x == x.x && this.y == x.y &&
-            this.z == x.z && this.w == x.w) ? 0 : 1;
-  }
-
-  if (IsFloat64x2(this)) {
-    if (!IsFloat64x2(x)) return 1;  // not equal
-    return (this.x == x.x && this.y == x.y) ? 0 : 1;
-  }
-
-  if (IsInt32x4(this)) {
-    if (!IsInt32x4(x)) return 1;  // not equal
-    return (this.x == x.x && this.y == x.y &&
-            this.z == x.z && this.w == x.w) ? 0 : 1;
-  }
-
   // If anything else gets here, we just do simple identity check.
   // Objects (including functions), null, undefined and booleans were
   // checked in the CompareStub, so there should be nothing left.
@@ -183,30 +127,6 @@ function COMPARE(x, ncr) {
   right = %ToPrimitive(x, NUMBER_HINT);
   if (IS_STRING(left) && IS_STRING(right)) {
     return %_StringCompare(left, right);
-  } else if ((IsFloat32x4(left)  || IsInt32x4(left)) &&
-             (IsFloat32x4(right) || IsInt32x4(right))) {
-    if ((left.x == right.x) && (left.y == right.y) &&
-        (left.z == right.z) && (left.w == right.w)) {
-      return 0;  // equal
-    }
-    if ((left.x < right.x) && (left.y < right.y) &&
-        (left.z < right.z) && (left.w < right.w)) {
-      return -1;  // less
-    }
-    if ((left.x > right.x) && (left.y > right.y) &&
-        (left.z > right.z) && (left.w > right.w)) {
-      return 1;  // great
-    }
-  } else if (IsFloat64x2(left) && IsFloat64x2(right)) {
-    if ((left.x == right.x) && (left.y == right.y)) {
-      return 0;  // equal
-    }
-    if ((left.x < right.x) && (left.y < right.y)) {
-      return -1;  // less
-    }
-    if ((left.x > right.x) && (left.y > right.y)) {
-      return 1;  // great
-    }
   } else {
     var left_number = %ToNumber(left);
     var right_number = %ToNumber(right);
@@ -582,10 +502,7 @@ function ToNumber(x) {
   }
   if (IS_BOOLEAN(x)) return x ? 1 : 0;
   if (IS_UNDEFINED(x)) return NAN;
-  if (IS_SYMBOL(x)) return NAN;
-  if (IsFloat32x4(x)) return NAN;
-  if (IsFloat64x2(x)) return NAN;
-  if (IsInt32x4(x)) return NAN;
+  if (IS_SYMBOL(x)) throw MakeTypeError('symbol_to_number', []);
   return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
 }
 
@@ -596,10 +513,7 @@ function NonNumberToNumber(x) {
   }
   if (IS_BOOLEAN(x)) return x ? 1 : 0;
   if (IS_UNDEFINED(x)) return NAN;
-  if (IS_SYMBOL(x)) return NAN;
-  if (IsFloat32x4(x)) return NAN;
-  if (IsFloat64x2(x)) return NAN;
-  if (IsInt32x4(x)) return NAN;
+  if (IS_SYMBOL(x)) throw MakeTypeError('symbol_to_number', []);
   return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
 }
 
@@ -634,9 +548,6 @@ function ToObject(x) {
   if (IS_STRING(x)) return new $String(x);
   if (IS_NUMBER(x)) return new $Number(x);
   if (IS_BOOLEAN(x)) return new $Boolean(x);
-  if (IsFloat32x4(x)) return new $Float32x4(x.x, x.y, x.z, x.w);
-  if (IsFloat64x2(x)) return new $Float64x2(x.x, x.y);
-  if (IsInt32x4(x)) return new $Int32x4(x.x, x.y, x.z, x.w);
   if (IS_SYMBOL(x)) return %NewSymbolWrapper(x);
   if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) {
     throw %MakeTypeError('undefined_or_null_to_object', []);
@@ -697,35 +608,37 @@ function IsPrimitive(x) {
 
 // ECMA-262, section 8.6.2.6, page 28.
 function DefaultNumber(x) {
-  var valueOf = x.valueOf;
-  if (IS_SPEC_FUNCTION(valueOf)) {
-    var v = %_CallFunction(x, valueOf);
-    if (%IsPrimitive(v)) return v;
-  }
+  if (!IS_SYMBOL_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 toString = x.toString;
+    if (IS_SPEC_FUNCTION(toString)) {
+      var s = %_CallFunction(x, toString);
+      if (%IsPrimitive(s)) return s;
+    }
   }
-
   throw %MakeTypeError('cannot_convert_to_primitive', []);
 }
 
 // ECMA-262, section 8.6.2.6, page 28.
 function DefaultString(x) {
-  var toString = x.toString;
-  if (IS_SPEC_FUNCTION(toString)) {
-    var s = %_CallFunction(x, toString);
-    if (%IsPrimitive(s)) return s;
-  }
+  if (!IS_SYMBOL_WRAPPER(x)) {
+    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 (%IsPrimitive(v)) return v;
+    var valueOf = x.valueOf;
+    if (IS_SPEC_FUNCTION(valueOf)) {
+      var v = %_CallFunction(x, valueOf);
+      if (%IsPrimitive(v)) return v;
+    }
   }
-
   throw %MakeTypeError('cannot_convert_to_primitive', []);
 }