Ignore:
Timestamp:
Aug 10, 2009, 9:35:02 PM (16 years ago)
Author:
[email protected]
Message:

Stack overflow crash in JavaScript garbage collector mark pass
https://bugs.webkit.org/show_bug.cgi?id=12216

Reviewed by Gavin Barraclough and Sam Weinig

Make the GC mark phase iterative by using an explicit mark stack.
To do this marking any single object is performed in multiple stages

  • The object is appended to the MarkStack, this sets the marked bit for the object using the new markDirect() function, and then returns
  • When the MarkStack is drain()ed the object is popped off the stack and markChildren(MarkStack&) is called on the object to collect all of its children. drain() then repeats until the stack is empty.

Additionally I renamed a number of methods from 'mark' to 'markAggregate'
in order to make it more clear that marking of those object was not
going to result in an actual recursive mark.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/MarkStackWin.cpp

    r47021 r47022  
    11/*
    2  * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2009 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#include "config.h"
    2727
    28 #if ENABLE(WORKERS)
    2928
    30 #include "JSWorker.h"
     29#include "MarkStack.h"
    3130
    32 #include "JSDOMGlobalObject.h"
    33 #include "Worker.h"
     31#include "windows.h"
    3432
    35 using namespace JSC;
    36 
    37 namespace WebCore {
    38    
    39 void JSWorker::mark()
     33namespace JSC {
     34void* MarkStack::allocateStack(size_t size)
    4035{
    41     Base::mark();
    42 
    43     markIfNotNull(static_cast<Worker*>(impl())->onmessage());
     36    return VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
     37}
     38void MarkStack::releaseStack(void* addr, size_t size)
     39{
     40    VirtualFree(addr, size, MEM_RELEASE);
    4441}
    4542
    46 } // namespace WebCore
    47 
    48 #endif // ENABLE(WORKERS)
     43}
Note: See TracChangeset for help on using the changeset viewer.