Ignore:
Timestamp:
Jan 2, 2014, 2:57:14 PM (12 years ago)
Author:
[email protected]
Message:

Storing new CopiedSpace memory into a JSObject should fire a write barrier
https://bugs.webkit.org/show_bug.cgi?id=126025

Reviewed by Filip Pizlo.

Technically this is creating a pointer between a (potentially) old generation object and a young
generation chunk of memory, thus there needs to be a barrier.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • dfg/DFGOperations.cpp:
  • heap/CopyWriteBarrier.h: Added. This class functions similarly to the WriteBarrier class. It

acts as a proxy for pointers to CopiedSpace. Assignments to the field cause a write barrier to
fire for the object that is the owner of the CopiedSpace memory. This is to ensure during nursery
collections that objects with new backing stores are visited, even if they are old generation objects.
(JSC::CopyWriteBarrier::CopyWriteBarrier):
(JSC::CopyWriteBarrier::operator!):
(JSC::CopyWriteBarrier::operator UnspecifiedBoolType*):
(JSC::CopyWriteBarrier::get):
(JSC::CopyWriteBarrier::operator*):
(JSC::CopyWriteBarrier::operator->):
(JSC::CopyWriteBarrier::set):
(JSC::CopyWriteBarrier::setWithoutWriteBarrier):
(JSC::CopyWriteBarrier::clear):

  • heap/Heap.h:
  • runtime/JSArray.cpp:

(JSC::JSArray::unshiftCountSlowCase):
(JSC::JSArray::shiftCountWithArrayStorage):
(JSC::JSArray::unshiftCountWithArrayStorage):

  • runtime/JSCell.h:

(JSC::JSCell::unvalidatedStructure):

  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::JSGenericTypedArrayView<Adaptor>::slowDownAndWasteMemory):

  • runtime/JSObject.cpp:

(JSC::JSObject::copyButterfly):
(JSC::JSObject::getOwnPropertySlotByIndex):
(JSC::JSObject::putByIndex):
(JSC::JSObject::enterDictionaryIndexingModeWhenArrayStorageAlreadyExists):
(JSC::JSObject::createInitialIndexedStorage):
(JSC::JSObject::createArrayStorage):
(JSC::JSObject::deletePropertyByIndex):
(JSC::JSObject::getOwnPropertyNames):
(JSC::JSObject::putByIndexBeyondVectorLengthWithoutAttributes):
(JSC::JSObject::countElements):
(JSC::JSObject::increaseVectorLength):
(JSC::JSObject::ensureLengthSlow):

  • runtime/JSObject.h:

(JSC::JSObject::butterfly):
(JSC::JSObject::setStructureAndButterfly):
(JSC::JSObject::setButterflyWithoutChangingStructure):
(JSC::JSObject::JSObject):
(JSC::JSObject::putDirectInternal):
(JSC::JSObject::putDirectWithoutTransition):

  • runtime/MapData.cpp:

(JSC::MapData::ensureSpaceForAppend):

  • runtime/Structure.cpp:

(JSC::Structure::materializePropertyMap):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r161220 r161230  
    2828#include "ArrayStorage.h"
    2929#include "Butterfly.h"
     30#include "CallFrame.h"
    3031#include "ClassInfo.h"
    3132#include "CommonIdentifiers.h"
    32 #include "CallFrame.h"
     33#include "CopyWriteBarrier.h"
    3334#include "DeferGC.h"
     35#include "Heap.h"
     36#include "IndexingHeaderInlines.h"
    3437#include "JSCell.h"
    3538#include "PropertySlot.h"
     
    540543    }
    541544       
    542     const Butterfly* butterfly() const { return m_butterfly; }
    543     Butterfly* butterfly() { return m_butterfly; }
     545    const Butterfly* butterfly() const { return m_butterfly.get(); }
     546    Butterfly* butterfly() { return m_butterfly.get(); }
    544547       
    545548    ConstPropertyStorage outOfLineStorage() const { return m_butterfly->propertyStorage(); }
     
    606609
    607610    JS_EXPORT_PRIVATE Butterfly* growOutOfLineStorage(VM&, size_t oldSize, size_t newSize);
    608     void setButterflyWithoutChangingStructure(Butterfly*); // You probably don't want to call this.
     611    void setButterflyWithoutChangingStructure(VM&, Butterfly*);
    609612       
    610613    void setStructure(VM&, Structure*);
     
    976979   
    977980protected:
    978     Butterfly* m_butterfly;
     981    CopyWriteBarrier<Butterfly> m_butterfly;
    979982};
    980983
     
    11361139inline void JSObject::setStructureAndButterfly(VM& vm, Structure* structure, Butterfly* butterfly)
    11371140{
    1138     m_butterfly = butterfly;
     1141    ASSERT(structure);
     1142    ASSERT(!butterfly == (!structure->outOfLineCapacity() && !structure->hasIndexingHeader(this)));
     1143    m_butterfly.set(vm, this, butterfly);
    11391144    setStructure(vm, structure);
    11401145}
     
    11471152}
    11481153
    1149 inline void JSObject::setButterflyWithoutChangingStructure(Butterfly* butterfly)
    1150 {
    1151     m_butterfly = butterfly;
     1154inline void JSObject::setButterflyWithoutChangingStructure(VM& vm, Butterfly* butterfly)
     1155{
     1156    m_butterfly.set(vm, this, butterfly);
    11521157}
    11531158
     
    11791184inline JSObject::JSObject(VM& vm, Structure* structure, Butterfly* butterfly)
    11801185    : JSCell(vm, structure)
    1181     , m_butterfly(butterfly)
     1186    , m_butterfly(vm, this, butterfly)
    11821187{
    11831188    vm.heap.ascribeOwner(this, butterfly);
     
    13031308
    13041309        DeferGC deferGC(vm.heap);
    1305         Butterfly* newButterfly = m_butterfly;
     1310        Butterfly* newButterfly = butterfly();
    13061311        if (structure()->putWillGrowOutOfLineStorage())
    13071312            newButterfly = growOutOfLineStorage(vm, structure()->outOfLineCapacity(), structure()->suggestedNewOutOfLineStorageCapacity());
     
    13241329    if (Structure* structure = Structure::addPropertyTransitionToExistingStructure(this->structure(), propertyName, attributes, specificFunction, offset)) {
    13251330        DeferGC deferGC(vm.heap);
    1326         Butterfly* newButterfly = m_butterfly;
    1327         if (currentCapacity != structure->outOfLineCapacity())
     1331        Butterfly* newButterfly = butterfly();
     1332        if (currentCapacity != structure->outOfLineCapacity()) {
     1333            ASSERT(structure != this->structure());
    13281334            newButterfly = growOutOfLineStorage(vm, currentCapacity, structure->outOfLineCapacity());
     1335        }
    13291336
    13301337        validateOffset(offset);
     
    14371444    DeferGC deferGC(vm.heap);
    14381445    ASSERT(!value.isGetterSetter() && !(attributes & Accessor));
    1439     Butterfly* newButterfly = m_butterfly;
     1446    Butterfly* newButterfly = m_butterfly.get();
    14401447    if (structure()->putWillGrowOutOfLineStorage())
    14411448        newButterfly = growOutOfLineStorage(vm, structure()->outOfLineCapacity(), structure()->suggestedNewOutOfLineStorageCapacity());
Note: See TracChangeset for help on using the changeset viewer.