Changeset 225768 in webkit


Ignore:
Timestamp:
Dec 11, 2017 7:24:43 PM (6 years ago)
Author:
sbarati@apple.com
Message:

We need to disableCaching() in ErrorInstance when we materialize properties
https://bugs.webkit.org/show_bug.cgi?id=180343
<rdar://problem/35833002>

Reviewed by Mark Lam.

JSTests:

  • stress/disable-caching-when-lazy-materializing-error-property-on-put.js: Added.

(assert):
(makeError):
(storeToStack):
(storeToStackAlreadyMaterialized):

Source/JavaScriptCore:

This patch fixes a bug in ErrorInstance where we forgot to call PutPropertySlot::disableCaching
on puts() to a property that we lazily materialized. Forgetting to do this goes against the
PutPropertySlot's caching API. This lazy materialization caused the ErrorInstance to transition
from a Structure A to a Structure B. However, we were telling the IC that we were caching an
existing property only found on Structure B. This is obviously wrong as it would lead to an
OOB store if we didn't already crash when generating the IC.

  • jit/Repatch.cpp:

(JSC::tryCachePutByID):

  • runtime/ErrorInstance.cpp:

(JSC::ErrorInstance::materializeErrorInfoIfNeeded):
(JSC::ErrorInstance::put):

  • runtime/ErrorInstance.h:
  • runtime/Structure.cpp:

(JSC::Structure::didCachePropertyReplacement):

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r225550 r225768  
     12017-12-11  Saam Barati  <sbarati@apple.com>
     2
     3        We need to disableCaching() in ErrorInstance when we materialize properties
     4        https://bugs.webkit.org/show_bug.cgi?id=180343
     5        <rdar://problem/35833002>
     6
     7        Reviewed by Mark Lam.
     8
     9        * stress/disable-caching-when-lazy-materializing-error-property-on-put.js: Added.
     10        (assert):
     11        (makeError):
     12        (storeToStack):
     13        (storeToStackAlreadyMaterialized):
     14
    1152017-12-05  JF Bastien  <jfbastien@apple.com>
    216
  • trunk/Source/JavaScriptCore/ChangeLog

    r225767 r225768  
     12017-12-11  Saam Barati  <sbarati@apple.com>
     2
     3        We need to disableCaching() in ErrorInstance when we materialize properties
     4        https://bugs.webkit.org/show_bug.cgi?id=180343
     5        <rdar://problem/35833002>
     6
     7        Reviewed by Mark Lam.
     8
     9        This patch fixes a bug in ErrorInstance where we forgot to call PutPropertySlot::disableCaching
     10        on puts() to a property that we lazily materialized. Forgetting to do this goes against the
     11        PutPropertySlot's caching API. This lazy materialization caused the ErrorInstance to transition
     12        from a Structure A to a Structure B. However, we were telling the IC that we were caching an
     13        existing property only found on Structure B. This is obviously wrong as it would lead to an
     14        OOB store if we didn't already crash when generating the IC.
     15
     16        * jit/Repatch.cpp:
     17        (JSC::tryCachePutByID):
     18        * runtime/ErrorInstance.cpp:
     19        (JSC::ErrorInstance::materializeErrorInfoIfNeeded):
     20        (JSC::ErrorInstance::put):
     21        * runtime/ErrorInstance.h:
     22        * runtime/Structure.cpp:
     23        (JSC::Structure::didCachePropertyReplacement):
     24
    1252017-12-11  Fujii Hironori  <Hironori.Fujii@sony.com>
    226
  • trunk/Source/JavaScriptCore/jit/Repatch.cpp

    r225363 r225768  
    423423        if (slot.base() == baseValue && slot.isCacheablePut()) {
    424424            if (slot.type() == PutPropertySlot::ExistingProperty) {
     425                // This assert helps catch bugs if we accidentally forget to disable caching
     426                // when we transition then store to an existing property. This is common among
     427                // paths that reify lazy properties. If we reify a lazy property and forget
     428                // to disable caching, we may come down this path. The Replace IC does not
     429                // know how to model these types of structure transitions (or any structure
     430                // transition for that matter).
     431                RELEASE_ASSERT(baseValue.asCell()->structure(vm) == structure);
     432
    425433                structure->didCachePropertyReplacement(vm, slot.cachedOffset());
    426434           
  • trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp

    r223746 r225768  
    203203}
    204204
    205 void ErrorInstance::materializeErrorInfoIfNeeded(VM& vm)
     205bool ErrorInstance::materializeErrorInfoIfNeeded(VM& vm)
    206206{
    207207    if (m_errorInfoMaterialized)
    208         return;
     208        return false;
    209209   
    210210    addErrorInfo(vm, m_stackTrace.get(), this);
     
    215215   
    216216    m_errorInfoMaterialized = true;
    217 }
    218 
    219 void ErrorInstance::materializeErrorInfoIfNeeded(VM& vm, PropertyName propertyName)
     217    return true;
     218}
     219
     220bool ErrorInstance::materializeErrorInfoIfNeeded(VM& vm, PropertyName propertyName)
    220221{
    221222    if (propertyName == vm.propertyNames->line
     
    223224        || propertyName == vm.propertyNames->sourceURL
    224225        || propertyName == vm.propertyNames->stack)
    225         materializeErrorInfoIfNeeded(vm);
     226        return materializeErrorInfoIfNeeded(vm);
     227    return false;
    226228}
    227229
     
    277279    VM& vm = exec->vm();
    278280    ErrorInstance* thisObject = jsCast<ErrorInstance*>(cell);
    279     thisObject->materializeErrorInfoIfNeeded(vm, propertyName);
     281    bool materializedProperties = thisObject->materializeErrorInfoIfNeeded(vm, propertyName);
     282    if (materializedProperties)
     283        slot.disableCaching();
    280284    return Base::put(thisObject, exec, propertyName, value, slot);
    281285}
  • trunk/Source/JavaScriptCore/runtime/ErrorInstance.h

    r222186 r225768  
    7070    Vector<StackFrame>* stackTrace() { return m_stackTrace.get(); }
    7171
    72     void materializeErrorInfoIfNeeded(VM&);
    73     void materializeErrorInfoIfNeeded(VM&, PropertyName);
     72    bool materializeErrorInfoIfNeeded(VM&);
     73    bool materializeErrorInfoIfNeeded(VM&, PropertyName);
    7474
    7575protected:
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r225659 r225768  
    874874void Structure::didCachePropertyReplacement(VM& vm, PropertyOffset offset)
    875875{
     876    RELEASE_ASSERT(isValidOffset(offset));
    876877    ensurePropertyReplacementWatchpointSet(vm, offset)->fireAll(vm, "Did cache property replacement");
    877878}
Note: See TracChangeset for help on using the changeset viewer.