Commit 0c674828 authored by bmeurer's avatar bmeurer Committed by Commit bot

[runtime] Remove premature optimization from ToPrimitive.

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}
parent 3cc7adc7
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment