[JSC] Drop PassRefPtr in inspector/
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Feb 2017 18:49:40 +0000 (18:49 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Feb 2017 18:49:40 +0000 (18:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168420

Reviewed by Alex Christensen.

Source/JavaScriptCore:

Drop PassRefPtr uses.
And use Ref<Inspector::ScriptArguments> and Ref<ScriptCallStack> as much as possible.
It drops some unnecessary null checks.

* debugger/Debugger.cpp:
(JSC::Debugger::hasBreakpoint):
(JSC::Debugger::currentDebuggerCallFrame):
* debugger/Debugger.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::create):
(Inspector::AsyncStackTrace::AsyncStackTrace):
(Inspector::AsyncStackTrace::buildInspectorObject):
(Inspector::AsyncStackTrace::truncate):
* inspector/AsyncStackTrace.h:
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::ConsoleMessage):
* inspector/ConsoleMessage.h:
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::InjectedScriptManager):
(Inspector::InjectedScriptManager::injectedScriptHost):
* inspector/InjectedScriptManager.h:
* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::messageWithTypeAndLevel):
(Inspector::JSGlobalObjectConsoleClient::count):
(Inspector::JSGlobalObjectConsoleClient::timeEnd):
(Inspector::JSGlobalObjectConsoleClient::timeStamp):
(Inspector::JSGlobalObjectConsoleClient::warnUnimplemented):
* inspector/JSGlobalObjectConsoleClient.h:
ConsoleClient now takes Ref<ScriptArgument>&& instead of RefPtr<ScriptArgument>&&.

* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace):
(Inspector::JSGlobalObjectInspectorController::reportAPIException):
* inspector/JSGlobalObjectInspectorController.h:
* inspector/JSJavaScriptCallFrame.cpp:
(Inspector::JSJavaScriptCallFrame::JSJavaScriptCallFrame):
(Inspector::toJS):
* inspector/JSJavaScriptCallFrame.h:
(Inspector::JSJavaScriptCallFrame::create):
* inspector/JavaScriptCallFrame.cpp:
(Inspector::JavaScriptCallFrame::JavaScriptCallFrame):
(Inspector::JavaScriptCallFrame::caller):
* inspector/JavaScriptCallFrame.h:
(Inspector::JavaScriptCallFrame::create):
* inspector/ScriptDebugServer.cpp:
(Inspector::ScriptDebugServer::evaluateBreakpointAction):
(Inspector::ScriptDebugServer::dispatchDidPause):
(Inspector::ScriptDebugServer::exceptionOrCaughtValue):
* inspector/agents/InspectorConsoleAgent.cpp:
(Inspector::InspectorConsoleAgent::stopTiming):
(Inspector::InspectorConsoleAgent::count):
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::didScheduleAsyncCall):
* runtime/ConsoleClient.cpp:
(JSC::ConsoleClient::printConsoleMessageWithArguments):
(JSC::ConsoleClient::internalMessageWithTypeAndLevel):
(JSC::ConsoleClient::logWithLevel):
(JSC::ConsoleClient::dir):
(JSC::ConsoleClient::dirXML):
(JSC::ConsoleClient::table):
(JSC::ConsoleClient::trace):
(JSC::ConsoleClient::assertion):
(JSC::ConsoleClient::group):
(JSC::ConsoleClient::groupCollapsed):
(JSC::ConsoleClient::groupEnd):
* runtime/ConsoleClient.h:
* runtime/ConsoleObject.cpp:
(JSC::consoleLogWithLevel):
(JSC::consoleProtoFuncDir):
(JSC::consoleProtoFuncDirXML):
(JSC::consoleProtoFuncTable):
(JSC::consoleProtoFuncTrace):
(JSC::consoleProtoFuncAssert):
(JSC::consoleProtoFuncCount):
(JSC::consoleProtoFuncTimeStamp):
(JSC::consoleProtoFuncGroup):
(JSC::consoleProtoFuncGroupCollapsed):
(JSC::consoleProtoFuncGroupEnd):

Source/WebCore:

Use Ref<Inspector::ScriptArguments> and Ref<ScriptCallStack> as much as possible.
It drops some unnecessary null checks.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallWith):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionWithScriptArgumentsAndCallStackCaller):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::PendingException::PendingException):
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::consoleCountImpl):
(WebCore::InspectorInstrumentation::stopConsoleTimingImpl):
(WebCore::InspectorInstrumentation::consoleTimeStampImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::consoleCount):
(WebCore::InspectorInstrumentation::stopConsoleTiming):
(WebCore::InspectorInstrumentation::consoleTimeStamp):
* inspector/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::buildInitiatorObject):
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::createGenericRecord):
* inspector/WebInjectedScriptManager.cpp:
(WebCore::WebInjectedScriptManager::WebInjectedScriptManager):
* inspector/WebInjectedScriptManager.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::postMessageTimerFired):
We dispatch appropriate addMessage function according to whether
`timer.stackTrace()` is nullptr.

* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::addMessage):
(WebCore::PageConsoleClient::messageWithTypeAndLevel):
(WebCore::PageConsoleClient::count):
(WebCore::PageConsoleClient::timeEnd):
(WebCore::PageConsoleClient::timeStamp):
* page/PageConsoleClient.h:
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::messageWithTypeAndLevel):
(WebCore::WorkerConsoleClient::count):
(WebCore::WorkerConsoleClient::timeEnd):
(WebCore::WorkerConsoleClient::timeStamp):
* workers/WorkerConsoleClient.h:
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::addMessage):

Source/WebKit/mac:

* WebView/WebScriptDebugger.mm:
(WebScriptDebugger::handlePause):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212448 268f45cc-cd09-0410-ab3c-d52691b4dbfc

42 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/debugger/Debugger.cpp
Source/JavaScriptCore/debugger/Debugger.h
Source/JavaScriptCore/inspector/AsyncStackTrace.cpp
Source/JavaScriptCore/inspector/AsyncStackTrace.h
Source/JavaScriptCore/inspector/ConsoleMessage.cpp
Source/JavaScriptCore/inspector/ConsoleMessage.h
Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
Source/JavaScriptCore/inspector/InjectedScriptManager.h
Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h
Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp
Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.h
Source/JavaScriptCore/inspector/JavaScriptCallFrame.cpp
Source/JavaScriptCore/inspector/JavaScriptCallFrame.h
Source/JavaScriptCore/inspector/ScriptDebugServer.cpp
Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h
Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
Source/JavaScriptCore/runtime/ConsoleClient.cpp
Source/JavaScriptCore/runtime/ConsoleClient.h
Source/JavaScriptCore/runtime/ConsoleObject.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorNetworkAgent.cpp
Source/WebCore/inspector/TimelineRecordFactory.cpp
Source/WebCore/inspector/WebInjectedScriptManager.cpp
Source/WebCore/inspector/WebInjectedScriptManager.h
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/PageConsoleClient.cpp
Source/WebCore/page/PageConsoleClient.h
Source/WebCore/workers/WorkerConsoleClient.cpp
Source/WebCore/workers/WorkerConsoleClient.h
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebScriptDebugger.mm

