[runtime] Remove premature optimization from ToPrimitive.
authorbmeurer <bmeurer@chromium.org>
Mon, 10 Aug 2015 06:07:20 +0000 (23:07 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 10 Aug 2015 06:07:39 +0000 (06:07 +0000)
The !IS_SPEC_OBJECT(x) check implies both IS_STRING(x) and
IS_SIMD_VALUE(x), and generates shorter/better code.  So we
can safely remove the redundant checks.

R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/1278873007

Cr-Commit-Position: refs/heads/master@{#30081}

src/runtime.js

index 21b3da9..a120d96 100644 (file)
@@ -750,11 +750,7 @@ TO_NAME = function TO_NAME() {
 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint,
 // (1) for number hint, and (2) for string hint.
 function ToPrimitive(x, hint) {
-  // Fast case check.
-  if (IS_STRING(x)) return x;
-  // Normal behavior.
   if (!IS_SPEC_OBJECT(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);
 }