Skip to content

Commit 92f5ae7

Browse files
committed
experimental: TU-isolation of IDEA-port symbols for mechanism #3 falsification
Move kVolatileTypeThreshold + type_invalidation_counts + volatile_types + isVolatileType + recordTypeInvalidation out of inline_cache.cpp's anonymous namespace into new translation unit ic_volatile_types.cpp + .h. inline_cache.cpp keeps the 2 invocation points (TypeWatcher::watch early-return + notifyICsTypeChanged record call) plus the new header include — net +4 lines vs upstream (was +21 on cluster5-pr). Branch is experimental; tests whether yield_from + 4 x86-LARGER regressions are caused by within-TU compiler-inlining shift from the +21-line code-size addition.
1 parent 0c99ac8 commit 92f5ae7

3 files changed

Lines changed: 43 additions & 17 deletions

File tree

cinderx/Jit/ic_volatile_types.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
3+
#include "cinderx/Jit/ic_volatile_types.h"
4+
5+
#include "cinderx/Jit/containers.h"
6+
#include "cinderx/Common/ref.h"
7+
8+
namespace jit {
9+
10+
namespace {
11+
12+
constexpr int kVolatileTypeThreshold = 10;
13+
14+
jit::UnorderedMap<BorrowedRef<PyTypeObject>, int> type_invalidation_counts;
15+
jit::UnorderedSet<BorrowedRef<PyTypeObject>> volatile_types;
16+
17+
} // namespace
18+
19+
bool isVolatileType(BorrowedRef<PyTypeObject> type) {
20+
return volatile_types.count(type) > 0;
21+
}
22+
23+
void recordTypeInvalidation(BorrowedRef<PyTypeObject> type) {
24+
int& count = type_invalidation_counts[type];
25+
count++;
26+
if (count >= kVolatileTypeThreshold) {
27+
volatile_types.emplace(type);
28+
}
29+
}
30+
31+
} // namespace jit

cinderx/Jit/ic_volatile_types.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#pragma once
3+
4+
#include "cinderx/Common/ref.h"
5+
6+
namespace jit {
7+
8+
bool isVolatileType(BorrowedRef<PyTypeObject> type);
9+
void recordTypeInvalidation(BorrowedRef<PyTypeObject> type);
10+
11+
} // namespace jit

cinderx/Jit/inline_cache.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "cinderx/Common/type.h"
1212
#include "cinderx/Common/util.h"
1313
#include "cinderx/Jit/containers.h"
14+
#include "cinderx/Jit/ic_volatile_types.h"
1415
#include "cinderx/StaticPython/strictmoduleobject.h"
1516
#include "cinderx/UpstreamBorrow/borrowed.h"
1617
#include "cinderx/module_state.h"
@@ -22,23 +23,6 @@ namespace jit {
2223

2324
namespace {
2425

25-
constexpr int kVolatileTypeThreshold = 10;
26-
27-
jit::UnorderedMap<BorrowedRef<PyTypeObject>, int> type_invalidation_counts;
28-
jit::UnorderedSet<BorrowedRef<PyTypeObject>> volatile_types;
29-
30-
bool isVolatileType(BorrowedRef<PyTypeObject> type) {
31-
return volatile_types.count(type) > 0;
32-
}
33-
34-
void recordTypeInvalidation(BorrowedRef<PyTypeObject> type) {
35-
int& count = type_invalidation_counts[type];
36-
count++;
37-
if (count >= kVolatileTypeThreshold) {
38-
volatile_types.emplace(type);
39-
}
40-
}
41-
4226
template <class T>
4327
struct TypeWatcher {
4428
jit::UnorderedMap<BorrowedRef<PyTypeObject>, jit::UnorderedSet<T*>> caches;

0 commit comments

Comments
 (0)