index 7a5826f..5985671 100644 (file)
@@ -1,3 +1,90 @@
+2017-02-16  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Drop PassRefPtr in inspector/
+        https://bugs.webkit.org/show_bug.cgi?id=168420
+
+        Reviewed by Alex Christensen.
+
+        Drop PassRefPtr uses.
+        And use Ref<Inspector::ScriptArguments> and Ref<ScriptCallStack> as much as possible.
+        It drops some unnecessary null checks.
+
+        * debugger/Debugger.cpp:
+        (JSC::Debugger::hasBreakpoint):
+        (JSC::Debugger::currentDebuggerCallFrame):
+        * debugger/Debugger.h:
+        * inspector/AsyncStackTrace.cpp:
+        (Inspector::AsyncStackTrace::create):
+        (Inspector::AsyncStackTrace::AsyncStackTrace):
+        (Inspector::AsyncStackTrace::buildInspectorObject):
+        (Inspector::AsyncStackTrace::truncate):
+        * inspector/AsyncStackTrace.h:
+        * inspector/ConsoleMessage.cpp:
+        (Inspector::ConsoleMessage::ConsoleMessage):
+        * inspector/ConsoleMessage.h:
+        * inspector/InjectedScriptManager.cpp:
+        (Inspector::InjectedScriptManager::InjectedScriptManager):
+        (Inspector::InjectedScriptManager::injectedScriptHost):
+        * inspector/InjectedScriptManager.h:
+        * inspector/JSGlobalObjectConsoleClient.cpp:
+        (Inspector::JSGlobalObjectConsoleClient::messageWithTypeAndLevel):
+        (Inspector::JSGlobalObjectConsoleClient::count):
+        (Inspector::JSGlobalObjectConsoleClient::timeEnd):
+        (Inspector::JSGlobalObjectConsoleClient::timeStamp):
+        (Inspector::JSGlobalObjectConsoleClient::warnUnimplemented):
+        * inspector/JSGlobalObjectConsoleClient.h:
+        ConsoleClient now takes Ref<ScriptArgument>&& instead of RefPtr<ScriptArgument>&&.
+
+        * inspector/JSGlobalObjectInspectorController.cpp:
+        (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace):
+        (Inspector::JSGlobalObjectInspectorController::reportAPIException):
+        * inspector/JSGlobalObjectInspectorController.h:
+        * inspector/JSJavaScriptCallFrame.cpp:
+        (Inspector::JSJavaScriptCallFrame::JSJavaScriptCallFrame):
+        (Inspector::toJS):
+        * inspector/JSJavaScriptCallFrame.h:
+        (Inspector::JSJavaScriptCallFrame::create):
+        * inspector/JavaScriptCallFrame.cpp:
+        (Inspector::JavaScriptCallFrame::JavaScriptCallFrame):
+        (Inspector::JavaScriptCallFrame::caller):
+        * inspector/JavaScriptCallFrame.h:
+        (Inspector::JavaScriptCallFrame::create):
+        * inspector/ScriptDebugServer.cpp:
+        (Inspector::ScriptDebugServer::evaluateBreakpointAction):
+        (Inspector::ScriptDebugServer::dispatchDidPause):
+        (Inspector::ScriptDebugServer::exceptionOrCaughtValue):
+        * inspector/agents/InspectorConsoleAgent.cpp:
+        (Inspector::InspectorConsoleAgent::stopTiming):
+        (Inspector::InspectorConsoleAgent::count):
+        * inspector/agents/InspectorConsoleAgent.h:
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::didScheduleAsyncCall):
+        * runtime/ConsoleClient.cpp:
+        (JSC::ConsoleClient::printConsoleMessageWithArguments):
+        (JSC::ConsoleClient::internalMessageWithTypeAndLevel):
+        (JSC::ConsoleClient::logWithLevel):
+        (JSC::ConsoleClient::dir):
+        (JSC::ConsoleClient::dirXML):
+        (JSC::ConsoleClient::table):
+        (JSC::ConsoleClient::trace):
+        (JSC::ConsoleClient::assertion):
+        (JSC::ConsoleClient::group):
+        (JSC::ConsoleClient::groupCollapsed):
+        (JSC::ConsoleClient::groupEnd):
+        * runtime/ConsoleClient.h:
+        * runtime/ConsoleObject.cpp:
+        (JSC::consoleLogWithLevel):
+        (JSC::consoleProtoFuncDir):
+        (JSC::consoleProtoFuncDirXML):
+        (JSC::consoleProtoFuncTable):
+        (JSC::consoleProtoFuncTrace):
+        (JSC::consoleProtoFuncAssert):
+        (JSC::consoleProtoFuncCount):
+        (JSC::consoleProtoFuncTimeStamp):
+        (JSC::consoleProtoFuncGroup):
+        (JSC::consoleProtoFuncGroupCollapsed):
+        (JSC::consoleProtoFuncGroupEnd):
+
 2017-02-15  Keith Miller  <keith_miller@apple.com>
 
         Weak should not use jsCast in its accessors
index d4778ef..8e70fbc 100644 (file)
@@ -502,9 +502,9 @@ bool Debugger::hasBreakpoint(SourceID sourceID, const TextPosition& position, Br
     TemporaryPausedState pausedState(*this);
 
     NakedPtr<Exception> exception;
-    DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();
+    DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
     JSObject* scopeExtensionObject = nullptr;
-    JSValue result = debuggerCallFrame->evaluateWithScopeExtension(breakpoint->condition, scopeExtensionObject, exception);
+    JSValue result = debuggerCallFrame.evaluateWithScopeExtension(breakpoint->condition, scopeExtensionObject, exception);
 
     // We can lose the debugger while executing JavaScript.
     if (!m_currentCallFrame)
@@ -911,11 +911,11 @@ void Debugger::didReachBreakpoint(CallFrame* callFrame)
     updateCallFrame(callFrame, AttemptPause);
 }
 
-DebuggerCallFrame* Debugger::currentDebuggerCallFrame()
+DebuggerCallFrame& Debugger::currentDebuggerCallFrame()
 {
     if (!m_currentDebuggerCallFrame)
         m_currentDebuggerCallFrame = DebuggerCallFrame::create(m_currentCallFrame);
-    return m_currentDebuggerCallFrame.get();
+    return *m_currentDebuggerCallFrame;
 }
 
 bool Debugger::isBlacklisted(SourceID sourceID) const
index fa6d31e..3f51bb4 100644 (file)
@@ -50,7 +50,7 @@ public:
 
     VM& vm() { return m_vm; }
 
-    JSC::DebuggerCallFrame* currentDebuggerCallFrame();
+    JSC::DebuggerCallFrame& currentDebuggerCallFrame();
     bool hasHandlerForExceptionCallback() const
     {
         ASSERT(m_reasonForPause == PausedForException);
index 880a362..4002964 100644 (file)
 
 namespace Inspector {
 
-RefPtr<AsyncStackTrace> AsyncStackTrace::create(RefPtr<ScriptCallStack> callStack, bool singleShot, RefPtr<AsyncStackTrace> parent)
+RefPtr<AsyncStackTrace> AsyncStackTrace::create(Ref<ScriptCallStack>&& callStack, bool singleShot, RefPtr<AsyncStackTrace> parent)
 {
-    ASSERT(callStack && callStack->size());
+    ASSERT(callStack->size());
     return adoptRef(*new AsyncStackTrace(WTFMove(callStack), singleShot, WTFMove(parent)));
 }
 
-AsyncStackTrace::AsyncStackTrace(RefPtr<ScriptCallStack> callStack, bool singleShot, RefPtr<AsyncStackTrace> parent)
-    : m_callStack(callStack)
+AsyncStackTrace::AsyncStackTrace(Ref<ScriptCallStack>&& callStack, bool singleShot, RefPtr<AsyncStackTrace> parent)
+    : m_callStack(WTFMove(callStack))
     , m_parent(parent)
     , m_singleShot(singleShot)
 {
@@ -104,8 +104,8 @@ RefPtr<Inspector::Protocol::Console::StackTrace> AsyncStackTrace::buildInspector
 
     auto* stackTrace = this;
     while (stackTrace) {
-        auto callStack = stackTrace->m_callStack;
-        ASSERT(callStack && callStack->size());
+        auto& callStack = stackTrace->m_callStack;
+        ASSERT(callStack->size());
 
         RefPtr<Inspector::Protocol::Console::StackTrace> protocolObject = Inspector::Protocol::Console::StackTrace::create()
             .setCallFrames(callStack->buildInspectorArray())
@@ -166,7 +166,7 @@ void AsyncStackTrace::truncate(size_t maxDepth)
     auto* currentNode = lastUnlockedAncestor;
     while (currentNode->m_parent) {
         auto& parentNode = currentNode->m_parent;
-        currentNode->m_parent = AsyncStackTrace::create(parentNode->m_callStack, true, parentNode->m_parent);
+        currentNode->m_parent = AsyncStackTrace::create(parentNode->m_callStack.copyRef(), true, parentNode->m_parent);
         currentNode = currentNode->m_parent.get();
 
         if (parentNode.get() == newStackTraceRoot)
index 2909672..a618fe7 100644 (file)
@@ -42,7 +42,7 @@ public:
         Canceled,
     };
 
-    static RefPtr<AsyncStackTrace> create(RefPtr<ScriptCallStack>, bool singleShot, RefPtr<AsyncStackTrace> parent);
+    static RefPtr<AsyncStackTrace> create(Ref<ScriptCallStack>&&, bool singleShot, RefPtr<AsyncStackTrace> parent);
 
     bool isPending() const;
     bool isLocked() const;
@@ -56,12 +56,12 @@ public:
     ~AsyncStackTrace();
 
 private:
-    AsyncStackTrace(RefPtr<ScriptCallStack>, bool, RefPtr<AsyncStackTrace>);
+    AsyncStackTrace(Ref<ScriptCallStack>&&, bool, RefPtr<AsyncStackTrace>);
 
     void truncate(size_t maxDepth);
     void remove();
 
-    RefPtr<ScriptCallStack> m_callStack;
+    Ref<ScriptCallStack> m_callStack;
     RefPtr<AsyncStackTrace> m_parent;
     unsigned m_childCount { 0 };
     State m_state { State::Pending };
index 133893f..ef09fcc 100644 (file)
@@ -66,16 +66,15 @@ ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLe
     autogenerateMetadata(state);
 }
 
-ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier)
+ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, Ref<ScriptCallStack>&& callStack, unsigned long requestIdentifier)
     : m_source(source)
     , m_type(type)
     , m_level(level)
     , m_message(message)
+    , m_callStack(WTFMove(callStack))
     , m_url()
     , m_requestId(IdentifiersFactory::requestId(requestIdentifier))
 {
-    m_callStack = callStack;
-
     const ScriptCallFrame* frame = m_callStack ? m_callStack->firstNonNativeCallFrame() : nullptr;
     if (frame) {
         m_url = frame->sourceURL();
@@ -84,12 +83,12 @@ ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLe
     }
 }
 
-ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, JSC::ExecState* state, unsigned long requestIdentifier)
+ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, Ref<ScriptArguments>&& arguments, JSC::ExecState* state, unsigned long requestIdentifier)
     : m_source(source)
     , m_type(type)
     , m_level(level)
     , m_message(message)
