source: webkit/trunk/JavaScriptCore/runtime/JSLock.h@ 45891

Last change on this file since 45891 was 45891, checked in by [email protected], 16 years ago

JavaScriptCore:

2009-07-14 Zoltan Horvath <[email protected]>

Reviewed by Darin Adler.

Change all Noncopyable inheriting visibility to public.
https://bugs.webkit.org/show_bug.cgi?id=27225

Change all Noncopyable inheriting visibility to public because
it is needed to the custom allocation framework (bug #20422).

  • bytecode/SamplingTool.h:
  • bytecompiler/RegisterID.h:
  • interpreter/CachedCall.h:
  • interpreter/RegisterFile.h:
  • parser/Lexer.h:
  • parser/Parser.h:
  • runtime/ArgList.h:
  • runtime/BatchedTransitionOptimizer.h:
  • runtime/Collector.h:
  • runtime/CommonIdentifiers.h:
  • runtime/JSCell.h:
  • runtime/JSGlobalObject.h:
  • runtime/JSLock.h:
  • runtime/JSONObject.cpp:
  • runtime/SmallStrings.cpp:
  • runtime/SmallStrings.h:
  • wtf/CrossThreadRefCounted.h:
  • wtf/GOwnPtr.h:
  • wtf/Locker.h:
  • wtf/MessageQueue.h:
  • wtf/OwnArrayPtr.h:
  • wtf/OwnFastMallocPtr.h:
  • wtf/OwnPtr.h:
  • wtf/RefCounted.h:
  • wtf/ThreadSpecific.h:
  • wtf/Threading.h:
  • wtf/Vector.h:
  • wtf/unicode/Collator.h:

WebCore:

2009-07-14 Zoltan Horvath <[email protected]>

Reviewed by Darin Adler.

Change all Noncopyable inheriting visibility to public.
https://bugs.webkit.org/show_bug.cgi?id=27225

Change all Noncopyable inheriting visibility to public because
it is needed to the custom allocation framework (bug #20422).

  • bindings/js/GCController.h:
  • bindings/js/WorkerScriptController.h:
  • bindings/v8/V8DOMMap.cpp: (WebCore::):
  • bridge/runtime.h:
  • css/CSSSelector.h:
  • css/CSSSelectorList.h:
  • css/CSSStyleSelector.h:
  • dom/ClassNames.h:
  • dom/MessagePortChannel.h:
  • dom/XMLTokenizerLibxml2.cpp:
  • dom/XMLTokenizerScope.h:
  • editing/ReplaceSelectionCommand.cpp:
  • editing/SelectionController.h:
  • editing/TextIterator.cpp:
  • history/PageCache.h:
  • html/CanvasRenderingContext2D.h:
  • html/HTMLParser.h:
  • html/HTMLParserQuirks.h:
  • html/PreloadScanner.h:
  • loader/Cache.h:
  • loader/CrossOriginPreflightResultCache.h:
  • loader/FrameLoader.h:
  • loader/ProgressTracker.h:
  • loader/ThreadableLoader.h:
  • loader/appcache/ApplicationCacheGroup.h:
  • loader/archive/ArchiveResourceCollection.h:
  • loader/icon/IconDatabase.h:
  • loader/icon/IconLoader.h:
  • loader/icon/PageURLRecord.h:
  • loader/loader.h:
  • page/ContextMenuController.h:
  • page/EventHandler.h:
  • page/FrameTree.h:
  • page/Page.h:
  • page/PageGroup.h:
  • page/PageGroupLoadDeferrer.h:
  • page/mac/EventHandlerMac.mm:
  • platform/AutodrainedPool.h:
  • platform/ContextMenu.h:
  • platform/EventLoop.h:
  • platform/HostWindow.h:
  • platform/Pasteboard.h:
  • platform/PurgeableBuffer.h:
  • platform/RunLoopTimer.h:
  • platform/ThreadGlobalData.h:
  • platform/ThreadTimers.h:
  • platform/Timer.h:
  • platform/TreeShared.h:
  • platform/graphics/FontData.h:
  • platform/graphics/GlyphWidthMap.h:
  • platform/graphics/GraphicsContext.h:
  • platform/graphics/ImageBuffer.h:
  • platform/graphics/ImageSource.h:
  • platform/graphics/MediaPlayer.h:
  • platform/graphics/skia/GraphicsContextPlatformPrivate.h:
  • platform/graphics/skia/PlatformContextSkia.h:
  • platform/graphics/win/QTMovieWin.cpp:
  • platform/mac/LocalCurrentGraphicsContext.h:
  • platform/network/FormDataBuilder.h:
  • platform/network/ResourceHandleInternal.h:
  • platform/network/soup/ResourceHandleSoup.cpp:
  • platform/text/StringBuffer.h:
  • platform/text/TextCodec.h:
  • platform/win/WindowMessageBroadcaster.h:
  • rendering/CounterNode.h:
  • rendering/LayoutState.h:
  • rendering/RenderFrameSet.h:
  • rendering/RenderView.h:
  • rendering/TransformState.h:
  • svg/SVGAnimatedProperty.h:
  • svg/SynchronizableTypeWrapper.h:
  • workers/WorkerMessagingProxy.h:
  • workers/WorkerRunLoop.cpp:
  • xml/XPathExpressionNode.h:
  • xml/XPathParser.h:
  • xml/XPathPredicate.h:
  • xml/XPathStep.h:

WebKit/gtk:

2009-07-14 Zoltan Horvath <[email protected]>

Reviewed by Darin Adler.

Change all Noncopyable inheriting visibility to public.
https://bugs.webkit.org/show_bug.cgi?id=27225

Change all Noncopyable inheriting visibility to public because
it is needed to the custom allocation framework (bug #20422).

  • webkit/webkitdownload.cpp:

WebKit/win:

2009-07-14 Zoltan Horvath <[email protected]>

Reviewed by Darin Adler.

Change all Noncopyable inheriting visibility to public.
https://bugs.webkit.org/show_bug.cgi?id=27225

Change all Noncopyable inheriting visibility to public because
it is needed to the custom allocation framework (bug #20422).

  • COMEnumVariant.h:
  • WebDatabaseManager.cpp:
  • WebInspector.h:
  • WebLocalizableStrings.cpp:
  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1/*
2 * Copyright (C) 2005, 2008, 2009 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#ifndef JSLock_h
22#define JSLock_h
23
24#include <wtf/Assertions.h>
25#include <wtf/Noncopyable.h>
26
27namespace JSC {
28
29 // To make it safe to use JavaScript on multiple threads, it is
30 // important to lock before doing anything that allocates a
31 // JavaScript data structure or that interacts with shared state
32 // such as the protect count hash table. The simplest way to lock
33 // is to create a local JSLock object in the scope where the lock
34 // must be held. The lock is recursive so nesting is ok. The JSLock
35 // object also acts as a convenience short-hand for running important
36 // initialization routines.
37
38 // To avoid deadlock, sometimes it is necessary to temporarily
39 // release the lock. Since it is recursive you actually have to
40 // release all locks held by your thread. This is safe to do if
41 // you are executing code that doesn't require the lock, and you
42 // reacquire the right number of locks at the end. You can do this
43 // by constructing a locally scoped JSLock::DropAllLocks object. The
44 // DropAllLocks object takes care to release the JSLock only if your
45 // thread acquired it to begin with.
46
47 // For contexts other than the single shared one, implicit locking is not done,
48 // but we still need to perform all the counting in order to keep debug
49 // assertions working, so that clients that use the shared context don't break.
50
51 class ExecState;
52
53 class JSLock : public Noncopyable {
54 public:
55 JSLock(ExecState*);
56
57 JSLock(bool lockingForReal)
58 : m_lockingForReal(lockingForReal)
59 {
60#ifdef NDEBUG
61 // Locking "not for real" is a debug-only feature.
62 if (!lockingForReal)
63 return;
64#endif
65 lock(lockingForReal);
66 }
67
68 ~JSLock()
69 {
70#ifdef NDEBUG
71 // Locking "not for real" is a debug-only feature.
72 if (!m_lockingForReal)
73 return;
74#endif
75 unlock(m_lockingForReal);
76 }
77
78 static void lock(bool);
79 static void unlock(bool);
80 static void lock(ExecState*);
81 static void unlock(ExecState*);
82
83 static intptr_t lockCount();
84 static bool currentThreadIsHoldingLock();
85
86 bool m_lockingForReal;
87
88 class DropAllLocks : public Noncopyable {
89 public:
90 DropAllLocks(ExecState* exec);
91 DropAllLocks(bool);
92 ~DropAllLocks();
93
94 private:
95 intptr_t m_lockCount;
96 bool m_lockingForReal;
97 };
98 };
99
100} // namespace
101
102#endif // JSLock_h
Note: See TracBrowser for help on using the repository browser.