<?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>154743</bug_id>
          
          <creation_ts>2016-02-26 12:46:22 -0800</creation_ts>
          <short_desc>Folding of OverridesHasInstance DFG nodes shoud happen in constant folding not fixup</short_desc>
          <delta_ts>2016-02-27 15:04:12 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Keith Miller">keith_miller</reporter>
          <assigned_to name="Keith Miller">keith_miller</assigned_to>
          <cc>commit-queue</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>1168629</commentid>
    <comment_count>0</comment_count>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2016-02-26 12:46:22 -0800</bug_when>
    <thetext>Folding of OverridesHasInstance DFG nodes shoud happen in constant folding not fixup</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1168632</commentid>
    <comment_count>1</comment_count>
      <attachid>272358</attachid>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2016-02-26 12:47:34 -0800</bug_when>
    <thetext>Created attachment 272358
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1168634</commentid>
    <comment_count>2</comment_count>
      <attachid>272358</attachid>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2016-02-26 12:52:39 -0800</bug_when>
    <thetext>Comment on attachment 272358
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1168659</commentid>
    <comment_count>3</comment_count>
      <attachid>272358</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-02-26 13:43:04 -0800</bug_when>
    <thetext>Comment on attachment 272358
Patch

Clearing flags on attachment: 272358

Committed r197196: &lt;http://trac.webkit.org/changeset/197196&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1168660</commentid>
    <comment_count>4</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-02-26 13:43:07 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1168681</commentid>
    <comment_count>5</comment_count>
      <attachid>272358</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2016-02-26 14:12:45 -0800</bug_when>
    <thetext>Comment on attachment 272358
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=272358&amp;action=review

&gt; Source/JavaScriptCore/ChangeLog:3
&gt; +        Folding of OverridesHasInstance DFG nodes shoud happen in constant folding not fixup

Why?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1168702</commentid>
    <comment_count>6</comment_count>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2016-02-26 14:37:44 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; Comment on attachment 272358 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=272358&amp;action=review
&gt; 
&gt; &gt; Source/JavaScriptCore/ChangeLog:3
&gt; &gt; +        Folding of OverridesHasInstance DFG nodes shoud happen in constant folding not fixup
&gt; 
&gt; Why?

When compiling a instanceof b we sometimes don&apos;t end up finding that b is a constant until after fixup. If we attempt to fold the OverridesHasInstance in fixup we won&apos;t end up removing the check when we otherwise could have.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1168906</commentid>
    <comment_count>7</comment_count>
      <attachid>272358</attachid>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2016-02-27 15:04:12 -0800</bug_when>
    <thetext>Comment on attachment 272358
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=272358&amp;action=review

&gt; Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp:573
&gt; +            case OverridesHasInstance: {
&gt; +                if (!node-&gt;child2().node()-&gt;isCellConstant())
&gt; +                    break;
&gt; +
&gt; +                if (node-&gt;child2().node()-&gt;asCell() != m_graph.globalObjectFor(node-&gt;origin.semantic)-&gt;functionProtoHasInstanceSymbolFunction()) {
&gt; +                    m_graph.convertToConstant(node, jsBoolean(true));
&gt; +                    changed = true;
&gt; +
&gt; +                } else if (!m_graph.hasExitSite(node-&gt;origin.semantic, BadTypeInfoFlags)) {
&gt; +                    // We optimistically assume that we will not see a function that has a custom instanceof operation as they should be rare.
&gt; +                    m_insertionSet.insertNode(indexInBlock, SpecNone, CheckTypeInfoFlags, node-&gt;origin, OpInfo(ImplementsDefaultHasInstance), Edge(node-&gt;child1().node(), CellUse));
&gt; +                    m_graph.convertToConstant(node, jsBoolean(false));
&gt; +                    changed = true;
&gt; +                }
&gt; +                
&gt; +                break;
&gt; +            }
&gt; +

This is not how we write constant folding rules.  A constant folding rule *must* occur in DFG::AbstractInterpreterInlines if it occurs in ConstantFoldingPhase.  Otherwise, the constant folding rule will have the following silly shortcomings:

