Changeset 51624 in webkit


Ignore:
Timestamp:
Dec 2, 2009 10:25:58 PM (14 years ago)
Author:
oliver@apple.com
Message:

Add zombies to JSC
https://bugs.webkit.org/show_bug.cgi?id=32103

Reviewed by Gavin Barraclough.

Add a compile time flag to make the JSC collector replace "unreachable"
objects with zombie objects. The zombie object is a JSCell subclass that
ASSERTs on any attempt to use the JSCell methods. In addition there are
a number of additional assertions in bottleneck code to catch zombie usage
as quickly as possible.

Grrr. Argh. Brains.

Location:
trunk/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r51566 r51624  
     12009-12-02  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Add zombies to JSC
     6        https://bugs.webkit.org/show_bug.cgi?id=32103
     7
     8        Add a compile time flag to make the JSC collector replace "unreachable"
     9        objects with zombie objects.  The zombie object is a JSCell subclass that
     10        ASSERTs on any attempt to use the JSCell methods.  In addition there are
     11        a number of additional assertions in bottleneck code to catch zombie usage
     12        as quickly as possible.
     13
     14        Grrr. Argh. Brains.
     15
     16        * JavaScriptCore.xcodeproj/project.pbxproj:
     17        * interpreter/Register.h:
     18        (JSC::Register::Register):
     19        * runtime/ArgList.h:
     20        (JSC::MarkedArgumentBuffer::append):
     21        (JSC::ArgList::ArgList):
     22        * runtime/Collector.cpp:
     23        (JSC::Heap::destroy):
     24        (JSC::Heap::sweep):
     25        * runtime/Collector.h:
     26        * runtime/JSCell.h:
     27        (JSC::JSCell::isZombie):
     28        (JSC::JSValue::isZombie):
     29        * runtime/JSValue.h:
     30        (JSC::JSValue::decode):
     31        (JSC::JSValue::JSValue):
     32        * wtf/Platform.h:
     33
    1342009-12-01  Jens Alfke  <snej@chromium.org>
    235
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r51337 r51624  
    285285                A7A1F7AD0F252B3C00E184E2 /* ByteArray.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A1F7AB0F252B3C00E184E2 /* ByteArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
    286286                A7B48F490EE8936F00DCBDB6 /* ExecutableAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */; };
     287                A7C2217810C7479400F97913 /* JSZombie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C2216B10C7469C00F97913 /* JSZombie.cpp */; };
    287288                A7C530E4102A3813005BC741 /* MarkStackPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C530E3102A3813005BC741 /* MarkStackPosix.cpp */; };
    288289                A7D649AA1015224E009B2E1B /* PossiblyNull.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D649A91015224E009B2E1B /* PossiblyNull.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    838839                A7B48DB50EE74CFC00DCBDB6 /* ExecutableAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExecutableAllocator.h; sourceTree = "<group>"; };
    839840                A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocator.cpp; sourceTree = "<group>"; };
     841                A7C2216810C745E000F97913 /* JSZombie.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSZombie.h; sourceTree = "<group>"; };
     842                A7C2216B10C7469C00F97913 /* JSZombie.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSZombie.cpp; sourceTree = "<group>"; };
    840843                A7C530E3102A3813005BC741 /* MarkStackPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkStackPosix.cpp; sourceTree = "<group>"; };
    841844                A7D649A91015224E009B2E1B /* PossiblyNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PossiblyNull.h; sourceTree = "<group>"; };
     
    15971600                                F692A8860255597D01FF60F7 /* UString.h */,
    15981601                                1420BE7A10AA6DDB00F455D2 /* WeakRandom.h */,
     1602                                A7C2216810C745E000F97913 /* JSZombie.h */,
     1603                                A7C2216B10C7469C00F97913 /* JSZombie.cpp */,
    15991604                        );
    16001605                        path = runtime;
     
    24492454                                1429DAE10ED2645B00B89619 /* WRECGenerator.cpp in Sources */,
    24502455                                1429DAC00ED263E700B89619 /* WRECParser.cpp in Sources */,
     2456                                A7C2217810C7479400F97913 /* JSZombie.cpp in Sources */,
    24512457                        );
    24522458                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/JavaScriptCore/interpreter/Register.h

    r48067 r51624  
    105105    ALWAYS_INLINE Register::Register(JSValue v)
    106106    {
     107#if ENABLE(JSC_ZOMBIES)
     108        ASSERT(!v.isZombie());
     109#endif
    107110        u.value = JSValue::encode(v);
    108111    }
  • trunk/JavaScriptCore/runtime/ArgList.h

    r48067 r51624  
    105105        {
    106106            ASSERT(!m_isReadOnly);
    107            
     107
     108#if ENABLE(JSC_ZOMBIES)
     109            ASSERT(!v.isZombie());
     110#endif
     111
    108112            if (m_isUsingInlineBuffer && m_size < inlineCapacity) {
    109113                m_vector.uncheckedAppend(v);
     
    188192            , m_argCount(argCount)
    189193        {
     194#if ENABLE(JSC_ZOMBIES)
     195            for (size_t i = 0; i < argCount; i++)
     196                ASSERT(!m_args[i].isZombie());
     197#endif
    190198        }
    191199       
  • trunk/JavaScriptCore/runtime/Collector.cpp

    r50833 r51624  
    3333#include "JSString.h"
    3434#include "JSValue.h"
     35#include "JSZombie.h"
    3536#include "MarkStack.h"
    3637#include "Nodes.h"
     
    195196    sweep<PrimaryHeap>();
    196197    // No need to sweep number heap, because the JSNumber destructor doesn't do anything.
    197 
     198#if ENABLE(JSC_ZOMBIES)
     199    ASSERT(primaryHeap.numLiveObjects == primaryHeap.numZombies);
     200#else
    198201    ASSERT(!primaryHeap.numLiveObjects);
    199 
     202#endif
    200203    freeBlocks(&primaryHeap);
    201204    freeBlocks(&numberHeap);
     
    10371040                        if (cell->u.freeCell.zeroIfFree == 0)
    10381041                            continue;
    1039                        
     1042#if ENABLE(JSC_ZOMBIES)
     1043                        if (!imp->isZombie()) {
     1044                            const ClassInfo* info = imp->classInfo();
     1045                            imp->~JSCell();
     1046                            new (imp) JSZombie(info, JSZombie::leakedZombieStructure());
     1047                            heap.numZombies++;
     1048                        }
     1049#else
    10401050                        imp->~JSCell();
     1051#endif
    10411052                    }
    1042                    
     1053                    --numLiveObjects;
     1054#if !ENABLE(JSC_ZOMBIES)
    10431055                    --usedCells;
    1044                     --numLiveObjects;
    10451056                   
    10461057                    // put cell on the free list
     
    10481059                    cell->u.freeCell.next = freeList - (cell + 1);
    10491060                    freeList = cell;
     1061#endif
    10501062                }
    10511063            }
     
    10601072                        if (heapType != NumberHeap) {
    10611073                            JSCell* imp = reinterpret_cast<JSCell*>(cell);
     1074#if ENABLE(JSC_ZOMBIES)
     1075                            if (!imp->isZombie()) {
     1076                                const ClassInfo* info = imp->classInfo();
     1077                                imp->~JSCell();
     1078                                new (imp) JSZombie(info, JSZombie::leakedZombieStructure());
     1079                                heap.numZombies++;
     1080                            }
     1081#else
    10621082                            imp->~JSCell();
     1083#endif
    10631084                        }
     1085#if !ENABLE(JSC_ZOMBIES)
    10641086                        --usedCells;
    10651087                        --numLiveObjects;
     
    10691091                        cell->u.freeCell.next = freeList - (cell + 1);
    10701092                        freeList = cell;
     1093#endif
    10711094                    }
    10721095                }
  • trunk/JavaScriptCore/runtime/Collector.h

    r49365 r51624  
    6161        size_t numLiveObjectsAtLastCollect;
    6262        size_t extraCost;
     63#if ENABLE(JSC_ZOMBIES)
     64        size_t numZombies;
     65#endif
    6366
    6467        OperationInProgress operationInProgress;
  • trunk/JavaScriptCore/runtime/JSCell.h

    r49955 r51624  
    4343        friend class JSValue;
    4444        friend class JSAPIValueWrapper;
     45        friend class JSZombie;
    4546        friend struct VPtrSet;
    4647
     
    9192
    9293        virtual void markChildren(MarkStack&);
     94#if ENABLE(JSC_ZOMBIES)
     95        virtual bool isZombie() const { return false; }
     96#endif
    9397
    9498        // Object operations, with the toObject operation included.
     
    343347        return cellBlock(c)->heap;
    344348    }
    345 
     349   
     350#if ENABLE(JSC_ZOMBIES)
     351    inline bool JSValue::isZombie() const
     352    {
     353        return isCell() && asCell() && asCell()->isZombie();
     354    }
     355#endif
    346356} // namespace JSC
    347357
  • trunk/JavaScriptCore/runtime/JSValue.h

    r51334 r51624  
    169169        uint32_t toUInt32(ExecState*, bool& ok) const;
    170170
     171#if ENABLE(JSC_ZOMBIES)
     172        bool isZombie() const;
     173#endif
     174
    171175        // Floating point conversions (this is a convenience method for webcore;
    172176        // signle precision float is not a representation used in JS or JSC).
     
    439443        JSValue v;
    440444        v.u.asEncodedJSValue = encodedJSValue;
     445#if ENABLE(JSC_ZOMBIES)
     446        ASSERT(!v.isZombie());
     447#endif
    441448        return v;
    442449    }
     
    485492            u.asBits.tag = EmptyValueTag;
    486493        u.asBits.payload = reinterpret_cast<int32_t>(ptr);
     494#if ENABLE(JSC_ZOMBIES)
     495        ASSERT(!isZombie());
     496#endif
    487497    }
    488498
     
    494504            u.asBits.tag = EmptyValueTag;
    495505        u.asBits.payload = reinterpret_cast<int32_t>(const_cast<JSCell*>(ptr));
     506#if ENABLE(JSC_ZOMBIES)
     507        ASSERT(!isZombie());
     508#endif
    496509    }
    497510
     
    794807        : m_ptr(ptr)
    795808    {
     809#if ENABLE(JSC_ZOMBIES)
     810        ASSERT(!isZombie());
     811#endif
    796812    }
    797813
     
    799815        : m_ptr(const_cast<JSCell*>(ptr))
    800816    {
     817#if ENABLE(JSC_ZOMBIES)
     818        ASSERT(!isZombie());
     819#endif
    801820    }
    802821
  • trunk/JavaScriptCore/wtf/Platform.h

    r51555 r51624  
    924924#define WTF_PLATFORM_CFNETWORK Error USE_macro_should_be_used_with_CFNETWORK
    925925
     926#define ENABLE_JSC_ZOMBIES 0
     927
    926928#endif /* WTF_Platform_h */
Note: See TracChangeset for help on using the changeset viewer.