⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 102067 in webkit


Ignore:
Timestamp:
Dec 5, 2011, 4:33:28 PM (15 years ago)
Author:
adamk@chromium.org
Message:

V8RecursionScope should call didLeaveScriptContext when recursionLevel reaches zero
https://bugs.webkit.org/show_bug.cgi?id=73867

Reviewed by Adam Barth.

Moved V8RecursionScope into its own file, and moved
V8Proxy::didLeaveScriptContext into that file, along with a static
recursionLevel accessor, hiding the V8BindingPerIsolateData methods
from V8Proxy.

This will make it easy and less error-prone to use V8RecursionScope
properly. I plan to make use of it in V8LazyEventListener to fix
https://bugs.webkit.org/show_bug.cgi?id=73492.

No new tests, refactoring only.

  • Target.pri:
  • UseV8.cmake:
  • WebCore.gypi:
  • bindings/v8/V8Binding.h:

(WebCore::V8BindingPerIsolateData::incrementRecursionLevel): return the new recursion level.
(WebCore::V8BindingPerIsolateData::decrementRecursionLevel): return the new recursion level.

  • bindings/v8/V8Proxy.cpp: remove didLeaveScriptContext.

(WebCore::V8Proxy::runScript): remove explicit call to didLeaveScriptContext.
(WebCore::V8Proxy::instrumentedCallFunction): remove explicit call to didLeaveScriptContext.

  • bindings/v8/V8Proxy.h: remove didLeaveScriptContext.
  • bindings/v8/V8RecursionScope.cpp: Added.

(WebCore::V8RecursionScope::didLeaveScriptContext): copied from V8Proxy.cpp.

  • bindings/v8/V8RecursionScope.h: Added.

(WebCore::V8RecursionScope::V8RecursionScope):
(WebCore::V8RecursionScope::~V8RecursionScope):
(WebCore::V8RecursionScope::recursionLevel):

