Skip to content
  •'s avatar
    -dealloc callbacks from wrapped Objective-C objects can happen at bad times · ac6f1fd4 authored
    Reviewed by Darin Adler.
    Currently with the JSC Obj-C API, JS wrappers for client Obj-C objects retain their associated Obj-C 
    object. When they are swept, they release their Obj-C objects which can trigger a call to that 
    object's -dealloc method. These -dealloc methods can then call back into the same VM, which is not 
    allowed during sweeping or VM shutdown.
    We can handle this case by creating our own pool of Obj-C objects to be released when it is safe to do so.
    This is accomplished by using DelayedReleaseScope, an RAII-style object that will retain all objects
    that are unsafe to release until the end of the DelayedReleaseScope.
    * API/APIShims.h:
    * API/
    * API/
    * API/tests/
    (-[TinyDOMNode initWithVirtualMachine:]):
    (-[TinyDOMNode dealloc]):
    (-[TinyDOMNode appendChild:]):
    (-[TinyDOMNode removeChildAtIndex:]):
    (-[EvilAllocationObject initWithContext:]):
    (-[EvilAllocationObject dealloc]):
    (-[EvilAllocationObject doEvilThingsWithContext:]):
    * JavaScriptCore.xcodeproj/project.pbxproj:
    * heap/DelayedReleaseScope.h: Added.
    * heap/Heap.cpp:
    * heap/Heap.h:
    * heap/MarkedAllocator.cpp:
    * heap/MarkedSpace.cpp:
    * heap/MarkedSpace.h:
    git-svn-id: 268f45cc-cd09-0410-ab3c-d52691b4dbfc