Changeset 126109 in webkit


Ignore:
Timestamp:
Aug 20, 2012 5:52:47 PM (12 years ago)
Author:
haraken@chromium.org
Message:

[V8] Move instrumentedCallFunction() from V8Proxy to ScriptController
https://bugs.webkit.org/show_bug.cgi?id=94456

Reviewed by Adam Barth.

To kill V8Proxy, this patch moves instrumentedCallFunction() from V8Proxy
to ScriptController. Also this patch renames instrumentedCallFunction()
to callFunctionWithInstrumentation(), for consistency with callFunction().

No tests. No change in behavior.

Source/WebCore:

  • bindings/v8/ScriptController.cpp:

(WebCore::ScriptController::callFunction):
(WebCore):
(WebCore::handleMaxRecursionDepthExceeded):
(WebCore::resourceInfo):
(WebCore::resourceString):
(WebCore::ScriptController::callFunctionWithInstrumentation):

  • bindings/v8/ScriptController.h:

(ScriptController):

  • bindings/v8/ScriptFunctionCall.cpp:

(WebCore::ScriptCallback::call):

  • bindings/v8/V8Callback.cpp:

(WebCore::invokeCallback):

  • bindings/v8/V8NodeFilterCondition.cpp:

(WebCore::V8NodeFilterCondition::acceptNode):

  • bindings/v8/V8Proxy.cpp:

(WebCore):

  • bindings/v8/V8Proxy.h:

(V8Proxy):

  • bindings/v8/V8WindowErrorHandler.cpp:

(WebCore::V8WindowErrorHandler::callListenerFunction):

  • bindings/v8/custom/V8CustomXPathNSResolver.cpp:

(WebCore::V8CustomXPathNSResolver::lookupNamespaceURI):

Source/WebKit/chromium:

  • src/WebDevToolsFrontendImpl.cpp:

