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

Changeset 283332 in webkit


Ignore:
Timestamp:
Sep 30, 2021, 1:37:55 PM (5 years ago)
Author:
sbarati@apple.com
Message:

The DFG/FTL need to be aware that Proxy's can produce "function" for typeof and might be callable
https://bugs.webkit.org/show_bug.cgi?id=230804
<rdar://problem/83543951>

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/ai-typeof-needs-to-be-aware-of-proxy-2.js: Added.

(assert):
(builtin.vm.createBuiltin):
(builtin2.vm.createBuiltin):
(let.p.new.Proxy):

  • stress/ai-typeof-needs-to-be-aware-of-proxy.js: Added.

(assert):
(builtin.vm.createBuiltin):
(let.p.new.Proxy):

  • stress/is-callable-in-ftl-needs-to-be-aware-of-proxy.js: Added.

(main):

Source/JavaScriptCore:

This patch fixes a couple bugs:

  • We were constant folding typeof on ProxyObject to "object" even when ProxyObject might produce a callable Proxy, and hence, should produce "function". This was a bug in AI.
  • This also fixes a similar bug in IsCallable's implementation in the FTL where we assumed that ProxyObject's type can't be callable.
  • bytecode/SpeculatedType.h:
  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):

Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r283300 r283332  
     12021-09-30  Saam Barati  <sbarati@apple.com>
     2
     3        The DFG/FTL need to be aware that Proxy's can produce "function" for typeof and might be callable
     4        https://bugs.webkit.org/show_bug.cgi?id=230804
     5        <rdar://problem/83543951>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * stress/ai-typeof-needs-to-be-aware-of-proxy-2.js: Added.
     10        (assert):
     11        (builtin.vm.createBuiltin):
     12        (builtin2.vm.createBuiltin):
     13        (let.p.new.Proxy):
     14        * stress/ai-typeof-needs-to-be-aware-of-proxy.js: Added.
     15        (assert):
     16        (builtin.vm.createBuiltin):
     17        (let.p.new.Proxy):
     18        * stress/is-callable-in-ftl-needs-to-be-aware-of-proxy.js: Added.
     19        (main):
     20
    1212021-09-29  Mark Lam  <mark.lam@apple.com>
    222
  • trunk/Source/JavaScriptCore/ChangeLog

    r283329 r283332  
     12021-09-30  Saam Barati  <sbarati@apple.com>
     2
     3        The DFG/FTL need to be aware that Proxy's can produce "function" for typeof and might be callable
     4        https://bugs.webkit.org/show_bug.cgi?id=230804
     5        <rdar://problem/83543951>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        This patch fixes a couple bugs:
     10        - We were constant folding typeof on ProxyObject to "object"
     11          even when ProxyObject might produce a callable Proxy, and hence,
     12          should produce "function". This was a bug in AI.
     13        - This also fixes a similar bug in IsCallable's implementation in
     14          the FTL where we assumed that ProxyObject's type can't be callable.
     15
     16        * bytecode/SpeculatedType.h:
     17        * dfg/DFGAbstractInterpreterInlines.h:
     18        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     19        * ftl/FTLLowerDFGToB3.cpp:
     20        (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
     21
    1222021-09-30  Fujii Hironori  <Hironori.Fujii@sony.com>
    223
  • trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h

    r282200 r283332  
    117117static constexpr SpeculatedType SpecFullTop                           = SpecBytecodeTop | SpecFullNumber; // It can be anything that bytecode could see plus exotic encodings of numbers.
    118118
     119static constexpr SpeculatedType SpecTypeofMightBeFunction             = SpecFunction | SpecObjectOther | SpecProxyObject; // If you don't see these types, you can't be callable, and you can't have typeof produce "function". Inverse is not true, however. If you only see these types, you may produce more things than "function" in typeof, and you might not be callable.
     120
    119121// SpecCellCheck is the type set representing the values that can flow through a cell check.
    120122// On 64-bit platforms, the empty value passes a cell check. Also, ~SpecCellCheck is the type
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r283098 r283332  
    16201620            // have masquaredes-as-undefined traps) and isn't a function? Then: we should fold
    16211621            // this to true.
    1622             if (!(child.m_type & ~(SpecObject - SpecObjectOther - SpecFunction))) {
     1622            if (!(child.m_type & ~(SpecObject - SpecTypeofMightBeFunction))) {
    16231623                setConstant(node, jsBoolean(true));
    16241624                constantWasSet = true;
     
    17331733            }
    17341734           
    1735             if (!(child.m_type & (SpecFunction | SpecObjectOther | SpecProxyObject))) {
     1735            if (!(child.m_type & SpecTypeofMightBeFunction)) {
    17361736                setConstant(node, jsBoolean(false));
    17371737                constantWasSet = true;
     
    18121812        // FIXME: We could use the masquerades-as-undefined watchpoint here.
    18131813        // https://bugs.webkit.org/show_bug.cgi?id=144456
    1814         if (!(abstractChild.m_type & ~(SpecObject - SpecObjectOther - SpecFunction))) {
     1814        if (!(abstractChild.m_type & ~(SpecObject - SpecTypeofMightBeFunction))) {
    18151815            setConstant(node, *m_graph.freeze(m_vm.smallStrings.objectString()));
    18161816            break;
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r283207 r283332  
    1954219542    LValue isExoticForTypeof(LValue cell, SpeculatedType type = SpecFullTop)
    1954319543    {
    19544         if (!(type & SpecObjectOther))
     19544        if (!(type & (SpecObjectOther | SpecProxyObject)))
    1954519545            return m_out.booleanFalse;
    1954619546        return m_out.testNonZero32(
Note: See TracChangeset for help on using the changeset viewer.