-    , m_arguments(arguments)
+    , m_arguments(WTFMove(arguments))
     , m_url()
     , m_requestId(IdentifiersFactory::requestId(requestIdentifier))
 {
index 4f06081..a4d18b8 100644 (file)
@@ -50,8 +50,8 @@ class JS_EXPORT_PRIVATE ConsoleMessage {
 public:
     ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned long requestIdentifier = 0);
     ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, unsigned column, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0);
-    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>, unsigned long requestIdentifier = 0);
-    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, JSC::ExecState*, unsigned long requestIdentifier = 0);
+    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref<ScriptCallStack>&&, unsigned long requestIdentifier = 0);
+    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref<ScriptArguments>&&, JSC::ExecState*, unsigned long requestIdentifier = 0);
     ~ConsoleMessage();
 
     void addToFrontend(ConsoleFrontendDispatcher&, InjectedScriptManager&, bool generatePreview);
index b7761cc..097615b 100644 (file)
@@ -45,9 +45,9 @@ using namespace JSC;
 
 namespace Inspector {
 
-InjectedScriptManager::InjectedScriptManager(InspectorEnvironment& environment, PassRefPtr<InjectedScriptHost> injectedScriptHost)
+InjectedScriptManager::InjectedScriptManager(InspectorEnvironment& environment, Ref<InjectedScriptHost>&& injectedScriptHost)
     : m_environment(environment)
-    , m_injectedScriptHost(injectedScriptHost)
+    , m_injectedScriptHost(WTFMove(injectedScriptHost))
     , m_nextInjectedScriptId(1)
 {
 }
@@ -68,7 +68,7 @@ void InjectedScriptManager::discardInjectedScripts()
     m_scriptStateToId.clear();
 }
 
-InjectedScriptHost* InjectedScriptManager::injectedScriptHost()
+InjectedScriptHost& InjectedScriptManager::injectedScriptHost()
 {
     return m_injectedScriptHost.get();
 }
index f1b7808..8475e42 100644 (file)
@@ -49,13 +49,13 @@ namespace Inspector {
 class JS_EXPORT_PRIVATE InjectedScriptManager {
     WTF_MAKE_NONCOPYABLE(InjectedScriptManager); WTF_MAKE_FAST_ALLOCATED;
 public:
-    InjectedScriptManager(InspectorEnvironment&, PassRefPtr<InjectedScriptHost>);
+    InjectedScriptManager(InspectorEnvironment&, Ref<InjectedScriptHost>&&);
     virtual ~InjectedScriptManager();
 
     virtual void disconnect();
     virtual void discardInjectedScripts();
 
-    InjectedScriptHost* injectedScriptHost();
+    InjectedScriptHost& injectedScriptHost();
     InspectorEnvironment& inspectorEnvironment() const { return m_environment; }
 
     InjectedScript injectedScriptFor(JSC::ExecState*);
@@ -76,7 +76,7 @@ private:
     JSC::JSObject* createInjectedScript(const String& source, JSC::ExecState*, int id);
 
     InspectorEnvironment& m_environment;
-    RefPtr<InjectedScriptHost> m_injectedScriptHost;
+    Ref<InjectedScriptHost> m_injectedScriptHost;
     int m_nextInjectedScriptId;
 };
 
index 8763d27..1f903ba 100644 (file)
@@ -62,7 +62,7 @@ JSGlobalObjectConsoleClient::JSGlobalObjectConsoleClient(InspectorConsoleAgent*
 {
 }
 
-void JSGlobalObjectConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void JSGlobalObjectConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     if (JSGlobalObjectConsoleClient::logToSystemConsole())
         ConsoleClient::printConsoleMessageWithArguments(MessageSource::ConsoleAPI, type, level, exec, arguments.copyRef());
@@ -72,9 +72,9 @@ void JSGlobalObjectConsoleClient::messageWithTypeAndLevel(MessageType type, Mess
     m_consoleAgent->addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, type, level, message, WTFMove(arguments), exec));
 }
 
-void JSGlobalObjectConsoleClient::count(ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void JSGlobalObjectConsoleClient::count(ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
-    m_consoleAgent->count(exec, arguments);
+    m_consoleAgent->count(exec, WTFMove(arguments));
 }
 
 void JSGlobalObjectConsoleClient::profile(JSC::ExecState*, const String& title)
@@ -156,11 +156,10 @@ void JSGlobalObjectConsoleClient::time(ExecState*, const String& title)
 
 void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& title)
 {
-    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1));
-    m_consoleAgent->stopTiming(title, WTFMove(callStack));
+    m_consoleAgent->stopTiming(title, createScriptCallStackForConsole(exec, 1));
 }
 
-void JSGlobalObjectConsoleClient::timeStamp(ExecState*, RefPtr<ScriptArguments>&&)
+void JSGlobalObjectConsoleClient::timeStamp(ExecState*, Ref<ScriptArguments>&&)
 {
     // FIXME: JSContext inspection needs a timeline.
     warnUnimplemented(ASCIILiteral("console.timeStamp"));
@@ -169,7 +168,7 @@ void JSGlobalObjectConsoleClient::timeStamp(ExecState*, RefPtr<ScriptArguments>&
 void JSGlobalObjectConsoleClient::warnUnimplemented(const String& method)
 {
     String message = method + " is currently ignored in JavaScript context inspection.";
-    m_consoleAgent->addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Warning, message, nullptr, nullptr));
+    m_consoleAgent->addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Warning, message));
 }
 
 } // namespace Inspector
index 527ffd9..d9b259c 100644 (file)
@@ -45,18 +45,18 @@ public:
     static void setLogToSystemConsole(bool);
 
 protected:
-    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, RefPtr<ScriptArguments>&&) override;
-    void count(JSC::ExecState*, RefPtr<ScriptArguments>&&) override;
+    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<ScriptArguments>&&) override;
+    void count(JSC::ExecState*, Ref<ScriptArguments>&&) override;
     void profile(JSC::ExecState*, const String& title) override;
     void profileEnd(JSC::ExecState*, const String& title) override;
     void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
     void time(JSC::ExecState*, const String& title) override;
     void timeEnd(JSC::ExecState*, const String& title) override;
-    void timeStamp(JSC::ExecState*, RefPtr<ScriptArguments>&&) override;
+    void timeStamp(JSC::ExecState*, Ref<ScriptArguments>&&) override;
 
 private:
     void warnUnimplemented(const String& method);
-    void internalAddMessage(MessageType, MessageLevel, JSC::ExecState*, RefPtr<ScriptArguments>&&);
+    void internalAddMessage(MessageType, MessageLevel, JSC::ExecState*, Ref<ScriptArguments>&&);
 
     void startConsoleProfile();
     void stopConsoleProfile();
index 1bf8008..313730a 100644 (file)
@@ -187,7 +187,7 @@ void JSGlobalObjectInspectorController::pause()
     m_debuggerAgent->pause(dummyError);
 }
 
-void JSGlobalObjectInspectorController::appendAPIBacktrace(ScriptCallStack* callStack)
+void JSGlobalObjectInspectorController::appendAPIBacktrace(ScriptCallStack& callStack)
 {
 #if OS(DARWIN) || (OS(LINUX) && !PLATFORM(GTK))
     static const int framesToShow = 31;
@@ -208,9 +208,9 @@ void JSGlobalObjectInspectorController::appendAPIBacktrace(ScriptCallStack* call
         if (mangledName)
             cxaDemangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, nullptr);
         if (mangledName || cxaDemangled)
-            callStack->append(ScriptCallFrame(cxaDemangled ? cxaDemangled : mangledName, ASCIILiteral("[native code]"), noSourceID, 0, 0));
+            callStack.append(ScriptCallFrame(cxaDemangled ? cxaDemangled : mangledName, ASCIILiteral("[native code]"), noSourceID, 0, 0));
         else
-            callStack->append(ScriptCallFrame(ASCIILiteral("?"), ASCIILiteral("[native code]"), noSourceID, 0, 0));
+            callStack.append(ScriptCallFrame(ASCIILiteral("?"), ASCIILiteral("[native code]"), noSourceID, 0, 0));
         free(cxaDemangled);
     }
 #else
@@ -227,7 +227,7 @@ void JSGlobalObjectInspectorController::reportAPIException(ExecState* exec, Exce
     auto scope = DECLARE_CATCH_SCOPE(vm);
     ErrorHandlingScope errorScope(vm);
 
-    RefPtr<ScriptCallStack> callStack = createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture);
+    Ref<ScriptCallStack> callStack = createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture);
     if (includesNativeCallStackWhenReportingExceptions())
         appendAPIBacktrace(callStack.get());
 
