Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions Python/bytecodes.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -112,7 +112,6 @@ dummy_func(

// stack effect: ( -- __0)
inst(LOAD_CONST){
PREDICTED(LOAD_CONST);
PyObject *value = GETITEM(consts, oparg);
Py_INCREF(value);
PUSH(value);
Expand DownExpand Up@@ -431,7 +430,6 @@ dummy_func(

// stack effect: (__0 -- )
inst(BINARY_SUBSCR){
PREDICTED(BINARY_SUBSCR);
PyObject *sub = POP();
PyObject *container = TOP();
PyObject *res = PyObject_GetItem(container, sub);
Expand DownExpand Up@@ -631,7 +629,6 @@ dummy_func(

// stack effect: (__0, __1, __2 -- )
inst(STORE_SUBSCR){
PREDICTED(STORE_SUBSCR);
PyObject *sub = TOP();
PyObject *container = SECOND();
PyObject *v = THIRD();
Expand DownExpand Up@@ -884,7 +881,6 @@ dummy_func(

// stack effect: ( -- )
inst(GET_AWAITABLE){
PREDICTED(GET_AWAITABLE);
PyObject *iterable = TOP();
PyObject *iter = _PyCoro_GetAwaitableIter(iterable);

Expand DownExpand Up@@ -1204,7 +1200,6 @@ dummy_func(

// stack effect: (__0 -- __array[oparg])
inst(UNPACK_SEQUENCE){
PREDICTED(UNPACK_SEQUENCE);
PyObject *seq = POP();
PyObject **top = stack_pointer + oparg;
if (!unpack_iterable(tstate, seq, oparg, -1, top)){
Expand DownExpand Up@@ -1290,7 +1285,6 @@ dummy_func(

// stack effect: (__0, __1 -- )
inst(STORE_ATTR){
PREDICTED(STORE_ATTR);
PyObject *name = GETITEM(names, oparg);
PyObject *owner = TOP();
PyObject *v = SECOND();
Expand DownExpand Up@@ -1407,7 +1401,6 @@ dummy_func(

// error: LOAD_GLOBAL has irregular stack effect
inst(LOAD_GLOBAL){
PREDICTED(LOAD_GLOBAL);
int push_null = oparg & 1;
PEEK(0) = NULL;
PyObject *name = GETITEM(names, oparg>>1);
Expand DownExpand Up@@ -1871,7 +1864,6 @@ dummy_func(

// error: LOAD_ATTR has irregular stack effect
inst(LOAD_ATTR){
PREDICTED(LOAD_ATTR);
PyObject *name = GETITEM(names, oparg >> 1);
PyObject *owner = TOP();
if (oparg & 1){
Expand DownExpand Up@@ -2276,7 +2268,6 @@ dummy_func(

// stack effect: (__0 -- )
inst(COMPARE_OP){
PREDICTED(COMPARE_OP);
assert(oparg <= Py_GE);
PyObject *right = POP();
PyObject *left = TOP();
Expand DownExpand Up@@ -2539,15 +2530,13 @@ dummy_func(

// stack effect: ( -- )
inst(JUMP_BACKWARD){
PREDICTED(JUMP_BACKWARD);
assert(oparg < INSTR_OFFSET());
JUMPBY(-oparg);
CHECK_EVAL_BREAKER();
}

// stack effect: (__0 -- )
inst(POP_JUMP_IF_FALSE){
PREDICTED(POP_JUMP_IF_FALSE);
PyObject *cond = POP();
if (Py_IsTrue(cond)){
_Py_DECREF_NO_DEALLOC(cond);
Expand DownExpand Up@@ -2788,7 +2777,6 @@ dummy_func(

// stack effect: ( -- __0)
inst(FOR_ITER){
PREDICTED(FOR_ITER);
/* before: [iter]; after: [iter, iter()] *or* [] */
PyObject *iter = TOP();
PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
Expand DownExpand Up@@ -3118,7 +3106,6 @@ dummy_func(

// stack effect: (__0, __array[oparg] -- )
inst(CALL){
PREDICTED(CALL);
int total_args, is_meth;
is_meth = is_method(stack_pointer, oparg);
PyObject *function = PEEK(oparg + 1);
Expand DownExpand Up@@ -3216,7 +3203,6 @@ dummy_func(

// stack effect: (__0, __array[oparg] -- )
inst(CALL_PY_EXACT_ARGS){
PREDICTED(CALL_PY_EXACT_ARGS);
assert(call_shape.kwnames == NULL);
DEOPT_IF(tstate->interp->eval_frame, CALL);
_PyCallCache *cache = (_PyCallCache *)next_instr;
Expand DownExpand Up@@ -3721,7 +3707,6 @@ dummy_func(

// error: CALL_FUNCTION_EX has irregular stack effect
inst(CALL_FUNCTION_EX){
PREDICTED(CALL_FUNCTION_EX);
PyObject *func, *callargs, *kwargs = NULL, *result;
if (oparg & 0x01){
kwargs = POP();
Expand DownExpand Up@@ -3913,7 +3898,6 @@ dummy_func(

// stack effect: (__0 -- )
inst(BINARY_OP){
PREDICTED(BINARY_OP);
PyObject *rhs = POP();
PyObject *lhs = TOP();
assert(0 <= oparg);
Expand Down
7 changes: 7 additions & 0 deletions Tools/cases_generator/generate_cases.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@

import argparse
import io
import re
import sys

import parser
Expand DownExpand Up@@ -61,12 +62,18 @@ def always_exits(block: parser.Block) -> bool:


def write_cases(f: io.TextIOBase, instrs: list[InstDef]):
predictions = set()
for inst in instrs:
for target in re.findall(r"(?:PREDICT|GO_TO_INSTRUCTION)\((\w+)\)", inst.block.text):
predictions.add(target)
indent = " "
f.write("// This file is generated by Tools/scripts/generate_cases.py\n")
f.write("// Do not edit!\n")
for instr in instrs:
assert isinstance(instr, InstDef)
f.write(f"\n{indent}TARGET({instr.name}){{\n")
if instr.name in predictions:
f.write(f"{indent} PREDICTED({instr.name});\n")
# input = ", ".join(instr.inputs)
# output = ", ".join(instr.outputs)
# f.write(f"{indent} //{input} --{output}\n")
Expand Down