Changeset 196678 in webkit


Ignore:
Timestamp:
Feb 16, 2016 6:34:36 PM (8 years ago)
Author:
Chris Dumez
Message:

JSDOMWindow::getOwnPropertySlot should just call getStaticPropertySlot
https://bugs.webkit.org/show_bug.cgi?id=154257

Patch by Gavin Barraclough <barraclough@apple.com> on 2016-02-16
Reviewed by Chris Dumez.

Source/JavaScriptCore:

  • runtime/Lookup.h:

(JSC::getStaticPropertySlot):
(JSC::getStaticFunctionSlot):
(JSC::getStaticValueSlot):

  • this could all do with a little more love. But enforce the basic precedence:

(1) regular storage properties always win over static table properties.
(2) if properties have been reified, don't consult the static tables.
(3) only if the property is not present on the object & not reified

should the static hashtable be consulted.

Source/WebCore:

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::getOwnPropertySlot):

  • JSDOMWindow::getOwnPropertySlot should just call getStaticPropertySlot
Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r196676 r196678  
     12016-02-16  Gavin Barraclough  <barraclough@apple.com>
     2
     3        JSDOMWindow::getOwnPropertySlot should just call getStaticPropertySlot
     4        https://bugs.webkit.org/show_bug.cgi?id=154257
     5
     6        Reviewed by Chris Dumez.
     7
     8        * runtime/Lookup.h:
     9        (JSC::getStaticPropertySlot):
     10        (JSC::getStaticFunctionSlot):
     11        (JSC::getStaticValueSlot):
     12            - this could all do with a little more love.
     13              But enforce the basic precedence:
     14                (1) regular storage properties always win over static table properties.
     15                (2) if properties have been reified, don't consult the static tables.
     16                (3) only if the property is not present on the object & not reified
     17                    should the static hashtable be consulted.
     18
    1192016-02-16  Gavin Barraclough  <barraclough@apple.com>
    220
  • trunk/Source/JavaScriptCore/runtime/Lookup.h

    r196648 r196678  
    211211inline bool getStaticPropertySlot(ExecState* exec, const HashTable& table, ThisImp* thisObj, PropertyName propertyName, PropertySlot& slot)
    212212{
    213     const HashTableValue* entry = table.entry(propertyName);
    214 
    215     if (!entry) // not found, forward to parent
    216         return ParentImp::getOwnPropertySlot(thisObj, exec, propertyName, slot);
     213    if (ParentImp::getOwnPropertySlot(thisObj, exec, propertyName, slot))
     214        return true;
     215
     216    if (thisObj->staticFunctionsReified())
     217        return false;
     218
     219    auto* entry = table.entry(propertyName);
     220    if (!entry)
     221        return false;
    217222
    218223    if (entry->attributes() & BuiltinOrFunctionOrAccessor)
     
    239244        return true;
    240245
    241     const HashTableValue* entry = table.entry(propertyName);
     246    if (thisObj->staticFunctionsReified())
     247        return false;
     248
     249    auto* entry = table.entry(propertyName);
    242250    if (!entry)
    243251        return false;
     
    253261inline bool getStaticValueSlot(ExecState* exec, const HashTable& table, ThisImp* thisObj, PropertyName propertyName, PropertySlot& slot)
    254262{
    255     const HashTableValue* entry = table.entry(propertyName);
    256 
    257     if (!entry) // not found, forward to parent
    258         return ParentImp::getOwnPropertySlot(thisObj, exec, propertyName, slot);
     263    if (ParentImp::getOwnPropertySlot(thisObj, exec, propertyName, slot))
     264        return true;
     265
     266    if (thisObj->staticFunctionsReified())
     267        return false;
     268
     269    auto* entry = table.entry(propertyName);
     270    if (!entry)
     271        return false;
    259272
    260273    ASSERT(!(entry->attributes() & BuiltinOrFunctionOrAccessor));
  • trunk/Source/WebCore/ChangeLog

    r196676 r196678  
     12016-02-16  Gavin Barraclough  <barraclough@apple.com>
     2
     3        JSDOMWindow::getOwnPropertySlot should just call getStaticPropertySlot
     4        https://bugs.webkit.org/show_bug.cgi?id=154257
     5
     6        Reviewed by Chris Dumez.
     7
     8        * bindings/js/JSDOMWindowCustom.cpp:
     9        (WebCore::JSDOMWindow::getOwnPropertySlot):
     10            - JSDOMWindow::getOwnPropertySlot should just call getStaticPropertySlot
     11
    1122016-02-16  Gavin Barraclough  <barraclough@apple.com>
    213
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r196676 r196678  
    253253    slot.setWatchpointSet(thisObject->m_windowCloseWatchpoints);
    254254
    255     // (2) Regular own properties.
    256     // FIXME: we should probably be able to use getStaticPropertySlot here.
    257     if (Base::getOwnPropertySlot(thisObject, exec, propertyName, slot))
    258         return true;
    259 
    260255    // FIXME: These are all bogus. Keeping these here make some tests pass that check these properties
    261256    // are own properties of the window, but introduces other problems instead (e.g. if you overwrite
    262257    // & delete then the original value is restored!) Should be removed.
    263258    if (propertyName == exec->propertyNames().blur) {
    264         slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionBlur, 0>);
     259        if (!Base::getOwnPropertySlot(thisObject, exec, propertyName, slot))
     260            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionBlur, 0>);
    265261        return true;
    266262    }
    267263    if (propertyName == exec->propertyNames().close) {
    268         slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0>);
     264        if (!Base::getOwnPropertySlot(thisObject, exec, propertyName, slot))
     265            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0>);
    269266        return true;
    270267    }
    271268    if (propertyName == exec->propertyNames().focus) {
    272         slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0>);
     269        if (!Base::getOwnPropertySlot(thisObject, exec, propertyName, slot))
     270            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0>);
    273271        return true;
    274272    }
    275273    if (propertyName == exec->propertyNames().postMessage) {
    276         slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 2>);
    277         return true;
    278     }
    279 
    280     if (!thisObject->staticFunctionsReified()) {
    281         if (auto* entry = JSDOMWindow::info()->staticPropHashTable->entry(propertyName)) {
    282             if (entry->attributes() & BuiltinOrFunctionOrAccessor)
    283                 return setUpStaticFunctionSlot(exec, entry, thisObject, propertyName, slot);
    284             slot.setCacheableCustom(thisObject, entry->attributes(), entry->propertyGetter());
    285             return true;
    286         }
    287     }
    288 
     274        if (!Base::getOwnPropertySlot(thisObject, exec, propertyName, slot))
     275            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 2>);
     276        return true;
     277    }
     278    // (2) Regular own properties.
     279    if (getStaticPropertySlot<JSDOMWindow, Base>(exec, *JSDOMWindow::info()->staticPropHashTable, thisObject, propertyName, slot))
     280        return true;
    289281    // FIXME: this looks pretty bogus. It seems highly likely that if !canShowModalDialog the
    290282    // funtion should still be present, or should be omitted entirely - present but reads as
Note: See TracChangeset for help on using the changeset viewer.