@@ -244,7 +244,7 @@ void JSGlobalObjectInspectorController::reportAPIException(ExecState* exec, Exce
             ConsoleClient::printConsoleMessage(MessageSource::JS, MessageType::Log, MessageLevel::Error, errorMessage, String(), 0, 0);
     }
 
-    m_consoleAgent->addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::JS, MessageType::Log, MessageLevel::Error, errorMessage, callStack));
+    m_consoleAgent->addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::JS, MessageType::Log, MessageLevel::Error, errorMessage, WTFMove(callStack)));
 }
 
 ConsoleClient* JSGlobalObjectInspectorController::consoleClient() const
index f3feafd..26a568f 100644 (file)
@@ -102,7 +102,7 @@ public:
 #endif
 
 private:
-    void appendAPIBacktrace(ScriptCallStack* callStack);
+    void appendAPIBacktrace(ScriptCallStack&);
 
     JSC::JSGlobalObject& m_globalObject;
     std::unique_ptr<InjectedScriptManager> m_injectedScriptManager;
index 1f1e469..1916c5d 100644 (file)
@@ -39,9 +39,9 @@ namespace Inspector {
 
 const ClassInfo JSJavaScriptCallFrame::s_info = { "JavaScriptCallFrame", &Base::s_info, 0, CREATE_METHOD_TABLE(JSJavaScriptCallFrame) };
 
-JSJavaScriptCallFrame::JSJavaScriptCallFrame(VM& vm, Structure* structure, PassRefPtr<JavaScriptCallFrame> impl)
+JSJavaScriptCallFrame::JSJavaScriptCallFrame(VM& vm, Structure* structure, Ref<JavaScriptCallFrame>&& impl)
     : JSDestructibleObject(vm, structure)
-    , m_impl(impl.leakRef())
+    , m_impl(&impl.leakRef())
 {
 }
 
@@ -228,7 +228,7 @@ JSValue toJS(ExecState* exec, JSGlobalObject* globalObject, JavaScriptCallFrame*
 
     JSObject* prototype = JSJavaScriptCallFrame::createPrototype(exec->vm(), globalObject);
     Structure* structure = JSJavaScriptCallFrame::createStructure(exec->vm(), globalObject, prototype);
-    JSJavaScriptCallFrame* javaScriptCallFrame = JSJavaScriptCallFrame::create(exec->vm(), structure, impl);
+    JSJavaScriptCallFrame* javaScriptCallFrame = JSJavaScriptCallFrame::create(exec->vm(), structure, *impl);
 
     return javaScriptCallFrame;
 }
index 56b69d4..2ac247c 100644 (file)
@@ -42,9 +42,9 @@ public:
         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
     }
 
-    static JSJavaScriptCallFrame* create(JSC::VM& vm, JSC::Structure* structure, PassRefPtr<JavaScriptCallFrame> impl)
+    static JSJavaScriptCallFrame* create(JSC::VM& vm, JSC::Structure* structure, Ref<JavaScriptCallFrame>&& impl)
     {
-        JSJavaScriptCallFrame* instance = new (NotNull, JSC::allocateCell<JSJavaScriptCallFrame>(vm.heap)) JSJavaScriptCallFrame(vm, structure, impl);
+        JSJavaScriptCallFrame* instance = new (NotNull, JSC::allocateCell<JSJavaScriptCallFrame>(vm.heap)) JSJavaScriptCallFrame(vm, structure, WTFMove(impl));
         instance->finishCreation(vm);
         return instance;
     }
@@ -83,7 +83,7 @@ protected:
     void finishCreation(JSC::VM&);
 
 private:
-    JSJavaScriptCallFrame(JSC::VM&, JSC::Structure*, PassRefPtr<JavaScriptCallFrame>);
+    JSJavaScriptCallFrame(JSC::VM&, JSC::Structure*, Ref<JavaScriptCallFrame>&&);
     ~JSJavaScriptCallFrame();
 
     JavaScriptCallFrame* m_impl;
index d5f73d5..3c28484 100644 (file)
@@ -30,8 +30,8 @@ using namespace JSC;
 
 namespace Inspector {
 
-JavaScriptCallFrame::JavaScriptCallFrame(PassRefPtr<DebuggerCallFrame> debuggerCallFrame)
-    : m_debuggerCallFrame(debuggerCallFrame)
+JavaScriptCallFrame::JavaScriptCallFrame(Ref<DebuggerCallFrame>&& debuggerCallFrame)
+    : m_debuggerCallFrame(WTFMove(debuggerCallFrame))
 {
 }
 
@@ -44,7 +44,7 @@ JavaScriptCallFrame* JavaScriptCallFrame::caller()
     if (!debuggerCallerFrame)
         return nullptr;
 
-    m_caller = create(debuggerCallerFrame);
+    m_caller = create(debuggerCallerFrame.releaseNonNull());
     return m_caller.get();
 }
 
index f9adbec..6af492e 100644 (file)
@@ -37,9 +37,9 @@ namespace Inspector {
 
 class JavaScriptCallFrame : public RefCounted<JavaScriptCallFrame> {
 public:
-    static Ref<JavaScriptCallFrame> create(PassRefPtr<JSC::DebuggerCallFrame> debuggerCallFrame)
+    static Ref<JavaScriptCallFrame> create(Ref<JSC::DebuggerCallFrame>&& debuggerCallFrame)
     {
-        return adoptRef(*new JavaScriptCallFrame(debuggerCallFrame));
+        return adoptRef(*new JavaScriptCallFrame(WTFMove(debuggerCallFrame)));
     }
 
     JavaScriptCallFrame* caller();
@@ -58,9 +58,9 @@ public:
     JSC::JSValue evaluateWithScopeExtension(const String& script, JSC::JSObject* scopeExtension, NakedPtr<JSC::Exception>& exception) const { return m_debuggerCallFrame->evaluateWithScopeExtension(script, scopeExtension, exception); }
 
 private:
-    JavaScriptCallFrame(PassRefPtr<JSC::DebuggerCallFrame>);
+    JavaScriptCallFrame(Ref<JSC::DebuggerCallFrame>&&);
 
-    RefPtr<JSC::DebuggerCallFrame> m_debuggerCallFrame;
+    Ref<JSC::DebuggerCallFrame> m_debuggerCallFrame;
     RefPtr<JavaScriptCallFrame> m_caller;
 };
 
index 755f5b8..84cefdf 100644 (file)
@@ -89,29 +89,29 @@ void ScriptDebugServer::clearBreakpointActions()
 
 bool ScriptDebugServer::evaluateBreakpointAction(const ScriptBreakpointAction& breakpointAction)
 {
-    DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();
+    DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
 
     switch (breakpointAction.type) {
     case ScriptBreakpointActionTypeLog: {
-        dispatchBreakpointActionLog(debuggerCallFrame->globalExec(), breakpointAction.data);
+        dispatchBreakpointActionLog(debuggerCallFrame.globalExec(), breakpointAction.data);
         break;
     }
     case ScriptBreakpointActionTypeEvaluate: {
         NakedPtr<Exception> exception;
         JSObject* scopeExtensionObject = nullptr;
-        debuggerCallFrame->evaluateWithScopeExtension(breakpointAction.data, scopeExtensionObject, exception);
+        debuggerCallFrame.evaluateWithScopeExtension(breakpointAction.data, scopeExtensionObject, exception);
         if (exception)
-            reportException(debuggerCallFrame->globalExec(), exception);
+            reportException(debuggerCallFrame.globalExec(), exception);
         break;
     }
     case ScriptBreakpointActionTypeSound:
-        dispatchBreakpointActionSound(debuggerCallFrame->globalExec(), breakpointAction.identifier);
+        dispatchBreakpointActionSound(debuggerCallFrame.globalExec(), breakpointAction.identifier);
         break;
     case ScriptBreakpointActionTypeProbe: {
         NakedPtr<Exception> exception;
         JSObject* scopeExtensionObject = nullptr;
-        JSValue result = debuggerCallFrame->evaluateWithScopeExtension(breakpointAction.data, scopeExtensionObject, exception);
-        JSC::ExecState* exec = debuggerCallFrame->globalExec();
+        JSValue result = debuggerCallFrame.evaluateWithScopeExtension(breakpointAction.data, scopeExtensionObject, exception);
+        JSC::ExecState* exec = debuggerCallFrame.globalExec();
         if (exception)
             reportException(exec, exception);
 
@@ -128,8 +128,8 @@ bool ScriptDebugServer::evaluateBreakpointAction(const ScriptBreakpointAction& b
 void ScriptDebugServer::dispatchDidPause(ScriptDebugListener* listener)
 {
     ASSERT(isPaused());
-    DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();
-    JSGlobalObject* globalObject = debuggerCallFrame->scope()->globalObject();
+    DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
+    JSGlobalObject* globalObject = debuggerCallFrame.scope()->globalObject();
     JSC::ExecState& state = *globalObject->globalExec();
     JSValue jsCallFrame = toJS(&state, globalObject, JavaScriptCallFrame::create(debuggerCallFrame).ptr());
     listener->didPause(state, jsCallFrame, exceptionOrCaughtValue(&state));
@@ -345,7 +345,7 @@ JSC::JSValue ScriptDebugServer::exceptionOrCaughtValue(JSC::ExecState* state)
     if (reasonForPause() == PausedForException)
         return currentException();
 
-    for (RefPtr<DebuggerCallFrame> frame = currentDebuggerCallFrame(); frame; frame = frame->callerFrame()) {
+    for (RefPtr<DebuggerCallFrame> frame = &currentDebuggerCallFrame(); frame; frame = frame->callerFrame()) {
         DebuggerScope& scope = *frame->scope();
         if (scope.isCatchScope())
             return scope.caughtValue(state);
index e956ee5..d453dbb 100644 (file)
@@ -145,7 +145,7 @@ void InspectorConsoleAgent::startTiming(const String& title)
     }
 }
 
-void InspectorConsoleAgent::stopTiming(const String& title, PassRefPtr<ScriptCallStack> callStack)
+void InspectorConsoleAgent::stopTiming(const String& title, Ref<ScriptCallStack>&& callStack)
 {
     ASSERT(!title.isNull());
     if (title.isNull())
@@ -164,7 +164,7 @@ void InspectorConsoleAgent::stopTiming(const String& title, PassRefPtr<ScriptCal
 
     double elapsed = monotonicallyIncreasingTime() - startTime;
     String message = title + String::format(": %.3fms", elapsed * 1000);
-    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, callStack));
+    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(callStack)));
 }
 
 void InspectorConsoleAgent::takeHeapSnapshot(const String& title)
@@ -180,9 +180,9 @@ void InspectorConsoleAgent::takeHeapSnapshot(const String& title)
     m_frontendDispatcher->heapSnapshot(timestamp, snapshotData, title.isEmpty() ? nullptr : &title);
 }
 
-void InspectorConsoleAgent::count(JSC::ExecState* state, PassRefPtr<ScriptArguments> arguments)
+void InspectorConsoleAgent::count(JSC::ExecState* state, Ref<ScriptArguments>&& arguments)
 {
-    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture));
+    Ref<ScriptCallStack> callStack = createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture);
 
     String title;
     String identifier;
