Skip to content

Commit ae70398

Browse files
author
Dmitry Titov
committed
REGRESSION: fast/workers/wrapper-map-gc.html crashes on Snow Leopard Release Bot
https://bugs.webkit.org/show_bug.cgi?id=37554 Reviewed by Geoffrey Garen. The flaky fast/workers/wrapper-map-gc.html will stop being flaky. * bindings/js/JSEventListener.cpp: (WebCore::JSEventListener::handleEvent): check if JS execution was terminated, as in cases of Worker.terminate() or WorkerGlobalScope.close(). * bindings/js/JSWorkerContextBase.cpp: (WebCore::toJS): ASSERT the value of workerContextWrapper, it should never be 0. * bindings/js/WorkerScriptController.h: (WebCore::WorkerScriptController::workerContextWrapper): remove returning 0 if JS execution was forbidden. (WebCore::WorkerScriptController::isExecutionForbidden): * bindings/v8/WorkerScriptController.h: (WebCore::WorkerScriptController::isExecutionForbidden): Add ScriptExecutionContext::isJSExecutionTerminated(), it is always 'false' for Document and 'true' for WorkerContext when script is terminated. * dom/ScriptExecutionContext.h: * dom/Document.h: (WebCore::Document::isJSExecutionTerminated): * workers/WorkerContext.cpp: (WebCore::WorkerContext::isJSExecutionTerminated): * workers/WorkerContext.h: Canonical link: https://commits.webkit.org/49690@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@58421 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 8dd0e63 commit ae70398

9 files changed

Lines changed: 43 additions & 5 deletions

WebCore/ChangeLog

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
2010-04-28 Dmitry Titov <dimich@chromium.org>
2+
3+
Reviewed by Geoffrey Garen.
4+
5+
REGRESSION: fast/workers/wrapper-map-gc.html crashes on Snow Leopard Release Bot
6+
https://bugs.webkit.org/show_bug.cgi?id=37554
7+
8+
The flaky fast/workers/wrapper-map-gc.html will stop being flaky.
9+
10+
* bindings/js/JSEventListener.cpp:
11+
(WebCore::JSEventListener::handleEvent):
12+
check if JS execution was terminated, as in cases of Worker.terminate() or WorkerGlobalScope.close().
13+
* bindings/js/JSWorkerContextBase.cpp:
14+
(WebCore::toJS): ASSERT the value of workerContextWrapper, it should never be 0.
15+
* bindings/js/WorkerScriptController.h:
16+
(WebCore::WorkerScriptController::workerContextWrapper): remove returning 0 if JS execution was forbidden.
17+
(WebCore::WorkerScriptController::isExecutionForbidden):
18+
* bindings/v8/WorkerScriptController.h:
19+
(WebCore::WorkerScriptController::isExecutionForbidden):
20+
21+
Add ScriptExecutionContext::isJSExecutionTerminated(), it is always 'false' for Document
22+
and 'true' for WorkerContext when script is terminated.
23+
* dom/ScriptExecutionContext.h:
24+
* dom/Document.h:
25+
(WebCore::Document::isJSExecutionTerminated):
26+
* workers/WorkerContext.cpp:
27+
(WebCore::WorkerContext::isJSExecutionTerminated):
28+
* workers/WorkerContext.h:
29+
130
2010-04-28 Ilya Tikhonovsky <loislo@chromium.org>
231

332
Reviewed by Yury Semikhatsky.

WebCore/bindings/js/JSEventListener.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void JSEventListener::markJSFunction(MarkStack& markStack)
6060
void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
6161
{
6262
ASSERT(scriptExecutionContext);
63-
if (!scriptExecutionContext)
63+
if (!scriptExecutionContext || scriptExecutionContext->isJSExecutionTerminated())
6464
return;
6565

6666
JSLock lock(SilenceAssertionsOnly);

WebCore/bindings/js/JSWorkerContextBase.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ JSValue toJS(ExecState*, WorkerContext* workerContext)
7171
WorkerScriptController* script = workerContext->script();
7272
if (!script)
7373
return jsNull();
74-
return script->workerContextWrapper();
74+
JSWorkerContext* contextWrapper = script->workerContextWrapper();
75+
ASSERT(contextWrapper);
76+
return contextWrapper;
7577
}
7678

7779
JSDedicatedWorkerContext* toJSDedicatedWorkerContext(JSValue value)

WebCore/bindings/js/WorkerScriptController.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ namespace WebCore {
5252

5353
JSWorkerContext* workerContextWrapper()
5454
{
55-
if (m_executionForbidden)
56-
return 0;
57-
5855
initScriptIfNeeded();
5956
return m_workerContextWrapper;
6057
}
@@ -66,6 +63,7 @@ namespace WebCore {
6663

6764
enum ForbidExecutionOption { TerminateRunningScript, LetRunningScriptFinish };
6865
void forbidExecution(ForbidExecutionOption);
66+
bool isExecutionForbidden() const { return m_executionForbidden; }
6967

7068
JSC::JSGlobalData* globalData() { return m_globalData.get(); }
7169

WebCore/bindings/v8/WorkerScriptController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ namespace WebCore {
5858

5959
enum ForbidExecutionOption { TerminateRunningScript, LetRunningScriptFinish };
6060
void forbidExecution(ForbidExecutionOption);
61+
bool isExecutionForbidden() const { return m_executionForbidden; }
6162

6263
// Returns WorkerScriptController for the currently executing context. 0 will be returned if the current executing context is not the worker context.
6364
static WorkerScriptController* controllerForContext();

WebCore/dom/Document.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ class Document : public ContainerNode, public ScriptExecutionContext {
950950
#endif
951951

952952
virtual bool isContextThread() const;
953+
virtual bool isJSExecutionTerminated() const { return false; }
953954

954955
void setUsingGeolocation(bool f) { m_usingGeolocation = f; }
955956
bool usingGeolocation() const { return m_usingGeolocation; };

WebCore/dom/ScriptExecutionContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ namespace WebCore {
7676
void stopDatabases(DatabaseTaskSynchronizer*);
7777
#endif
7878
virtual bool isContextThread() const = 0;
79+
virtual bool isJSExecutionTerminated() const = 0;
7980

8081
const KURL& url() const { return virtualURL(); }
8182
KURL completeURL(const String& url) const { return virtualCompleteURL(url); }

WebCore/workers/WorkerContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ bool WorkerContext::isContextThread() const
288288
return currentThread() == thread()->threadID();
289289
}
290290

291+
bool WorkerContext::isJSExecutionTerminated() const
292+
{
293+
return m_script->isExecutionForbidden();
294+
}
295+
291296
EventTargetData* WorkerContext::eventTargetData()
292297
{
293298
return &m_eventTargetData;

WebCore/workers/WorkerContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ namespace WebCore {
111111
virtual void databaseExceededQuota(const String&) { }
112112
#endif
113113
virtual bool isContextThread() const;
114+
virtual bool isJSExecutionTerminated() const;
114115

115116

116117
// These methods are used for GC marking. See JSWorkerContext::markChildren(MarkStack&) in

0 commit comments

Comments
 (0)