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
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
4 changes: 4 additions & 0 deletions 4 Include/internal/pycore_jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
extern "C" {
#endif

#include "pycore_interp.h"
#include "pycore_optimizer.h"
#include "pycore_stackref.h"

#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
Expand Down
104 changes: 6 additions & 98 deletions 104 Lib/test/test_generated_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ class TestEffects(unittest.TestCase):
def test_effect_sizes(self):
stack = Stack()
inputs = [
x := StackItem("x", None, "", "1"),
y := StackItem("y", None, "", "oparg"),
z := StackItem("z", None, "", "oparg*2"),
x := StackItem("x", None, "1"),
y := StackItem("y", None, "oparg"),
z := StackItem("z", None, "oparg*2"),
]
outputs = [
StackItem("x", None, "", "1"),
StackItem("b", None, "", "oparg*4"),
StackItem("c", None, "", "1"),
StackItem("x", None, "1"),
StackItem("b", None, "oparg*4"),
StackItem("c", None, "1"),
]
stack.pop(z)
stack.pop(y)
Expand Down Expand Up @@ -903,98 +903,6 @@ def test_array_error_if(self):
"""
self.run_cases_test(input, output)

def test_cond_effect(self):
input = """
inst(OP, (aa, input if ((oparg & 1) == 1), cc -- xx, output if (oparg & 2), zz)) {
output = SPAM(oparg, aa, cc, input);
INPUTS_DEAD();
xx = 0;
zz = 0;
}
"""
output = """
TARGET(OP) {
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
frame->instr_ptr = next_instr;
next_instr += 1;
INSTRUCTION_STATS(OP);
_PyStackRef aa;
_PyStackRef input = PyStackRef_NULL;
_PyStackRef cc;
_PyStackRef xx;
_PyStackRef output = PyStackRef_NULL;
_PyStackRef zz;
cc = stack_pointer[-1];
if ((oparg & 1) == 1) { input = stack_pointer[-1 - (((oparg & 1) == 1) ? 1 : 0)]; }
aa = stack_pointer[-2 - (((oparg & 1) == 1) ? 1 : 0)];
output = SPAM(oparg, aa, cc, input);
xx = 0;
zz = 0;
stack_pointer[-2 - (((oparg & 1) == 1) ? 1 : 0)] = xx;
if (oparg & 2) stack_pointer[-1 - (((oparg & 1) == 1) ? 1 : 0)] = output;
stack_pointer[-1 - (((oparg & 1) == 1) ? 1 : 0) + ((oparg & 2) ? 1 : 0)] = zz;
stack_pointer += -(((oparg & 1) == 1) ? 1 : 0) + ((oparg & 2) ? 1 : 0);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
self.run_cases_test(input, output)

def test_macro_cond_effect(self):
input = """
op(A, (left, middle, right --)) {
USE(left, middle, right);
INPUTS_DEAD();
}
op(B, (-- deep, extra if (oparg), res)) {
deep = -1;
res = 0;
extra = 1;
INPUTS_DEAD();
}
macro(M) = A + B;
"""
output = """
TARGET(M) {
#if Py_TAIL_CALL_INTERP
int opcode = M;
(void)(opcode);
#endif
frame->instr_ptr = next_instr;
next_instr += 1;
INSTRUCTION_STATS(M);
_PyStackRef left;
_PyStackRef middle;
_PyStackRef right;
_PyStackRef deep;
_PyStackRef extra = PyStackRef_NULL;
_PyStackRef res;
// A
{
right = stack_pointer[-1];
middle = stack_pointer[-2];
left = stack_pointer[-3];
USE(left, middle, right);
}
// B
{
deep = -1;
res = 0;
extra = 1;
}
stack_pointer[-3] = deep;
if (oparg) stack_pointer[-2] = extra;
stack_pointer[-2 + ((oparg) ? 1 : 0)] = res;
stack_pointer += -1 + ((oparg) ? 1 : 0);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
}
"""
self.run_cases_test(input, output)

def test_macro_push_push(self):
input = """
op(A, (-- val1)) {
Expand Down
1 change: 1 addition & 0 deletions 1 Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "pycore_instruction_sequence.h" // _PyInstructionSequence_New()
#include "pycore_interpframe.h" // _PyFrame_GetFunction()
#include "pycore_object.h" // _PyObject_IsFreed()
#include "pycore_optimizer.h" // _Py_Executor_DependsOn
#include "pycore_pathconfig.h" // _PyPathConfig_ClearGlobal()
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
#include "pycore_pylifecycle.h" // _PyInterpreterConfig_InitFromDict()
Expand Down
1 change: 1 addition & 0 deletions 1 Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "pycore_interpframe.h" // FRAME_SPECIALS_SIZE
#include "pycore_opcode_metadata.h" // _PyOpcode_Caches
#include "pycore_opcode_utils.h" // RESUME_AT_FUNC_START
#include "pycore_optimizer.h" // _Py_ExecutorDetach
#include "pycore_pymem.h" // _PyMem_FreeDelayed()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_setobject.h" // _PySet_NextEntry()
Expand Down
7 changes: 4 additions & 3 deletions 7 Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#define guard
#define override
#define specializing
#define split
#define replicate(TIMES)
#define tier1
#define no_save_ip
Expand Down Expand Up @@ -1686,8 +1685,10 @@ dummy_func(
ERROR_IF(PyStackRef_IsNull(*res), error);
}

op(_PUSH_NULL_CONDITIONAL, ( -- null if (oparg & 1))) {
null = PyStackRef_NULL;
op(_PUSH_NULL_CONDITIONAL, ( -- null[oparg & 1])) {
if (oparg & 1) {
null[0] = PyStackRef_NULL;
}
}

macro(LOAD_GLOBAL) =
Expand Down
8 changes: 5 additions & 3 deletions 8 Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.