@@ -203,7 +203,7 @@ void InspectorConsoleAgent::count(JSC::ExecState* state, PassRefPtr<ScriptArgume
     // FIXME: Web Inspector should have a better UI for counters, but for now we just log an updated counter value.
 
     String message = makeString(title, ": ", String::number(result.iterator->value));
-    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, callStack));
+    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, WTFMove(callStack)));
 }
 
 static bool isGroupMessage(MessageType type)
index 45840e6..175cec9 100644 (file)
@@ -71,9 +71,9 @@ public:
     void addMessageToConsole(std::unique_ptr<ConsoleMessage>);
 
     void startTiming(const String& title);
-    void stopTiming(const String& title, PassRefPtr<ScriptCallStack>);
+    void stopTiming(const String& title, Ref<ScriptCallStack>&&);
     void takeHeapSnapshot(const String& title);
-    void count(JSC::ExecState*, PassRefPtr<ScriptArguments>);
+    void count(JSC::ExecState*, Ref<ScriptArguments>&&);
 
 protected:
     void addConsoleMessage(std::unique_ptr<ConsoleMessage>);
index d34d29f..617efb9 100644 (file)
@@ -230,9 +230,9 @@ void InspectorDebuggerAgent::didScheduleAsyncCall(JSC::ExecState* exec, int asyn
     if (!m_scriptDebugServer.breakpointsActive())
         return;
 
-    RefPtr<ScriptCallStack> callStack = createScriptCallStack(exec, m_asyncStackTraceDepth);
-    ASSERT(callStack && callStack->size());
-    if (!callStack || !callStack->size())
+    Ref<ScriptCallStack> callStack = createScriptCallStack(exec, m_asyncStackTraceDepth);
+    ASSERT(callStack->size());
+    if (!callStack->size())
         return;
 
     RefPtr<AsyncStackTrace> parentStackTrace;
index 1ae3e29..68d71c3 100644 (file)
@@ -147,11 +147,11 @@ void ConsoleClient::printConsoleMessage(MessageSource source, MessageType type,
     WTFLogAlways("%s", builder.toString().utf8().data());
 }
 
-void ConsoleClient::printConsoleMessageWithArguments(MessageSource source, MessageType type, MessageLevel level, JSC::ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void ConsoleClient::printConsoleMessageWithArguments(MessageSource source, MessageType type, MessageLevel level, JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     bool isTraceMessage = type == MessageType::Trace;
     size_t stackSize = isTraceMessage ? ScriptCallStack::maxCallStackSizeToCapture : 1;
-    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, stackSize));
+    Ref<ScriptCallStack> callStack = createScriptCallStackForConsole(exec, stackSize);
     const ScriptCallFrame& lastCaller = callStack->at(0);
 
     StringBuilder builder;
@@ -190,7 +190,7 @@ void ConsoleClient::printConsoleMessageWithArguments(MessageSource source, Messa
     }
 }
 
-void ConsoleClient::internalMessageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, RefPtr<ScriptArguments>&& arguments, ArgumentRequirement argumentRequirement)
+void ConsoleClient::internalMessageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, Ref<ScriptArguments>&& arguments, ArgumentRequirement argumentRequirement)
 {
     if (argumentRequirement == ArgumentRequired && !arguments->argumentCount())
         return;
@@ -198,7 +198,7 @@ void ConsoleClient::internalMessageWithTypeAndLevel(MessageType type, MessageLev
     messageWithTypeAndLevel(type, level, exec, WTFMove(arguments));
 }
 
-void ConsoleClient::logWithLevel(ExecState* exec, RefPtr<ScriptArguments>&& arguments, MessageLevel level)
+void ConsoleClient::logWithLevel(ExecState* exec, Ref<ScriptArguments>&& arguments, MessageLevel level)
 {
     internalMessageWithTypeAndLevel(MessageType::Log, level, exec, WTFMove(arguments), ArgumentRequired);
 }
@@ -208,42 +208,42 @@ void ConsoleClient::clear(ExecState* exec)
     internalMessageWithTypeAndLevel(MessageType::Clear, MessageLevel::Log, exec, ScriptArguments::createEmpty(exec), ArgumentNotRequired);
 }
 
