@@ -91,7 +91,7 @@ out_of_space(JitOptContext *ctx)
9191JitOptRef
9292out_of_space_ref (JitOptContext * ctx )
9393{
94- return PyJitRef_FromSymbolSteal (out_of_space (ctx ));
94+ return PyJitRef_Wrap (out_of_space (ctx ));
9595}
9696
9797static JitOptSymbol *
@@ -125,26 +125,26 @@ sym_set_bottom(JitOptContext *ctx, JitOptSymbol *sym)
125125bool
126126_Py_uop_sym_is_bottom (JitOptRef ref )
127127{
128- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
128+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
129129 return sym -> tag == JIT_SYM_BOTTOM_TAG ;
130130}
131131
132132bool
133133_Py_uop_sym_is_not_null (JitOptRef ref ) {
134- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
134+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
135135 return sym -> tag == JIT_SYM_NON_NULL_TAG || sym -> tag > JIT_SYM_BOTTOM_TAG ;
136136}
137137
138138bool
139139_Py_uop_sym_is_const (JitOptContext * ctx , JitOptRef ref )
140140{
141- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
141+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
142142 if (sym -> tag == JIT_SYM_KNOWN_VALUE_TAG ) {
143143 return true;
144144 }
145145 if (sym -> tag == JIT_SYM_TRUTHINESS_TAG ) {
146146 JitOptSymbol * value = allocation_base (ctx ) + sym -> truthiness .value ;
147- int truthiness = _Py_uop_sym_truthiness (ctx , PyJitRef_FromSymbolSteal (value ));
147+ int truthiness = _Py_uop_sym_truthiness (ctx , PyJitRef_Wrap (value ));
148148 if (truthiness < 0 ) {
149149 return false;
150150 }
@@ -157,20 +157,20 @@ _Py_uop_sym_is_const(JitOptContext *ctx, JitOptRef ref)
157157bool
158158_Py_uop_sym_is_null (JitOptRef ref )
159159{
160- return PyJitRef_AsSymbolBorrow (ref )-> tag == JIT_SYM_NULL_TAG ;
160+ return PyJitRef_Unwrap (ref )-> tag == JIT_SYM_NULL_TAG ;
161161}
162162
163163
164164PyObject *
165165_Py_uop_sym_get_const (JitOptContext * ctx , JitOptRef ref )
166166{
167- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
167+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
168168 if (sym -> tag == JIT_SYM_KNOWN_VALUE_TAG ) {
169169 return sym -> value .value ;
170170 }
171171 if (sym -> tag == JIT_SYM_TRUTHINESS_TAG ) {
172172 JitOptSymbol * value = allocation_base (ctx ) + sym -> truthiness .value ;
173- int truthiness = _Py_uop_sym_truthiness (ctx , PyJitRef_FromSymbolSteal (value ));
173+ int truthiness = _Py_uop_sym_truthiness (ctx , PyJitRef_Wrap (value ));
174174 if (truthiness < 0 ) {
175175 return NULL ;
176176 }
@@ -184,7 +184,7 @@ _Py_uop_sym_get_const(JitOptContext *ctx, JitOptRef ref)
184184void
185185_Py_uop_sym_set_type (JitOptContext * ctx , JitOptRef ref , PyTypeObject * typ )
186186{
187- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
187+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
188188 JitSymType tag = sym -> tag ;
189189 switch (tag ) {
190190 case JIT_SYM_NULL_TAG :
@@ -235,7 +235,7 @@ _Py_uop_sym_set_type(JitOptContext *ctx, JitOptRef ref, PyTypeObject *typ)
235235bool
236236_Py_uop_sym_set_type_version (JitOptContext * ctx , JitOptRef ref , unsigned int version )
237237{
238- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
238+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
239239 PyTypeObject * type = _PyType_LookupByVersion (version );
240240 if (type ) {
241241 _Py_uop_sym_set_type (ctx , ref , type );
@@ -293,7 +293,7 @@ _Py_uop_sym_set_type_version(JitOptContext *ctx, JitOptRef ref, unsigned int ver
293293void
294294_Py_uop_sym_set_const (JitOptContext * ctx , JitOptRef ref , PyObject * const_val )
295295{
296- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
296+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
297297 JitSymType tag = sym -> tag ;
298298 switch (tag ) {
299299 case JIT_SYM_NULL_TAG :
@@ -348,7 +348,8 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptRef ref, PyObject *const_val)
348348 sym_set_bottom (ctx , sym );
349349 return ;
350350 }
351- JitOptRef value = PyJitRef_FromSymbolSteal (allocation_base (ctx ) + sym -> truthiness .value );
351+ JitOptRef value = PyJitRef_Wrap (
352+ allocation_base (ctx ) + sym -> truthiness .value );
352353 PyTypeObject * type = _Py_uop_sym_get_type (value );
353354 if (const_val == (sym -> truthiness .invert ? Py_False : Py_True )) {
354355 // value is truthy. This is only useful for bool:
@@ -375,7 +376,7 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptRef ref, PyObject *const_val)
375376void
376377_Py_uop_sym_set_null (JitOptContext * ctx , JitOptRef ref )
377378{
378- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
379+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
379380 if (sym -> tag == JIT_SYM_UNKNOWN_TAG ) {
380381 sym -> tag = JIT_SYM_NULL_TAG ;
381382 }
@@ -387,7 +388,7 @@ _Py_uop_sym_set_null(JitOptContext *ctx, JitOptRef ref)
387388void
388389_Py_uop_sym_set_non_null (JitOptContext * ctx , JitOptRef ref )
389390{
390- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
391+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
391392 if (sym -> tag == JIT_SYM_UNKNOWN_TAG ) {
392393 sym -> tag = JIT_SYM_NON_NULL_TAG ;
393394 }
@@ -403,7 +404,7 @@ _Py_uop_sym_new_unknown(JitOptContext *ctx)
403404 if (res == NULL ) {
404405 return out_of_space_ref (ctx );
405406 }
406- return PyJitRef_FromSymbolSteal (res );
407+ return PyJitRef_Wrap (res );
407408}
408409
409410JitOptRef
@@ -414,7 +415,7 @@ _Py_uop_sym_new_not_null(JitOptContext *ctx)
414415 return out_of_space_ref (ctx );
415416 }
416417 res -> tag = JIT_SYM_NON_NULL_TAG ;
417- return PyJitRef_FromSymbolSteal (res );
418+ return PyJitRef_Wrap (res );
418419}
419420
420421JitOptRef
@@ -424,7 +425,7 @@ _Py_uop_sym_new_type(JitOptContext *ctx, PyTypeObject *typ)
424425 if (res == NULL ) {
425426 return out_of_space_ref (ctx );
426427 }
427- JitOptRef ref = PyJitRef_FromSymbolSteal (res );
428+ JitOptRef ref = PyJitRef_Wrap (res );
428429 _Py_uop_sym_set_type (ctx , ref , typ );
429430 return ref ;
430431}
@@ -438,7 +439,7 @@ _Py_uop_sym_new_const(JitOptContext *ctx, PyObject *const_val)
438439 if (res == NULL ) {
439440 return out_of_space_ref (ctx );
440441 }
441- JitOptRef ref = PyJitRef_FromSymbolSteal (res );
442+ JitOptRef ref = PyJitRef_Wrap (res );
442443 _Py_uop_sym_set_const (ctx , ref , const_val );
443444 return ref ;
444445}
@@ -450,15 +451,15 @@ _Py_uop_sym_new_null(JitOptContext *ctx)
450451 if (null_sym == NULL ) {
451452 return out_of_space_ref (ctx );
452453 }
453- JitOptRef ref = PyJitRef_FromSymbolSteal (null_sym );
454+ JitOptRef ref = PyJitRef_Wrap (null_sym );
454455 _Py_uop_sym_set_null (ctx , ref );
455456 return ref ;
456457}
457458
458459PyTypeObject *
459460_Py_uop_sym_get_type (JitOptRef ref )
460461{
461- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
462+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
462463 JitSymType tag = sym -> tag ;
463464 switch (tag ) {
464465 case JIT_SYM_NULL_TAG :
@@ -483,7 +484,7 @@ _Py_uop_sym_get_type(JitOptRef ref)
483484unsigned int
484485_Py_uop_sym_get_type_version (JitOptRef ref )
485486{
486- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
487+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
487488 JitSymType tag = sym -> tag ;
488489 switch (tag ) {
489490 case JIT_SYM_NULL_TAG :
@@ -527,7 +528,7 @@ _Py_uop_sym_matches_type_version(JitOptRef sym, unsigned int version)
527528int
528529_Py_uop_sym_truthiness (JitOptContext * ctx , JitOptRef ref )
529530{
530- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
531+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
531532 switch (sym -> tag ) {
532533 case JIT_SYM_NULL_TAG :
533534 case JIT_SYM_TYPE_VERSION_TAG :
@@ -548,7 +549,7 @@ _Py_uop_sym_truthiness(JitOptContext *ctx, JitOptRef ref)
548549 ;
549550 JitOptSymbol * value = allocation_base (ctx ) + sym -> truthiness .value ;
550551 int truthiness = _Py_uop_sym_truthiness (ctx ,
551- PyJitRef_FromSymbolBorrow (value ));
552+ PyJitRef_Wrap (value ));
552553 if (truthiness < 0 ) {
553554 return truthiness ;
554555 }
@@ -589,16 +590,16 @@ _Py_uop_sym_new_tuple(JitOptContext *ctx, int size, JitOptRef *args)
589590 res -> tag = JIT_SYM_TUPLE_TAG ;
590591 res -> tuple .length = size ;
591592 for (int i = 0 ; i < size ; i ++ ) {
592- res -> tuple .items [i ] = (uint16_t )(PyJitRef_AsSymbolBorrow (args [i ]) - allocation_base (ctx ));
593+ res -> tuple .items [i ] = (uint16_t )(PyJitRef_Unwrap (args [i ]) - allocation_base (ctx ));
593594 }
594595 }
595- return PyJitRef_FromSymbolSteal (res );
596+ return PyJitRef_Wrap (res );
596597}
597598
598599JitOptRef
599600_Py_uop_sym_tuple_getitem (JitOptContext * ctx , JitOptRef ref , int item )
600601{
601- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
602+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
602603 assert (item >= 0 );
603604 if (sym -> tag == JIT_SYM_KNOWN_VALUE_TAG ) {
604605 PyObject * tuple = sym -> value .value ;
@@ -607,15 +608,15 @@ _Py_uop_sym_tuple_getitem(JitOptContext *ctx, JitOptRef ref, int item)
607608 }
608609 }
609610 else if (sym -> tag == JIT_SYM_TUPLE_TAG && item < sym -> tuple .length ) {
610- return PyJitRef_FromSymbolSteal (allocation_base (ctx ) + sym -> tuple .items [item ]);
611+ return PyJitRef_Wrap (allocation_base (ctx ) + sym -> tuple .items [item ]);
611612 }
612613 return _Py_uop_sym_new_not_null (ctx );
613614}
614615
615616int
616617_Py_uop_sym_tuple_length (JitOptRef ref )
617618{
618- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
619+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
619620 if (sym -> tag == JIT_SYM_KNOWN_VALUE_TAG ) {
620621 PyObject * tuple = sym -> value .value ;
621622 if (PyTuple_CheckExact (tuple )) {
@@ -647,14 +648,14 @@ _Py_uop_symbol_is_immortal(JitOptSymbol *sym)
647648bool
648649_Py_uop_sym_is_immortal (JitOptRef ref )
649650{
650- JitOptSymbol * sym = PyJitRef_AsSymbolBorrow (ref );
651+ JitOptSymbol * sym = PyJitRef_Unwrap (ref );
651652 return _Py_uop_symbol_is_immortal (sym );
652653}
653654
654655JitOptRef
655656_Py_uop_sym_new_truthiness (JitOptContext * ctx , JitOptRef ref , bool truthy )
656657{
657- JitOptSymbol * value = PyJitRef_AsSymbolBorrow (ref );
658+ JitOptSymbol * value = PyJitRef_Unwrap (ref );
658659 // It's clearer to invert this in the signature:
659660 bool invert = !truthy ;
660661 if (value -> tag == JIT_SYM_TRUTHINESS_TAG && value -> truthiness .invert == invert ) {
@@ -673,7 +674,7 @@ _Py_uop_sym_new_truthiness(JitOptContext *ctx, JitOptRef ref, bool truthy)
673674 else {
674675 make_const (res , (truthiness ^ invert ) ? Py_True : Py_False );
675676 }
676- return PyJitRef_FromSymbolSteal (res );
677+ return PyJitRef_Wrap (res );
677678}
678679
679680// 0 on success, -1 on error.
@@ -809,7 +810,7 @@ _Py_uop_symbols_test(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(ignored))
809810 TEST_PREDICATE (_Py_uop_sym_get_const (ctx , ref ) == NULL , "top as constant is not NULL" );
810811 TEST_PREDICATE (!_Py_uop_sym_is_bottom (ref ), "top is bottom" );
811812
812- ref = PyJitRef_FromSymbolSteal (make_bottom (ctx ));
813+ ref = PyJitRef_Wrap (make_bottom (ctx ));
813814 if (PyJitRef_IsNull (ref )) {
814815 goto fail ;
815816 }
0 commit comments