Skip to content

Commit 5928818

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
ThreadedRef
Summary: Fixes up some usages of `Ref` to use `ThreadedRef`. I'm not actually sure how we are getting away with this today, but somehow I started hitting this elsewhere in this stack. We are clearly using these in multi-threaded compile (hence the serialization guards!) but we can't use `Ref` on 3.12+ because it's stored in interpreter state and we don't have access to it in multi-threaded compile. So this just moves them over to our ThreadedRef helper. Reviewed By: alexmalyshev Differential Revision: D92781351 fbshipit-source-id: 9cddbce620283057a35101420e8dad2f2b5d7cd5
1 parent b6d5dce commit 5928818

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

cinderx/Jit/hir/hir.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ TypedArgument::TypedArgument(
11951195
exact(exact),
11961196
jit_type(jit_type) {
11971197
ThreadedCompileSerialize guard;
1198-
this->pytype = Ref<PyTypeObject>::create(pytype);
1198+
this->pytype = ThreadedRef<PyTypeObject>::create(pytype);
11991199
thread_safe_flags = pytype->tp_flags & kThreadSafeFlagsMask;
12001200
}
12011201

@@ -1211,7 +1211,7 @@ TypedArgument::TypedArgument(const TypedArgument& other)
12111211
jit_type(other.jit_type),
12121212
thread_safe_flags(other.thread_safe_flags) {
12131213
ThreadedCompileSerialize guard;
1214-
pytype = Ref<PyTypeObject>::create(other.pytype);
1214+
pytype = ThreadedRef<PyTypeObject>::create(other.pytype);
12151215
}
12161216

12171217
TypedArgument& TypedArgument::operator=(const TypedArgument& other) {

cinderx/Jit/hir/hir.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4025,7 +4025,7 @@ struct TypedArgument {
40254025
unsigned long threadSafeTpFlags() const;
40264026

40274027
long locals_idx;
4028-
Ref<PyTypeObject> pytype;
4028+
ThreadedRef<PyTypeObject> pytype;
40294029
int optional;
40304030
int exact;
40314031
Type jit_type;

cinderx/Jit/type_deopt_patchers.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "cinderx/Common/ref.h"
55
#include "cinderx/Jit/code_patcher.h"
6+
#include "cinderx/Jit/threaded_compile.h"
67

78
namespace jit {
89

@@ -41,8 +42,8 @@ class TypeAttrDeoptPatcher : public TypeDeoptPatcher {
4142
private:
4243
void onPatch() override;
4344

44-
Ref<PyUnicodeObject> attr_name_;
45-
Ref<> target_object_;
45+
ThreadedRef<PyUnicodeObject> attr_name_;
46+
ThreadedRef<> target_object_;
4647
};
4748

4849
class SplitDictDeoptPatcher : public TypeDeoptPatcher {
@@ -57,7 +58,7 @@ class SplitDictDeoptPatcher : public TypeDeoptPatcher {
5758
private:
5859
void onPatch() override;
5960

60-
Ref<PyUnicodeObject> attr_name_;
61+
ThreadedRef<PyUnicodeObject> attr_name_;
6162

6263
// We don't need to hold a strong reference to keys_ like we do for
6364
// attr_name_ because calls to PyTypeModified() happen before the old keys

0 commit comments

Comments
 (0)