-void ConsoleClient::dir(ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void ConsoleClient::dir(ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     internalMessageWithTypeAndLevel(MessageType::Dir, MessageLevel::Log, exec, WTFMove(arguments), ArgumentRequired);
 }
 
-void ConsoleClient::dirXML(ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void ConsoleClient::dirXML(ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     internalMessageWithTypeAndLevel(MessageType::DirXML, MessageLevel::Log, exec, WTFMove(arguments), ArgumentRequired);
 }
 
-void ConsoleClient::table(ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void ConsoleClient::table(ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     internalMessageWithTypeAndLevel(MessageType::Table, MessageLevel::Log, exec, WTFMove(arguments), ArgumentRequired);
 }
 
-void ConsoleClient::trace(ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void ConsoleClient::trace(ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     internalMessageWithTypeAndLevel(MessageType::Trace, MessageLevel::Log, exec, WTFMove(arguments), ArgumentNotRequired);
 }
 
-void ConsoleClient::assertion(ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void ConsoleClient::assertion(ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     internalMessageWithTypeAndLevel(MessageType::Assert, MessageLevel::Error, exec, WTFMove(arguments), ArgumentNotRequired);
 }
 
-void ConsoleClient::group(ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void ConsoleClient::group(ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     internalMessageWithTypeAndLevel(MessageType::StartGroup, MessageLevel::Log, exec, WTFMove(arguments), ArgumentNotRequired);
 }
 
-void ConsoleClient::groupCollapsed(ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void ConsoleClient::groupCollapsed(ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     internalMessageWithTypeAndLevel(MessageType::StartGroupCollapsed, MessageLevel::Log, exec, WTFMove(arguments), ArgumentNotRequired);
 }
 
-void ConsoleClient::groupEnd(ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void ConsoleClient::groupEnd(ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     internalMessageWithTypeAndLevel(MessageType::EndGroup, MessageLevel::Log, exec, WTFMove(arguments), ArgumentNotRequired);
 }
index 759df7f..4951f46 100644 (file)
@@ -41,31 +41,31 @@ public:
     virtual ~ConsoleClient() { }
 
     JS_EXPORT_PRIVATE static void printConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned lineNumber, unsigned columnNumber);
-    JS_EXPORT_PRIVATE static void printConsoleMessageWithArguments(MessageSource, MessageType, MessageLevel, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&);
+    JS_EXPORT_PRIVATE static void printConsoleMessageWithArguments(MessageSource, MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
 
-    void logWithLevel(ExecState*, RefPtr<Inspector::ScriptArguments>&&, MessageLevel);
+    void logWithLevel(ExecState*, Ref<Inspector::ScriptArguments>&&, MessageLevel);
     void clear(ExecState*);
-    void dir(ExecState*, RefPtr<Inspector::ScriptArguments>&&);
-    void dirXML(ExecState*, RefPtr<Inspector::ScriptArguments>&&);
-    void table(ExecState*, RefPtr<Inspector::ScriptArguments>&&);
-    void trace(ExecState*, RefPtr<Inspector::ScriptArguments>&&);
-    void assertion(ExecState*, RefPtr<Inspector::ScriptArguments>&&);
-    void group(ExecState*, RefPtr<Inspector::ScriptArguments>&&);
-    void groupCollapsed(ExecState*, RefPtr<Inspector::ScriptArguments>&&);
-    void groupEnd(ExecState*, RefPtr<Inspector::ScriptArguments>&&);
+    void dir(ExecState*, Ref<Inspector::ScriptArguments>&&);
+    void dirXML(ExecState*, Ref<Inspector::ScriptArguments>&&);
+    void table(ExecState*, Ref<Inspector::ScriptArguments>&&);
+    void trace(ExecState*, Ref<Inspector::ScriptArguments>&&);
+    void assertion(ExecState*, Ref<Inspector::ScriptArguments>&&);
+    void group(ExecState*, Ref<Inspector::ScriptArguments>&&);
+    void groupCollapsed(ExecState*, Ref<Inspector::ScriptArguments>&&);
+    void groupEnd(ExecState*, Ref<Inspector::ScriptArguments>&&);
 
-    virtual void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) = 0;
-    virtual void count(ExecState*, RefPtr<Inspector::ScriptArguments>&&) = 0;
+    virtual void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
+    virtual void count(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
     virtual void profile(ExecState*, const String& title) = 0;
     virtual void profileEnd(ExecState*, const String& title) = 0;
     virtual void takeHeapSnapshot(ExecState*, const String& title) = 0;
     virtual void time(ExecState*, const String& title) = 0;
     virtual void timeEnd(ExecState*, const String& title) = 0;
-    virtual void timeStamp(ExecState*, RefPtr<Inspector::ScriptArguments>&&) = 0;
+    virtual void timeStamp(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
 
 private:
     enum ArgumentRequirement { ArgumentRequired, ArgumentNotRequired };
-    void internalMessageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&, ArgumentRequirement);
+    void internalMessageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&, ArgumentRequirement);
 };
 
 } // namespace JSC
index ee8e599..76ae45d 100644 (file)
@@ -110,8 +110,7 @@ static EncodedJSValue consoleLogWithLevel(ExecState* exec, MessageLevel level)
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->logWithLevel(exec, WTFMove(arguments), level);
+    client->logWithLevel(exec, Inspector::createScriptArguments(exec, 0), level);
     return JSValue::encode(jsUndefined());
 }
 
@@ -156,8 +155,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncDir(ExecState* exec)
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->dir(exec, WTFMove(arguments));
+    client->dir(exec, Inspector::createScriptArguments(exec, 0));
     return JSValue::encode(jsUndefined());
 }
 
@@ -167,8 +165,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncDirXML(ExecState* exec)
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->dirXML(exec, WTFMove(arguments));
+    client->dirXML(exec, Inspector::createScriptArguments(exec, 0));
     return JSValue::encode(jsUndefined());
 }
 
@@ -178,8 +175,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTable(ExecState* exec)
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->table(exec, WTFMove(arguments));
+    client->table(exec, Inspector::createScriptArguments(exec, 0));
     return JSValue::encode(jsUndefined());
 }
 
@@ -189,8 +185,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTrace(ExecState* exec)
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->trace(exec, WTFMove(arguments));
+    client->trace(exec, Inspector::createScriptArguments(exec, 0));
     return JSValue::encode(jsUndefined());
 }
 
@@ -208,8 +203,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncAssert(ExecState* exec)
     if (condition)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 1));
-    client->assertion(exec, WTFMove(arguments));
+    client->assertion(exec, Inspector::createScriptArguments(exec, 1));
     return JSValue::encode(jsUndefined());
 }
 
@@ -219,8 +213,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncCount(ExecState* exec)
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->count(exec, WTFMove(arguments));
+    client->count(exec, Inspector::createScriptArguments(exec, 0));
     return JSValue::encode(jsUndefined());
 }
 
@@ -340,8 +333,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeStamp(ExecState* exec)
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->timeStamp(exec, WTFMove(arguments));
+    client->timeStamp(exec, Inspector::createScriptArguments(exec, 0));
     return JSValue::encode(jsUndefined());
 }
 
@@ -351,8 +343,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncGroup(ExecState* exec)
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->group(exec, WTFMove(arguments));
+    client->group(exec, Inspector::createScriptArguments(exec, 0));
     return JSValue::encode(jsUndefined());
 }
 
@@ -362,8 +353,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncGroupCollapsed(ExecState* ex
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->groupCollapsed(exec, WTFMove(arguments));
+    client->groupCollapsed(exec, Inspector::createScriptArguments(exec, 0));
     return JSValue::encode(jsUndefined());
 }
 
@@ -373,8 +363,7 @@ static EncodedJSValue JSC_HOST_CALL consoleProtoFuncGroupEnd(ExecState* exec)
     if (!client)
         return JSValue::encode(jsUndefined());
 
-    RefPtr<Inspector::ScriptArguments> arguments(Inspector::createScriptArguments(exec, 0));
-    client->groupEnd(exec, WTFMove(arguments));
+    client->groupEnd(exec, Inspector::createScriptArguments(exec, 0));
     return JSValue::encode(jsUndefined());
 }
 
index 34de653..d07a62b 100644 (file)
@@ -1,3 +1,55 @@
+2017-02-16  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Drop PassRefPtr in inspector/
+        https://bugs.webkit.org/show_bug.cgi?id=168420
+
+        Reviewed by Alex Christensen.
+
+        Use Ref<Inspector::ScriptArguments> and Ref<ScriptCallStack> as much as possible.
+        It drops some unnecessary null checks.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallWith):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionWithScriptArgumentsAndCallStackCaller):
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::PendingException::PendingException):
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::consoleCountImpl):
+        (WebCore::InspectorInstrumentation::stopConsoleTimingImpl):
+        (WebCore::InspectorInstrumentation::consoleTimeStampImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::consoleCount):
+        (WebCore::InspectorInstrumentation::stopConsoleTiming):
+        (WebCore::InspectorInstrumentation::consoleTimeStamp):
+        * inspector/InspectorNetworkAgent.cpp:
+        (WebCore::InspectorNetworkAgent::buildInitiatorObject):
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore::TimelineRecordFactory::createGenericRecord):
+        * inspector/WebInjectedScriptManager.cpp:
+        (WebCore::WebInjectedScriptManager::WebInjectedScriptManager):
+        * inspector/WebInjectedScriptManager.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::postMessageTimerFired):
+        We dispatch appropriate addMessage function according to whether
+        `timer.stackTrace()` is nullptr.
+
+        * page/PageConsoleClient.cpp:
+        (WebCore::PageConsoleClient::addMessage):
+        (WebCore::PageConsoleClient::messageWithTypeAndLevel):
+        (WebCore::PageConsoleClient::count):
+        (WebCore::PageConsoleClient::timeEnd):
+        (WebCore::PageConsoleClient::timeStamp):
+        * page/PageConsoleClient.h:
+        * workers/WorkerConsoleClient.cpp:
+        (WebCore::WorkerConsoleClient::messageWithTypeAndLevel):
+        (WebCore::WorkerConsoleClient::count):
+        (WebCore::WorkerConsoleClient::timeEnd):
+        (WebCore::WorkerConsoleClient::timeStamp):
+        * workers/WorkerConsoleClient.h:
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::addMessage):
+
 2017-02-16  Chris Fleizach  <cfleizach@apple.com>
 
         AX: Make form validation accessible on iOS
index 05fe033..a6d47cb 100644 (file)
@@ -4529,7 +4529,7 @@ sub GenerateCallWith
         push(@callWithArgs, "*document");
     }
     if ($function and $codeGenerator->ExtendedAttributeContains($callWith, "ScriptArguments")) {
-        push(@$outputArray, "    RefPtr<Inspector::ScriptArguments> scriptArguments(Inspector::createScriptArguments($statePointer, " . @{$function->arguments} . "));\n");
+        push(@$outputArray, "    Ref<Inspector::ScriptArguments> scriptArguments(Inspector::createScriptArguments($statePointer, " . @{$function->arguments} . "));\n");
         $implIncludes{"<inspector/ScriptArguments.h>"} = 1;
         $implIncludes{"<inspector/ScriptCallStackFactory.h>"} = 1;
         push(@callWithArgs, "WTFMove(scriptArguments)");
index 5b5394f..b8519ce 100644 (file)
@@ -6112,7 +6112,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionWithScriptArgumentsA
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
-    RefPtr<Inspector::ScriptArguments> scriptArguments(Inspector::createScriptArguments(state, 0));
+    Ref<Inspector::ScriptArguments> scriptArguments(Inspector::createScriptArguments(state, 0));
     impl.withScriptArgumentsAndCallStack(WTFMove(scriptArguments));
     return JSValue::encode(jsUndefined());
 }
index e279244..328818f 100644 (file)
@@ -61,7 +61,7 @@ public:
         , m_lineNumber(lineNumber)
         , m_columnNumber(columnNumber)
         , m_sourceURL(sourceURL)
