<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>153738</bug_id>
          
          <creation_ts>2016-02-01 02:57:52 -0800</creation_ts>
          <short_desc>[JSC] Make array iteration methods faster</short_desc>
          <delta_ts>2017-05-28 22:10:12 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>154844</dependson>
    
    <dependson>154022</dependson>
    
    <dependson>154683</dependson>
    
    <dependson>172690</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yusuke Suzuki">ysuzuki</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>benjamin</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>saam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1160810</commentid>
    <comment_count>0</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2016-02-01 02:57:52 -0800</bug_when>
    <thetext>Seeing DFG dump, (unfortunately!) Array iteration methods (like forEach) performs Double Comparison on loop condition!
This is because,

1. Poor toInteger implementation

We should convert @Number(...) to NumberUse edge filtering. And implementing isFinite in JS is better (If value is speculated as Int32, we can purge many conditions!)
Like, (Number.isFinite)
function isFinite(value)
{
    return value === Infinity || value === -Infinity;
}
And, (global).isFinite
function isFinite(value)
{
    var numberValue = @Number(value);  // This should be converted to edge filtering.
    return numberValue === Infinity || numberValue === -Infinity;
}

Handling NumberConstructor::info() in DFGByteCodeParser.cpp makes it easy I think. And to ensure more high performance implementation, introducing @toNumber bytecode intrinsic (that emits to_number bytecode) may also be good.

2. maxSafeInteger = 0x1FFFFFFFFFFFFF

Now, in toLength, we have a chance to return maxSafeInteger (This is represented as double). It is unfortunate, because it makes the result value double rep.
One plan is,

When comparing value &lt; maxSafeInteger, and if we know value is Int32, value &lt; maxSafeInteger becomes always true.
So we can purge this comparison and maxSafeInteger. It makes the result value Int32.

How about this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1161098</commentid>
    <comment_count>1</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2016-02-01 16:07:00 -0800</bug_when>
    <thetext>Sounds good to me.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>