Skip to content

Commit 9fa773b

Browse files
phourimeta-codesync[bot]
authored andcommitted
Revert D98315856: Don't generate Decrefs for immortal types
Differential Revision: D98315856 Original commit changeset: 291bd19916bf Original Phabricator Diff: D98315856 fbshipit-source-id: 46da0a1ecd8bb34fb060bfffe0ad88168b1394d1
1 parent d5fa88c commit 9fa773b

6 files changed

Lines changed: 23 additions & 14 deletions

File tree

cinderx/Jit/hir/refcount_insertion.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,7 @@ std::vector<PredState> collectPredStates(Env& env, BasicBlock* block) {
476476
// Return true iff the given Register is definitely not a reference-counted
477477
// value.
478478
bool isUncounted(const Register* reg) {
479-
auto ty = reg->type();
480-
if (!ty.couldBe(TMortalObject)) {
481-
return true;
482-
}
483-
484-
// Types like TMortalBool always exist in the type system but with immortal
485-
// instances enabled they're identical to their immortal equivalents.
486-
return kImmortalInstances && (ty <= (TNoneType | TBool));
479+
return !reg->type().couldBe(TMortalObject);
487480
}
488481

489482
// Insert an Incref of `reg` before `cursor`.

cinderx/RuntimeTests/hir_guard_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,26 +165,26 @@ fun __main__:test {
165165
}
166166
v1:NoneType = LoadConst<NoneType>
167167
v2:Object = LoadGlobal<0> {
168-
LiveValues<2> b:v0 unc:v1
168+
LiveValues<2> b:v0 b:v1
169169
FrameState {
170170
CurInstrOffset -2
171171
}
172172
}
173173
CheckExc v2 {
174-
LiveValues<3> b:v0 unc:v1 o:v2
174+
LiveValues<3> b:v0 b:v1 o:v2
175175
FrameState {
176176
CurInstrOffset 6
177177
}
178178
}
179179
Guard v2 {
180-
LiveValues<3> b:v0 unc:v1 o:v2
180+
LiveValues<3> b:v0 b:v1 o:v2
181181
FrameState {
182182
CurInstrOffset 6
183183
Stack<3> v0 v1 v2
184184
}
185185
}
186186
v3:Object = VectorCall<2> v0 v1 v2 {
187-
LiveValues<3> b:v0 unc:v1 o:v2
187+
LiveValues<3> b:v0 b:v1 o:v2
188188
FrameState {
189189
CurInstrOffset -2
190190
}

cinderx/RuntimeTests/hir_tests/all_passes_static_test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ fun jittestmodule:test {
8989
bb 3 (preds 1) {
9090
XDecref v25
9191
v44:NoneType = LoadConst<NoneType>
92+
Incref v44
9293
Return v44
9394
}
9495
}

cinderx/RuntimeTests/hir_tests/all_passes_test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ fun jittestmodule:test {
980980
}
981981
Decref v8
982982
v15:NoneType = LoadConst<NoneType>
983+
Incref v15
983984
Return v15
984985
}
985986
}

cinderx/RuntimeTests/hir_tests/refcount_insertion_static_test.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fun jittestmodule:Test.__init__ {
2020
v8:Nullptr = LoadConst<Nullptr>
2121
StoreField<x@16> v5 v6 v8
2222
v10:NoneType = LoadConst<NoneType>
23+
Incref v10
2324
Return<NoneType> v10
2425
}
2526
}
@@ -124,6 +125,7 @@ fun jittestmodule:Test.__init__ {
124125
StoreField<x@16> v4 v5 v7
125126
XDecref v7
126127
v8:NoneType = LoadConst<NoneType>
128+
Incref v8
127129
Return<NoneType> v8
128130
}
129131
}

