Changeset 274882 in webkit


Ignore:
Timestamp:
Mar 23, 2021 11:04:34 AM (16 months ago)
Author:
rmorisset@apple.com
Message:

Object.freeze(this) at the global scope can lose a reference to a WatchpointSet
https://bugs.webkit.org/show_bug.cgi?id=223608

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/freeze-global-object.js: Added.

(foo):

Source/JavaScriptCore:

When freezing the global object, we should make a proper copy of symbol table entries, to keep any outstanding reference to the WatchpointSet.
We cannot use pack(), because it does not support FatEntries.

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::defineOwnProperty):

  • runtime/JSSymbolTableObject.h:

(JSC::symbolTableGet):

  • runtime/SymbolTable.h:

(JSC::SymbolTableEntry::setReadOnly):

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r274813 r274882  
     12021-03-23  Robin Morisset  <rmorisset@apple.com>
     2
     3        Object.freeze(this) at the global scope can lose a reference to a WatchpointSet
     4        https://bugs.webkit.org/show_bug.cgi?id=223608
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * stress/freeze-global-object.js: Added.
     9        (foo):
     10
    1112021-03-22  Saam Barati  <sbarati@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r274817 r274882  
     12021-03-23  Robin Morisset  <rmorisset@apple.com>
     2
     3        Object.freeze(this) at the global scope can lose a reference to a WatchpointSet
     4        https://bugs.webkit.org/show_bug.cgi?id=223608
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        When freezing the global object, we should make a proper copy of symbol table entries, to keep any outstanding reference to the WatchpointSet.
     9        We cannot use pack(), because it does not support FatEntries.
     10
     11        * runtime/JSGlobalObject.cpp:
     12        (JSC::JSGlobalObject::defineOwnProperty):
     13        * runtime/JSSymbolTableObject.h:
     14        (JSC::symbolTableGet):
     15        * runtime/SymbolTable.h:
     16        (JSC::SymbolTableEntry::setReadOnly):
     17
    1182021-03-22  Yusuke Suzuki  <ysuzuki@apple.com>
    219
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r274406 r274882  
    14851485    JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
    14861486
    1487     SymbolTableEntry::Fast entry;
     1487    SymbolTableEntry entry;
    14881488    PropertyDescriptor currentDescriptor;
    14891489    if (symbolTableGet(thisObject, propertyName, entry, currentDescriptor)) {
     
    15031503        }
    15041504        if (descriptor.writablePresent() && !descriptor.writable() && !entry.isReadOnly()) {
    1505             thisObject->symbolTable()->set(propertyName.uid(), SymbolTableEntry(entry.varOffset(), entry.getAttributes() | PropertyAttribute::ReadOnly));
     1505            entry.setReadOnly();
     1506            thisObject->symbolTable()->set(propertyName.uid(), entry);
    15061507            thisObject->varReadOnlyWatchpoint()->fireAll(vm, "GlobalVar was redefined as ReadOnly");
    15071508        }
  • trunk/Source/JavaScriptCore/runtime/JSSymbolTableObject.h

    r274406 r274882  
    100100template<typename SymbolTableObjectType>
    101101inline bool symbolTableGet(
    102     SymbolTableObjectType* object, PropertyName propertyName, SymbolTableEntry::Fast& entry, PropertyDescriptor& descriptor)
     102    SymbolTableObjectType* object, PropertyName propertyName, SymbolTableEntry& entry, PropertyDescriptor& descriptor)
    103103{
    104104    SymbolTable& symbolTable = *object->symbolTable();
  • trunk/Source/JavaScriptCore/runtime/SymbolTable.h

    r274406 r274882  
    265265    }
    266266
     267    void setReadOnly()
     268    {
     269        bits() |= ReadOnlyFlag;
     270    }
     271
    267272    bool isReadOnly() const
    268273    {
Note: See TracChangeset for help on using the changeset viewer.