<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[170589] trunk/Source/JavaScriptCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/170589">170589</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2014-06-30 10:57:39 -0700 (Mon, 30 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>JSContext Inspection: Provide a way to use a non-Main RunLoop for Inspector JavaScript Evaluations
https://bugs.webkit.org/show_bug.cgi?id=134371
Reviewed by Timothy Hatcher.
* API/JSContextPrivate.h:
* API/JSContext.mm:
(-[JSContext _debuggerRunLoop]):
(-[JSContext _setDebuggerRunLoop:]):
Private API for setting the CFRunLoop for a debugger to evaluate in.
* API/JSContextRefInternal.h: Added.
* API/JSContextRef.cpp:
(JSGlobalContextGetDebuggerRunLoop):
(JSGlobalContextSetDebuggerRunLoop):
Internal API for setting a CFRunLoop on a JSContextRef.
Set this on the debuggable.
* inspector/remote/RemoteInspectorDebuggable.h:
* inspector/remote/RemoteInspectorDebuggableConnection.h:
(Inspector::RemoteInspectorBlock::RemoteInspectorBlock):
(Inspector::RemoteInspectorBlock::~RemoteInspectorBlock):
(Inspector::RemoteInspectorBlock::operator=):
(Inspector::RemoteInspectorBlock::operator()):
Moved into the header.
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::inspectorDebuggable):
Lets store the RunLoop on the debuggable instead of this core
platform agnostic class, so expose the debuggable.
* inspector/remote/RemoteInspectorDebuggableConnection.mm:
(Inspector::RemoteInspectorHandleRunSourceGlobal):
(Inspector::RemoteInspectorQueueTaskOnGlobalQueue):
(Inspector::RemoteInspectorInitializeGlobalQueue):
Rename the global functions for clarity.
(Inspector::RemoteInspectorHandleRunSourceWithInfo):
Handler for private run loops.
(Inspector::RemoteInspectorDebuggableConnection::RemoteInspectorDebuggableConnection):
(Inspector::RemoteInspectorDebuggableConnection::~RemoteInspectorDebuggableConnection):
(Inspector::RemoteInspectorDebuggableConnection::dispatchAsyncOnDebuggable):
(Inspector::RemoteInspectorDebuggableConnection::setupRunLoop):
(Inspector::RemoteInspectorDebuggableConnection::teardownRunLoop):
(Inspector::RemoteInspectorDebuggableConnection::queueTaskOnPrivateRunLoop):
Setup and teardown and use private run loop sources if the debuggable needs it.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreAPIJSContextmm">trunk/Source/JavaScriptCore/API/JSContext.mm</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPIJSContextPrivateh">trunk/Source/JavaScriptCore/API/JSContextPrivate.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPIJSContextRefcpp">trunk/Source/JavaScriptCore/API/JSContextRef.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPIJSContextRefPrivateh">trunk/Source/JavaScriptCore/API/JSContextRefPrivate.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorDebuggableh">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorDebuggableConnectionh">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorDebuggableConnectionmm">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.mm</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjecth">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreAPIJSContextRefInternalh">trunk/Source/JavaScriptCore/API/JSContextRefInternal.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreAPIJSContextmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSContext.mm (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSContext.mm        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/API/JSContext.mm        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #import "JSCInlines.h"
</span><span class="cx"> #import "JSContextInternal.h"
</span><span class="cx"> #import "JSContextPrivate.h"
</span><del>-#import "JSContextRefPrivate.h"
</del><ins>+#import "JSContextRefInternal.h"
</ins><span class="cx"> #import "JSGlobalObject.h"
</span><span class="cx"> #import "JSValueInternal.h"
</span><span class="cx"> #import "JSVirtualMachineInternal.h"
</span><span class="lines">@@ -223,6 +223,16 @@
</span><span class="cx"> JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(m_context, includeNativeCallStack);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (CFRunLoopRef)_debuggerRunLoop
+{
+ return JSGlobalContextGetDebuggerRunLoop(m_context);
+}
+
+- (void)_setDebuggerRunLoop:(CFRunLoopRef)runLoop
+{
+ JSGlobalContextSetDebuggerRunLoop(m_context, runLoop);
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @implementation JSContext(SubscriptSupport)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIJSContextPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSContextPrivate.h (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSContextPrivate.h        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/API/JSContextPrivate.h        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -44,6 +44,12 @@
</span><span class="cx"> */
</span><span class="cx"> @property (setter=_setIncludesNativeCallStackWhenReportingExceptions:) BOOL _includesNativeCallStackWhenReportingExceptions NS_AVAILABLE(10_10, 8_0);
</span><span class="cx">
</span><ins>+/*!
+@property
+@discussion Set the run loop the Web Inspector debugger should use when evaluating JavaScript in the JSContext.
+*/
+@property (setter=_setDebuggerRunLoop:) CFRunLoopRef _debuggerRunLoop NS_AVAILABLE(10_10, 8_0);
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIJSContextRefcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSContextRef.cpp (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSContextRef.cpp        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/API/JSContextRef.cpp        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "JSContextRef.h"
</span><del>-#include "JSContextRefPrivate.h"
</del><ins>+#include "JSContextRefInternal.h"
</ins><span class="cx">
</span><span class="cx"> #include "APICast.h"
</span><span class="cx"> #include "CallFrame.h"
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include <wtf/text/StringHash.h>
</span><span class="cx">
</span><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><ins>+#include "JSGlobalObjectDebuggable.h"
</ins><span class="cx"> #include "JSGlobalObjectInspectorController.h"
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -367,3 +368,40 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if USE(CF)
+CFRunLoopRef JSGlobalContextGetDebuggerRunLoop(JSGlobalContextRef ctx)
+{
+#if ENABLE(REMOTE_INSPECTOR)
+ if (!ctx) {
+ ASSERT_NOT_REACHED();
+ return nullptr;
+ }
+
+ ExecState* exec = toJS(ctx);
+ JSLockHolder lock(exec);
+
+ return exec->vmEntryGlobalObject()->inspectorDebuggable().debuggerRunLoop();
+#else
+ UNUSED_PARAM(ctx);
+ return nullptr;
+#endif
+}
+
+void JSGlobalContextSetDebuggerRunLoop(JSGlobalContextRef ctx, CFRunLoopRef runLoop)
+{
+#if ENABLE(REMOTE_INSPECTOR)
+ if (!ctx) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ ExecState* exec = toJS(ctx);
+ JSLockHolder lock(exec);
+
+ exec->vmEntryGlobalObject()->inspectorDebuggable().setDebuggerRunLoop(runLoop);
+#else
+ UNUSED_PARAM(ctx);
+ UNUSED_PARAM(runLoop);
+#endif
+}
+#endif
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIJSContextRefInternalhfromrev170586trunkSourceJavaScriptCoreAPIJSContextPrivateh"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/API/JSContextRefInternal.h (from rev 170586, trunk/Source/JavaScriptCore/API/JSContextPrivate.h) (0 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSContextRefInternal.h         (rev 0)
+++ trunk/Source/JavaScriptCore/API/JSContextRefInternal.h        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSContextRefInternal_h
+#define JSContextRefInternal_h
+
+#include "JSContextRefPrivate.h"
+
+#if USE(CF)
+#include <CoreFoundation/CFRunLoop.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if USE(CF)
+/*!
+@function
+@abstract Gets the run loop used by the Web Inspector debugger when evaluating JavaScript in this context.
+@param ctx The JSGlobalContext whose setting you want to get.
+*/
+JS_EXPORT CFRunLoopRef JSGlobalContextGetDebuggerRunLoop(JSGlobalContextRef ctx) CF_AVAILABLE(10_10, 8_0);
+
+/*!
+@function
+@abstract Sets the run loop used by the Web Inspector debugger when evaluating JavaScript in this context.
+@param ctx The JSGlobalContext that you want to change.
+@param runLoop The new value of the setting for the context.
+*/
+JS_EXPORT void JSGlobalContextSetDebuggerRunLoop(JSGlobalContextRef ctx, CFRunLoopRef) CF_AVAILABLE(10_10, 8_0);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // JSContextRefInternal_h
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIJSContextRefPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSContextRefPrivate.h (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSContextRefPrivate.h        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/API/JSContextRefPrivate.h        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -126,7 +126,7 @@
</span><span class="cx"> @param ctx The JSGlobalContext that you want to change.
</span><span class="cx"> @param includeNativeCallStack The new value of the setting for the context.
</span><span class="cx"> */
</span><del>-JS_EXPORT void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack) CF_AVAILABLE(10_10, 8_0);
</del><ins>+JS_EXPORT void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack) CF_AVAILABLE(10_10, 8_0);
</ins><span class="cx">
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -1,3 +1,53 @@
</span><ins>+2014-06-30 Joseph Pecoraro <pecoraro@apple.com>
+
+ JSContext Inspection: Provide a way to use a non-Main RunLoop for Inspector JavaScript Evaluations
+ https://bugs.webkit.org/show_bug.cgi?id=134371
+
+ Reviewed by Timothy Hatcher.
+
+ * API/JSContextPrivate.h:
+ * API/JSContext.mm:
+ (-[JSContext _debuggerRunLoop]):
+ (-[JSContext _setDebuggerRunLoop:]):
+ Private API for setting the CFRunLoop for a debugger to evaluate in.
+
+ * API/JSContextRefInternal.h: Added.
+ * API/JSContextRef.cpp:
+ (JSGlobalContextGetDebuggerRunLoop):
+ (JSGlobalContextSetDebuggerRunLoop):
+ Internal API for setting a CFRunLoop on a JSContextRef.
+ Set this on the debuggable.
+
+ * inspector/remote/RemoteInspectorDebuggable.h:
+ * inspector/remote/RemoteInspectorDebuggableConnection.h:
+ (Inspector::RemoteInspectorBlock::RemoteInspectorBlock):
+ (Inspector::RemoteInspectorBlock::~RemoteInspectorBlock):
+ (Inspector::RemoteInspectorBlock::operator=):
+ (Inspector::RemoteInspectorBlock::operator()):
+ Moved into the header.
+
+ * runtime/JSGlobalObject.h:
+ (JSC::JSGlobalObject::inspectorDebuggable):
+ Lets store the RunLoop on the debuggable instead of this core
+ platform agnostic class, so expose the debuggable.
+
+ * inspector/remote/RemoteInspectorDebuggableConnection.mm:
+ (Inspector::RemoteInspectorHandleRunSourceGlobal):
+ (Inspector::RemoteInspectorQueueTaskOnGlobalQueue):
+ (Inspector::RemoteInspectorInitializeGlobalQueue):
+ Rename the global functions for clarity.
+
+ (Inspector::RemoteInspectorHandleRunSourceWithInfo):
+ Handler for private run loops.
+
+ (Inspector::RemoteInspectorDebuggableConnection::RemoteInspectorDebuggableConnection):
+ (Inspector::RemoteInspectorDebuggableConnection::~RemoteInspectorDebuggableConnection):
+ (Inspector::RemoteInspectorDebuggableConnection::dispatchAsyncOnDebuggable):
+ (Inspector::RemoteInspectorDebuggableConnection::setupRunLoop):
+ (Inspector::RemoteInspectorDebuggableConnection::teardownRunLoop):
+ (Inspector::RemoteInspectorDebuggableConnection::queueTaskOnPrivateRunLoop):
+ Setup and teardown and use private run loop sources if the debuggable needs it.
+
</ins><span class="cx"> 2014-06-30 Tibor Meszaros <tmeszaros.u-szeged@partner.samsung.com>
</span><span class="cx">
</span><span class="cx"> Add missing ENABLE(DFG_JIT) guards
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -1332,6 +1332,7 @@
</span><span class="cx">                 A5C3A1A618C0490200C9593A /* JSConsoleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A5C3A1A418C0490200C9593A /* JSConsoleClient.h */; };
</span><span class="cx">                 A5CEEE14187F3BAD00E55C99 /* InspectorAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5CEEE12187F3BAD00E55C99 /* InspectorAgent.cpp */; };
</span><span class="cx">                 A5D0A1BB1862301B00C7B496 /* InspectorEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = A5D0A1BA1862301B00C7B496 /* InspectorEnvironment.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                A5D2E665195E174000A518E7 /* JSContextRefInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A5D2E664195E173800A518E7 /* JSContextRefInternal.h */; };
</ins><span class="cx">                 A5FD0067189AFE9C00633231 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5FD0065189AFE9C00633231 /* ScriptArguments.cpp */; };
</span><span class="cx">                 A5FD0068189AFE9C00633231 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = A5FD0066189AFE9C00633231 /* ScriptArguments.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A5FD006D189B00AA00633231 /* ScriptCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5FD0069189B00A900633231 /* ScriptCallFrame.cpp */; };
</span><span class="lines">@@ -2933,6 +2934,7 @@
</span><span class="cx">                 A5CEEE12187F3BAD00E55C99 /* InspectorAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorAgent.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 A5CEEE13187F3BAD00E55C99 /* InspectorAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorAgent.h; sourceTree = "<group>"; };
</span><span class="cx">                 A5D0A1BA1862301B00C7B496 /* InspectorEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorEnvironment.h; sourceTree = "<group>"; };
</span><ins>+                A5D2E664195E173800A518E7 /* JSContextRefInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSContextRefInternal.h; sourceTree = "<group>"; };
</ins><span class="cx">                 A5FD0065189AFE9C00633231 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 A5FD0066189AFE9C00633231 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; };
</span><span class="cx">                 A5FD0069189B00A900633231 /* ScriptCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptCallFrame.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -3965,6 +3967,7 @@
</span><span class="cx">                                 86E3C609167BAB87006D760A /* JSContextInternal.h */,
</span><span class="cx">                                 14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */,
</span><span class="cx">                                 14BD5A2A0A3E91F600BAF59C /* JSContextRef.h */,
</span><ins>+                                A5D2E664195E173800A518E7 /* JSContextRefInternal.h */,
</ins><span class="cx">                                 148CD1D7108CF902008163C6 /* JSContextRefPrivate.h */,
</span><span class="cx">                                 A72028B41797601E0098028C /* JSCTestRunnerUtils.cpp */,
</span><span class="cx">                                 A72028B51797601E0098028C /* JSCTestRunnerUtils.h */,
</span><span class="lines">@@ -5537,6 +5540,7 @@
</span><span class="cx">                                 14816E1C154CC56C00B8054C /* BlockAllocator.h in Headers */,
</span><span class="cx">                                 BC18C3EC0E16F5CD00B34460 /* BooleanObject.h in Headers */,
</span><span class="cx">                                 FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */,
</span><ins>+                                A5D2E665195E174000A518E7 /* JSContextRefInternal.h in Headers */,
</ins><span class="cx">                                 A7D801A51880D66E0026C39B /* BuiltinExecutables.h in Headers */,
</span><span class="cx">                                 A75EE9B218AAB7E200AAD043 /* BuiltinNames.h in Headers */,
</span><span class="cx">                                 0FB7F39715ED8E4600F167B2 /* Butterfly.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorDebuggableh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.h (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.h        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggable.h        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -28,6 +28,8 @@
</span><span class="cx"> #ifndef RemoteInspectorDebuggable_h
</span><span class="cx"> #define RemoteInspectorDebuggable_h
</span><span class="cx">
</span><ins>+#include <CoreFoundation/CFRunLoop.h>
+#include <wtf/RetainPtr.h>
</ins><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span><span class="cx"> namespace Inspector {
</span><span class="lines">@@ -49,6 +51,9 @@
</span><span class="cx"> bool remoteDebuggingAllowed() const { return m_allowed; }
</span><span class="cx"> void setRemoteDebuggingAllowed(bool);
</span><span class="cx">
</span><ins>+ CFRunLoopRef debuggerRunLoop() { return m_runLoop.get(); }
+ void setDebuggerRunLoop(CFRunLoopRef runLoop) { m_runLoop = runLoop; }
+
</ins><span class="cx"> RemoteInspectorDebuggableInfo info() const;
</span><span class="cx">
</span><span class="cx"> enum DebuggableType { JavaScript, Web };
</span><span class="lines">@@ -65,6 +70,7 @@
</span><span class="cx"> private:
</span><span class="cx"> unsigned m_identifier;
</span><span class="cx"> bool m_allowed;
</span><ins>+ RetainPtr<CFRunLoopRef> m_runLoop;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct RemoteInspectorDebuggableInfo {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorDebuggableConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.h (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.h        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.h        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -38,7 +38,43 @@
</span><span class="cx"> OBJC_CLASS NSString;
</span><span class="cx">
</span><span class="cx"> namespace Inspector {
</span><ins>+
+class RemoteInspectorBlock {
+public:
+ RemoteInspectorBlock(void (^task)())
+ : m_task(Block_copy(task))
+ {
+ }
</ins><span class="cx">
</span><ins>+ RemoteInspectorBlock(const RemoteInspectorBlock& other)
+ : m_task(Block_copy(other.m_task))
+ {
+ }
+
+ ~RemoteInspectorBlock()
+ {
+ Block_release(m_task);
+ }
+
+ RemoteInspectorBlock& operator=(const RemoteInspectorBlock& other)
+ {
+ void (^oldTask)() = m_task;
+ m_task = Block_copy(other.m_task);
+ Block_release(oldTask);
+ return *this;
+ }
+
+ void operator()() const
+ {
+ m_task();
+ }
+
+private:
+ void (^m_task)();
+};
+
+typedef Vector<RemoteInspectorBlock> RemoteInspectorQueue;
+
</ins><span class="cx"> class RemoteInspectorDebuggableConnection final : public ThreadSafeRefCounted<RemoteInspectorDebuggableConnection>, public InspectorFrontendChannel {
</span><span class="cx"> public:
</span><span class="cx"> RemoteInspectorDebuggableConnection(RemoteInspectorDebuggable*, NSString *connectionIdentifier, NSString *destination, RemoteInspectorDebuggable::DebuggableType);
</span><span class="lines">@@ -56,14 +92,29 @@
</span><span class="cx"> void sendMessageToBackend(NSString *);
</span><span class="cx"> virtual bool sendMessageToFrontend(const String&) override;
</span><span class="cx">
</span><ins>+ std::mutex& queueMutex() { return m_queueMutex; }
+ RemoteInspectorQueue queue() const { return m_queue; }
+ void clearQueue() { m_queue.clear(); }
+
</ins><span class="cx"> private:
</span><span class="cx"> void dispatchAsyncOnDebuggable(void (^block)());
</span><span class="cx">
</span><ins>+ void setupRunLoop();
+ void teardownRunLoop();
+ void queueTaskOnPrivateRunLoop(void (^block)());
+
</ins><span class="cx"> // This connection from the RemoteInspector singleton to the Debuggable
</span><span class="cx"> // can be used on multiple threads. So any access to the debuggable
</span><span class="cx"> // itself must take this mutex to ensure m_debuggable is valid.
</span><span class="cx"> std::mutex m_debuggableMutex;
</span><span class="cx">
</span><ins>+ // If a debuggable has a specific run loop it wants to evaluate on
+ // we setup our run loop sources on that specific run loop.
+ RetainPtr<CFRunLoopRef> m_runLoop;
+ RetainPtr<CFRunLoopSourceRef> m_runLoopSource;
+ RemoteInspectorQueue m_queue;
+ std::mutex m_queueMutex;
+
</ins><span class="cx"> RemoteInspectorDebuggable* m_debuggable;
</span><span class="cx"> RetainPtr<NSString> m_connectionIdentifier;
</span><span class="cx"> RetainPtr<NSString> m_destination;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorDebuggableConnectionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.mm (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.mm        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.mm        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -38,46 +38,11 @@
</span><span class="cx">
</span><span class="cx"> namespace Inspector {
</span><span class="cx">
</span><del>-class RemoteInspectorBlock {
-public:
- RemoteInspectorBlock(void (^task)())
- : m_task(Block_copy(task))
- {
- }
-
- RemoteInspectorBlock(const RemoteInspectorBlock& other)
- : m_task(Block_copy(other.m_task))
- {
- }
-
- ~RemoteInspectorBlock()
- {
- Block_release(m_task);
- }
-
- RemoteInspectorBlock& operator=(const RemoteInspectorBlock& other)
- {
- void (^oldTask)() = m_task;
- m_task = Block_copy(other.m_task);
- Block_release(oldTask);
- return *this;
- }
-
- void operator()() const
- {
- m_task();
- }
-
-private:
- void (^m_task)();
-};
-
-typedef Vector<RemoteInspectorBlock> RemoteInspectorQueue;
</del><span class="cx"> static std::mutex* rwiQueueMutex;
</span><span class="cx"> static CFRunLoopSourceRef rwiRunLoopSource;
</span><span class="cx"> static RemoteInspectorQueue* rwiQueue;
</span><span class="cx">
</span><del>-static void RemoteInspectorHandleRunSource(void*)
</del><ins>+static void RemoteInspectorHandleRunSourceGlobal(void*)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(CFRunLoopGetCurrent() == CFRunLoopGetMain());
</span><span class="cx"> ASSERT(rwiQueueMutex);
</span><span class="lines">@@ -95,7 +60,7 @@
</span><span class="cx"> block();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void RemoteInspectorQueueTask(void (^task)())
</del><ins>+static void RemoteInspectorQueueTaskOnGlobalQueue(void (^task)())
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(rwiQueueMutex);
</span><span class="cx"> ASSERT(rwiRunLoopSource);
</span><span class="lines">@@ -110,21 +75,38 @@
</span><span class="cx"> CFRunLoopWakeUp(CFRunLoopGetMain());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void RemoteInspectorInitializeQueue()
</del><ins>+static void RemoteInspectorInitializeGlobalQueue()
</ins><span class="cx"> {
</span><span class="cx"> static dispatch_once_t pred;
</span><span class="cx"> dispatch_once(&pred, ^{
</span><span class="cx"> rwiQueue = new RemoteInspectorQueue;
</span><span class="cx"> rwiQueueMutex = std::make_unique<std::mutex>().release();
</span><span class="cx">
</span><del>- CFRunLoopSourceContext runLoopSourceContext = {0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, RemoteInspectorHandleRunSource};
</del><ins>+ CFRunLoopSourceContext runLoopSourceContext = {0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, RemoteInspectorHandleRunSourceGlobal};
</ins><span class="cx"> rwiRunLoopSource = CFRunLoopSourceCreate(nullptr, 1, &runLoopSourceContext);
</span><ins>+
</ins><span class="cx"> // Add to the default run loop mode for default handling, and the JSContext remote inspector run loop mode when paused.
</span><span class="cx"> CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, kCFRunLoopDefaultMode);
</span><span class="cx"> CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, EventLoop::remoteInspectorRunLoopMode());
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void RemoteInspectorHandleRunSourceWithInfo(void* info)
+{
+ RemoteInspectorDebuggableConnection *debuggableConnection = static_cast<RemoteInspectorDebuggableConnection*>(info);
+
+ RemoteInspectorQueue queueCopy;
+ {
+ std::lock_guard<std::mutex> lock(debuggableConnection->queueMutex());
+ queueCopy = debuggableConnection->queue();
+ debuggableConnection->clearQueue();
+ }
+
+ for (const auto& block : queueCopy)
+ block();
+}
+
+
</ins><span class="cx"> RemoteInspectorDebuggableConnection::RemoteInspectorDebuggableConnection(RemoteInspectorDebuggable* debuggable, NSString *connectionIdentifier, NSString *destination, RemoteInspectorDebuggable::DebuggableType)
</span><span class="cx"> : m_debuggable(debuggable)
</span><span class="cx"> , m_connectionIdentifier(connectionIdentifier)
</span><span class="lines">@@ -132,11 +114,12 @@
</span><span class="cx"> , m_identifier(debuggable->identifier())
</span><span class="cx"> , m_connected(false)
</span><span class="cx"> {
</span><del>- RemoteInspectorInitializeQueue();
</del><ins>+ setupRunLoop();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RemoteInspectorDebuggableConnection::~RemoteInspectorDebuggableConnection()
</span><span class="cx"> {
</span><ins>+ teardownRunLoop();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NSString *RemoteInspectorDebuggableConnection::destination() const
</span><span class="lines">@@ -151,6 +134,11 @@
</span><span class="cx">
</span><span class="cx"> void RemoteInspectorDebuggableConnection::dispatchAsyncOnDebuggable(void (^block)())
</span><span class="cx"> {
</span><ins>+ if (m_runLoop) {
+ queueTaskOnPrivateRunLoop(block);
+ return;
+ }
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> if (WebCoreWebThreadIsEnabled && WebCoreWebThreadIsEnabled()) {
</span><span class="cx"> WebCoreWebThreadRun(block);
</span><span class="lines">@@ -158,7 +146,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- RemoteInspectorQueueTask(block);
</del><ins>+ RemoteInspectorQueueTaskOnGlobalQueue(block);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool RemoteInspectorDebuggableConnection::setup()
</span><span class="lines">@@ -237,6 +225,48 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void RemoteInspectorDebuggableConnection::setupRunLoop()
+{
+ CFRunLoopRef debuggerRunLoop = m_debuggable->debuggerRunLoop();
+ if (!debuggerRunLoop) {
+ RemoteInspectorInitializeGlobalQueue();
+ return;
+ }
+
+ m_runLoop = debuggerRunLoop;
+
+ CFRunLoopSourceContext runLoopSourceContext = {0, this, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, RemoteInspectorHandleRunSourceWithInfo};
+ m_runLoopSource = CFRunLoopSourceCreate(nullptr, 1, &runLoopSourceContext);
+
+ CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopDefaultMode);
+ CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), EventLoop::remoteInspectorRunLoopMode());
+}
+
+void RemoteInspectorDebuggableConnection::teardownRunLoop()
+{
+ if (!m_runLoop)
+ return;
+
+ CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopDefaultMode);
+ CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), EventLoop::remoteInspectorRunLoopMode());
+
+ m_runLoop = nullptr;
+ m_runLoopSource = nullptr;
+}
+
+void RemoteInspectorDebuggableConnection::queueTaskOnPrivateRunLoop(void (^block)())
+{
+ ASSERT(m_runLoop);
+
+ {
+ std::lock_guard<std::mutex> lock(m_queueMutex);
+ m_queue.append(RemoteInspectorBlock(block));
+ }
+
+ CFRunLoopSourceSignal(m_runLoopSource.get());
+ CFRunLoopWakeUp(m_runLoop.get());
+}
+
</ins><span class="cx"> } // namespace Inspector
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(REMOTE_INSPECTOR)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h (170588 => 170589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2014-06-30 17:42:52 UTC (rev 170588)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2014-06-30 17:57:39 UTC (rev 170589)
</span><span class="lines">@@ -456,6 +456,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><span class="cx"> Inspector::JSGlobalObjectInspectorController& inspectorController() const { return *m_inspectorController.get(); }
</span><ins>+ JSGlobalObjectDebuggable& inspectorDebuggable() { return *m_inspectorDebuggable.get(); }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> JS_EXPORT_PRIVATE void setConsoleClient(ConsoleClient* consoleClient) { m_consoleClient = consoleClient; }
</span></span></pre>
</div>
</div>
</body>
</html>