source: webkit/trunk/Source/JavaScriptCore/dfg/DFGCommon.cpp

Last change on this file was 278069, checked in by Chris Dumez, 4 years ago

Use UncheckedLock less in JavaScriptCore
https://bugs.webkit.org/show_bug.cgi?id=226212

Reviewed by Saam Barati.

Source/JavaScriptCore:

Use UncheckedLock less in JavaScriptCore as it is being phased out in favor of Lock, which
enables Clang thread safety analysis.

  • assembler/testmasm.cpp:
  • dfg/DFGCommon.cpp:
  • dynbench.cpp:
  • heap/Heap.cpp:
  • heap/Heap.h:
  • inspector/remote/socket/RemoteInspectorSocketEndpoint.h:
  • runtime/JSLock.cpp:
  • runtime/JSLock.h:
  • runtime/VM.h:

Source/WTF:

Add support for unlockEarly() to Locker<Lock> specialization, for consistency
with the generic Locker.

  • wtf/Lock.h:
File size: 4.2 KB
Line 
1/*
2 * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "DFGCommon.h"
28
29#include <wtf/Lock.h>
30#include <wtf/PrintStream.h>
31
32#if ENABLE(DFG_JIT)
33
34namespace JSC { namespace DFG {
35
36const char* const tierName = "DFG ";
37
38static Lock crashLock;
39
40// Use WTF_IGNORES_THREAD_SAFETY_ANALYSIS since the function keeps holding the lock when returning.
41void startCrashing() WTF_IGNORES_THREAD_SAFETY_ANALYSIS
42{
43 crashLock.lock();
44}
45
46bool isCrashing()
47{
48 return crashLock.isLocked();
49}
50
51bool stringLessThan(StringImpl& a, StringImpl& b)
52{
53 unsigned minLength = std::min(a.length(), b.length());
54 for (unsigned i = 0; i < minLength; ++i) {
55 if (a[i] == b[i])
56 continue;
57 return a[i] < b[i];
58 }
59 return a.length() < b.length();
60}
61
62} } // namespace JSC::DFG
63
64namespace WTF {
65
66using namespace JSC::DFG;
67
68void printInternal(PrintStream& out, OptimizationFixpointState state)
69{
70 switch (state) {
71 case BeforeFixpoint:
72 out.print("BeforeFixpoint");
73 return;
74 case FixpointNotConverged:
75 out.print("FixpointNotConverged");
76 return;
77 case FixpointConverged:
78 out.print("FixpointConverged");
79 return;
80 }
81 RELEASE_ASSERT_NOT_REACHED();
82}
83
84void printInternal(PrintStream& out, GraphForm form)
85{
86 switch (form) {
87 case LoadStore:
88 out.print("LoadStore");
89 return;
90 case ThreadedCPS:
91 out.print("ThreadedCPS");
92 return;
93 case SSA:
94 out.print("SSA");
95 return;
96 }
97 RELEASE_ASSERT_NOT_REACHED();
98}
99
100void printInternal(PrintStream& out, UnificationState state)
101{
102 switch (state) {
103 case LocallyUnified:
104 out.print("LocallyUnified");
105 return;
106 case GloballyUnified:
107 out.print("GloballyUnified");
108 return;
109 }
110 RELEASE_ASSERT_NOT_REACHED();
111}
112
113void printInternal(PrintStream& out, RefCountState state)
114{
115 switch (state) {
116 case EverythingIsLive:
117 out.print("EverythingIsLive");
118 return;
119 case ExactRefCount:
120 out.print("ExactRefCount");
121 return;
122 }
123 RELEASE_ASSERT_NOT_REACHED();
124}
125
126void printInternal(PrintStream& out, ProofStatus status)
127{
128 switch (status) {
129 case IsProved:
130 out.print("IsProved");
131 return;
132 case NeedsCheck:
133 out.print("NeedsCheck");
134 return;
135 }
136 RELEASE_ASSERT_NOT_REACHED();
137}
138
139} // namespace WTF
140
141#endif // ENABLE(DFG_JIT)
142
143namespace WTF {
144
145using namespace JSC::DFG;
146
147void printInternal(PrintStream& out, CapabilityLevel capabilityLevel)
148{
149 switch (capabilityLevel) {
150 case CannotCompile:
151 out.print("CannotCompile");
152 return;
153 case CanCompile:
154 out.print("CanCompile");
155 return;
156 case CanCompileAndInline:
157 out.print("CanCompileAndInline");
158 return;
159 case CapabilityLevelNotSet:
160 out.print("CapabilityLevelNotSet");
161 return;
162 }
163 RELEASE_ASSERT_NOT_REACHED();
164}
165
166} // namespace WTF
167
Note: See TracBrowser for help on using the repository browser.