⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 202936 in webkit


Ignore:
Timestamp:
Jul 7, 2016, 3:15:04 PM (10 years ago)
Author:
sbarati@apple.com
Message:

ToThis constant folding in DFG is incorrect when the structure indicates that toThis is overridden
https://bugs.webkit.org/show_bug.cgi?id=159501
<rdar://problem/27109354>

Reviewed by Mark Lam.

We *cannot* constant fold ToThis when the structure of an object
indicates that toThis() is overridden. isToThisAnIdentity() inside
AbstractInterpreterInlines accidentally wrote the opposite rule.
The rule was written as we can constant fold ToThis only when
toThis() is overridden. To fix the bug, we must write the rule
as isToThisAnIdentity() can only be true as long as the structure
set indicates that no structures override toThis().

We could probably get more clever in the future and notice
when we're dealing with a constant |this| values. For example,
a ToThis might occur on a constant JSLexicalEnvironment. We could
implement the rules of JSLexicalEnvironment's toThis() implementation
inside AI/constant folding.

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::isToThisAnIdentity):

  • tests/stress/to-this-on-constant-lexical-environment.js: Added.

(foo.bar):
(foo.inner):
(foo):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r202926 r202936  
     12016-07-07  Saam Barati  <sbarati@apple.com>
     2
     3        ToThis constant folding in DFG is incorrect when the structure indicates that toThis is overridden
     4        https://bugs.webkit.org/show_bug.cgi?id=159501
     5        <rdar://problem/27109354>
     6
     7        Reviewed by Mark Lam.
     8
     9        We *cannot* constant fold ToThis when the structure of an object
     10        indicates that toThis() is overridden. isToThisAnIdentity() inside
     11        AbstractInterpreterInlines accidentally wrote the opposite rule.
     12        The rule was written as we can constant fold ToThis only when
     13        toThis() is overridden. To fix the bug, we must write the rule
     14        as isToThisAnIdentity() can only be true as long as the structure
     15        set indicates that no structures override toThis().
     16
     17        We could probably get more clever in the future and notice
     18        when we're dealing with a constant |this| values. For example,
     19        a ToThis might occur on a constant JSLexicalEnvironment. We could
     20        implement the rules of JSLexicalEnvironment's toThis() implementation
     21        inside AI/constant folding.
     22
     23        * dfg/DFGAbstractInterpreterInlines.h:
     24        (JSC::DFG::isToThisAnIdentity):
     25        * tests/stress/to-this-on-constant-lexical-environment.js: Added.
     26        (foo.bar):
     27        (foo.inner):
     28        (foo):
     29
    1302016-07-07  Benjamin Poulain  <benjamin@webkit.org>
    231
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r202680 r202936  
    168168                overridesToThis = true;
    169169        });
    170         return overridesToThis;
     170        return !overridesToThis;
    171171    }
    172172
Note: See TracChangeset for help on using the changeset viewer.