Location:
trunk/Source/WebCore
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102064 r102067  
     12011-12-05  Adam Klein  <adamk@chromium.org>
     2
     3        V8RecursionScope should call didLeaveScriptContext when recursionLevel reaches zero
     4        https://bugs.webkit.org/show_bug.cgi?id=73867
     5
     6        Reviewed by Adam Barth.
     7
     8        Moved V8RecursionScope into its own file, and moved
     9        V8Proxy::didLeaveScriptContext into that file, along with a static
     10        recursionLevel accessor, hiding the V8BindingPerIsolateData methods
     11        from V8Proxy.
     12
     13        This will make it easy and less error-prone to use V8RecursionScope
     14        properly. I plan to make use of it in V8LazyEventListener to fix
     15        https://bugs.webkit.org/show_bug.cgi?id=73492.
     16
     17        No new tests, refactoring only.
     18
     19        * Target.pri:
     20        * UseV8.cmake:
     21        * WebCore.gypi:
     22        * bindings/v8/V8Binding.h:
     23        (WebCore::V8BindingPerIsolateData::incrementRecursionLevel): return the new recursion level.
     24        (WebCore::V8BindingPerIsolateData::decrementRecursionLevel): return the new recursion level.
     25        * bindings/v8/V8Proxy.cpp: remove didLeaveScriptContext.
     26        (WebCore::V8Proxy::runScript): remove explicit call to didLeaveScriptContext.
     27        (WebCore::V8Proxy::instrumentedCallFunction): remove explicit call to didLeaveScriptContext.
     28        * bindings/v8/V8Proxy.h: remove didLeaveScriptContext.
     29        * bindings/v8/V8RecursionScope.cpp: Added.
     30        (WebCore::V8RecursionScope::didLeaveScriptContext): copied from V8Proxy.cpp.
     31        * bindings/v8/V8RecursionScope.h: Added.
     32        (WebCore::V8RecursionScope::V8RecursionScope):
     33        (WebCore::V8RecursionScope::~V8RecursionScope):
     34        (WebCore::V8RecursionScope::recursionLevel):
     35
    1362011-12-05  Benjamin Poulain  <bpoulain@apple.com>
    237
  • trunk/Source/WebCore/Target.pri

    r101932 r102067  
    135135        bindings/v8/V8NodeFilterCondition.cpp \
    136136        bindings/v8/V8Proxy.cpp \
     137        bindings/v8/V8RecursionScope.cpp \
    137138        bindings/v8/V8Utilities.cpp \
    138139        bindings/v8/V8WindowErrorHandler.cpp \
     
    13901391        bindings/v8/V8NPUtils.h \
    13911392        bindings/v8/V8Proxy.h \
     1393        bindings/v8/V8RecursionScope.h \
    13921394        bindings/v8/V8Utilities.h \
    13931395        bindings/v8/V8WindowErrorHandler.h \
  • trunk/Source/WebCore/UseV8.cmake

    r100126 r102067  
    5454    bindings/v8/V8NodeFilterCondition.cpp
    5555    bindings/v8/V8Proxy.cpp
     56    bindings/v8/V8RecursionScope.cpp
    5657    bindings/v8/V8Utilities.cpp
    5758    bindings/v8/V8WindowErrorHandler.cpp
  • trunk/Source/WebCore/WebCore.gypi

    r102018 r102067  
    21402140            'bindings/v8/V8Proxy.cpp',
    21412141            'bindings/v8/V8Proxy.h',
     2142            'bindings/v8/V8RecursionScope.cpp',
     2143            'bindings/v8/V8RecursionScope.h',
    21422144            'bindings/v8/V8Utilities.cpp',
    21432145            'bindings/v8/V8Utilities.h',
  • trunk/Source/WebCore/bindings/v8/V8Binding.h

    r100721 r102067  
    146146
    147147        int recursionLevel() const { return m_recursionLevel; }
    148         void incrementRecursionLevel() { ++m_recursionLevel; }
    149         void decrementRecursionLevel() { --m_recursionLevel; }
     148        int incrementRecursionLevel() { return ++m_recursionLevel; }
     149        int decrementRecursionLevel() { return --m_recursionLevel; }
    150150
    151151#ifndef NDEBUG
     
    177177        GlobalHandleMap m_globalHandleMap;
    178178#endif
    179     };
    180 
    181     class V8RecursionScope {
    182         WTF_MAKE_NONCOPYABLE(V8RecursionScope);
    183     public:
    184         V8RecursionScope() { V8BindingPerIsolateData::current()->incrementRecursionLevel(); }
    185         ~V8RecursionScope() { V8BindingPerIsolateData::current()->decrementRecursionLevel(); }
    186179    };
    187180
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r101490 r102067  
    4343#include "FrameLoaderClient.h"
    4444#include "IDBFactoryBackendInterface.h"
    45 #include "IDBPendingTransactionMonitor.h"
    4645#include "InspectorInstrumentation.h"
    4746#include "Page.h"
     
    5857#include "V8HiddenPropertyName.h"
    5958#include "V8IsolatedContext.h"
    60 #include "WebKitMutationObserver.h"
     59#include "V8RecursionScope.h"
    6160#include "WorkerContext.h"
    6261#include "WorkerContextExecutionProxy.h"
     
    174173    // such as out-of-memory by crashing the renderer.
    175174    CRASH();
    176 }
    177 
    178 static int recursionLevel()
    179 {
    180     return V8BindingPerIsolateData::current()->recursionLevel();
    181175}
    182176
     
    391385
    392386    V8GCController::checkMemoryUsage();
    393     if (recursionLevel() >= kMaxRecursionDepth)
     387    if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
    394388        return handleMaxRecursionDepthExceeded();
    395389
     
    409403    }
    410404
    411     didLeaveScriptContext();
    412 
    413405    if (handleOutOfMemory())
    414406        ASSERT(result.IsEmpty());
     
    440432    V8GCController::checkMemoryUsage();
    441433
    442     if (recursionLevel() >= kMaxRecursionDepth)
     434    if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
    443435        return handleMaxRecursionDepthExceeded();
    444436
     
    461453    }
    462454
    463     // FIXME: Instrument any work that takes place when script exits to c++ (e.g. Mutation Observers).
    464     didLeaveScriptContext();
    465 
    466455    InspectorInstrumentation::didCallFunction(cookie);
    467456
     
    551540        return 0;
    552541    return retrieve(static_cast<Document*>(context)->frame());
    553 }
    554 
    555 void V8Proxy::didLeaveScriptContext()
    556 {
    557     if (recursionLevel())
    558         return;
    559 
    560 #if ENABLE(INDEXED_DATABASE)
    561     // If we've just left a script context and indexed database has been
    562     // instantiated, we must let its transaction coordinator know so it can terminate
    563     // any not-yet-started transactions.
    564     IDBPendingTransactionMonitor::abortPendingTransactions();
    565 #endif // ENABLE(INDEXED_DATABASE)
    566 
    567 #if ENABLE(MUTATION_OBSERVERS)
    568     WebCore::WebKitMutationObserver::deliverAllMutations();
    569 #endif
    570542}
    571543
  • trunk/Source/WebCore/bindings/v8/V8Proxy.h

    r101490 r102067  
    265265
    266266    private:
    267         static void didLeaveScriptContext();
    268 
    269267        void resetIsolatedWorlds();
    270268
Note: See TracChangeset for help on using the changeset viewer.