WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Renamed stuff according to feedback. Fixed WebKit style issues.
function_name_v5.patch (text/plain), 17.13 KB, created by
jaimeyap
on 2010-04-06 14:36:26 PDT
(
hide
)
Description:
Renamed stuff according to feedback. Fixed WebKit style issues.
Filename:
MIME Type:
Creator:
jaimeyap
Created:
2010-04-06 14:36:26 PDT
Size:
17.13 KB
patch
obsolete
>Index: WebCore/ChangeLog >=================================================================== >--- WebCore/ChangeLog (revision 57162) >+++ WebCore/ChangeLog (working copy) >@@ -1,3 +1,31 @@ >+2010-04-06 Jaime Yap <jaimeyap@google.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds the ability to get the function symbol name when looking up the call location >+ for records sent by the InspectorTimelineAgent. >+ https://bugs.webkit.org/show_bug.cgi?id=36839 >+ >+ No new tests. >+ >+ * bindings/js/ScriptCallStack.cpp: >+ (WebCore::ScriptCallStack::callLocation): >+ * bindings/js/ScriptCallStack.h: >+ * bindings/v8/ScriptCallStack.cpp: >+ (WebCore::ScriptCallStack::create): >+ (WebCore::ScriptCallStack::callLocation): >+ (WebCore::ScriptCallStack::ScriptCallStack): >+ * bindings/v8/ScriptCallStack.h: >+ * bindings/v8/ScriptDebugServer.cpp: >+ (WebCore::ScriptDebugServer::createUtilityContext): >+ (WebCore::ScriptDebugServer::lastCallFrame): >+ * bindings/v8/ScriptDebugServer.h: >+ (WebCore::ScriptDebugServer::utilityContext): >+ * bindings/v8/V8Proxy.cpp: >+ * bindings/v8/V8Proxy.h: >+ * inspector/TimelineRecordFactory.cpp: >+ (WebCore::TimelineRecordFactory::createGenericRecord): >+ > 2010-04-06 Evan Stade <estade@chromium.org> > > Reviewed by Dimitri Glazkov. >Index: WebCore/bindings/js/ScriptCallStack.cpp >=================================================================== >--- WebCore/bindings/js/ScriptCallStack.cpp (revision 57156) >+++ WebCore/bindings/js/ScriptCallStack.cpp (working copy) >@@ -101,7 +101,7 @@ void ScriptCallStack::initialize() > m_initialized = true; > } > >-bool ScriptCallStack::callLocation(String*, int*) >+bool ScriptCallStack::callLocation(String*, int*, String*) > { > return false; > } >Index: WebCore/bindings/js/ScriptCallStack.h >=================================================================== >--- WebCore/bindings/js/ScriptCallStack.h (revision 57156) >+++ WebCore/bindings/js/ScriptCallStack.h (working copy) >@@ -53,7 +53,7 @@ namespace WebCore { > // frame retrieval methods > const ScriptCallFrame &at(unsigned); > unsigned size(); >- static bool callLocation(String*, int*); >+ static bool callLocation(String*, int*, String*); > > private: > void initialize(); >Index: WebCore/bindings/v8/ScriptCallStack.cpp >=================================================================== >--- WebCore/bindings/v8/ScriptCallStack.cpp (revision 57156) >+++ WebCore/bindings/v8/ScriptCallStack.cpp (working copy) >@@ -32,32 +32,33 @@ > #include "ScriptCallStack.h" > > #include "ScriptController.h" >+#include "ScriptDebugServer.h" > > #include <v8.h> > > #include "V8Binding.h" >-#include "V8Proxy.h" > > namespace WebCore { > > ScriptCallStack* ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount) { > String sourceName; > int sourceLineNumber; >- if (!callLocation(&sourceName, &sourceLineNumber)) >+ String funcName; >+ if (!callLocation(&sourceName, &sourceLineNumber, &funcName)) > return 0; >- return new ScriptCallStack(arguments, skipArgumentCount, sourceName, sourceLineNumber); >+ return new ScriptCallStack(arguments, skipArgumentCount, sourceName, sourceLineNumber, funcName); > } > >-bool ScriptCallStack::callLocation(String* sourceName, int* sourceLineNumber) >+bool ScriptCallStack::callLocation(String* sourceName, int* sourceLineNumber, String* functionName) > { >- if (!V8Proxy::sourceName(*sourceName) || !V8Proxy::sourceLineNumber(*sourceLineNumber)) >+ if (!ScriptDebugServer::topStackFrame(*sourceName, *sourceLineNumber, *functionName)) > return false; > *sourceLineNumber += 1; > return true; > } > >-ScriptCallStack::ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber) >- : m_lastCaller(String(), sourceName, sourceLineNumber, arguments, skipArgumentCount) >+ScriptCallStack::ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber, String functionName) >+ : m_lastCaller(functionName, sourceName, sourceLineNumber, arguments, skipArgumentCount) > , m_scriptState(ScriptState::current()) > { > } >Index: WebCore/bindings/v8/ScriptCallStack.h >=================================================================== >--- WebCore/bindings/v8/ScriptCallStack.h (revision 57156) >+++ WebCore/bindings/v8/ScriptCallStack.h (working copy) >@@ -47,7 +47,7 @@ namespace WebCore { > static ScriptCallStack* create(const v8::Arguments&, unsigned skipArgumentCount = 0); > ~ScriptCallStack(); > >- static bool callLocation(String* sourceName, int* sourceLineNumber); >+ static bool callLocation(String* sourceName, int* sourceLineNumber, String* functionName); > > const ScriptCallFrame& at(unsigned) const; > // FIXME: implement retrieving and storing call stack trace >@@ -57,7 +57,7 @@ namespace WebCore { > ScriptState* globalState() const { return m_scriptState; } > > private: >- ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber); >+ ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber, String funcName); > > ScriptCallFrame m_lastCaller; > ScriptState* m_scriptState; >Index: WebCore/bindings/v8/ScriptDebugServer.cpp >=================================================================== >--- WebCore/bindings/v8/ScriptDebugServer.cpp (revision 57156) >+++ WebCore/bindings/v8/ScriptDebugServer.cpp (working copy) >@@ -33,16 +33,76 @@ > > #if ENABLE(JAVASCRIPT_DEBUGGER) > >+#include "V8Binding.h" >+#include <v8-debug.h> >+ > #include <wtf/StdLibExtras.h> > > namespace WebCore { > >+v8::Persistent<v8::Context> ScriptDebugServer::s_utilityContext; >+ > ScriptDebugServer& ScriptDebugServer::shared() > { > DEFINE_STATIC_LOCAL(ScriptDebugServer, server, ()); > return server; > } > >+// Create the utility context for holding JavaScript functions used internally >+// which are not visible to JavaScript executing on the page. >+void ScriptDebugServer::createUtilityContext() >+{ >+ ASSERT(s_utilityContext.IsEmpty()); >+ >+ v8::HandleScope scope; >+ v8::Handle<v8::ObjectTemplate> globalTemplate = v8::ObjectTemplate::New(); >+ s_utilityContext = v8::Context::New(0, globalTemplate); >+ v8::Context::Scope contextScope(s_utilityContext); >+ >+ // Compile JavaScript function for retrieving the source line, the source >+ // name and the symbol name for the top JavaScript stack frame. >+ DEFINE_STATIC_LOCAL(const char*, topStackFrame, >+ ("function topStackFrame(exec_state) {" >+ " if (!exec_state.frameCount())" >+ " return undefined;" >+ " var frame = exec_state.frame(0);" >+ " var func = frame.func();" >+ " var scriptName;" >+ " if (func.resolved() && func.script())" >+ " scriptName = func.script().name();" >+ " return [scriptName, frame.sourceLine(), (func.name() || func.inferredName())];" >+ "}")); >+ v8::Script::Compile(v8::String::New(topStackFrame))->Run(); >+} >+ >+bool ScriptDebugServer::topStackFrame(String& sourceName, int& lineNumber, String& functionName) >+{ >+ v8::HandleScope scope; >+ v8::Handle<v8::Context> v8UtilityContext = utilityContext(); >+ if (v8UtilityContext.IsEmpty()) >+ return false; >+ v8::Context::Scope contextScope(v8UtilityContext); >+ v8::Handle<v8::Function> topStackFrame; >+ topStackFrame = v8::Local<v8::Function>::Cast(v8UtilityContext->Global()->Get(v8::String::New("topStackFrame"))); >+ if (topStackFrame.IsEmpty()) >+ return false; >+ v8::Handle<v8::Value> value = v8::Debug::Call(topStackFrame); >+ if (value.IsEmpty()) >+ return false; >+ if (!value->IsArray()) >+ return false; >+ v8::Local<v8::Object> jsArray = value->ToObject(); >+ v8::Local<v8::Value> sourceNameValue = jsArray->Get(0); >+ v8::Local<v8::Value> lineNumberValue = jsArray->Get(1); >+ v8::Local<v8::Value> functionNameValue = jsArray->Get(2); >+ if (sourceNameValue.IsEmpty() || lineNumberValue.IsEmpty() || functionNameValue.IsEmpty()) >+ return false; >+ sourceName = toWebCoreString(sourceNameValue); >+ lineNumber = lineNumberValue->Int32Value(); >+ functionName = toWebCoreString(functionNameValue); >+ return true; >+} >+ > } // namespace WebCore > > #endif // ENABLE(JAVASCRIPT_DEBUGGER) >Index: WebCore/bindings/v8/ScriptDebugServer.h >=================================================================== >--- WebCore/bindings/v8/ScriptDebugServer.h (revision 57156) >+++ WebCore/bindings/v8/ScriptDebugServer.h (working copy) >@@ -47,6 +47,15 @@ class ScriptDebugListener; > class ScriptDebugServer : public Noncopyable { > public: > static ScriptDebugServer& shared(); >+ >+ // Function for retrieving the source name, line number and function name for the top >+ // JavaScript stack frame. >+ // >+ // It will return true if the caller information was successfully retrieved and written >+ // into the function parameters, otherwise the function will return false. It may >+ // fail due to a stck overflow in the underlying JavaScript implentation, handling >+ // of such exception is up to the caller. >+ static bool topStackFrame(String& sourceName, int& lineNumber, String& functionName); > > void addListener(ScriptDebugListener*, Page*) { } > void removeListener(ScriptDebugListener*, Page*) { } >@@ -80,6 +89,19 @@ public: > private: > ScriptDebugServer() { } > ~ScriptDebugServer() { } >+ >+ static void createUtilityContext(); >+ >+ // Returns a local handle of the utility context. >+ static v8::Local<v8::Context> utilityContext() >+ { >+ if (s_utilityContext.IsEmpty()) >+ createUtilityContext(); >+ return v8::Local<v8::Context>::New(s_utilityContext); >+ } >+ >+ // Utility context holding JavaScript functions used internally. >+ static v8::Persistent<v8::Context> s_utilityContext; > }; > > } // namespace WebCore >Index: WebCore/bindings/v8/V8Proxy.cpp >=================================================================== >--- WebCore/bindings/v8/V8Proxy.cpp (revision 57156) >+++ WebCore/bindings/v8/V8Proxy.cpp (working copy) >@@ -68,7 +68,6 @@ > #include <stdio.h> > #include <utility> > #include <v8.h> >-#include <v8-debug.h> > #include <wtf/Assertions.h> > #include <wtf/OwnArrayPtr.h> > #include <wtf/StdLibExtras.h> >@@ -77,8 +76,6 @@ > > namespace WebCore { > >-v8::Persistent<v8::Context> V8Proxy::m_utilityContext; >- > // Static list of registered extensions > V8Extensions V8Proxy::m_extensions; > >@@ -755,79 +752,6 @@ void V8Proxy::processConsoleMessages() > V8ConsoleMessage::processDelayed(); > } > >-// Create the utility context for holding JavaScript functions used internally >-// which are not visible to JavaScript executing on the page. >-void V8Proxy::createUtilityContext() >-{ >- ASSERT(m_utilityContext.IsEmpty()); >- >- v8::HandleScope scope; >- v8::Handle<v8::ObjectTemplate> globalTemplate = v8::ObjectTemplate::New(); >- m_utilityContext = v8::Context::New(0, globalTemplate); >- v8::Context::Scope contextScope(m_utilityContext); >- >- // Compile JavaScript function for retrieving the source line of the top >- // JavaScript stack frame. >- DEFINE_STATIC_LOCAL(const char*, frameSourceLineSource, >- ("function frameSourceLine(exec_state) {" >- " if (!exec_state.frameCount())" >- " return undefined;" >- " return exec_state.frame(0).sourceLine();" >- "}")); >- v8::Script::Compile(v8::String::New(frameSourceLineSource))->Run(); >- >- // Compile JavaScript function for retrieving the source name of the top >- // JavaScript stack frame. >- DEFINE_STATIC_LOCAL(const char*, frameSourceNameSource, >- ("function frameSourceName(exec_state) {" >- " if (!exec_state.frameCount())" >- " return undefined;" >- " var frame = exec_state.frame(0);" >- " if (frame.func().resolved() && " >- " frame.func().script() && " >- " frame.func().script().name()) {" >- " return frame.func().script().name();" >- " }" >- "}")); >- v8::Script::Compile(v8::String::New(frameSourceNameSource))->Run(); >-} >- >-bool V8Proxy::sourceLineNumber(int& result) >-{ >- v8::HandleScope scope; >- v8::Handle<v8::Context> v8UtilityContext = V8Proxy::utilityContext(); >- if (v8UtilityContext.IsEmpty()) >- return false; >- v8::Context::Scope contextScope(v8UtilityContext); >- v8::Handle<v8::Function> frameSourceLine; >- frameSourceLine = v8::Local<v8::Function>::Cast(v8UtilityContext->Global()->Get(v8::String::New("frameSourceLine"))); >- if (frameSourceLine.IsEmpty()) >- return false; >- v8::Handle<v8::Value> value = v8::Debug::Call(frameSourceLine); >- if (value.IsEmpty()) >- return false; >- result = value->Int32Value(); >- return true; >-} >- >-bool V8Proxy::sourceName(String& result) >-{ >- v8::HandleScope scope; >- v8::Handle<v8::Context> v8UtilityContext = utilityContext(); >- if (v8UtilityContext.IsEmpty()) >- return false; >- v8::Context::Scope contextScope(v8UtilityContext); >- v8::Handle<v8::Function> frameSourceName; >- frameSourceName = v8::Local<v8::Function>::Cast(v8UtilityContext->Global()->Get(v8::String::New("frameSourceName"))); >- if (frameSourceName.IsEmpty()) >- return false; >- v8::Handle<v8::Value> value = v8::Debug::Call(frameSourceName); >- if (value.IsEmpty()) >- return false; >- result = toWebCoreString(value); >- return true; >-} >- > void V8Proxy::registerExtensionWithV8(v8::Extension* extension) > { > // If the extension exists in our list, it was already registered with V8. >Index: WebCore/bindings/v8/V8Proxy.h >=================================================================== >--- WebCore/bindings/v8/V8Proxy.h (revision 57156) >+++ WebCore/bindings/v8/V8Proxy.h (working copy) >@@ -296,16 +296,6 @@ namespace WebCore { > // Process any pending JavaScript console messages. > static void processConsoleMessages(); > >- // Function for retrieving the line number and source name for the top >- // JavaScript stack frame. >- // >- // It will return true if the line number was successfully retrieved and written >- // into the |result| parameter, otherwise the function will return false. It may >- // fail due to a stck overflow in the underlying JavaScript implentation, handling >- // of such exception is up to the caller. >- static bool sourceLineNumber(int& result); >- static bool sourceName(String& result); >- > v8::Local<v8::Context> context(); > v8::Local<v8::Context> mainWorldContext(); > >@@ -356,23 +346,10 @@ namespace WebCore { > static const char* svgExceptionName(int exceptionCode); > #endif > >- static void createUtilityContext(); >- >- // Returns a local handle of the utility context. >- static v8::Local<v8::Context> utilityContext() >- { >- if (m_utilityContext.IsEmpty()) >- createUtilityContext(); >- return v8::Local<v8::Context>::New(m_utilityContext); >- } >- > Frame* m_frame; > > // For the moment, we have one of these. Soon we will have one per DOMWrapperWorld. > RefPtr<V8DOMWindowShell> m_windowShell; >- >- // Utility context holding JavaScript functions used internally. >- static v8::Persistent<v8::Context> m_utilityContext; > > int m_handlerLineNumber; > >Index: WebCore/inspector/TimelineRecordFactory.cpp >=================================================================== >--- WebCore/inspector/TimelineRecordFactory.cpp (revision 57156) >+++ WebCore/inspector/TimelineRecordFactory.cpp (working copy) >@@ -51,9 +51,11 @@ ScriptObject TimelineRecordFactory::crea > > String sourceName; > int sourceLineNumber; >- if (ScriptCallStack::callLocation(&sourceName, &sourceLineNumber) && sourceName != "undefined") { >+ String functionName; >+ if (ScriptCallStack::callLocation(&sourceName, &sourceLineNumber, &functionName) && sourceName != "undefined") { > record.set("callerScriptName", sourceName); > record.set("callerScriptLine", sourceLineNumber); >+ record.set("callerFunctionName", functionName); > } > return record; > } >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 57162) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,13 @@ >+2010-04-06 Jaime Yap <jaimeyap@google.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds callerFuncName to the list of nondeterministic fields in the timeline >+ layout tests. >+ https://bugs.webkit.org/show_bug.cgi?id=36839 >+ >+ * inspector/timeline-test.js: >+ > 2010-04-01 Yuzo Fujishima <yuzo@google.com> > > Reviewed by Darin Adler. >Index: LayoutTests/inspector/timeline-test.js >=================================================================== >--- LayoutTests/inspector/timeline-test.js (revision 57156) >+++ LayoutTests/inspector/timeline-test.js (working copy) >@@ -10,6 +10,7 @@ var timelineNonDeterministicProps = { > width : 1, > callerScriptName: 1, > callerScriptLine: 1, >+ callerFunctionName: 1, > url : 1, > usedHeapSize: 1, > totalHeapSize: 1,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 36839
:
52060
|
52062
|
52645
|
52655
|
52668
|
52773