Changeset 100347 in webkit


Ignore:
Timestamp:
Nov 15, 2011 3:34:04 PM (12 years ago)
Author:
adamk@chromium.org
Message:

Factor out V8Proxy's max recursion depth handling code
https://bugs.webkit.org/show_bug.cgi?id=72422

Reviewed by Nate Chapin.

Previously, V8Proxy used slightly different code to handle stack limit
violations depending on whether they occured in runScript or
callFunction. As described in http://webkit.org/b/72063, I intend to
expand the usage of m_recursion when calling into script. This patch
is intended to unify the existing handling code, making it easier to
move elsewhere without causing unintended side-effects.

No tests changed, as the only change in behavior is the string passed
to RangeError in the runScript case, and it's not mentioned anywhere
in the LayoutTests.

  • bindings/v8/V8Proxy.cpp:

(WebCore::handleMaxRecursionDepthExceeded):
(WebCore::V8Proxy::runScript): Use callFunction's factored-out code.
(WebCore::V8Proxy::callFunction): Simplify and factor out code into handleMaxRecursionDepthExceeded.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r100343 r100347  
     12011-11-15  Adam Klein  <adamk@chromium.org>
     2
     3        Factor out V8Proxy's max recursion depth handling code
     4        https://bugs.webkit.org/show_bug.cgi?id=72422
     5
     6        Reviewed by Nate Chapin.
     7
     8        Previously, V8Proxy used slightly different code to handle stack limit
     9        violations depending on whether they occured in runScript or
     10        callFunction. As described in http://webkit.org/b/72063, I intend to
     11        expand the usage of m_recursion when calling into script. This patch
     12        is intended to unify the existing handling code, making it easier to
     13        move elsewhere without causing unintended side-effects.
     14
     15        No tests changed, as the only change in behavior is the string passed
     16        to RangeError in the runScript case, and it's not mentioned anywhere
     17        in the LayoutTests.
     18
     19        * bindings/v8/V8Proxy.cpp:
     20        (WebCore::handleMaxRecursionDepthExceeded):
     21        (WebCore::V8Proxy::runScript): Use callFunction's factored-out code.
     22        (WebCore::V8Proxy::callFunction): Simplify and factor out code into handleMaxRecursionDepthExceeded.
     23
    1242011-11-15  Jessie Berlin  <jberlin@apple.com>
    225
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r100041 r100347  
    176176}
    177177
     178static v8::Local<v8::Value> handleMaxRecursionDepthExceeded()
     179{
     180    v8::Local<v8::String> code = v8::String::New("throw new RangeError('Maximum call stack size exceeded.')");
     181    v8::Local<v8::Script> script = v8::Script::Compile(code);
     182    script->Run();
     183    return v8::Local<v8::Value>();
     184}
     185
    178186V8Proxy::V8Proxy(Frame* frame)
    179187    : m_frame(frame)
     
    385393
    386394    V8GCController::checkMemoryUsage();
    387     // Compute the source string and prevent against infinite recursion.
    388     if (m_recursion >= kMaxRecursionDepth) {
    389         v8::Local<v8::String> code = v8ExternalString("throw RangeError('Recursion too deep')");
    390         // FIXME: Ideally, we should be able to re-use the origin of the
    391         // script passed to us as the argument instead of using an empty string
    392         // and 0 baseLine.
    393         script = compileScript(code, "", TextPosition::minimumPosition());
    394     }
     395    if (m_recursion >= kMaxRecursionDepth)
     396        return handleMaxRecursionDepthExceeded();
    395397
    396398    if (handleOutOfMemory())
    397399        ASSERT(script.IsEmpty());
    398 
    399     if (script.IsEmpty())
    400         return notHandledByInterceptor();
    401400
    402401    // Save the previous value of the inlineCode flag and update the flag for
     
    446445    V8GCController::checkMemoryUsage();
    447446
     447    if (m_recursion >= kMaxRecursionDepth)
     448        return handleMaxRecursionDepthExceeded();
     449
    448450    // Keep Frame (and therefore ScriptController and V8Proxy) alive.
    449451    RefPtr<Frame> protect(frame());
     
    451453    v8::Local<v8::Value> result;
    452454    {
    453         if (m_recursion >= kMaxRecursionDepth) {
    454             v8::Local<v8::String> code = v8::String::New("throw new RangeError('Maximum call stack size exceeded.')");
    455             if (code.IsEmpty())
    456                 return result;
    457             v8::Local<v8::Script> script = v8::Script::Compile(code);
    458             if (script.IsEmpty())
    459                 return result;
    460             script->Run();
    461             return result;
    462         }
    463 
    464455        m_recursion++;
    465456        result = V8Proxy::instrumentedCallFunction(m_frame->page(), function, receiver, argc, args);
Note: See TracChangeset for help on using the changeset viewer.