<?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>150760</bug_id>
          
          <creation_ts>2015-10-31 16:22:13 -0700</creation_ts>
          <short_desc>Wrong value recovery for DFG try/catch with a getter that throws during an IC miss</short_desc>
          <delta_ts>2015-11-02 17:20:26 -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>JavaScriptCore</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>
          
          <blocked>149409</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Saam Barati">saam</reporter>
          <assigned_to name="Saam Barati">saam</assigned_to>
          <cc>benjamin</cc>
    
    <cc>commit-queue</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>gskachkov</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>oliver</cc>
    
    <cc>sukolsak</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1138234</commentid>
    <comment_count>0</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2015-10-31 16:22:13 -0700</bug_when>
    <thetext>This program breaks in the DFG. Probably because we&apos;re assigning the base and the result to the same register and the IC fails.
```
function assert(b) {
    if (!b)
        throw new Error(&quot;bad value&quot;)
}
noInline(assert);

let oThrow = {
    x: 20,
    y: 40,
    z: 50,
    get f() { throw new Error(&quot;Hello World!&quot;); }
};

let o1 = {
    x: 20,
    f: 40
};

let o2 = {
    x: 20,
    y: 50,
    get f() { return 20; }
};

function foo(f) {
    let o = f();
    try {
        o = o.f;
    } catch(e) {
        print(o); // Make this not undefined.
        assert(o === oThrow);
    }
}
noInline(foo);

let i;
let flag = false;
function f() {
    if (flag)
        return oThrow;
    if (i % 2)
        return o1;
    return o2;
}
noInline(f);
for (i = 0; i &lt; 10000; i++) {
    foo(f);
}
flag = true;
foo(f);
```
I discovered this while solving this issue in FTL try/catch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1138235</commentid>
    <comment_count>1</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2015-10-31 16:26:16 -0700</bug_when>
    <thetext>What I think is happening.
