Changeset 126109 in webkit
- Timestamp:
- Aug 20, 2012 5:52:47 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126107 r126109 1 2012-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 1 38 2012-08-20 Elliott Sprehn <esprehn@chromium.org> 2 39 -
trunk/Source/WebCore/bindings/v8/ScriptController.cpp
r126098 r126109 34 34 35 35 #include "BindingState.h" 36 #include "DOMWindow.h" 36 37 #include "Document.h" 37 #include "ScriptCallStack.h"38 #include "ScriptCallStackFactory.h"39 #include "ScriptableDocumentParser.h"40 #include "DOMWindow.h"41 38 #include "Event.h" 42 39 #include "EventListener.h" … … 44 41 #include "Frame.h" 45 42 #include "FrameLoaderClient.h" 43 #include "InspectorInstrumentation.h" 44 #include "NPObjectWrapper.h" 45 #include "NPV8Object.h" 46 46 #include "Node.h" 47 47 #include "NotImplemented.h" 48 #include "NPObjectWrapper.h"49 48 #include "npruntime_impl.h" 50 49 #include "npruntime_priv.h" 51 #include "NPV8Object.h"52 50 #include "PlatformSupport.h" 51 #include "ScriptCallStack.h" 52 #include "ScriptCallStackFactory.h" 53 53 #include "ScriptSourceCode.h" 54 #include "ScriptableDocumentParser.h" 54 55 #include "SecurityOrigin.h" 55 56 #include "Settings.h" … … 68 69 #include <wtf/StringExtras.h> 69 70 #include <wtf/text/CString.h> 71 #include <wtf/text/StringBuilder.h> 72 73 #if PLATFORM(CHROMIUM) 74 #include "TraceEvent.h" 75 #endif 70 76 71 77 namespace WebCore { … … 190 196 // Keep Frame (and therefore ScriptController and V8Proxy) alive. 191 197 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 201 static v8::Local<v8::Value> handleMaxRecursionDepthExceeded() 202 { 203 throwError(RangeError, "Maximum call stack size exceeded."); 204 return v8::Local<v8::Value>(); 205 } 206 207 static 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 219 static 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 232 v8::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; 193 257 } 194 258 -
trunk/Source/WebCore/bindings/v8/ScriptController.h
r126098 r126109 78 78 v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]); 79 79 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 80 83 ScriptValue callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]); 81 84 -
trunk/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp
r125995 r126109 32 32 #include "ScriptFunctionCall.h" 33 33 34 #include "ScriptController.h" 34 35 #include "ScriptScope.h" 35 36 #include "ScriptState.h" … … 37 38 #include "V8Binding.h" 38 39 #include "V8ObjectConstructor.h" 39 #include "V8Proxy.h"40 40 #include "V8RecursionScope.h" 41 41 #include "V8Utilities.h" … … 203 203 args[i] = m_arguments[i].v8Value(); 204 204 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()); 206 206 207 207 if (exceptionCatcher.HasCaught()) { -
trunk/Source/WebCore/bindings/v8/V8Callback.cpp
r125745 r126109 33 33 34 34 #include "Document.h" 35 #include " V8Proxy.h"35 #include "ScriptController.h" 36 36 37 37 namespace WebCore { … … 60 60 return false; 61 61 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); 64 63 65 64 callbackReturnValue = !result.IsEmpty() && result->BooleanValue(); -
trunk/Source/WebCore/bindings/v8/V8NodeFilterCondition.cpp
r125495 r126109 34 34 #include "Node.h" 35 35 #include "NodeFilter.h" 36 #include "ScriptController.h" 36 37 #include "ScriptState.h" 37 38 #include "V8Node.h" 38 #include "V8Proxy.h"39 39 40 40 #include <wtf/OwnArrayPtr.h> … … 84 84 args[0] = toV8(node); 85 85 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()); 87 87 88 88 if (exceptionCatcher.HasCaught()) { -
trunk/Source/WebCore/bindings/v8/V8Proxy.cpp
r126103 r126109 70 70 #include <wtf/StringExtras.h> 71 71 #include <wtf/UnusedParam.h> 72 #include <wtf/text/StringBuilder.h>73 72 #include <wtf/text/WTFString.h> 74 73 … … 106 105 } 107 106 107 // FIXME: This will be soon removed when we move runScript() to ScriptController. 108 108 static v8::Local<v8::Value> handleMaxRecursionDepthExceeded() 109 109 { … … 259 259 } 260 260 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 #endif308 V8RecursionScope recursionScope(context);309 result = function->Call(receiver, argc, args);310 }311 312 InspectorInstrumentation::didCallFunction(cookie);313 crashIfV8IsDead();314 return result;315 }316 317 261 V8DOMWindowShell* V8Proxy::windowShell() const 318 262 { -
trunk/Source/WebCore/bindings/v8/V8Proxy.h
r126103 r126109 98 98 v8::Local<v8::Value> runScript(v8::Handle<v8::Script>); 99 99 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 103 100 // Call the function as constructor with the given arguments. 104 101 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 35 35 #include "EventNames.h" 36 36 #include "ErrorEvent.h" 37 #include "ScriptController.h" 37 38 #include "V8Binding.h" 38 #include "V8Proxy.h"39 39 40 40 namespace WebCore { … … 59 59 v8::TryCatch tryCatch; 60 60 tryCatch.SetVerbose(true); 61 returnValue = V8Proxy::instrumentedCallFunction(0 /* frame */, callFunction, thisValue, 3, parameters);61 returnValue = ScriptController::callFunctionWithInstrumentation(0, callFunction, thisValue, 3, parameters); 62 62 } 63 63 return returnValue; -
trunk/Source/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp
r107170 r126109 32 32 33 33 #include "ScriptCallStack.h" 34 #include "ScriptController.h" 34 35 #include "ScriptExecutionContext.h" 35 36 #include "V8Binding.h" 36 #include "V8Proxy.h"37 37 #include "V8Utilities.h" 38 38 #include <wtf/text/WTFString.h> … … 80 80 v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc; 81 81 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); 83 83 84 84 // Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR. -
trunk/Source/WebKit/chromium/ChangeLog
r126103 r126109 1 2012-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 1 17 2012-08-20 Kentaro Hara <haraken@chromium.org> 2 18 -
trunk/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp
r107677 r126109 123 123 v8::TryCatch tryCatch; 124 124 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()); 126 126 } 127 127
Note: See TracChangeset
for help on using the changeset viewer.