cinderx/RuntimeTests/hir_tests/refcount_insertion_test.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ fun jittestmodule:test {
931931
Decref v44
932932
Decref v47
933933
v48:NoneType = LoadConst<NoneType>
934+
Incref v48
934935
Return v48
935936
}
936937
}
@@ -1406,6 +1407,7 @@ fun jittestmodule:test {
14061407
Decref v54
14071408
Decref v57
14081409
v58:NoneType = LoadConst<NoneType>
1410+
Incref v58
14091411
Return v58
14101412
}
14111413
}
@@ -1949,6 +1951,7 @@ fun jittestmodule:test {
19491951
Decref v25
19501952
XDecref v26
19511953
v42:NoneType = LoadConst<NoneType>
1954+
Incref v42
19521955
Return v42
19531956
}
19541957
}
@@ -2358,6 +2361,7 @@ fun jittestmodule:test {
23582361
}
23592362
}
23602363
v7:NoneType = LoadConst<NoneType>
2364+
Incref v7
23612365
Return v7
23622366
}
23632367
}
@@ -3351,12 +3355,14 @@ fun jittestmodule:test {
33513355
Decref v32
33523356
Decref v33
33533357
v34:NoneType = LoadConst<NoneType>
3358+
Incref v34
33543359
Return v34
33553360
}
33563361

33573362
bb 6 (preds 4) {
33583363
XDecref v27
33593364
v35:NoneType = LoadConst<NoneType>
3365+
Incref v35
33603366
Return v35
33613367
}
33623368
}
@@ -3824,6 +3830,7 @@ fun jittestmodule:test {
38243830

38253831
bb 3 (preds 2) {
38263832
v39:NoneType = LoadConst<NoneType>
3833+
Incref v39
38273834
Branch<4>
38283835
}
38293836

@@ -3839,7 +3846,7 @@ fun jittestmodule:test {
38393846
v47:OptObject = LoadGlobalCached<1; "print">
38403847
v48:MortalObjectUser[builtin_function_or_method:print:0xdeadbeef] = GuardIs<0xdeadbeef> v47 {
38413848
Descr 'LOAD_GLOBAL: print'
3842-
LiveValues<6> b:v17 b:v27 o:v42 o:v44 unc:v45 b:v47
3849+
LiveValues<6> b:v17 b:v27 o:v42 o:v44 b:v45 b:v47
38433850
FrameState {
38443851
CurInstrOffset 34
38453852
Locals<4> v27 v42 v17 v44
@@ -3848,7 +3855,7 @@ fun jittestmodule:test {
38483855
Incref v27
38493856
Decref v42
38503857
v50:Object = VectorCall<1> v48 v27 {
3851-
LiveValues<5> b:v17 o:v27 o:v44 unc:v45 b:v48
3858+
LiveValues<5> b:v17 o:v27 o:v44 b:v45 b:v48
38523859
FrameState {
38533860
CurInstrOffset 42
38543861
Locals<4> v27 v45 v17 v44
@@ -3858,6 +3865,7 @@ fun jittestmodule:test {
38583865
Decref v44
38593866
Decref v50
38603867
v51:NoneType = LoadConst<NoneType>
3868+
Incref v51
38613869
Return v51
38623870
}
38633871
}
@@ -4277,6 +4285,7 @@ fun jittestmodule:test {
42774285
}
42784286
Decref v11
42794287
v14:NoneType = LoadConst<NoneType>
4288+
Incref v14
42804289
Return v14
42814290
}
42824291
}
@@ -4298,6 +4307,7 @@ fun jittestmodule:test {
42984307
}
42994308
Decref v11
43004309
v14:NoneType = LoadConst<NoneType>
4310+
Incref v14
43014311
Return v14
43024312
}
43034313
}
@@ -4319,6 +4329,7 @@ fun jittestmodule:test {
43194329
}
43204330
Decref v11
43214331
v14:NoneType = LoadConst<NoneType>
4332+
Incref v14
43224333
Return v14
43234334
}
43244335
}
@@ -4340,6 +4351,7 @@ fun jittestmodule:test {
43404351
}
43414352
Decref v11
43424353
v14:NoneType = LoadConst<NoneType>
4354+
Incref v14
43434355
Return v14
43444356
}
43454357
}

0 commit comments

Comments
 (0)