-        , m_callStack(callStack)
+        , m_callStack(WTFMove(callStack))
     {
     }
     String m_errorMessage;
index d68c522..87f0d93 100644 (file)
@@ -838,10 +838,10 @@ void InspectorInstrumentation::addMessageToConsoleImpl(InstrumentingAgents& inst
     }
 }
 
-void InspectorInstrumentation::consoleCountImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, RefPtr<ScriptArguments>&& arguments)
+void InspectorInstrumentation::consoleCountImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, Ref<ScriptArguments>&& arguments)
 {
     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
-        consoleAgent->count(state, arguments);
+        consoleAgent->count(state, WTFMove(arguments));
 }
 
 void InspectorInstrumentation::takeHeapSnapshotImpl(InstrumentingAgents& instrumentingAgents, const String& title)
@@ -864,21 +864,21 @@ void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instr
         consoleAgent->startTiming(title);
 }
 
-void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& title, RefPtr<ScriptCallStack>&& stack)
+void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& title, Ref<ScriptCallStack>&& stack)
 {
     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
-        consoleAgent->stopTiming(title, stack);
+        consoleAgent->stopTiming(title, WTFMove(stack));
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
         timelineAgent->timeEnd(frame, title);
 }
 
-void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title, RefPtr<ScriptCallStack>&& stack)
+void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title, Ref<ScriptCallStack>&& stack)
 {
     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
-        consoleAgent->stopTiming(title, stack);
+        consoleAgent->stopTiming(title, WTFMove(stack));
 }
 
-void InspectorInstrumentation::consoleTimeStampImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, RefPtr<ScriptArguments>&& arguments)
+void InspectorInstrumentation::consoleTimeStampImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, Ref<ScriptArguments>&& arguments)
 {
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent()) {
         String message;
index 245cdc8..68ceccf 100644 (file)
@@ -184,14 +184,14 @@ public:
     static void addMessageToConsole(Page&, std::unique_ptr<Inspector::ConsoleMessage>);
     static void addMessageToConsole(WorkerGlobalScope&, std::unique_ptr<Inspector::ConsoleMessage>);
 
-    static void consoleCount(Page&, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&);
-    static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&);
+    static void consoleCount(Page&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
+    static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
     static void takeHeapSnapshot(Frame&, const String& title);
     static void startConsoleTiming(Frame&, const String& title);
     static void startConsoleTiming(WorkerGlobalScope&, const String& title);
-    static void stopConsoleTiming(Frame&, const String& title, RefPtr<Inspector::ScriptCallStack>&&);
-    static void stopConsoleTiming(WorkerGlobalScope&, const String& title, RefPtr<Inspector::ScriptCallStack>&&);
-    static void consoleTimeStamp(Frame&, RefPtr<Inspector::ScriptArguments>&&);
+    static void stopConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
+    static void stopConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptCallStack>&&);
+    static void consoleTimeStamp(Frame&, Ref<Inspector::ScriptArguments>&&);
     static void startProfiling(Page&, JSC::ExecState*, const String& title);
     static void stopProfiling(Page&, JSC::ExecState*, const String& title);
 
@@ -349,13 +349,13 @@ private:
 
     static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>);
 
-    static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&);
+    static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
     static void takeHeapSnapshotImpl(InstrumentingAgents&, const String& title);
     static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title);
     static void startConsoleTimingImpl(InstrumentingAgents&, const String& title);
-    static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title, RefPtr<Inspector::ScriptCallStack>&&);
-    static void stopConsoleTimingImpl(InstrumentingAgents&, const String& title, RefPtr<Inspector::ScriptCallStack>&&);
-    static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, RefPtr<Inspector::ScriptArguments>&&);
+    static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
+    static void stopConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptCallStack>&&);
+    static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&);
 
     static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Frame*);
     static void didCancelAnimationFrameImpl(InstrumentingAgents&, int callbackId, Frame*);
@@ -1195,12 +1195,12 @@ inline void InspectorInstrumentation::addMessageToConsole(WorkerGlobalScope& wor
     addMessageToConsoleImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), WTFMove(message));
 }
 
-inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, RefPtr<Inspector::ScriptArguments>&& arguments)
+inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)
 {
     consoleCountImpl(instrumentingAgentsForPage(page), state, WTFMove(arguments));
 }
 
-inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, RefPtr<Inspector::ScriptArguments>&& arguments)
+inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)
 {
     consoleCountImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, WTFMove(arguments));
 }
@@ -1223,18 +1223,18 @@ inline void InspectorInstrumentation::startConsoleTiming(WorkerGlobalScope& work
     startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title);
 }
 
-inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, const String& title, RefPtr<Inspector::ScriptCallStack>&& stack)
+inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptCallStack>&& stack)
 {
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
         stopConsoleTimingImpl(*instrumentingAgents, frame, title, WTFMove(stack));
 }
 
-inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title, RefPtr<Inspector::ScriptCallStack>&& stack)
+inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title, Ref<Inspector::ScriptCallStack>&& stack)
 {
     stopConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title, WTFMove(stack));
 }
 
-inline void InspectorInstrumentation::consoleTimeStamp(Frame& frame, RefPtr<Inspector::ScriptArguments>&& arguments)
+inline void InspectorInstrumentation::consoleTimeStamp(Frame& frame, Ref<Inspector::ScriptArguments>&& arguments)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
index 432478f..569ce4a 100644 (file)
@@ -502,8 +502,8 @@ void InspectorNetworkAgent::didScheduleStyleRecalculation(Document& document)
 
 RefPtr<Inspector::Protocol::Network::Initiator> InspectorNetworkAgent::buildInitiatorObject(Document* document)
 {
-    RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture);
-    if (stackTrace && stackTrace->size() > 0) {
+    Ref<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture);
+    if (stackTrace->size() > 0) {
         auto initiatorObject = Inspector::Protocol::Network::Initiator::create()
             .setType(Inspector::Protocol::Network::Initiator::Type::Script)
             .release();
index 68f7591..a216593 100644 (file)
@@ -50,8 +50,8 @@ Ref<InspectorObject> TimelineRecordFactory::createGenericRecord(double startTime
     record->setDouble(ASCIILiteral("startTime"), startTime);
 
     if (maxCallStackDepth) {
-        RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), maxCallStackDepth);
-        if (stackTrace && stackTrace->size())
+        Ref<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), maxCallStackDepth);
+        if (stackTrace->size())
             record->setValue(ASCIILiteral("stackTrace"), stackTrace->buildInspectorArray());
     }
     return record;
index 7a996dc..c7f82ff 100644 (file)
@@ -33,7 +33,7 @@ using namespace Inspector;
 
 namespace WebCore {
 
-WebInjectedScriptManager::WebInjectedScriptManager(InspectorEnvironment& environment, RefPtr<InjectedScriptHost>&& host)
+WebInjectedScriptManager::WebInjectedScriptManager(InspectorEnvironment& environment, Ref<InjectedScriptHost>&& host)
     : InjectedScriptManager(environment, WTFMove(host))
     , m_commandLineAPIHost(CommandLineAPIHost::create())
 {
index bc1637c..6b4ad7c 100644 (file)
@@ -35,7 +35,7 @@ class DOMWindow;
 
 class WebInjectedScriptManager final : public Inspector::InjectedScriptManager {
 public:
-    WebInjectedScriptManager(Inspector::InspectorEnvironment&, RefPtr<Inspector::InjectedScriptHost>&&);
+    WebInjectedScriptManager(Inspector::InspectorEnvironment&, Ref<Inspector::InjectedScriptHost>&&);
     virtual ~WebInjectedScriptManager() { }
 
     CommandLineAPIHost* commandLineAPIHost() const { return m_commandLineAPIHost.get(); }
index 9b6abb2..d9b7c6a 100644 (file)
@@ -993,7 +993,10 @@ void DOMWindow::postMessageTimerFired(PostMessageTimer& timer)
         if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrigin())) {
             if (auto* pageConsole = console()) {
                 String message = makeString("Unable to post message to ", intendedTargetOrigin->toString(), ". Recipient has origin ", document()->securityOrigin().toString(), ".\n");
-                pageConsole->addMessage(MessageSource::Security, MessageLevel::Error, message, timer.stackTrace());
+                if (timer.stackTrace())
+                    pageConsole->addMessage(MessageSource::Security, MessageLevel::Error, message, *timer.stackTrace());
+                else
+                    pageConsole->addMessage(MessageSource::Security, MessageLevel::Error, message);
             }
             return;
         }
index 79cae18..2093e73 100644 (file)
@@ -115,7 +115,7 @@ void PageConsoleClient::addMessage(MessageSource source, MessageLevel level, con
     addMessage(source, level, message, url, line, column, 0, JSMainThreadExecState::currentState(), requestIdentifier);
 }
 
-void PageConsoleClient::addMessage(MessageSource source, MessageLevel level, const String& message, RefPtr<ScriptCallStack>&& callStack)
+void PageConsoleClient::addMessage(MessageSource source, MessageLevel level, const String& message, Ref<ScriptCallStack>&& callStack)
 {
     addMessage(source, level, message, String(), 0, 0, WTFMove(callStack), 0);
 }
@@ -128,7 +128,7 @@ void PageConsoleClient::addMessage(MessageSource source, MessageLevel level, con
     std::unique_ptr<Inspector::ConsoleMessage> message;
 
     if (callStack)
-        message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, WTFMove(callStack), requestIdentifier);
+        message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, callStack.releaseNonNull(), requestIdentifier);
     else
         message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, suggestedURL, suggestedLineNumber, suggestedColumnNumber, state, requestIdentifier);
 
