Skip to content

Commit b31c40c

Browse files
janometa-codesync[bot]
authored andcommitted
Remove StickyFlags now that all surprise flags are sticky
Summary: Now that all surprise flags are individually cleared at their handling sites, the StickyFlags concept is redundant — every flag is sticky. This removes the StickyFlags enum value and simplifies fetchAndClearSurpriseFlags() into fetchSurpriseFlags(), which is now a plain atomic load instead of a fetch_and that preserved sticky flags (which was all of them, making it a no-op). The conditional `if (StickyFlags & Flag)` guards in handle_request_surprise() are also removed since they were always true. Reviewed By: ricklavoie Differential Revision: D92776193 fbshipit-source-id: ff146afe88a60416b8da3563995e8e7b7fd99fa2
1 parent 00ca92d commit b31c40c

2 files changed

Lines changed: 9 additions & 40 deletions

File tree

hphp/runtime/base/request-info.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ size_t handle_request_surprise(c_WaitableWaitHandle* wh, size_t mask) {
272272
auto& info = RI();
273273
auto& p = info.m_reqInjectionData;
274274

275-
auto flags = fetchAndClearSurpriseFlags() & mask;
275+
auto flags = fetchSurpriseFlags() & mask;
276276
auto const debugging = p.getDebuggerAttached();
277277

278278
// Start with any pending exception that might be on the request.
@@ -321,7 +321,6 @@ size_t handle_request_surprise(c_WaitableWaitHandle* wh, size_t mask) {
321321
}
322322

323323
if (flags & MemExceededFlag) {
324-
assertx(MemExceededFlag & StickyFlags);
325324
if (p.hostOOMFlag() && !pendingException) {
326325
// When the host is running out of memory, don't abort all requests.
327326
// Instead, only kill a request if it uses a nontrivial amount of memory.
@@ -354,19 +353,13 @@ size_t handle_request_surprise(c_WaitableWaitHandle* wh, size_t mask) {
354353
// we'll disable specific flags to make sure Xenon (or other)
355354
// re-entrant code doesn't interfere with debugging.
356355
if (flags & XenonSignalFlag) {
357-
if (StickyFlags & XenonSignalFlag) {
358-
clearSurpriseFlag(XenonSignalFlag);
359-
}
356+
clearSurpriseFlag(XenonSignalFlag);
360357
}
361358
if (flags & HeapSamplingFlag) {
362-
if (StickyFlags & HeapSamplingFlag) {
363-
clearSurpriseFlag(HeapSamplingFlag);
364-
}
359+
clearSurpriseFlag(HeapSamplingFlag);
365360
}
366361
if (flags & IntervalTimerFlag) {
367-
if (StickyFlags & IntervalTimerFlag) {
368-
clearSurpriseFlag(IntervalTimerFlag);
369-
}
362+
clearSurpriseFlag(IntervalTimerFlag);
370363
}
371364
}
372365
if (flags & CLIClientTerminated) {
@@ -377,9 +370,7 @@ size_t handle_request_surprise(c_WaitableWaitHandle* wh, size_t mask) {
377370
}
378371
}
379372
if (flags & PendingGCFlag) {
380-
if (StickyFlags & PendingGCFlag) {
381-
clearSurpriseFlag(PendingGCFlag);
382-
}
373+
clearSurpriseFlag(PendingGCFlag);
383374
if (tl_heap->isGCEnabled()) {
384375
tl_heap->collect("surprise");
385376
} else {
@@ -392,9 +383,7 @@ size_t handle_request_surprise(c_WaitableWaitHandle* wh, size_t mask) {
392383
}
393384

394385
if (flags & PendingPerfEventFlag) {
395-
if (StickyFlags & PendingPerfEventFlag) {
396-
clearSurpriseFlag(PendingPerfEventFlag);
397-
}
386+
clearSurpriseFlag(PendingPerfEventFlag);
398387
perf_event_consume(record_perf_mem_event);
399388
}
400389

hphp/runtime/base/surprise-flags.h

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,32 +73,12 @@ enum SurpriseFlag : size_t {
7373
/* Set when executing a CLI-server request and the client has vanished. */
7474
CLIClientTerminated = 1ull << 63,
7575

76-
/*
77-
* Flags that shouldn't be cleared by fetchAndClearSurpriseFlags, because
78-
* fetchAndClearSurpriseFlags is only supposed to touch flags related to
79-
* PHP-visible signals/exceptions and resource limits.
80-
*/
8176
ResourceFlags =
8277
MemExceededFlag |
8378
TimedOutFlag |
8479
PendingGCFlag |
8580
PendingPerfEventFlag,
8681

87-
StickyFlags =
88-
AsyncEventHookFlag |
89-
DebuggerHookFlag |
90-
DebuggerSignalFlag |
91-
EventHookFlag |
92-
InterceptFlag |
93-
PendingExceptionFlag |
94-
SignaledFlag |
95-
XenonSignalFlag |
96-
HeapSamplingFlag |
97-
IntervalTimerFlag |
98-
MemThresholdFlag |
99-
CLIClientTerminated |
100-
ResourceFlags,
101-
10282
/*
10383
* Flags that should only be checked at MemoryManager safe points.
10484
*/
@@ -174,9 +154,9 @@ inline void clearSurpriseFlag(SurpriseFlag flag) {
174154
stackLimitAndSurprise().fetch_and(~flag);
175155
}
176156

177-
inline size_t fetchAndClearSurpriseFlags() {
178-
return stackLimitAndSurprise().
179-
fetch_and(StickyFlags | kSurpriseFlagStackMask) & kSurpriseFlagMask;
157+
inline size_t fetchSurpriseFlags() {
158+
return stackLimitAndSurprise().load(std::memory_order_acquire) &
159+
kSurpriseFlagMask;
180160
}
181161

182162
///////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)