The IC misses, but the operationGetByIdOptimize stores the result
of the call into the result register. Even though the C call throws,
we store the result. And then, we try to recover the base from
the register we stored the result into because the result and base
are the same register. This is a big bag of fail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1138744</commentid>
    <comment_count>2</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2015-11-02 16:01:23 -0800</bug_when>
    <thetext>(In reply to comment #1)
&gt; What I think is happening.
&gt; The IC misses, but the operationGetByIdOptimize stores the result
&gt; of the call into the result register. Even though the C call throws,
&gt; we store the result. And then, we try to recover the base from
&gt; the register we stored the result into because the result and base
&gt; are the same register. This is a big bag of fail.

I&apos;ve actually realized that the problem is deeper than this.
I do think the situation I&apos;m describing is a problem, but
I&apos;ve realized that the result of the call in this example
is looking dead to DFG OSR exit when we use PhantomLocal
as the liveness preservation mechanism. I&apos;m going
to switch the code back to using Flush so that I can
land FTL try/catch, and then I will investigate this problem
further.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1138746</commentid>
    <comment_count>3</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2015-11-02 16:03:07 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; (In reply to comment #1)
&gt; &gt; What I think is happening.
&gt; &gt; The IC misses, but the operationGetByIdOptimize stores the result
&gt; &gt; of the call into the result register. Even though the C call throws,
&gt; &gt; we store the result. And then, we try to recover the base from
&gt; &gt; the register we stored the result into because the result and base
&gt; &gt; are the same register. This is a big bag of fail.
&gt; 
&gt; I&apos;ve actually realized that the problem is deeper than this.
&gt; I do think the situation I&apos;m describing is a problem, but
&gt; I&apos;ve realized that the result of the call in this example
&gt; is looking dead to DFG OSR exit when we use PhantomLocal
&gt; as the liveness preservation mechanism. I&apos;m going
&gt; to switch the code back to using Flush so that I can
&gt; land FTL try/catch, and then I will investigate this problem
&gt; further.

Let me elaborate:
the result of the call looks dead after we do flushRegisters().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1138767</commentid>
    <comment_count>4</comment_count>
      <attachid>264646</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2015-11-02 16:49:22 -0800</bug_when>
    <thetext>Created attachment 264646
patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1138768</commentid>
    <comment_count>5</comment_count>
      <attachid>264646</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2015-11-02 16:51:03 -0800</bug_when>
    <thetext>Comment on attachment 264646
patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1138769</commentid>
    <comment_count>6</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2015-11-02 16:52:04 -0800</bug_when>
    <thetext>Attachment 264646 did not pass style-queue:


ERROR: Source/JavaScriptCore/dfg/DFGLiveCatchVariablePreservationPhase.cpp:133:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1138779</commentid>
    <comment_count>7</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2015-11-02 17:20:26 -0800</bug_when>
    <thetext>landed in:
http://trac.webkit.org/changeset/191930</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>264646</attachid>
            <date>2015-11-02 16:49:22 -0800</date>
            <delta_ts>2015-11-02 16:51:03 -0800</delta_ts>
            <desc>patch</desc>
            <filename>a-backup.diff</filename>
            <type>text/plain</type>
            <size>5075</size>
            <attacher name="Saam Barati">saam</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gU291
cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkocmV2aXNpb24gMTkxOTI1KQorKysgU291cmNl
L0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDI4IEBA
CisyMDE1LTExLTAyICBTYWFtIGJhcmF0aSAgPHNiYXJhdGlAYXBwbGUuY29tPgorCisgICAgICAg
IFdyb25nIHZhbHVlIHJlY292ZXJ5IGZvciBERkcgdHJ5L2NhdGNoIHdpdGggYSBnZXR0ZXIgdGhh
dCB0aHJvd3MgZHVyaW5nIGFuIElDIG1pc3MKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5v
cmcvc2hvd19idWcuY2dpP2lkPTE1MDc2MAorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAo
T09QUyEpLgorCisgICAgICAgIFRoaXMgaXMgcmVsYXRlZCB0byB1c2luZyBQaGFudG9tTG9jYWwg
aW5zdGVhZCBvZiBGbHVzaCBhcyAKKyAgICAgICAgdGhlIGxpdmVuZXNzIHByZXNlcnZhdGlvbiBt
ZWNoYW5pc20gZm9yIGxpdmUgY2F0Y2ggdmFyaWFibGVzLiAKKyAgICAgICAgSSdtI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R1YWxSZWdpc3RlcihDYWxsRnJhbWU6OnRoaXNBcmd1bWVudE9mZnNl
dCgpKSwgdHJ1ZSk7CiAgICAgICAgIH0KICAgICB9CiAKSW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0
Q29yZS90ZXN0cy9zdHJlc3MvZGZnLXRyeS1jYXRjaC13cm9uZy12YWx1ZS1yZWNvdmVyeS1vbi1p
Yy1taXNzLmpzCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT0KLS0tIFNvdXJjZS9KYXZhU2NyaXB0Q29yZS90ZXN0cy9zdHJl
c3MvZGZnLXRyeS1jYXRjaC13cm9uZy12YWx1ZS1yZWNvdmVyeS1vbi1pYy1taXNzLmpzCShyZXZp
c2lvbiAwKQorKysgU291cmNlL0phdmFTY3JpcHRDb3JlL3Rlc3RzL3N0cmVzcy9kZmctdHJ5LWNh
dGNoLXdyb25nLXZhbHVlLXJlY292ZXJ5LW9uLWljLW1pc3MuanMJKHdvcmtpbmcgY29weSkKQEAg
LTAsMCArMSw1MCBAQAorZnVuY3Rpb24gYXNzZXJ0KGIpIHsKKyAgICBpZiAoIWIpCisgICAgICAg
IHRocm93IG5ldyBFcnJvcigiYmFkIHZhbHVlIikKK30KK25vSW5saW5lKGFzc2VydCk7CisKK2xl
dCBvVGhyb3cgPSB7CisgICAgeDogMjAsCisgICAgeTogNDAsCisgICAgejogNTAsCisgICAgZ2V0
IGYoKSB7IHRocm93IG5ldyBFcnJvcigiSGVsbG8gV29ybGQhIik7IH0KK307CisKK2xldCBvMSA9
IHsKKyAgICB4OiAyMCwKKyAgICBmOiA0MAorfTsKKworbGV0IG8yID0geworICAgIHg6IDIwLAor
ICAgIHk6IDUwLAorICAgIGY6IDUwMCwKKyAgICBnZXQgZigpIHsgcmV0dXJuIDIwOyB9Cit9Owor
CitmdW5jdGlvbiBmb28oZikgeworICAgIGxldCBvID0gZigpOworICAgIHRyeSB7CisgICAgICAg
IG8gPSBvLmY7CisgICAgfSBjYXRjaChlKSB7CisgICAgICAgIGFzc2VydChvID09PSBvVGhyb3cp
OyAvLyBNYWtlIHN1cmUgdGhpcyBpcyBub3QgdW5kZWZpbmVkLgorICAgIH0KK30KK25vSW5saW5l
KGZvbyk7CisKK2xldCBpOworbGV0IGZsYWcgPSBmYWxzZTsKK2Z1bmN0aW9uIGYoKSB7CisgICAg
aWYgKGZsYWcpCisgICAgICAgIHJldHVybiBvVGhyb3c7CisgICAgaWYgKGkgJSAyKQorICAgICAg
ICByZXR1cm4gbzE7CisgICAgcmV0dXJuIG8yOworfQorbm9JbmxpbmUoZik7Citmb3IgKGkgPSAw
OyBpIDwgMTAwMDA7IGkrKykgeworICAgIGZvbyhmKTsKK30KK2ZsYWcgPSB0cnVlOworZm9vKGYp
Owo=
</data>
<flag name="review"
          id="289738"
          type_id="1"
          status="+"
          setter="ggaren"
    />
          </attachment>
      

    </bug>

</bugzilla>