Skip to content

Commit d811b0f

Browse files
committed
Support LOAD_CONST
1 parent 24c8ed3 commit d811b0f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Python/optimizer.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,16 @@ uop_execute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject **
337337
{
338338
fprintf(stderr, "LOAD_FAST %d\n", oparg);
339339
PyObject *value = frame->localsplus[oparg];
340-
assert(value != 0);
340+
assert(value != NULL);
341+
Py_INCREF(value);
342+
*stack_pointer++ = value;
343+
break;
344+
}
345+
case LOAD_CONST:
346+
{
347+
fprintf(stderr, "LOAD_CONST %d\n", oparg);
348+
PyObject *value = PyTuple_GET_ITEM(_PyFrame_GetCode(frame)->co_consts, oparg);
349+
assert(value != NULL);
341350
Py_INCREF(value);
342351
*stack_pointer++ = value;
343352
break;
@@ -399,6 +408,11 @@ translate_bytecode_to_trace(
399408
ADD_TO_TRACE(LOAD_FAST, oparg2);
400409
break;
401410
}
411+
case LOAD_CONST:
412+
{
413+
ADD_TO_TRACE(opcode, oparg);
414+
break;
415+
}
402416
default:
403417
{
404418
goto done; // Break out of while loop

0 commit comments

Comments
 (0)