8000 gh-107149: make new opcode util functions private rather than public … · python/cpython@36aab34 · GitHub
[go: up one dir, main page]

Skip to content

Commit 36aab34

Browse files
authored
gh-107149: make new opcode util functions private rather than public and unstable (#112042)
1 parent b28bb13 commit 36aab34

File tree

5 files changed

+43
-39
lines changed

5 files changed

+43
-39
lines changed

Include/cpython/compile.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,3 @@ typedef struct {
6868
#define PY_INVALID_STACK_EFFECT INT_MAX
6969
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
7070
PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump);
71-
72-
PyAPI_FUNC(int) PyUnstable_OpcodeIsValid(int opcode);
73-
PyAPI_FUNC(int) PyUnstable_OpcodeHasArg(int opcode);
74-
PyAPI_FUNC(int) PyUnstable_OpcodeHasConst(int opcode);
75-
PyAPI_FUNC(int) PyUnstable_OpcodeHasName(int opcode);
76-
PyAPI_FUNC(int) PyUnstable_OpcodeHasJump(int opcode);
77-
PyAPI_FUNC(int) PyUnstable_OpcodeHasFree(int opcode);
78-
PyAPI_FUNC(int) PyUnstable_OpcodeHasLocal(int opcode);
79-
PyAPI_FUNC(int) PyUnstable_OpcodeHasExc(int opcode);
80-
81-
PyAPI_FUNC(PyObject*) PyUnstable_GetUnaryIntrinsicName(int index);
82-
PyAPI_FUNC(PyObject*) PyUnstable_GetBinaryIntrinsicName(int index);

Include/internal/pycore_compile.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ int _PyCompile_EnsureArrayLargeEnough(
102102

103103
int _PyCompile_ConstCacheMergeOne(PyObject *const_cache, PyObject **obj);
104104

105+
106+
// Export for '_opcode' extention module
107+
PyAPI_FUNC(int) _PyCompile_OpcodeIsValid(int opcode);
108+
PyAPI_FUNC(int) _PyCompile_OpcodeHasArg(int opcode);
109+
PyAPI_FUNC(int) _PyCompile_OpcodeHasConst(int opcode);
110+
PyAPI_FUNC(int) _PyCompile_OpcodeHasName(int opcode);
111+
PyAPI_FUNC(int) _PyCompile_OpcodeHasJump(int opcode);
112+
PyAPI_FUNC(int) _PyCompile_OpcodeHasFree(int opcode);
113+
PyAPI_FUNC(int) _PyCompile_OpcodeHasLocal(int opcode);
114+
PyAPI_FUNC(int) _PyCompile_OpcodeHasExc(int opcode);
115+
116+
PyAPI_FUNC(PyObject*) _PyCompile_GetUnaryIntrinsicName(int index);
117+
PyAPI_FUNC(PyObject*) _PyCompile_GetBinaryIntrinsicName(int index);
118+
105119
/* Access compiler internals for unit testing */
106120

107121
// Export for '_testinternalcapi' shared extension

Modules/_opcode.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "compile.h"
77
#include "opcode.h"
88
#include "internal/pycore_code.h"
9+
#include "internal/pycore_compile.h"
910
#include "internal/pycore_intrinsics.h"
1011

1112
/*[clinic input]
@@ -78,7 +79,7 @@ static int
7879
_opcode_is_valid_impl(PyObject *module, int opcode)
7980
/*[clinic end generated code: output=b0d918ea1d073f65 input=fe23e0aa194ddae0]*/
8081
{
81-
return PyUnstable_OpcodeIsValid(opcode);
82+
return _PyCompile_OpcodeIsValid(opcode);
8283
}
8384

8485
/*[clinic input]
@@ -94,8 +95,8 @@ static int
9495
_opcode_has_arg_impl(PyObject *module, int opcode)
9596
/*[clinic end generated code: output=7a062d3b2dcc0815 input=93d878ba6361db5f]*/
9697
{
97-
return PyUnstable_OpcodeIsValid(opcode) &&
98-
PyUnstable_OpcodeHasArg(opcode);
98+
return _PyCompile_OpcodeIsValid(opcode) &&
99+
_PyCompile_OpcodeHasArg(opcode);
99100
}
100101

101102
/*[clinic input]
@@ -111,8 +112,8 @@ static int
111112
_opcode_has_const_impl(PyObject *module, int opcode)
112113
/*[clinic end generated code: output=c646d5027c634120 input=a6999e4cf13f9410]*/
113114
{
114-
return PyUnstable_OpcodeIsValid(opcode) &&
115-
PyUnstable_OpcodeHasConst(opcode);
115+
return _PyCompile_OpcodeIsValid(opcode) &&
116+
_PyCompile_OpcodeHasConst(opcode);
116117
}
117118

118119
/*[clinic input]
@@ -128,8 +129,8 @@ static int
128129
_opcode_has_name_impl(PyObject *module, int opcode)
129130
/*[clinic end generated code: output=b49a83555c2fa517 input=448aa5e4bcc947ba]*/
130131
{
131-
return PyUnstable_OpcodeIsValid(opcode) &&
132-
PyUnstable_OpcodeHasName(opcode);
132+
return _PyCompile_OpcodeIsValid(opcode) &&
133+
_PyCompile_OpcodeHasName(opcode);
133134
}
134135

135136
/*[clinic input]
@@ -145,8 +146,8 @@ static int
145146
_opcode_has_jump_impl(PyObject *module, int opcode)
146147
/*[clinic end generated code: output=e9c583c669f1c46a input=35f711274357a0c3]*/
147148
{
148-
return PyUnstable_OpcodeIsValid(opcode) &&
149-
PyUnstable_OpcodeHasJump(opcode);
149+
return _PyCompile_OpcodeIsValid(opcode) &&
150+
_PyCompile_OpcodeHasJump(opcode);
150151

151152
}
152153

@@ -168,8 +169,8 @@ static int
168169
_opcode_has_free_impl(PyObject *module, int opcode)
169170
/*[clinic end generated code: output=d81ae4d79af0ee26 input=117dcd5c19c1139b]*/
170171
{
171-
return PyUnstable_OpcodeIsValid(opcode) &&
172-
PyUnstable_OpcodeHasFree(opcode);
172+
return _PyCompile_OpcodeIsValid(opcode) &&
173+
_PyCompile_OpcodeHasFree(opcode);
173174

174175
}
175176

@@ -186,8 +187,8 @@ static int
186187
_opcode_has_local_impl(PyObject *module, int opcode)
187188
/*[clinic end generated code: output=da5a8616b7a5097b input=9a798ee24aaef49d]*/
188189
{
189-
return PyUnstable_OpcodeIsValid(opcode) &&
190-
PyUnstable_OpcodeHasLocal(opcode);
190+
return _PyCompile_OpcodeIsValid(opcode) &&
191+
_PyCompile_OpcodeHasLocal(opcode);
191192
}
192193

193194
/*[clinic input]
@@ -203,8 +204,8 @@ static int
203204
_opcode_has_exc_impl(PyObject *module, int opcode)
204205
/*[clinic end generated code: output=41b68dff0ec82a52 input=db0e4bdb9bf13fa5]*/
205206
{
206-
return PyUnstable_OpcodeIsValid(opcode) &&
207-
PyUnstable_OpcodeHasExc(opcode);
207+
return _PyCompile_OpcodeIsValid(opcode) &&
208+
_PyCompile_OpcodeHasExc(opcode);
208209
}
209210

210211
/*[clinic input]
@@ -309,7 +310,7 @@ _opcode_get_intrinsic1_descs_impl(PyObject *module)
309310
return NULL;
310311
}
311312
for (int i=0; i <= MAX_INTRINSIC_1; i++) {
312-
PyObject *name = PyUnstable_GetUnaryIntrinsicName(i);
313+
PyObject *name = _PyCompile_GetUnaryIntrinsicName(i);
313314
if (name == NULL) {
314315
Py_DECREF(list);
315316
return NULL;
@@ -336,7 +337,7 @@ _opcode_get_intrinsic2_descs_impl(PyObject *module)
336337
return NULL;
337338
}
338339
for (int i=0; i <= MAX_INTRINSIC_2; i++) {
339-
PyObject *name = PyUnstable_GetBinaryIntrinsicName(i);
340+
PyObject *name = _PyCompile_GetBinaryIntrinsicName(i);
340341
if (name == NULL) {
341342
Py_DECREF(list);
342343
return NULL;

Python/compile.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -883,49 +883,49 @@ PyCompile_OpcodeStackEffect(int opcode, int oparg)
883883
}
884884

885885
int
886-
PyUnstable_OpcodeIsValid(int opcode)
886+
_PyCompile_OpcodeIsValid(int opcode)
887887
{
888888
return IS_VALID_OPCODE(opcode);
889889
}
890890

891891
int
892-
PyUnstable_OpcodeHasArg(int opcode)
892+
_PyCompile_OpcodeHasArg(int opcode)
893893
{
894894
return OPCODE_HAS_ARG(opcode);
895895
}
896896

897897
int
898-
PyUnstable_OpcodeHasConst(int opcode)
898+
_PyCompile_OpcodeHasConst(int opcode)
899899
{
900900
return OPCODE_HAS_CONST(opcode);
901901
}
902902

903903
int
904-
PyUnstable_OpcodeHasName(int opcode)
904+
_PyCompile_OpcodeHasName(int opcode)
905905
{
906906
return OPCODE_HAS_NAME(opcode);
907907
}
908908

909909
int
910-
PyUnstable_OpcodeHasJump(int opcode)
910+
_PyCompile_OpcodeHasJump(int opcode)
911911
{
912912
return OPCODE_HAS_JUMP(opcode);
913913
}
914914

915915
int
916-
PyUnstable_OpcodeHasFree(int opcode)
916+
_PyCompile_OpcodeHasFree(int opcode)
917917
{
918918
return OPCODE_HAS_FREE(opcode);
919919
}
920920

921921
int
922-
PyUnstable_OpcodeHasLocal(int opcode)
922+
_PyCompile_OpcodeHasLocal(int opcode)
923923
{
924924
return OPCODE_HAS_LOCAL(opcode);
925925
}
926926

927927
int
928-
PyUnstable_OpcodeHasExc(int opcode)
928+
_PyCompile_OpcodeHasExc(int opcode)
929929
{
930930
return IS_BLOCK_PUSH_OPCODE(opcode);
931931
}

Python/intrinsics.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "pycore_frame.h"
66
#include "pycore_function.h"
77
#include "pycore_global_objects.h"
8+
#include "pycore_compile.h" // _PyCompile_GetUnaryIntrinsicName, etc
89
#include "pycore_intrinsics.h" // INTRINSIC_PRINT
910
#include "pycore_pyerrors.h" // _PyErr_SetString()
1011
#include "pycore_runtime.h" // _Py_ID()
@@ -269,7 +270,7 @@ _PyIntrinsics_BinaryFunctions[] = {
269270
#undef INTRINSIC_FUNC_ENTRY
270271

271272
PyObject*
272-
PyUnstable_GetUnaryIntrinsicName(int index)
273+
_PyCompile_GetUnaryIntrinsicName(int index)
273274
{
274275
if (index < 0 || index > MAX_INTRINSIC_1) {
275276
return NULL;
@@ -278,7 +279,7 @@ PyUnstable_GetUnaryIntrinsicName(int index)
278279
}
279280

280281
PyObject*
281-
PyUnstable_GetBinaryIntrinsicName(int index)
282+
_PyCompile_GetBinaryIntrinsicName(int index)
282283
{
283284
if (index < 0 || index > MAX_INTRINSIC_2) {
284285
return NULL;

0 commit comments

Comments
 (0)
0