Skip to content

Commit 5b75ee6

Browse files
camillobrunijuanarbol
authored andcommitted
deps: V8: cherry-pick a6eaf7574109
Original commit message: [logging] Use RecursiveMutex for Logger Logger::allows_code_compaction might be called from within a CodeCreateEvent where initializing line script line ends might trigger a GC. During compaction we check if code compaction is allowed which calls back into the above Logger method. Bug: 41497149 Change-Id: Ifd1b740df8600584780341d8214e995832e663b4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5572952 Reviewed-by: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/main@{#94140} Refs: v8/v8@a6eaf75
1 parent 7c2df5d commit 5b75ee6

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.56',
41+
'v8_embedder_string': '-node.57',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/logging/code-events.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class Logger {
125125
Logger& operator=(const Logger&) = delete;
126126

127127
bool AddListener(LogEventListener* listener) {
128-
base::MutexGuard guard(&mutex_);
128+
base::RecursiveMutexGuard guard(&mutex_);
129129
auto position = std::find(listeners_.begin(), listeners_.end(), listener);
130130
if (position != listeners_.end()) return false;
131131
// Add the listener to the end and update the element
@@ -134,23 +134,23 @@ class Logger {
134134
}
135135

136136
bool RemoveListener(LogEventListener* listener) {
137-
base::MutexGuard guard(&mutex_);
137+
base::RecursiveMutexGuard guard(&mutex_);
138138
auto position = std::find(listeners_.begin(), listeners_.end(), listener);
139139
if (position == listeners_.end()) return false;
140140
listeners_.erase(position);
141141
return true;
142142
}
143143

144144
bool is_listening_to_code_events() {
145-
base::MutexGuard guard(&mutex_);
145+
base::RecursiveMutexGuard guard(&mutex_);
146146
for (auto listener : listeners_) {
147147
if (listener->is_listening_to_code_events()) return true;
148148
}
149149
return false;
150150
}
151151

152152
bool allows_code_compaction() {
153-
base::MutexGuard guard(&mutex_);
153+
base::RecursiveMutexGuard guard(&mutex_);
154154
for (auto listener : listeners_) {
155155
if (!listener->allows_code_compaction()) return false;
156156
}
@@ -159,23 +159,23 @@ class Logger {
159159

160160
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
161161
const char* comment) {
162-
base::MutexGuard guard(&mutex_);
162+
base::RecursiveMutexGuard guard(&mutex_);
163163
for (auto listener : listeners_) {
164164
listener->CodeCreateEvent(tag, code, comment);
165165
}
166166
}
167167

168168
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
169169
Handle<Name> name) {
170-
base::MutexGuard guard(&mutex_);
170+
base::RecursiveMutexGuard guard(&mutex_);
171171
for (auto listener : listeners_) {
172172
listener->CodeCreateEvent(tag, code, name);
173173
}
174174
}
175175

176176
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
177177
Handle<SharedFunctionInfo> shared, Handle<Name> name) {
178-
base::MutexGuard guard(&mutex_);
178+
base::RecursiveMutexGuard guard(&mutex_);
179179
for (auto listener : listeners_) {
180180
listener->CodeCreateEvent(tag, code, shared, name);
181181
}
@@ -184,7 +184,7 @@ class Logger {
184184
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
185185
Handle<SharedFunctionInfo> shared, Handle<Name> source,
186186
int line, int column) {
187-
base::MutexGuard guard(&mutex_);
187+
base::RecursiveMutexGuard guard(&mutex_);
188188
for (auto listener : listeners_) {
189189
listener->CodeCreateEvent(tag, code, shared, source, line, column);
190190
}
@@ -194,7 +194,7 @@ class Logger {
194194
void CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
195195
wasm::WasmName name, const char* source_url,
196196
int code_offset, int script_id) {
197-
base::MutexGuard guard(&mutex_);
197+
base::RecursiveMutexGuard guard(&mutex_);
198198
for (auto listener : listeners_) {
199199
listener->CodeCreateEvent(tag, code, name, source_url, code_offset,
200200
script_id);
@@ -203,80 +203,80 @@ class Logger {
203203
#endif // V8_ENABLE_WEBASSEMBLY
204204

205205
void CallbackEvent(Handle<Name> name, Address entry_point) {
206-
base::MutexGuard guard(&mutex_);
206+
base::RecursiveMutexGuard guard(&mutex_);
207207
for (auto listener : listeners_) {
208208
listener->CallbackEvent(name, entry_point);
209209
}
210210
}
211211

212212
void GetterCallbackEvent(Handle<Name> name, Address entry_point) {
213-
base::MutexGuard guard(&mutex_);
213+
base::RecursiveMutexGuard guard(&mutex_);
214214
for (auto listener : listeners_) {
215215
listener->GetterCallbackEvent(name, entry_point);
216216
}
217217
}
218218

219219
void SetterCallbackEvent(Handle<Name> name, Address entry_point) {
220-
base::MutexGuard guard(&mutex_);
220+
base::RecursiveMutexGuard guard(&mutex_);
221221
for (auto listener : listeners_) {
222222
listener->SetterCallbackEvent(name, entry_point);
223223
}
224224
}
225225

226226
void RegExpCodeCreateEvent(Handle<AbstractCode> code, Handle<String> source) {
227-
base::MutexGuard guard(&mutex_);
227+
base::RecursiveMutexGuard guard(&mutex_);
228228
for (auto listener : listeners_) {
229229
listener->RegExpCodeCreateEvent(code, source);
230230
}
231231
}
232232

233233
void CodeMoveEvent(Tagged<InstructionStream> from,
234234
Tagged<InstructionStream> to) {
235-
base::MutexGuard guard(&mutex_);
235+
base::RecursiveMutexGuard guard(&mutex_);
236236
for (auto listener : listeners_) {
237237
listener->CodeMoveEvent(from, to);
238238
}
239239
}
240240

241241
void BytecodeMoveEvent(Tagged<BytecodeArray> from, Tagged<BytecodeArray> to) {
242-
base::MutexGuard guard(&mutex_);
242+
base::RecursiveMutexGuard guard(&mutex_);
243243
for (auto listener : listeners_) {
244244
listener->BytecodeMoveEvent(from, to);
245245
}
246246
}
247247

248248
void SharedFunctionInfoMoveEvent(Address from, Address to) {
249-
base::MutexGuard guard(&mutex_);
249+
base::RecursiveMutexGuard guard(&mutex_);
250250
for (auto listener : listeners_) {
251251
listener->SharedFunctionInfoMoveEvent(from, to);
252252
}
253253
}
254254

255255
void NativeContextMoveEvent(Address from, Address to) {
256-
base::MutexGuard guard(&mutex_);
256+
base::RecursiveMutexGuard guard(&mutex_);
257257
for (auto listener : listeners_) {
258258
listener->NativeContextMoveEvent(from, to);
259259
}
260260
}
261261

262262
void CodeMovingGCEvent() {
263-
base::MutexGuard guard(&mutex_);
263+
base::RecursiveMutexGuard guard(&mutex_);
264264
for (auto listener : listeners_) {
265265
listener->CodeMovingGCEvent();
266266
}
267267
}
268268

269269
void CodeDisableOptEvent(Handle<AbstractCode> code,
270270
Handle<SharedFunctionInfo> shared) {
271-
base::MutexGuard guard(&mutex_);
271+
base::RecursiveMutexGuard guard(&mutex_);
272272
for (auto listener : listeners_) {
273273
listener->CodeDisableOptEvent(code, shared);
274274
}
275275
}
276276

277277
void CodeDeoptEvent(Handle<Code> code, DeoptimizeKind kind, Address pc,
278278
int fp_to_sp_delta) {
279-
base::MutexGuard guard(&mutex_);
279+
base::RecursiveMutexGuard guard(&mutex_);
280280
for (auto listener : listeners_) {
281281
listener->CodeDeoptEvent(code, kind, pc, fp_to_sp_delta);
282282
}
@@ -285,22 +285,22 @@ class Logger {
285285
void CodeDependencyChangeEvent(Handle<Code> code,
286286
Handle<SharedFunctionInfo> sfi,
287287
const char* reason) {
288-
base::MutexGuard guard(&mutex_);
288+
base::RecursiveMutexGuard guard(&mutex_);
289289
for (auto listener : listeners_) {
290290
listener->CodeDependencyChangeEvent(code, sfi, reason);
291291
}
292292
}
293293

294294
void WeakCodeClearEvent() {
295-
base::MutexGuard guard(&mutex_);
295+
base::RecursiveMutexGuard guard(&mutex_);
296296
for (auto listener : listeners_) {
297297
listener->WeakCodeClearEvent();
298298
}
299299
}
300300

301301
private:
302302
std::vector<LogEventListener*> listeners_;
303-
base::Mutex mutex_;
303+
base::RecursiveMutex mutex_;
304304
};
305305

306306
} // namespace internal

0 commit comments

Comments
 (0)