Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit deec638

Browse filesBrowse files
Merge pull request #25 from JuliaPoo/types_metainterpreter
Perf+Feat: Removed unnecessary declarations in type propagator and type annotated more bytecode
2 parents cd32a5a + 24ded88 commit deec638
Copy full SHA for deec638

File tree

4 files changed

+151
-328
lines changed
Filter options

4 files changed

+151
-328
lines changed

‎Python/bytecodes.c

Copy file name to clipboardExpand all lines: Python/bytecodes.c
+24-24Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ dummy_func(
140140
DECREF_INPUTS();
141141
}
142142

143-
inst(PUSH_NULL, (-- res)) {
143+
inst(PUSH_NULL, (-- res: NULL)) {
144144
res = NULL;
145145
}
146146

@@ -184,7 +184,7 @@ dummy_func(
184184
};
185185

186186

187-
inst(BINARY_OP_MULTIPLY_INT, (unused/1, left, right -- prod)) {
187+
inst(BINARY_OP_MULTIPLY_INT, (unused/1, left, right -- prod: PyLong_Type)) {
188188
assert(cframe.use_tracing == 0);
189189
DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
190190
DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
@@ -195,7 +195,7 @@ dummy_func(
195195
ERROR_IF(prod == NULL, error);
196196
}
197197

198-
inst(BINARY_OP_MULTIPLY_FLOAT, (unused/1, left, right -- prod)) {
198+
inst(BINARY_OP_MULTIPLY_FLOAT, (unused/1, left, right -- prod: PyFloat_Type)) {
199199
assert(cframe.use_tracing == 0);
200200
DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
201201
DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
@@ -208,7 +208,7 @@ dummy_func(
208208
ERROR_IF(prod == NULL, error);
209209
}
210210

211-
inst(BINARY_OP_SUBTRACT_INT, (unused/1, left, right -- sub)) {
211+
inst(BINARY_OP_SUBTRACT_INT, (unused/1, left, right -- sub: PyLong_Type)) {
212212
assert(cframe.use_tracing == 0);
213213
DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
214214
DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP);
@@ -219,7 +219,7 @@ dummy_func(
219219
ERROR_IF(sub == NULL, error);
220220
}
221221

222-
inst(BINARY_OP_SUBTRACT_FLOAT, (unused/1, left, right -- sub)) {
222+
inst(BINARY_OP_SUBTRACT_FLOAT, (unused/1, left, right -- sub: PyFloat_Type)) {
223223
assert(cframe.use_tracing == 0);
224224
DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
225225
DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP);
@@ -231,7 +231,7 @@ dummy_func(
231231
ERROR_IF(sub == NULL, error);
232232
}
233233

234-
inst(BINARY_OP_ADD_UNICODE, (unused/1, left, right -- res)) {
234+
inst(BINARY_OP_ADD_UNICODE, (unused/1, left, right -- res: PyUnicode_Type)) {
235235
assert(cframe.use_tracing == 0);
236236
DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP);
237237
DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
@@ -278,7 +278,7 @@ dummy_func(
278278
JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP + 1);
279279
}
280280

281-
inst(BINARY_OP_ADD_FLOAT, (unused/1, left, right -- sum)) {
281+
inst(BINARY_OP_ADD_FLOAT, (unused/1, left, right -- sum: PyFloat_Type)) {
282282
assert(cframe.use_tracing == 0);
283283
DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP);
284284
DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
@@ -291,7 +291,7 @@ dummy_func(
291291
ERROR_IF(sum == NULL, error);
292292
}
293293

294-
macro_inst(BINARY_OP_ADD_INT, (unused/1, left, right -- sum)) {
294+
macro_inst(BINARY_OP_ADD_INT, (unused/1, left, right -- sum: PyLong_Type)) {
295295
assert(cframe.use_tracing == 0);
296296
DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP);
297297
DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP);
@@ -303,7 +303,7 @@ dummy_func(
303303
bb_test = PyLong_CheckExact(left) && (Py_TYPE(left) == Py_TYPE(right));
304304
}
305305

306-
u_inst(BINARY_OP_ADD_INT_REST, (left : PyLong_Type, right : PyLong_Type -- sum : PyLong_Type)) {
306+
u_inst(BINARY_OP_ADD_INT_REST, (left, right -- sum : PyLong_Type)) {
307307
STAT_INC(BINARY_OP, hit);
308308
sum = _PyLong_Add((PyLongObject *)left, (PyLongObject *)right);
309309
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
@@ -1274,20 +1274,20 @@ dummy_func(
12741274
}
12751275
}
12761276

1277-
inst(BUILD_STRING, (pieces[oparg] -- str)) {
1277+
inst(BUILD_STRING, (pieces[oparg] -- str: PyUnicode_Type)) {
12781278
str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg);
12791279
for (int i = 0; i < oparg; i++) {
12801280
Py_DECREF(pieces[i]);
12811281
}
12821282
ERROR_IF(str == NULL, error);
12831283
}
12841284

1285-
inst(BUILD_TUPLE, (values[oparg] -- tup)) {
1285+
inst(BUILD_TUPLE, (values[oparg] -- tup: PyTuple_Type)) {
12861286
tup = _PyTuple_FromArraySteal(values, oparg);
12871287
ERROR_IF(tup == NULL, error);
12881288
}
12891289

1290-
inst(BUILD_LIST, (values[oparg] -- list)) {
1290+
inst(BUILD_LIST, (values[oparg] -- list: PyList_Type)) {
12911291
list = _PyList_FromArraySteal(values, oparg);
12921292
ERROR_IF(list == NULL, error);
12931293
}
@@ -1316,7 +1316,7 @@ dummy_func(
13161316
ERROR_IF(err < 0, error);
13171317
}
13181318

1319-
inst(BUILD_SET, (values[oparg] -- set)) {
1319+
inst(BUILD_SET, (values[oparg] -- set: PySet_Type)) {
13201320
set = PySet_New(NULL);
13211321
if (set == NULL)
13221322
goto error;
@@ -1333,7 +1333,7 @@ dummy_func(
13331333
}
13341334
}
13351335

1336-
inst(BUILD_MAP, (values[oparg*2] -- map)) {
1336+
inst(BUILD_MAP, (values[oparg*2] -- map: PyDict_Type)) {
13371337
map = _PyDict_FromItems(
13381338
values, 2,
13391339
values+1, 2,
@@ -1390,7 +1390,7 @@ dummy_func(
13901390
}
13911391
}
13921392

1393-
inst(BUILD_CONST_KEY_MAP, (values[oparg], keys -- map)) {
1393+
inst(BUILD_CONST_KEY_MAP, (values[oparg], keys -- map: PyDict_Type)) {
13941394
if (!PyTuple_CheckExact(keys) ||
13951395
PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) {
13961396
_PyErr_SetString(tstate, PyExc_SystemError,
@@ -1833,13 +1833,13 @@ dummy_func(
18331833
}
18341834
}
18351835

1836-
inst(IS_OP, (left, right -- b)) {
1836+
inst(IS_OP, (left, right -- b: PyBool_Type)) {
18371837
int res = Py_Is(left, right) ^ oparg;
18381838
DECREF_INPUTS();
18391839
b = Py_NewRef(res ? Py_True : Py_False);
18401840
}
18411841

1842-
inst(CONTAINS_OP, (left, right -- b)) {
1842+
inst(CONTAINS_OP, (left, right -- b: PyBool_Type)) {
18431843
int res = PySequence_Contains(right, left);
18441844
DECREF_INPUTS();
18451845
ERROR_IF(res < 0, error);
@@ -1867,7 +1867,7 @@ dummy_func(
18671867
}
18681868
}
18691869

1870-
inst(CHECK_EXC_MATCH, (left, right -- left, b)) {
1870+
inst(CHECK_EXC_MATCH, (left, right -- left, b: PyBool_Type)) {
18711871
assert(PyExceptionInstance_Check(left));
18721872
if (check_except_type_valid(tstate, right) < 0) {
18731873
DECREF_INPUTS();
@@ -2153,7 +2153,7 @@ dummy_func(
21532153
JUMPBY(-oparg);
21542154
}
21552155

2156-
inst(GET_LEN, (obj -- obj, len_o)) {
2156+
inst(GET_LEN, (obj -- obj, len_o: PyLong_Type)) {
21572157
// PUSH(len(TOS))
21582158
Py_ssize_t len_i = PyObject_Length(obj);
21592159
ERROR_IF(len_i < 0, error);
@@ -2176,13 +2176,13 @@ dummy_func(
21762176
}
21772177
}
21782178

2179-
inst(MATCH_MAPPING, (subject -- subject, res)) {
2179+
inst(MATCH_MAPPING, (subject -- subject, res: PyBool_Type)) {
21802180
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING;
21812181
res = Py_NewRef(match ? Py_True : Py_False);
21822182
PREDICT(POP_JUMP_IF_FALSE);
21832183
}
21842184

2185-
inst(MATCH_SEQUENCE, (subject -- subject, res)) {
2185+
inst(MATCH_SEQUENCE, (subject -- subject, res: PyBool_Type)) {
21862186
int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE;
21872187
res = Py_NewRef(match ? Py_True : Py_False);
21882188
PREDICT(POP_JUMP_IF_FALSE);
@@ -2453,7 +2453,7 @@ dummy_func(
24532453
}
24542454
}
24552455

2456-
inst(WITH_EXCEPT_START, (exit_func, lasti, unused, val -- exit_func, lasti, unused, val, res)) {
2456+
inst(WITH_EXCEPT_START, (exit_func, lasti, unused, val -- exit_func, lasti: PyLong_Type, unused, val, res)) {
24572457
/* At the top of the stack are 4 values:
24582458
- val: TOP = exc_info()
24592459
- unused: SECOND = previous exception
@@ -3245,7 +3245,7 @@ dummy_func(
32453245
}
32463246
}
32473247

3248-
inst(COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
3248+
inst(COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top: *bottom)) {
32493249
assert(oparg > 0);
32503250
top = Py_NewRef(bottom);
32513251
}
@@ -3272,7 +3272,7 @@ dummy_func(
32723272
}
32733273

32743274
inst(SWAP, (bottom, unused[oparg-2], top --
3275-
top, unused[oparg-2], bottom)) {
3275+
top : *top, unused[oparg-2], bottom : *bottom)) {
32763276
assert(oparg >= 2);
32773277
}
32783278

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.