Changeset 82849 in webkit


Ignore:
Timestamp:
Apr 4, 2011 11:41:15 AM (13 years ago)
Author:
oliver@apple.com
Message:

2011-04-01 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

Make StructureChain GC allocated
https://bugs.webkit.org/show_bug.cgi?id=56695

Make StructureChain GC allocated, and make the various owners
mark it correctly.

  • JavaScriptCore.exp:
  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::derefStructures): (JSC::CodeBlock::refStructures): (JSC::CodeBlock::markAggregate):
  • bytecode/Instruction.h: (JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set): (JSC::PolymorphicAccessStructureList::PolymorphicAccessStructureList): (JSC::PolymorphicAccessStructureList::derefStructures): (JSC::PolymorphicAccessStructureList::markAggregate): (JSC::Instruction::Instruction):
  • bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::deref): (JSC::StructureStubInfo::markAggregate):
  • bytecode/StructureStubInfo.h: (JSC::StructureStubInfo::initGetByIdChain): (JSC::StructureStubInfo::initPutByIdTransition):
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitJumpIfNotFunctionCall): (JSC::BytecodeGenerator::emitJumpIfNotFunctionApply):
  • collector/handles/Handle.h: (JSC::HandleConverter::operator->): (JSC::HandleConverter::operator*):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute):
  • jit/JITOpcodes.cpp: (JSC::JIT::emit_op_jneq_ptr):
  • jit/JITOpcodes32_64.cpp: (JSC::JIT::emit_op_jneq_ptr):
  • jit/JITPropertyAccess.cpp: (JSC::JIT::privateCompileGetByIdChainList):
  • jit/JITPropertyAccess32_64.cpp: (JSC::JIT::privateCompileGetByIdChainList):
  • jit/JITStubs.cpp: (JSC::JITThunks::tryCachePutByID): (JSC::JITThunks::tryCacheGetByID): (JSC::getPolymorphicAccessStructureListSlot): (JSC::DEFINE_STUB_FUNCTION):
  • runtime/JSCell.h:
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • runtime/JSGlobalData.h:
  • runtime/JSGlobalObject.cpp: (JSC::markIfNeeded):
  • runtime/JSGlobalObject.h: (JSC::Structure::prototypeChain):
  • runtime/JSObject.h: (JSC::JSObject::putDirectInternal): (JSC::JSObject::markChildrenDirect):
  • runtime/JSPropertyNameIterator.cpp: (JSC::JSPropertyNameIterator::create): (JSC::JSPropertyNameIterator::get): (JSC::JSPropertyNameIterator::markChildren):
  • runtime/JSPropertyNameIterator.h: (JSC::JSPropertyNameIterator::setCachedPrototypeChain):
  • runtime/JSZombie.cpp: (JSC::JSZombie::leakedZombieStructure):
  • runtime/JSZombie.h:
  • runtime/MarkStack.h: (JSC::MarkStack::append):
  • runtime/MarkedBlock.cpp: (JSC::MarkedBlock::sweep):
  • runtime/Structure.cpp: (JSC::Structure::addPropertyTransition):
  • runtime/Structure.h: (JSC::Structure::markAggregate):
  • runtime/StructureChain.cpp: (JSC::StructureChain::StructureChain): (JSC::StructureChain::~StructureChain): (JSC::StructureChain::markChildren):
  • runtime/StructureChain.h: (JSC::StructureChain::create): (JSC::StructureChain::createStructure):
  • runtime/WriteBarrier.h: (JSC::WriteBarrierBase::get): (JSC::WriteBarrierBase::operator*): (JSC::WriteBarrierBase::operator->):

2011-04-01 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

Make StructureChain GC allocated
https://bugs.webkit.org/show_bug.cgi?id=56695

Update for new Structure marking function

  • bindings/js/JSDOMGlobalObject.cpp: (WebCore::JSDOMGlobalObject::markChildren):