(WebKit::WebDevToolsFrontendImpl::dispatchOnInspectorFrontend):

Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126107 r126109  
     12012-08-20  Kentaro Hara  <haraken@chromium.org>
     2
     3        [V8] Move instrumentedCallFunction() from V8Proxy to ScriptController
     4        https://bugs.webkit.org/show_bug.cgi?id=94456
     5
     6        Reviewed by Adam Barth.
     7
     8        To kill V8Proxy, this patch moves instrumentedCallFunction() from V8Proxy
     9        to ScriptController. Also this patch renames instrumentedCallFunction()
     10        to callFunctionWithInstrumentation(), for consistency with callFunction().
     11
     12        No tests. No change in behavior.
     13
     14        * bindings/v8/ScriptController.cpp:
     15        (WebCore::ScriptController::callFunction):
     16        (WebCore):
     17        (WebCore::handleMaxRecursionDepthExceeded):
     18        (WebCore::resourceInfo):
     19        (WebCore::resourceString):
     20        (WebCore::ScriptController::callFunctionWithInstrumentation):
     21        * bindings/v8/ScriptController.h:
     22        (ScriptController):
     23        * bindings/v8/ScriptFunctionCall.cpp:
     24        (WebCore::ScriptCallback::call):
     25        * bindings/v8/V8Callback.cpp:
     26        (WebCore::invokeCallback):
     27        * bindings/v8/V8NodeFilterCondition.cpp:
     28        (WebCore::V8NodeFilterCondition::acceptNode):
     29        * bindings/v8/V8Proxy.cpp:
     30        (WebCore):
     31        * bindings/v8/V8Proxy.h:
     32        (V8Proxy):
     33        * bindings/v8/V8WindowErrorHandler.cpp:
     34        (WebCore::V8WindowErrorHandler::callListenerFunction):
     35        * bindings/v8/custom/V8CustomXPathNSResolver.cpp:
     36        (WebCore::V8CustomXPathNSResolver::lookupNamespaceURI):
     37
    1382012-08-20  Elliott Sprehn  <esprehn@chromium.org>
    239
  • trunk/Source/WebCore/bindings/v8/ScriptController.cpp

    r126098 r126109  
    3434
    3535#include "BindingState.h"
     36#include "DOMWindow.h"
    3637#include "Document.h"
    37 #include "ScriptCallStack.h"
    38 #include "ScriptCallStackFactory.h"
    39 #include "ScriptableDocumentParser.h"
    40 #include "DOMWindow.h"
    4138#include "Event.h"
    4239#include "EventListener.h"
     
    4441#include "Frame.h"
    4542#include "FrameLoaderClient.h"
     43#include "InspectorInstrumentation.h"
     44#include "NPObjectWrapper.h"
     45#include "NPV8Object.h"
    4646#include "Node.h"
    4747#include "NotImplemented.h"
    48 #include "NPObjectWrapper.h"
    4948#include "npruntime_impl.h"
    5049#include "npruntime_priv.h"
    51 #include "NPV8Object.h"
    5250#include "PlatformSupport.h"
     51#include "ScriptCallStack.h"
     52#include "ScriptCallStackFactory.h"
    5353#include "ScriptSourceCode.h"
     54#include "ScriptableDocumentParser.h"
    5455#include "SecurityOrigin.h"
    5556#include "Settings.h"
     
    6869#include <wtf/StringExtras.h>
    6970#include <wtf/text/CString.h>
     71#include <wtf/text/StringBuilder.h>
     72
     73#if PLATFORM(CHROMIUM)
     74#include "TraceEvent.h"
     75#endif
    7076
    7177namespace WebCore {
     
    190196    // Keep Frame (and therefore ScriptController and V8Proxy) alive.
    191197    RefPtr<Frame> protect(m_frame);
    192     return V8Proxy::instrumentedCallFunction(m_frame, function, receiver, argc, args);
     198    return ScriptController::callFunctionWithInstrumentation(m_frame ? m_frame->document() : 0, function, receiver, argc, args);
     199}
     200
     201static v8::Local<v8::Value> handleMaxRecursionDepthExceeded()
     202{
     203    throwError(RangeError, "Maximum call stack size exceeded.");
     204    return v8::Local<v8::Value>();
     205}
     206
     207static inline void resourceInfo(const v8::Handle<v8::Function> function, String& resourceName, int& lineNumber)
     208{
     209    v8::ScriptOrigin origin = function->GetScriptOrigin();
     210    if (origin.ResourceName().IsEmpty()) {
     211        resourceName = "undefined";
     212        lineNumber = 1;
     213    } else {
     214        resourceName = toWebCoreString(origin.ResourceName());
     215        lineNumber = function->GetScriptLineNumber() + 1;
     216    }
     217}
     218
     219static inline String resourceString(const v8::Handle<v8::Function> function)
     220{
     221    String resourceName;
     222    int lineNumber;
     223    resourceInfo(function, resourceName, lineNumber);
     224
     225    StringBuilder builder;
     226    builder.append(resourceName);
     227    builder.append(':');
     228    builder.append(String::number(lineNumber));
     229    return builder.toString();
     230}
     231
     232v8::Local<v8::Value> ScriptController::callFunctionWithInstrumentation(ScriptExecutionContext* context, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
     233{
     234    V8GCController::checkMemoryUsage();
     235
     236    if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
     237        return handleMaxRecursionDepthExceeded();
     238
     239    InspectorInstrumentationCookie cookie;
     240    if (InspectorInstrumentation::hasFrontends() && context) {
     241        String resourceName;
     242        int lineNumber;
     243        resourceInfo(function, resourceName, lineNumber);
     244        cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber);
     245    }
     246
     247    v8::Local<v8::Value> result;
     248    {
     249        TRACE_EVENT1("v8", "v8.callFunction", "callsite", resourceString(function).utf8());
     250        V8RecursionScope recursionScope(context);
     251        result = function->Call(receiver, argc, args);
     252    }
     253
     254    InspectorInstrumentation::didCallFunction(cookie);
     255    crashIfV8IsDead();
     256    return result;
    193257}
    194258
  • trunk/Source/WebCore/bindings/v8/ScriptController.h

    r126098 r126109  
    7878    v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
    7979
     80    // Call the function with the given receiver and arguments and report times to DevTools.
     81    static v8::Local<v8::Value> callFunctionWithInstrumentation(ScriptExecutionContext*, v8::Handle<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]);
     82
    8083    ScriptValue callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
    8184
  • trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp

    r125995 r126109  
    3232#include "ScriptFunctionCall.h"
    3333
     34#include "ScriptController.h"
    3435#include "ScriptScope.h"
    3536#include "ScriptState.h"
     
    3738#include "V8Binding.h"
    3839#include "V8ObjectConstructor.h"
    39 #include "V8Proxy.h"
    4040#include "V8RecursionScope.h"
    4141#include "V8Utilities.h"
     
    203203        args[i] = m_arguments[i].v8Value();
    204204
    205     v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(0 /* frame */, function, object, m_arguments.size(), args.get());
     205    v8::Handle<v8::Value> result = ScriptController::callFunctionWithInstrumentation(0, function, object, m_arguments.size(), args.get());
    206206
    207207    if (exceptionCatcher.HasCaught()) {
  • trunk/Source/WebCore/bindings/v8/V8Callback.cpp

    r125745 r126109  
    3333
    3434#include "Document.h"
    35 #include "V8Proxy.h"
     35#include "ScriptController.h"
    3636
    3737namespace WebCore {
     
    6060        return false;
    6161
    62     Frame* frame = scriptExecutionContext && scriptExecutionContext->isDocument() ? static_cast<Document*>(scriptExecutionContext)->frame() : 0;
    63     v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(frame, callbackFunction, thisObject, argc, argv);
     62    v8::Handle<v8::Value> result = ScriptController::callFunctionWithInstrumentation(scriptExecutionContext, callbackFunction, thisObject, argc, argv);
    6463
    6564    callbackReturnValue = !result.IsEmpty() && result->BooleanValue();
  • trunk/Source/WebCore/bindings/v8/V8NodeFilterCondition.cpp

    r125495 r126109  
    3434#include "Node.h"
    3535#include "NodeFilter.h"
     36#include "ScriptController.h"
    3637#include "ScriptState.h"
    3738#include "V8Node.h"
    38 #include "V8Proxy.h"
    3939
    4040#include <wtf/OwnArrayPtr.h>
     
    8484    args[0] = toV8(node);
    8585
    86     v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(0 /* frame */, callback, object, 1, args.get());
     86    v8::Handle<v8::Value> result = ScriptController::callFunctionWithInstrumentation(0, callback, object, 1, args.get());
    8787
    8888    if (exceptionCatcher.HasCaught()) {
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r126103 r126109  
    7070#include <wtf/StringExtras.h>
    7171#include <wtf/UnusedParam.h>
    72 #include <wtf/text/StringBuilder.h>
    7372#include <wtf/text/WTFString.h>
    7473
     
    106105}
    107106
     107// FIXME: This will be soon removed when we move runScript() to ScriptController.
    108108static v8::Local<v8::Value> handleMaxRecursionDepthExceeded()
    109109{
     
    259259}
    260260
    261 static inline void resourceInfo(const v8::Handle<v8::Function> function, String& resourceName, int& lineNumber)
    262 {
    263     v8::ScriptOrigin origin = function->GetScriptOrigin();
    264     if (origin.ResourceName().IsEmpty()) {
    265         resourceName = "undefined";
    266         lineNumber = 1;
    267     } else {
    268         resourceName = toWebCoreString(origin.ResourceName());
    269         lineNumber = function->GetScriptLineNumber() + 1;
    270     }
    271 }
    272 
    273 static inline String resourceString(const v8::Handle<v8::Function> function)
    274 {
    275     String resourceName;
    276     int lineNumber;
    277     resourceInfo(function, resourceName, lineNumber);
    278 
    279     StringBuilder builder;
    280     builder.append(resourceName);
    281     builder.append(':');
    282     builder.append(String::number(lineNumber));
    283     return builder.toString();
    284 }
    285 
    286 v8::Local<v8::Value> V8Proxy::instrumentedCallFunction(Frame* frame, v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
    287 {
    288     V8GCController::checkMemoryUsage();
    289 
    290     if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
    291         return handleMaxRecursionDepthExceeded();
    292 
    293     ScriptExecutionContext* context = frame ? frame->document() : 0;
    294 
    295     InspectorInstrumentationCookie cookie;
    296     if (InspectorInstrumentation::hasFrontends() && context) {
    297         String resourceName;
    298         int lineNumber;
    299         resourceInfo(function, resourceName, lineNumber);
    300         cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber);
    301     }
    302 
    303     v8::Local<v8::Value> result;
    304     {
    305 #if PLATFORM(CHROMIUM)
    306         TRACE_EVENT1("v8", "v8.callFunction", "callsite", resourceString(function).utf8());
    307 #endif
    308         V8RecursionScope recursionScope(context);
    309         result = function->Call(receiver, argc, args);
    310     }
    311 
    312     InspectorInstrumentation::didCallFunction(cookie);
    313     crashIfV8IsDead();
    314     return result;
    315 }
    316 
    317261V8DOMWindowShell* V8Proxy::windowShell() const
    318262{
  • trunk/Source/WebCore/bindings/v8/V8Proxy.h

    r126103 r126109  
    9898        v8::Local<v8::Value> runScript(v8::Handle<v8::Script>);
    9999
    100         // call the function with the given receiver and arguments and report times to DevTools.
    101         static v8::Local<v8::Value> instrumentedCallFunction(Frame*, v8::Handle<v8::Function>, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[]);
    102 
    103100        // Call the function as constructor with the given arguments.
    104101        v8::Local<v8::Value> newInstance(v8::Handle<v8::Function>, int argc, v8::Handle<v8::Value> argv[]);
  • trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp

    r121538 r126109  
    3535#include "EventNames.h"
    3636#include "ErrorEvent.h"
     37#include "ScriptController.h"
    3738#include "V8Binding.h"
    38 #include "V8Proxy.h"
    3939
    4040namespace WebCore {
     
    5959        v8::TryCatch tryCatch;
    6060        tryCatch.SetVerbose(true);
    61         returnValue = V8Proxy::instrumentedCallFunction(0 /* frame */, callFunction, thisValue, 3, parameters);
     61        returnValue = ScriptController::callFunctionWithInstrumentation(0, callFunction, thisValue, 3, parameters);
    6262    }
    6363    return returnValue;
  • trunk/Source/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp

    r107170 r126109  
    3232
    3333#include "ScriptCallStack.h"
     34#include "ScriptController.h"
    3435#include "ScriptExecutionContext.h"
    3536#include "V8Binding.h"
    36 #include "V8Proxy.h"
    3737#include "V8Utilities.h"
    3838#include <wtf/text/WTFString.h>
     
    8080    v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc;
    8181
    82     v8::Handle<v8::Value> retval = V8Proxy::instrumentedCallFunction(0 /* frame */, function, m_resolver, argc, argv);
     82    v8::Handle<v8::Value> retval = ScriptController::callFunctionWithInstrumentation(0, function, m_resolver, argc, argv);
    8383
    8484    // Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR.
  • trunk/Source/WebKit/chromium/ChangeLog

    r126103 r126109  
     12012-08-20  Kentaro Hara  <haraken@chromium.org>
     2
     3        [V8] Move instrumentedCallFunction() from V8Proxy to ScriptController
     4        https://bugs.webkit.org/show_bug.cgi?id=94456
     5
     6        Reviewed by Adam Barth.
     7
     8        To kill V8Proxy, this patch moves instrumentedCallFunction() from V8Proxy
     9        to ScriptController. Also this patch renames instrumentedCallFunction()
     10        to callFunctionWithInstrumentation(), for consistency with callFunction().
     11
     12        No tests. No change in behavior.
     13
     14        * src/WebDevToolsFrontendImpl.cpp:
     15        (WebKit::WebDevToolsFrontendImpl::dispatchOnInspectorFrontend):
     16
    1172012-08-20  Kentaro Hara  <haraken@chromium.org>
    218
  • trunk/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp

    r107677 r126109  
    123123    v8::TryCatch tryCatch;
    124124    tryCatch.SetVerbose(true);
    125     V8Proxy::instrumentedCallFunction(frame->frame(), function, inspectorBackend, args.size(), args.data());
     125    ScriptController::callFunctionWithInstrumentation(frame->frame() ? frame->frame()->document() : 0, function, inspectorBackend, args.size(), args.data());
    126126}
    127127
Note: See TracChangeset for help on using the changeset viewer.