@@ -153,7 +153,7 @@ void PageConsoleClient::addMessage(MessageSource source, MessageLevel level, con
 }
 
 
-void PageConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, RefPtr<Inspector::ScriptArguments>&& arguments)
+void PageConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, Ref<Inspector::ScriptArguments>&& arguments)
 {
     String messageText;
     bool gotMessage = arguments->getFirstArgumentAsString(messageText);
@@ -176,7 +176,7 @@ void PageConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel l
         ConsoleClient::printConsoleMessageWithArguments(MessageSource::ConsoleAPI, type, level, exec, WTFMove(arguments));
 }
 
-void PageConsoleClient::count(JSC::ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void PageConsoleClient::count(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     InspectorInstrumentation::consoleCount(m_page, exec, WTFMove(arguments));
 }
@@ -205,11 +205,10 @@ void PageConsoleClient::time(JSC::ExecState*, const String& title)
 
 void PageConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)
 {
-    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1));
-    InspectorInstrumentation::stopConsoleTiming(m_page.mainFrame(), title, WTFMove(callStack));
+    InspectorInstrumentation::stopConsoleTiming(m_page.mainFrame(), title, createScriptCallStackForConsole(exec, 1));
 }
 
-void PageConsoleClient::timeStamp(JSC::ExecState*, RefPtr<ScriptArguments>&& arguments)
+void PageConsoleClient::timeStamp(JSC::ExecState*, Ref<ScriptArguments>&& arguments)
 {
     InspectorInstrumentation::consoleTimeStamp(m_page.mainFrame(), WTFMove(arguments));
 }
index c8e51e9..5e44f28 100644 (file)
@@ -54,18 +54,18 @@ public:
     static void unmute();
 
     void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&& = nullptr, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0);
-    void addMessage(MessageSource, MessageLevel, const String& message, RefPtr<Inspector::ScriptCallStack>&&);
+    void addMessage(MessageSource, MessageLevel, const String& message, Ref<Inspector::ScriptCallStack>&&);
     void addMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0, Document* = nullptr);
 
 protected:
-    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
-    void count(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
+    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
+    void count(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
     void profile(JSC::ExecState*, const String& title) override;
     void profileEnd(JSC::ExecState*, const String& title) override;
     void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
     void time(JSC::ExecState*, const String& title) override;
     void timeEnd(JSC::ExecState*, const String& title) override;
-    void timeStamp(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
+    void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
 
 private:
     Page& m_page;
index 6d824c2..af99f5e 100644 (file)
@@ -45,7 +45,7 @@ WorkerConsoleClient::~WorkerConsoleClient()
 {
 }
 
-void WorkerConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, RefPtr<Inspector::ScriptArguments>&& arguments)
+void WorkerConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, Ref<Inspector::ScriptArguments>&& arguments)
 {
     String messageText;
     arguments->getFirstArgumentAsString(messageText);
@@ -53,7 +53,7 @@ void WorkerConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel
     m_workerGlobalScope.addConsoleMessage(WTFMove(message));
 }
 
-void WorkerConsoleClient::count(JSC::ExecState* exec, RefPtr<ScriptArguments>&& arguments)
+void WorkerConsoleClient::count(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)
 {
     InspectorInstrumentation::consoleCount(m_workerGlobalScope, exec, WTFMove(arguments));
 }
@@ -65,8 +65,7 @@ void WorkerConsoleClient::time(JSC::ExecState*, const String& title)
 
 void WorkerConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)
 {
-    RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(exec, 1));
-    InspectorInstrumentation::stopConsoleTiming(m_workerGlobalScope, title, WTFMove(callStack));
+    InspectorInstrumentation::stopConsoleTiming(m_workerGlobalScope, title, createScriptCallStackForConsole(exec, 1));
 }
 
 // FIXME: <https://webkit.org/b/153499> Web Inspector: console.profile should use the new Sampling Profiler
@@ -75,6 +74,6 @@ void WorkerConsoleClient::profileEnd(JSC::ExecState*, const String&) { }
 
 // FIXME: <https://webkit.org/b/127634> Web Inspector: support debugging web workers
 void WorkerConsoleClient::takeHeapSnapshot(JSC::ExecState*, const String&) { }
-void WorkerConsoleClient::timeStamp(JSC::ExecState*, RefPtr<ScriptArguments>&&) { }
+void WorkerConsoleClient::timeStamp(JSC::ExecState*, Ref<ScriptArguments>&&) { }
 
 } // namespace WebCore
index 5eca975..a8d1228 100644 (file)
@@ -42,14 +42,14 @@ public:
     virtual ~WorkerConsoleClient();
 
 protected:
-    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
-    void count(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
+    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
+    void count(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
     void profile(JSC::ExecState*, const String& title) override;
     void profileEnd(JSC::ExecState*, const String& title) override;
     void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
     void time(JSC::ExecState*, const String& title) override;
     void timeEnd(JSC::ExecState*, const String& title) override;
-    void timeStamp(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
+    void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
 
 private:
     WorkerGlobalScope& m_workerGlobalScope;
index 5e2e2cf..40e786b 100644 (file)
@@ -285,7 +285,7 @@ void WorkerGlobalScope::addMessage(MessageSource source, MessageLevel level, con
 
     std::unique_ptr<Inspector::ConsoleMessage> message;
     if (callStack)
-        message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, WTFMove(callStack), requestIdentifier);
+        message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, callStack.releaseNonNull(), requestIdentifier);
     else
         message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, sourceURL, lineNumber, columnNumber, state, requestIdentifier);
     InspectorInstrumentation::addMessageToConsole(*this, WTFMove(message));
index d2e5208..33c4c38 100644 (file)
@@ -1,3 +1,13 @@
+2017-02-16  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Drop PassRefPtr in inspector/
+        https://bugs.webkit.org/show_bug.cgi?id=168420
+
+        Reviewed by Alex Christensen.
+
+        * WebView/WebScriptDebugger.mm:
+        (WebScriptDebugger::handlePause):
+
 2017-02-16  Simon Fraser  <simon.fraser@apple.com>
 
         Clean up use of some CALayer-related SPI
index 70b8e04..17c1afa 100644 (file)
@@ -131,18 +131,18 @@ void WebScriptDebugger::handlePause(JSGlobalObject* globalObject, Debugger::Reas
 
     WebFrame *webFrame = toWebFrame(globalObject);
     WebView *webView = [webFrame webView];
-    DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();
+    DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
     JSValue exceptionValue = currentException();
-    String functionName = debuggerCallFrame->functionName();
+    String functionName = debuggerCallFrame.functionName();
     RetainPtr<WebScriptCallFrame> webCallFrame = adoptNS([[WebScriptCallFrame alloc] _initWithGlobalObject:core(webFrame)->script().windowScriptObject() functionName:functionName exceptionValue:exceptionValue]);
 
     WebScriptDebugDelegateImplementationCache* cache = WebViewGetScriptDebugDelegateImplementations(webView);
     if (cache->exceptionWasRaisedFunc) {
         if (cache->exceptionWasRaisedExpectsHasHandlerFlag) {
             bool hasHandler = hasHandlerForExceptionCallback();
-            CallScriptDebugDelegate(cache->exceptionWasRaisedFunc, webView, @selector(webView:exceptionWasRaised:hasHandler:sourceId:line:forWebFrame:), webCallFrame.get(), hasHandler, debuggerCallFrame->sourceID(), debuggerCallFrame->line(), webFrame);
+            CallScriptDebugDelegate(cache->exceptionWasRaisedFunc, webView, @selector(webView:exceptionWasRaised:hasHandler:sourceId:line:forWebFrame:), webCallFrame.get(), hasHandler, debuggerCallFrame.sourceID(), debuggerCallFrame.line(), webFrame);
         } else
-            CallScriptDebugDelegate(cache->exceptionWasRaisedFunc, webView, @selector(webView:exceptionWasRaised:sourceId:line:forWebFrame:), webCallFrame.get(), debuggerCallFrame->sourceID(), debuggerCallFrame->line(), webFrame);
+            CallScriptDebugDelegate(cache->exceptionWasRaisedFunc, webView, @selector(webView:exceptionWasRaised:sourceId:line:forWebFrame:), webCallFrame.get(), debuggerCallFrame.sourceID(), debuggerCallFrame.line(), webFrame);
     }
 
     m_callingDelegate = false;