Changeset 209442 in webkit


Ignore:
Timestamp:
Dec 6, 2016 7:12:05 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

GetByID IC is wrongly unwrapping the global proxy this value for getter/setters.
https://bugs.webkit.org/show_bug.cgi?id=165401

Reviewed by Saam Barati.

Source/JavaScriptCore:

When the this value for a property access is the JS global and that property
access is via a GetterSetter, the underlying getter / setter functions would
expect the this value they receive to be the JSProxy instance instead of the
JSGlobalObject. This is consistent with how the LLINT and runtime code behaves.
The IC code should behave the same way.

Also added some ASSERTs to document invariants in the code, and help detect
bugs sooner if the code gets changed in a way that breaks those invariants in
the future.

  • bytecode/PolymorphicAccess.cpp:

(JSC::AccessCase::generateImpl):

LayoutTests:

Set the test loose now that this bug is fixed.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r209439 r209442  
     12016-12-06  Mark Lam  <mark.lam@apple.com>
     2
     3        GetByID IC is wrongly unwrapping the global proxy this value for getter/setters.
     4        https://bugs.webkit.org/show_bug.cgi?id=165401
     5
     6        Reviewed by Saam Barati.
     7
     8        Set the test loose now that this bug is fixed.
     9
     10        * TestExpectations:
     11        * js/script-tests/prototype-assignment.js:
     12
    1132016-12-06  Dean Jackson  <dino@apple.com>
    214
  • trunk/LayoutTests/TestExpectations

    r209424 r209442  
    641641[ Debug ] js/regress-141098.html [ Slow ]
    642642
    643 webkit.org/b/165401 js/prototype-assignment.html [ Skip ]
    644 
    645643# IDBVersionChangeEvent tests need to be rewritten to use event constructors instead of createEvent,
    646644# after we implement the IDBVersionChangeEvent constructor.
  • trunk/LayoutTests/js/script-tests/prototype-assignment.js

    r209424 r209442  
    1 //@ runFTLNoCJIT("--useJIT=false")
    2 // FIXME: Remove the "--useJIT=false" option when https://bugs.webkit.org/show_bug.cgi?id=165401 is fixed.
     1//@ runFTLNoCJIT
    32
    43// This test suite compares the behavior of setting the prototype on various values
  • trunk/Source/JavaScriptCore/ChangeLog

    r209440 r209442  
     12016-12-06  Mark Lam  <mark.lam@apple.com>
     2
     3        GetByID IC is wrongly unwrapping the global proxy this value for getter/setters.
     4        https://bugs.webkit.org/show_bug.cgi?id=165401
     5
     6        Reviewed by Saam Barati.
     7
     8        When the this value for a property access is the JS global and that property
     9        access is via a GetterSetter, the underlying getter / setter functions would
     10        expect the this value they receive to be the JSProxy instance instead of the
     11        JSGlobalObject.  This is consistent with how the LLINT and runtime code behaves.
     12        The IC code should behave the same way.
     13
     14        Also added some ASSERTs to document invariants in the code, and help detect
     15        bugs sooner if the code gets changed in a way that breaks those invariants in
     16        the future.
     17
     18        * bytecode/PolymorphicAccess.cpp:
     19        (JSC::AccessCase::generateImpl):
     20
    1212016-12-06  Joseph Pecoraro  <pecoraro@apple.com>
    222
  • trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp

    r208860 r209442  
    886886    case CustomValueSetter:
    887887    case CustomAccessorSetter: {
     888        GPRReg valueRegsPayloadGPR = valueRegs.payloadGPR();
     889       
    888890        if (isValidOffset(m_offset)) {
    889891            Structure* currStructure;
     
    897899        GPRReg baseForGetGPR;
    898900        if (viaProxy()) {
    899             baseForGetGPR = valueRegs.payloadGPR();
     901            ASSERT(m_type != CustomValueSetter || m_type != CustomAccessorSetter); // Because setters need to not trash valueRegsPayloadGPR.
     902            if (m_type == Getter || m_type == Setter)
     903                baseForGetGPR = scratchGPR;
     904            else
     905                baseForGetGPR = valueRegsPayloadGPR;
     906
     907            ASSERT((m_type != Getter && m_type != Setter) || baseForGetGPR != baseGPR);
     908            ASSERT(m_type != Setter || baseForGetGPR != valueRegsPayloadGPR);
     909
    900910            jit.loadPtr(
    901911                CCallHelpers::Address(baseGPR, JSProxy::targetOffset()),
     
    916926        if (m_type != CustomValueGetter && m_type != CustomAccessorGetter && m_type != CustomValueSetter && m_type != CustomAccessorSetter) {
    917927            if (m_type == Load || m_type == GetGetter)
    918                 loadedValueGPR = valueRegs.payloadGPR();
     928                loadedValueGPR = valueRegsPayloadGPR;
    919929            else
    920930                loadedValueGPR = scratchGPR;
     931
     932            ASSERT((m_type != Getter && m_type != Setter) || loadedValueGPR != baseGPR);
     933            ASSERT(m_type != Setter || loadedValueGPR != valueRegsPayloadGPR);
    921934
    922935            GPRReg storageGPR;
     
    9871000
    9881001        if (m_type == Getter || m_type == Setter) {
     1002            ASSERT(baseGPR != loadedValueGPR);
     1003            ASSERT(m_type != Setter || (baseGPR != valueRegsPayloadGPR && loadedValueGPR != valueRegsPayloadGPR));
     1004
    9891005            // Create a JS call using a JS call inline cache. Assume that:
    9901006            //
     
    10651081
    10661082            jit.storeCell(
    1067                 baseForGetGPR,
     1083                baseGPR,
    10681084                calleeFrame.withOffset(virtualRegisterForArgument(0).offset() * sizeof(Register)));
    10691085
     
    11191135                });
    11201136        } else {
     1137            ASSERT(m_type == CustomValueGetter || m_type == CustomAccessorGetter || m_type == CustomValueSetter || m_type == CustomAccessorSetter);
     1138
    11211139            // Need to make room for the C call so any of our stack spillage isn't overwritten. It's
    11221140            // hard to track if someone did spillage or not, so we just assume that we always need
Note: See TracChangeset for help on using the changeset viewer.