Location:
trunk/Source
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r82718 r82849  
     12011-04-01  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        Make StructureChain GC allocated
     6        https://bugs.webkit.org/show_bug.cgi?id=56695
     7
     8        Make StructureChain GC allocated, and make the various owners
     9        mark it correctly.
     10
     11        * JavaScriptCore.exp:
     12        * bytecode/CodeBlock.cpp:
     13        (JSC::CodeBlock::dump):
     14        (JSC::CodeBlock::derefStructures):
     15        (JSC::CodeBlock::refStructures):
     16        (JSC::CodeBlock::markAggregate):
     17        * bytecode/Instruction.h:
     18        (JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set):
     19        (JSC::PolymorphicAccessStructureList::PolymorphicAccessStructureList):
     20        (JSC::PolymorphicAccessStructureList::derefStructures):
     21        (JSC::PolymorphicAccessStructureList::markAggregate):
     22        (JSC::Instruction::Instruction):
     23        * bytecode/StructureStubInfo.cpp:
     24        (JSC::StructureStubInfo::deref):
     25        (JSC::StructureStubInfo::markAggregate):
     26        * bytecode/StructureStubInfo.h:
     27        (JSC::StructureStubInfo::initGetByIdChain):
     28        (JSC::StructureStubInfo::initPutByIdTransition):
     29        * bytecompiler/BytecodeGenerator.cpp:
     30        (JSC::BytecodeGenerator::emitJumpIfNotFunctionCall):
     31        (JSC::BytecodeGenerator::emitJumpIfNotFunctionApply):
     32        * collector/handles/Handle.h:
     33        (JSC::HandleConverter::operator->):
     34        (JSC::HandleConverter::operator*):
     35        * interpreter/Interpreter.cpp:
     36        (JSC::Interpreter::privateExecute):
     37        * jit/JITOpcodes.cpp:
     38        (JSC::JIT::emit_op_jneq_ptr):
     39        * jit/JITOpcodes32_64.cpp:
     40        (JSC::JIT::emit_op_jneq_ptr):
     41        * jit/JITPropertyAccess.cpp:
     42        (JSC::JIT::privateCompileGetByIdChainList):
     43        * jit/JITPropertyAccess32_64.cpp:
     44        (JSC::JIT::privateCompileGetByIdChainList):
     45        * jit/JITStubs.cpp:
     46        (JSC::JITThunks::tryCachePutByID):
     47        (JSC::JITThunks::tryCacheGetByID):
     48        (JSC::getPolymorphicAccessStructureListSlot):
     49        (JSC::DEFINE_STUB_FUNCTION):
     50        * runtime/JSCell.h:
     51        * runtime/JSGlobalData.cpp:
     52        (JSC::JSGlobalData::JSGlobalData):
     53        * runtime/JSGlobalData.h:
     54        * runtime/JSGlobalObject.cpp:
     55        (JSC::markIfNeeded):
     56        * runtime/JSGlobalObject.h:
     57        (JSC::Structure::prototypeChain):
     58        * runtime/JSObject.h:
     59        (JSC::JSObject::putDirectInternal):
     60        (JSC::JSObject::markChildrenDirect):
     61        * runtime/JSPropertyNameIterator.cpp:
     62        (JSC::JSPropertyNameIterator::create):
     63        (JSC::JSPropertyNameIterator::get):
     64        (JSC::JSPropertyNameIterator::markChildren):
     65        * runtime/JSPropertyNameIterator.h:
     66        (JSC::JSPropertyNameIterator::setCachedPrototypeChain):
     67        * runtime/JSZombie.cpp:
     68        (JSC::JSZombie::leakedZombieStructure):
     69        * runtime/JSZombie.h:
     70        * runtime/MarkStack.h:
     71        (JSC::MarkStack::append):
     72        * runtime/MarkedBlock.cpp:
     73        (JSC::MarkedBlock::sweep):
     74        * runtime/Structure.cpp:
     75        (JSC::Structure::addPropertyTransition):
     76        * runtime/Structure.h:
     77        (JSC::Structure::markAggregate):
     78        * runtime/StructureChain.cpp:
     79        (JSC::StructureChain::StructureChain):
     80        (JSC::StructureChain::~StructureChain):
     81        (JSC::StructureChain::markChildren):
     82        * runtime/StructureChain.h:
     83        (JSC::StructureChain::create):
     84        (JSC::StructureChain::createStructure):
     85        * runtime/WriteBarrier.h:
     86        (JSC::WriteBarrierBase::get):
     87        (JSC::WriteBarrierBase::operator*):
     88        (JSC::WriteBarrierBase::operator->):
     89
    1902011-04-01  Geoffrey Garen  <ggaren@apple.com>
    291
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r82173 r82849  
    315315__ZN3JSC9Structure17stopIgnoringLeaksEv
    316316__ZN3JSC9Structure18startIgnoringLeaksEv
    317 __ZN3JSC9Structure21addPropertyTransitionEPS0_RKNS_10IdentifierEjPNS_6JSCellERm
     317__ZN3JSC9Structure21addPropertyTransitionERNS_12JSGlobalDataEPS0_RKNS_10IdentifierEjPNS_6JSCellERm
    318318__ZN3JSC9Structure22materializePropertyMapEv
    319319__ZN3JSC9Structure25changePrototypeTransitionEPS0_NS_7JSValueE
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r82173 r82849  
    5252    ?addBytes@SHA1@WTF@@QAEXPBEI@Z
    5353    ?addCurrentThread@MachineThreads@JSC@@QAEXXZ
    54     ?addPropertyTransition@Structure@JSC@@SA?AV?$PassRefPtr@VStructure@JSC@@@WTF@@PAV12@ABVIdentifier@2@IPAVJSCell@2@AAI@Z
     54    ?addPropertyTransition@Structure@JSC@@SA?AV?$PassRefPtr@VStructure@JSC@@@WTF@@AAVJSGlobalData@2@PAV12@ABVIdentifier@2@IPAVJSCell@2@AAI@Z
    5555    ?addPropertyTransitionToExistingStructure@Structure@JSC@@SA?AV?$PassRefPtr@VStructure@JSC@@@WTF@@PAV12@ABVIdentifier@2@IPAVJSCell@2@AAI@Z
    5656    ?addPropertyWithoutTransition@Structure@JSC@@QAEIABVIdentifier@2@IPAVJSCell@2@@Z
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r82519 r82849  
    732732            int r0 = (++it)->u.operand;
    733733            int id0 = (++it)->u.operand;
    734             JSValue scope = JSValue((++it)->u.jsCell);
     734            JSValue scope = JSValue((++it)->u.jsCell.get());
    735735            ++it;
    736736            int depth = (++it)->u.operand;
     
    14381438    if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_chain)) {
    14391439        vPC[4].u.structure->deref();
    1440         vPC[5].u.structureChain->deref();
    14411440        return;
    14421441    }
     
    14441443        vPC[4].u.structure->deref();
    14451444        vPC[5].u.structure->deref();
    1446         vPC[6].u.structureChain->deref();
    14471445        return;
    14481446    }
     
    14871485    if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_chain)) {
    14881486        vPC[4].u.structure->ref();
    1489         vPC[5].u.structureChain->ref();
    14901487        return;
    14911488    }
     
    14931490        vPC[4].u.structure->ref();
    14941491        vPC[5].u.structure->ref();
    1495         vPC[6].u.structureChain->ref();
    14961492        return;
    14971493    }
     
    15281524            markStack.append(&callLinkInfo(i).callee);
    15291525#endif
     1526#if ENABLE(INTERPRETER)
     1527    Interpreter* interpreter = m_globalData->interpreter;
     1528    for (size_t size = m_propertyAccessInstructions.size(), i = 0; i < size; ++i) {
     1529        Instruction* vPC = &m_instructions[m_propertyAccessInstructions[i]];
     1530        if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_getter_chain) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_custom_chain))
     1531            markStack.append(&vPC[5].u.structureChain);
     1532        else if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition))
     1533            markStack.append(&vPC[6].u.structureChain);
     1534    }
     1535#endif
     1536#if ENABLE(JIT)
     1537    for (size_t size = m_globalResolveInfos.size(), i = 0; i < size; ++i) {
     1538        if (Structure* structure = m_globalResolveInfos[i].structure)
     1539            structure->markAggregate(markStack);
     1540    }
     1541
     1542    for (size_t size = m_structureStubInfos.size(), i = 0; i < size; ++i)
     1543        m_structureStubInfos[i].markAggregate(markStack);
     1544
     1545    for (size_t size = m_methodCallLinkInfos.size(), i = 0; i < size; ++i) {
     1546        if (Structure* structure = m_methodCallLinkInfos[i].cachedStructure) {
     1547            // Both members must be filled at the same time
     1548            structure->markAggregate(markStack);
     1549            ASSERT(!!m_methodCallLinkInfos[i].cachedPrototypeStructure);
     1550            m_methodCallLinkInfos[i].cachedPrototypeStructure->markAggregate(markStack);
     1551        }
     1552    }
     1553#endif
    15301554}
    15311555
  • trunk/Source/JavaScriptCore/bytecode/Instruction.h

    r82519 r82849  
    3434#include "PropertySlot.h"
    3535#include "Structure.h"
     36#include "StructureChain.h"
    3637#include <wtf/VectorTraits.h>
    3738
     
    6465            union {
    6566                Structure* proto;
    66                 StructureChain* chain;
     67                WriteBarrierBase<StructureChain> chain;
    6768            } u;
    6869
     
    8384            }
    8485           
    85             void set(PolymorphicAccessStructureListStubRoutineType _stubRoutine, Structure* _base, StructureChain* _chain)
     86            void set(JSGlobalData& globalData, JSCell* owner, PolymorphicAccessStructureListStubRoutineType _stubRoutine, Structure* _base, StructureChain* _chain)
    8687            {
    8788                stubRoutine = _stubRoutine;
    8889                base = _base;
    89                 u.chain = _chain;
     90                u.chain.set(globalData, owner, _chain);
    9091                isChain = true;
    9192            }
     
    102103        }
    103104
    104         PolymorphicAccessStructureList(PolymorphicAccessStructureListStubRoutineType stubRoutine, Structure* firstBase, StructureChain* firstChain)
     105        PolymorphicAccessStructureList(JSGlobalData& globalData, JSCell* owner, PolymorphicAccessStructureListStubRoutineType stubRoutine, Structure* firstBase, StructureChain* firstChain)
    105106        {
    106             list[0].set(stubRoutine, firstBase, firstChain);
     107            list[0].set(globalData, owner, stubRoutine, firstBase, firstChain);
    107108        }
    108109
     
    116117
    117118                if (info.u.proto) {
    118                     if (info.isChain)
    119                         info.u.chain->deref();
    120                     else
     119                    if (!info.isChain)
    121120                        info.u.proto->deref();
    122121                }
     122            }
     123        }
     124
     125        void markAggregate(MarkStack& markStack, int count)
     126        {
     127            for (int i = 0; i < count; ++i) {
     128                PolymorphicStubInfo& info = list[i];
     129                ASSERT(info.base);
     130               
     131                if (info.u.chain && info.isChain)
     132                    markStack.append(&info.u.chain);
    123133            }
    124134        }
     
    131141            // We have to initialize one of the pointer members to ensure that
    132142            // the entire struct is initialized, when opcode is not a pointer.
    133             u.jsCell = 0;
     143            u.jsCell.clear();
    134144#endif
    135145            u.opcode = opcode;
     
    140150            // We have to initialize one of the pointer members to ensure that
    141151            // the entire struct is initialized in 64-bit.
    142             u.jsCell = 0;
     152            u.jsCell.clear();
    143153            u.operand = operand;
    144154        }
    145155
    146156        Instruction(Structure* structure) { u.structure = structure; }
    147         Instruction(StructureChain* structureChain) { u.structureChain = structureChain; }
    148         Instruction(JSCell* jsCell) { u.jsCell = jsCell; }
     157        Instruction(JSGlobalData& globalData, JSCell* owner, StructureChain* structureChain)
     158        {
     159            u.structureChain.clear();
     160            u.structureChain.set(globalData, owner, structureChain);
     161        }
     162        Instruction(JSGlobalData& globalData, JSCell* owner, JSCell* jsCell)
     163        {
     164            u.jsCell.clear();
     165            u.jsCell.set(globalData, owner, jsCell);
     166        }
    149167        Instruction(PolymorphicAccessStructureList* polymorphicStructures) { u.polymorphicStructures = polymorphicStructures; }
    150168        Instruction(PropertySlot::GetValueFunc getterFunc) { u.getterFunc = getterFunc; }
     
    154172            int operand;
    155173            Structure* structure;
    156             StructureChain* structureChain;
    157             JSCell* jsCell;
     174            WriteBarrierBase<StructureChain> structureChain;
     175            WriteBarrierBase<JSCell> jsCell;
    158176            PolymorphicAccessStructureList* polymorphicStructures;
    159177            PropertySlot::GetValueFunc getterFunc;
  • trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp

    r82519 r82849  
    4545    case access_get_by_id_chain:
    4646        u.getByIdChain.baseObjectStructure->deref();
    47         u.getByIdChain.chain->deref();
    4847        return;
    4948    case access_get_by_id_self_list: {
     
    6160    case access_put_by_id_transition:
    6261        u.putByIdTransition.previousStructure->deref();
    63         u.putByIdTransition.structure->deref();
    64         u.putByIdTransition.chain->deref();
    6562        return;
    6663    case access_put_by_id_replace:
     
    7976    }
    8077}
     78
     79void StructureStubInfo::markAggregate(MarkStack& markStack)
     80{
     81    switch (accessType) {
     82    case access_get_by_id_self:
     83        u.getByIdSelf.baseObjectStructure->markAggregate(markStack);
     84        return;
     85    case access_get_by_id_proto:
     86        u.getByIdProto.baseObjectStructure->markAggregate(markStack);
     87        u.getByIdProto.prototypeStructure->markAggregate(markStack);
     88        return;
     89    case access_get_by_id_chain:
     90        u.getByIdChain.baseObjectStructure->markAggregate(markStack);
     91        markStack.append(&u.getByIdChain.chain);
     92        return;
     93    case access_get_by_id_self_list: {
     94        PolymorphicAccessStructureList* polymorphicStructures = u.getByIdSelfList.structureList;
     95        polymorphicStructures->markAggregate(markStack, u.getByIdSelfList.listSize);
     96        return;
     97    }
     98    case access_get_by_id_proto_list: {
     99        PolymorphicAccessStructureList* polymorphicStructures = u.getByIdProtoList.structureList;
     100        polymorphicStructures->markAggregate(markStack, u.getByIdProtoList.listSize);
     101        return;
     102    }
     103    case access_put_by_id_transition:
     104        u.putByIdTransition.previousStructure->markAggregate(markStack);
     105        u.putByIdTransition.structure->markAggregate(markStack);
     106        markStack.append(&u.putByIdTransition.chain);
     107        return;
     108    case access_put_by_id_replace:
     109        u.putByIdReplace.baseObjectStructure->markAggregate(markStack);
     110        return;
     111    case access_get_by_id:
     112    case access_put_by_id:
     113    case access_get_by_id_generic:
     114    case access_put_by_id_generic:
     115    case access_get_array_length:
     116    case access_get_string_length:
     117        // These instructions don't ref their Structures.
     118        return;
     119    default:
     120        ASSERT_NOT_REACHED();
     121    }
     122}
    81123#endif
    82124
  • trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h

    r82519 r82849  
    7878        }
    7979
    80         void initGetByIdChain(Structure* baseObjectStructure, StructureChain* chain)
     80        void initGetByIdChain(JSGlobalData& globalData, JSCell* owner, Structure* baseObjectStructure, StructureChain* chain)
    8181        {
    8282            accessType = access_get_by_id_chain;
     
    8585            baseObjectStructure->ref();
    8686
    87             u.getByIdChain.chain = chain;
    88             chain->ref();
     87            u.getByIdChain.chain.set(globalData, owner, chain);
    8988        }
    9089
     
    107106        // PutById*
    108107
    109         void initPutByIdTransition(Structure* previousStructure, Structure* structure, StructureChain* chain)
     108        void initPutByIdTransition(JSGlobalData& globalData, JSCell* owner, Structure* previousStructure, Structure* structure, StructureChain* chain)
    110109        {
    111110            accessType = access_put_by_id_transition;
     
    117116            structure->ref();
    118117
    119             u.putByIdTransition.chain = chain;
    120             chain->ref();
     118            u.putByIdTransition.chain.set(globalData, owner, chain);
    121119        }
    122120
     
    130128
    131129        void deref();
     130        void markAggregate(MarkStack&);
    132131
    133132        bool seenOnce()
     
    154153            struct {
    155154                Structure* baseObjectStructure;
    156                 StructureChain* chain;
     155                WriteBarrierBase<StructureChain> chain;
    157156            } getByIdChain;
    158157            struct {
     
    167166                Structure* previousStructure;
    168167                Structure* structure;
    169                 StructureChain* chain;
     168                WriteBarrierBase<StructureChain> chain;
    170169            } putByIdTransition;
    171170            struct {
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r82519 r82849  
    926926    emitOpcode(op_jneq_ptr);
    927927    instructions().append(cond->index());
    928     instructions().append(m_scopeChain->globalObject->callFunction());
     928    instructions().append(Instruction(*m_globalData, m_codeBlock->ownerExecutable(), m_scopeChain->globalObject->callFunction()));
    929929    instructions().append(target->bind(begin, instructions().size()));
    930930    return target;
     
    937937    emitOpcode(op_jneq_ptr);
    938938    instructions().append(cond->index());
    939     instructions().append(m_scopeChain->globalObject->applyFunction());
     939    instructions().append(Instruction(*m_globalData, m_codeBlock->ownerExecutable(), m_scopeChain->globalObject->applyFunction()));
    940940    instructions().append(target->bind(begin, instructions().size()));
    941941    return target;
  • trunk/Source/JavaScriptCore/collector/handles/Handle.h

    r81188 r82849  
    105105
    106106template <typename Base, typename T> struct HandleConverter {
    107     T* operator->() { return static_cast<Base*>(this)->get(); }
    108     const T* operator->() const { return static_cast<const Base*>(this)->get(); }
    109     T* operator*() { return static_cast<Base*>(this)->get(); }
    110     const T* operator*() const { return static_cast<const Base*>(this)->get(); }
     107    T* operator->()
     108    {
     109#if ENABLE(JSC_ZOMBIES)
     110        ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get()->isZombie());
     111#endif
     112        return static_cast<Base*>(this)->get();
     113    }
     114    const T* operator->() const
     115    {
     116#if ENABLE(JSC_ZOMBIES)
     117        ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get()->isZombie());
     118#endif
     119        return static_cast<const Base*>(this)->get();
     120    }
     121
     122    T* operator*()
     123    {
     124#if ENABLE(JSC_ZOMBIES)
     125        ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get()->isZombie());
     126#endif
     127        return static_cast<Base*>(this)->get();
     128    }
     129    const T* operator*() const
     130    {
     131#if ENABLE(JSC_ZOMBIES)
     132        ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get()->isZombie());
     133#endif
     134        return static_cast<const Base*>(this)->get();
     135    }
    111136};
    112137
     
    119144
    120145private:
    121     JSValue jsValue() const { return static_cast<const Base*>(this)->get(); }
     146    JSValue jsValue() const
     147    {
     148#if ENABLE(JSC_ZOMBIES)
     149        ASSERT(!static_cast<const Base*>(this)->get() || !static_cast<const Base*>(this)->get().isZombie());
     150#endif
     151        return static_cast<const Base*>(this)->get();
     152    }
    122153};
    123154
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r82519 r82849  
    35383538         */
    35393539        int src = vPC[1].u.operand;
    3540         JSValue ptr = JSValue(vPC[2].u.jsCell);
    35413540        int target = vPC[3].u.operand;
    35423541        JSValue srcValue = callFrame->r(src).jsValue();
    3543         if (srcValue != ptr) {
     3542        if (srcValue != vPC[2].u.jsCell.get()) {
    35443543            vPC += target;
    35453544            NEXT_INSTRUCTION();
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r82519 r82849  
    763763{
    764764    unsigned src = currentInstruction[1].u.operand;
    765     JSCell* ptr = currentInstruction[2].u.jsCell;
     765    JSCell* ptr = currentInstruction[2].u.jsCell.get();
    766766    unsigned target = currentInstruction[3].u.operand;
    767767   
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r82519 r82849  
    980980{
    981981    unsigned src = currentInstruction[1].u.operand;
    982     JSCell* ptr = currentInstruction[2].u.jsCell;
     982    JSCell* ptr = currentInstruction[2].u.jsCell.get();
    983983    unsigned target = currentInstruction[3].u.operand;
    984984
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp

    r82519 r82849  
    980980    // Track the stub we have created so that it will be deleted later.
    981981    structure->ref();
    982     chain->ref();
    983     prototypeStructures->list[currentIndex].set(entryLabel, structure, chain);
     982    prototypeStructures->list[currentIndex].set(callFrame->globalData(), m_codeBlock->ownerExecutable(), entryLabel, structure, chain);
    984983
    985984    // Finally patch the jump to slow case back in the hot path to jump here instead.
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp

    r82519 r82849  
    10081008    // Track the stub we have created so that it will be deleted later.
    10091009    structure->ref();
    1010     chain->ref();
    1011     prototypeStructures->list[currentIndex].set(entryLabel, structure, chain);
     1010    prototypeStructures->list[currentIndex].set(callFrame->globalData(), m_codeBlock->ownerExecutable(), entryLabel, structure, chain);
    10121011   
    10131012    // Finally patch the jump to slow case back in the hot path to jump here instead.
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r82519 r82849  
    772772
    773773        StructureChain* prototypeChain = structure->prototypeChain(callFrame);
    774         stubInfo->initPutByIdTransition(structure->previousID(), structure, prototypeChain);
     774        stubInfo->initPutByIdTransition(callFrame->globalData(), codeBlock->ownerExecutable(), structure->previousID(), structure, prototypeChain);
    775775        JIT::compilePutByIdTransition(callFrame->scopeChain()->globalData, codeBlock, stubInfo, structure->previousID(), structure, slot.cachedOffset(), prototypeChain, returnAddress, direct);
    776776        return;
     
    867867
    868868    StructureChain* prototypeChain = structure->prototypeChain(callFrame);
    869     stubInfo->initGetByIdChain(structure, prototypeChain);
     869    stubInfo->initGetByIdChain(callFrame->globalData(), codeBlock->ownerExecutable(), structure, prototypeChain);
    870870    JIT::compileGetByIdChain(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, structure, prototypeChain, count, propertyName, slot, offset, returnAddress);
    871871}
     
    15541554}
    15551555
    1556 static PolymorphicAccessStructureList* getPolymorphicAccessStructureListSlot(StructureStubInfo* stubInfo, int& listIndex)
     1556static PolymorphicAccessStructureList* getPolymorphicAccessStructureListSlot(JSGlobalData& globalData, ScriptExecutable* owner, StructureStubInfo* stubInfo, int& listIndex)
    15571557{
    15581558    PolymorphicAccessStructureList* prototypeStructureList = 0;
     
    15661566        break;
    15671567    case access_get_by_id_chain:
    1568         prototypeStructureList = new PolymorphicAccessStructureList(stubInfo->stubRoutine, stubInfo->u.getByIdChain.baseObjectStructure, stubInfo->u.getByIdChain.chain);
     1568        prototypeStructureList = new PolymorphicAccessStructureList(globalData, owner, stubInfo->stubRoutine, stubInfo->u.getByIdChain.baseObjectStructure, stubInfo->u.getByIdChain.chain.get());
    15691569        stubInfo->stubRoutine = CodeLocationLabel();
    15701570        stubInfo->initGetByIdProtoList(prototypeStructureList, 2);
     
    16541654
    16551655        int listIndex;
    1656         PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(stubInfo, listIndex);
     1656        PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(callFrame->globalData(), codeBlock->ownerExecutable(), stubInfo, listIndex);
    16571657        if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
    16581658            JIT::compileGetByIdProtoList(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, slotBaseObject->structure(), propertyName, slot, offset);
     
    16641664        ASSERT(!baseValue.asCell()->structure()->isDictionary());
    16651665        int listIndex;
    1666         PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(stubInfo, listIndex);
     1666        PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(callFrame->globalData(), codeBlock->ownerExecutable(), stubInfo, listIndex);
    16671667       
    16681668        if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r82519 r82849  
    6969        friend class MarkedBlock;
    7070        friend class ScopeChainNode;
     71        friend class StructureChain;
    7172
    7273    private:
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r82519 r82849  
    185185    functionExecutableStructure = FunctionExecutable::createStructure(*this, jsNull());
    186186    dummyMarkableCellStructure = JSCell::createDummyStructure(*this);
     187    structureChainStructure = StructureChain::createStructure(*this, jsNull());
    187188
    188189    interpreter = new Interpreter(*this);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r82519 r82849  
    162162        RefPtr<Structure> functionExecutableStructure;
    163163        RefPtr<Structure> dummyMarkableCellStructure;
     164        RefPtr<Structure> structureChainStructure;
    164165
    165166        static void storeVPtrs();
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r82519 r82849  
    8787static inline void markIfNeeded(MarkStack& markStack, const RefPtr<Structure>& s)
    8888{
    89     if (s && s->storedPrototype())
    90         markStack.append(s->storedPrototypeSlot());
     89    if (s)
     90        s->markAggregate(markStack);
    9191}
    9292
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r82519 r82849  
    2929#include "NumberPrototype.h"
    3030#include "StringPrototype.h"
     31#include "StructureChain.h"
    3132#include <wtf/HashSet.h>
    3233#include <wtf/OwnPtr.h>
     
    363364        if (!isValid(exec, m_cachedPrototypeChain.get())) {
    364365            JSValue prototype = prototypeForLookup(exec);
    365             m_cachedPrototypeChain = StructureChain::create(prototype.isNull() ? 0 : asObject(prototype)->structure());
     366            m_cachedPrototypeChain.set(exec->globalData(), StructureChain::create(exec->globalData(), prototype.isNull() ? 0 : asObject(prototype)->structure()), 0);
    366367        }
    367368        return m_cachedPrototypeChain.get();
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r82519 r82849  
    646646        return false;
    647647
    648     RefPtr<Structure> structure = Structure::addPropertyTransition(m_structure, propertyName, attributes, specificFunction, offset);
     648    RefPtr<Structure> structure = Structure::addPropertyTransition(globalData, m_structure, propertyName, attributes, specificFunction, offset);
    649649
    650650    if (currentCapacity != structure->propertyStorageCapacity())
     
    816816    JSCell::markChildren(markStack);
    817817
    818     markStack.append(m_structure->storedPrototypeSlot());
     818    m_structure->markAggregate(markStack);
    819819    PropertyStorage storage = propertyStorage();
    820820    size_t storageSize = m_structure->propertyStorageSize();
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp

    r82519 r82849  
    7878    }
    7979
    80     jsPropertyNameIterator->setCachedPrototypeChain(structureChain);
     80    jsPropertyNameIterator->setCachedPrototypeChain(exec->globalData(), structureChain);
    8181    jsPropertyNameIterator->setCachedStructure(o->structure());
    8282    o->structure()->setEnumerationCache(exec->globalData(), jsPropertyNameIterator);
     
    8787{
    8888    JSValue identifier = m_jsStrings[i].get();
    89     if (m_cachedStructure == base->structure() && m_cachedPrototypeChain == base->structure()->prototypeChain(exec))
     89    if (m_cachedStructure == base->structure() && m_cachedPrototypeChain.get() == base->structure()->prototypeChain(exec))
    9090        return identifier;
    9191
     
    9898{
    9999    markStack.appendValues(m_jsStrings.get(), m_jsStringsSize, MayContainNullValues);
     100    if (m_cachedPrototypeChain)
     101        markStack.append(&m_cachedPrototypeChain);
    100102}
    101103
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameIterator.h

    r82519 r82849  
    7474        Structure* cachedStructure() { return m_cachedStructure.get(); }
    7575
    76         void setCachedPrototypeChain(NonNullPassRefPtr<StructureChain> cachedPrototypeChain) { m_cachedPrototypeChain = cachedPrototypeChain; }
     76        void setCachedPrototypeChain(JSGlobalData& globalData, StructureChain* cachedPrototypeChain) { m_cachedPrototypeChain.set(globalData, this, cachedPrototypeChain); }
    7777        StructureChain* cachedPrototypeChain() { return m_cachedPrototypeChain.get(); }
    7878
     
    8585
    8686        RefPtr<Structure> m_cachedStructure;
    87         RefPtr<StructureChain> m_cachedPrototypeChain;
     87        WriteBarrier<StructureChain> m_cachedPrototypeChain;
    8888        uint32_t m_numCacheableSlots;
    8989        uint32_t m_jsStringsSize;
  • trunk/Source/JavaScriptCore/runtime/JSZombie.cpp

    r81040 r82849  
    3636const ClassInfo JSZombie::s_info = { "Zombie", 0, 0, 0 };
    3737
    38 Structure* JSZombie::leakedZombieStructure() {
     38Structure* JSZombie::leakedZombieStructure(JSGlobalData& globalData)
     39{
    3940    static Structure* structure = 0;
    4041    if (!structure) {
    4142        Structure::startIgnoringLeaks();
    42         structure = Structure::create(jsNull(), TypeInfo(UnspecifiedType), 0, &s_info).leakRef();
     43        structure = Structure::create(globalData, jsNull(), TypeInfo(UnspecifiedType), 0, &s_info).leakRef();
    4344        Structure::stopIgnoringLeaks();
    4445    }
  • trunk/Source/JavaScriptCore/runtime/JSZombie.h

    r81272 r82849  
    4242
    4343    virtual bool isZombie() const { return true; }
    44     static Structure* leakedZombieStructure();
     44    static Structure* leakedZombieStructure(JSGlobalData&);
    4545
    4646    virtual bool isGetterSetter() const { ASSERT_NOT_REACHED(); return false; }
  • trunk/Source/JavaScriptCore/runtime/MarkStack.h

    r82519 r82849  
    216216    template <typename T> inline void MarkStack::append(DeprecatedPtr<T>* slot)
    217217    {
    218         internalAppend(slot->get());
     218        internalAppend(*slot->slot());
    219219    }
    220220   
    221221    template <typename T> inline void MarkStack::append(WriteBarrierBase<T>* slot)
    222222    {
    223         internalAppend(slot->get());
     223        internalAppend(*slot->slot());
    224224    }
    225225
  • trunk/Source/JavaScriptCore/runtime/MarkedBlock.cpp

    r81040 r82849  
    7979            const ClassInfo* info = cell->classInfo();
    8080            cell->~JSCell();
    81             new (cell) JSZombie(info, JSZombie::leakedZombieStructure());
     81            new (cell) JSZombie(info, JSZombie::leakedZombieStructure(*m_heap->globalData()));
    8282            m_marks.set(i);
    8383        }
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r80378 r82849  
    368368}
    369369
    370 PassRefPtr<Structure> Structure::addPropertyTransition(Structure* structure, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset)
     370PassRefPtr<Structure> Structure::addPropertyTransition(JSGlobalData& globalData, Structure* structure, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset)
    371371{
    372372    // If we have a specific function, we may have got to this point if there is
     
    400400    RefPtr<Structure> transition = create(structure);
    401401
    402     transition->m_cachedPrototypeChain = structure->m_cachedPrototypeChain;
     402    transition->m_cachedPrototypeChain.set(globalData, structure->m_cachedPrototypeChain.get(), 0);
    403403    transition->m_previous = structure;
    404404    transition->m_nameInPrevious = propertyName.impl();
  • trunk/Source/JavaScriptCore/runtime/Structure.h

    r82519 r82849  
    3333#include "PropertyNameArray.h"
    3434#include "Protect.h"
    35 #include "StructureChain.h"
    3635#include "StructureTransitionTable.h"
    3736#include "JSTypeInfo.h"
     
    4746    class PropertyNameArray;
    4847    class PropertyNameArrayData;
     48    class StructureChain;
    4949
    5050    struct ClassInfo;
     
    7474        static void dumpStatistics();
    7575
    76         static PassRefPtr<Structure> addPropertyTransition(Structure*, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset);
     76        static PassRefPtr<Structure> addPropertyTransition(JSGlobalData&, Structure*, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset);
    7777        static PassRefPtr<Structure> addPropertyTransitionToExistingStructure(Structure*, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset);
    7878        static PassRefPtr<Structure> removePropertyTransition(Structure*, const Identifier& propertyName, size_t& offset);
     
    105105
    106106        JSValue storedPrototype() const { return m_prototype.get(); }
    107         DeprecatedPtr<Unknown>* storedPrototypeSlot() { return &m_prototype; }
    108107        JSValue prototypeForLookup(ExecState*) const;
    109108        StructureChain* prototypeChain(ExecState*) const;
     109        void markAggregate(MarkStack& markStack)
     110        {
     111            if (m_prototype)
     112                markStack.append(&m_prototype);
     113        }
    110114
    111115        Structure* previousID() const { return m_previous.get(); }
     
    211215
    212216        DeprecatedPtr<Unknown> m_prototype;
    213         mutable RefPtr<StructureChain> m_cachedPrototypeChain;
     217        mutable WeakGCPtr<StructureChain> m_cachedPrototypeChain;
    214218
    215219        RefPtr<Structure> m_previous;
  • trunk/Source/JavaScriptCore/runtime/StructureChain.cpp

    r82519 r82849  
    3333namespace JSC {
    3434
    35 StructureChain::StructureChain(Structure* head)
     35StructureChain::StructureChain(NonNullPassRefPtr<Structure> structure, Structure* head)
     36    : JSCell(structure.releaseRef())
    3637{
    3738    size_t size = 0;
     
    4748}
    4849
     50StructureChain::~StructureChain()
     51{
     52}
     53
     54void StructureChain::markChildren(MarkStack& markStack)
     55{
     56    size_t i = 0;
     57    while (m_vector[i])
     58        m_vector[i++]->markAggregate(markStack);
     59}
     60
    4961} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/StructureChain.h

    r82519 r82849  
    2727#define StructureChain_h
    2828
     29#include "JSCell.h"
     30
    2931#include <wtf/OwnArrayPtr.h>
    3032#include <wtf/PassRefPtr.h>
     
    3638    class Structure;
    3739
    38     class StructureChain : public RefCounted<StructureChain> {
     40    class StructureChain : public JSCell {
    3941        friend class JIT;
    4042
    4143    public:
    42         static PassRefPtr<StructureChain> create(Structure* head) { return adoptRef(new StructureChain(head)); }
     44        static StructureChain* create(JSGlobalData& globalData, Structure* head) { return new (&globalData) StructureChain(globalData.structureChainStructure, head); }
    4345        RefPtr<Structure>* head() { return m_vector.get(); }
     46        void markChildren(MarkStack&);
     47
     48        static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(CompoundType, OverridesMarkChildren), 0, 0); }
    4449
    4550    private:
    46         StructureChain(Structure* head);
    47 
     51        StructureChain(NonNullPassRefPtr<Structure>, Structure* head);
     52        ~StructureChain();
    4853        OwnArrayPtr<RefPtr<Structure> > m_vector;
    4954    };
  • trunk/Source/JavaScriptCore/runtime/WriteBarrier.h

    r81191 r82849  
    9595    void set(JSGlobalData&, const JSCell*, T* value) { this->m_cell = reinterpret_cast<JSCell*>(value); }
    9696   
    97     T* get() const { return reinterpret_cast<T*>(m_cell); }
    98     T* operator*() const { return static_cast<T*>(m_cell); }
    99     T* operator->() const { return static_cast<T*>(m_cell); }
     97    T* get() const
     98    {
     99        return reinterpret_cast<T*>(m_cell);
     100    }
     101
     102    T* operator*() const
     103    {
     104        return static_cast<T*>(m_cell);
     105    }
     106
     107    T* operator->() const
     108    {
     109        return static_cast<T*>(m_cell);
     110    }
     111
    100112    void clear() { m_cell = 0; }
    101113   
     
    117129    void set(JSGlobalData&, const JSCell*, JSValue value) { m_value = JSValue::encode(value); }
    118130    void setWithoutWriteBarrier(JSValue value) { m_value = JSValue::encode(value); }
    119     JSValue get() const { return JSValue::decode(m_value); }
     131    JSValue get() const
     132    {
     133#if ENABLE(JSC_ZOMBIES)
     134        ASSERT(!JSValue::decode(m_value) || !JSValue::decode(m_value).isZombie());
     135#endif
     136        return JSValue::decode(m_value);
     137    }
    120138    void clear() { m_value = JSValue::encode(JSValue()); }
    121139    void setUndefined() { m_value = JSValue::encode(jsUndefined()); }
  • trunk/Source/WebCore/ChangeLog

    r82847 r82849  
     12011-04-01  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        Make StructureChain GC allocated
     6        https://bugs.webkit.org/show_bug.cgi?id=56695
     7
     8        Update for new Structure marking function
     9
     10        * bindings/js/JSDOMGlobalObject.cpp:
     11        (WebCore::JSDOMGlobalObject::markChildren):
     12
    1132011-04-04  Pavel Feldman  <pfeldman@google.com>
    214
  • trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp

    r80742 r82849  
    5757    JSDOMStructureMap::iterator end = structures().end();
    5858    for (JSDOMStructureMap::iterator it = structures().begin(); it != end; ++it)
    59         markStack.append(it->second->storedPrototypeSlot());
     59        it->second->markAggregate(markStack);
    6060
    6161    JSDOMConstructorMap::iterator end2 = constructors().end();
Note: See TracChangeset for help on using the changeset viewer.