- It will only work in basic blocks that also incidentally did other constant folding, since you need a rule in AbstractInterpreterInlines to tell the ConstantFoldingPhase to do things in a block.
- It will trigger inductive constant folding beyond the current basic block.  Since AbstractInterpterInlines thinks that this node returns any boolean, other basic blocks that use this value will not know to constant-fold their uses.

A simple rule to follow is: if someone writes a patch that touches ConstantFoldingPhase but not AbstractInterpreterInlines, then their patch is pretty much guaranteed to be wrong.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>272358</attachid>
            <date>2016-02-26 12:47:34 -0800</date>
            <delta_ts>2016-02-26 13:43:04 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-154743-20160226124717.patch</filename>
            <type>text/plain</type>
            <size>3816</size>
            <attacher name="Keith Miller">keith_miller</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTk2ODI3CmRpZmYgLS1naXQgYS9Tb3VyY2UvSmF2YVNjcmlw
dENvcmUvQ2hhbmdlTG9nIGIvU291cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwppbmRleCBm
NmU1NTFkMzllMzJmMDkzNTBhMzgzYTJmOWJmNzU1MmFlNTNjOWM0Li5mMDhmZjdjNTkwNjM4NDA0
OWViMjZhZjFlMGM4MjU2MjU2MWVhMjcyIDEwMDY0NAotLS0gYS9Tb3VyY2UvSmF2YVNjcmlwdENv
cmUvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKQEAgLTEs
MyArMSwxNSBAQAorMjAxNi0wMi0yNiAgS2VpdGggTWlsbGVyICA8a2VpdGhfbWlsbGVyQGFwcGxl
LmNvbT4KKworICAgICAgICBGb2xkaW5nIG9mIE92ZXJyaWRlc0hhc0luc3RhbmNlIERGRyBub2Rl
cyBzaG91ZCBoYXBwZW4gaW4gY29uc3RhbnQgZm9sZGluZyBub3QgZml4dXAKKyAgICAgICAgaHR0
cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE1NDc0MworCisgICAgICAgIFJl
dmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgICogZGZnL0RGR0NvbnN0YW50Rm9s
ZGluZ1BoYXNlLmNwcDoKKyAgICAgICAgKEpTQzo6REZHOjpDb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AgICAgICAgICBicmVhazsKLSAg
ICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBpZiAoIW1fZ3JhcGguaGFzRXhpdFNp
dGUobm9kZS0+b3JpZ2luLnNlbWFudGljLCBCYWRUeXBlSW5mb0ZsYWdzKSkgewotICAgICAgICAg
ICAgICAgICAgICAvLyBIZXJlIHdlIG9wdGltaXN0aWNhbGx5IGFzc3VtZSB0aGF0IHdlIHdpbGwg
bm90IHNlZSBhbiBib3VuZC9DLUFQSSBmdW5jdGlvbiBoZXJlLgotICAgICAgICAgICAgICAgICAg
ICBtX2luc2VydGlvblNldC5pbnNlcnROb2RlKG1faW5kZXhJbkJsb2NrLCBTcGVjTm9uZSwgQ2hl
Y2tUeXBlSW5mb0ZsYWdzLCBub2RlLT5vcmlnaW4sIE9wSW5mbyhJbXBsZW1lbnRzRGVmYXVsdEhh
c0luc3RhbmNlKSwgRWRnZShub2RlLT5jaGlsZDEoKS5ub2RlKCksIENlbGxVc2UpKTsKLSAgICAg
ICAgICAgICAgICAgICAgbV9ncmFwaC5jb252ZXJ0VG9Db25zdGFudChub2RlLCBqc0Jvb2xlYW4o
ZmFsc2UpKTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQot
ICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBmaXhFZGdlPENlbGxVc2U+KG5vZGUtPmNoaWxk
MSgpKTsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICB9Ci0gICAgICAgICAgICAKKyAgICAg
ICAgY2FzZSBPdmVycmlkZXNIYXNJbnN0YW5jZToKICAgICAgICAgY2FzZSBDaGVja1N0cnVjdHVy
ZToKICAgICAgICAgY2FzZSBDaGVja0NlbGw6CiAgICAgICAgIGNhc2UgQ3JlYXRlVGhpczoK
</data>

          </attachment>
      

    </bug>

</bugzilla>