summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/bytecodes.c7
-rw-r--r--Python/executor_cases.c.h8
-rw-r--r--Python/generated_cases.c.h88
-rw-r--r--Python/jit.c7
-rw-r--r--Python/optimizer.c10
-rw-r--r--Python/optimizer_analysis.c1
-rw-r--r--Python/optimizer_bytecodes.c14
-rw-r--r--Python/optimizer_cases.c.h14
-rw-r--r--Python/optimizer_symbols.c1
-rw-r--r--Python/pylifecycle.c1
10 files changed, 97 insertions, 54 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 6654608..cdd4d5b 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -59,7 +59,6 @@
#define guard
#define override
#define specializing
-#define split
#define replicate(TIMES)
#define tier1
#define no_save_ip
@@ -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) =
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index ff9f33b..42a3d6d 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -2285,10 +2285,12 @@
}
case _PUSH_NULL_CONDITIONAL: {
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
oparg = CURRENT_OPARG();
- null = PyStackRef_NULL;
- if (oparg & 1) stack_pointer[0] = null;
+ null = &stack_pointer[0];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 558b0b4..9ce2b63 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -6982,7 +6982,7 @@
_PyStackRef class_st;
_PyStackRef self_st;
_PyStackRef attr;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
/* Skip 1 cache entry */
// _LOAD_SUPER_ATTR
{
@@ -7078,10 +7078,12 @@
}
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[1];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
stack_pointer[0] = attr;
- if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -7840,7 +7842,7 @@
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
_PyStackRef owner;
_PyStackRef attr;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
/* Skip 1 cache entry */
// _CHECK_ATTR_CLASS
{
@@ -7876,9 +7878,11 @@
}
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[0];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
- if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -7897,7 +7901,7 @@
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
_PyStackRef owner;
_PyStackRef attr;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
/* Skip 1 cache entry */
// _CHECK_ATTR_CLASS
{
@@ -7943,9 +7947,11 @@
}
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[0];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
- if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -8022,7 +8028,7 @@
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
_PyStackRef owner;
_PyStackRef attr;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
/* Skip 1 cache entry */
// _GUARD_TYPE_VERSION
{
@@ -8078,9 +8084,11 @@
/* Skip 5 cache entries */
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[0];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
- if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -8270,7 +8278,7 @@
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
_PyStackRef owner;
_PyStackRef attr;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
/* Skip 1 cache entry */
// _LOAD_ATTR_MODULE
{
@@ -8321,9 +8329,11 @@
/* Skip 5 cache entries */
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[0];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
- if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -8552,7 +8562,7 @@
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
_PyStackRef owner;
_PyStackRef attr;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
/* Skip 1 cache entry */
// _GUARD_TYPE_VERSION
{
@@ -8599,9 +8609,11 @@
/* Skip 5 cache entries */
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[0];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
- if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -8620,7 +8632,7 @@
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
_PyStackRef owner;
_PyStackRef attr;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
/* Skip 1 cache entry */
// _GUARD_TYPE_VERSION
{
@@ -8700,9 +8712,11 @@
/* Skip 5 cache entries */
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[0];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
- if (oparg & 1) stack_pointer[0] = null;
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -9080,7 +9094,7 @@
_Py_CODEUNIT* const this_instr = next_instr - 5;
(void)this_instr;
_PyStackRef *res;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
// _SPECIALIZE_LOAD_GLOBAL
{
uint16_t counter = read_u16(&this_instr[1].cache);
@@ -9114,9 +9128,11 @@
}
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[1];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
- if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -9134,7 +9150,7 @@
INSTRUCTION_STATS(LOAD_GLOBAL_BUILTIN);
static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
_PyStackRef res;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
/* Skip 1 cache entry */
// _GUARD_GLOBALS_VERSION
{
@@ -9191,10 +9207,12 @@
}
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[1];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
stack_pointer[0] = res;
- if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -9212,7 +9230,7 @@
INSTRUCTION_STATS(LOAD_GLOBAL_MODULE);
static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
_PyStackRef res;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
/* Skip 1 cache entry */
// _NOP
{
@@ -9256,10 +9274,12 @@
}
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[1];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
stack_pointer[0] = res;
- if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
@@ -9387,7 +9407,7 @@
_PyStackRef class_st;
_PyStackRef self_st;
_PyStackRef attr;
- _PyStackRef null = PyStackRef_NULL;
+ _PyStackRef *null;
// _SPECIALIZE_LOAD_SUPER_ATTR
{
class_st = stack_pointer[-2];
@@ -9499,10 +9519,12 @@
}
// _PUSH_NULL_CONDITIONAL
{
- null = PyStackRef_NULL;
+ null = &stack_pointer[1];
+ if (oparg & 1) {
+ null[0] = PyStackRef_NULL;
+ }
}
stack_pointer[0] = attr;
- if (oparg & 1) stack_pointer[1] = null;
stack_pointer += 1 + (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
DISPATCH();
diff --git a/Python/jit.c b/Python/jit.c
index 95b5a1b..1f4873e 100644
--- a/Python/jit.c
+++ b/Python/jit.c
@@ -8,7 +8,11 @@
#include "pycore_ceval.h"
#include "pycore_critical_section.h"
#include "pycore_dict.h"
+#include "pycore_floatobject.h"
+#include "pycore_frame.h"
+#include "pycore_interpframe.h"
#include "pycore_intrinsics.h"
+#include "pycore_list.h"
#include "pycore_long.h"
#include "pycore_opcode_metadata.h"
#include "pycore_opcode_utils.h"
@@ -16,6 +20,9 @@
#include "pycore_pyerrors.h"
#include "pycore_setobject.h"
#include "pycore_sliceobject.h"
+#include "pycore_tuple.h"
+#include "pycore_unicodeobject.h"
+
#include "pycore_jit.h"
// Memory management stuff: ////////////////////////////////////////////////////
diff --git a/Python/optimizer.c b/Python/optimizer.c
index 6fc5eab..e2fe0f6 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -6,11 +6,15 @@
#include "pycore_interp.h"
#include "pycore_backoff.h"
#include "pycore_bitutils.h" // _Py_popcount32()
+#include "pycore_code.h" // _Py_GetBaseCodeUnit
+#include "pycore_interpframe.h"
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "pycore_opcode_metadata.h" // _PyOpcode_OpName[]
#include "pycore_opcode_utils.h" // MAX_REAL_OPCODE
#include "pycore_optimizer.h" // _Py_uop_analyze_and_optimize()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
+#include "pycore_tuple.h" // _PyTuple_FromArraySteal
+#include "pycore_unicodeobject.h" // _PyUnicode_FromASCII
#include "pycore_uop_ids.h"
#include "pycore_jit.h"
#include <stdbool.h>
@@ -1226,11 +1230,7 @@ uop_optimize(
for (int pc = 0; pc < length; pc++) {
int opcode = buffer[pc].opcode;
int oparg = buffer[pc].oparg;
- if (_PyUop_Flags[opcode] & HAS_OPARG_AND_1_FLAG) {
- buffer[pc].opcode = opcode + 1 + (oparg & 1);
- assert(strncmp(_PyOpcode_uop_name[buffer[pc].opcode], _PyOpcode_uop_name[opcode], strlen(_PyOpcode_uop_name[opcode])) == 0);
- }
- else if (oparg < _PyUop_Replication[opcode]) {
+ if (oparg < _PyUop_Replication[opcode]) {
buffer[pc].opcode = opcode + oparg + 1;
assert(strncmp(_PyOpcode_uop_name[buffer[pc].opcode], _PyOpcode_uop_name[opcode], strlen(_PyOpcode_uop_name[opcode])) == 0);
}
diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c
index 67bf8d1..017a2ee 100644
--- a/Python/optimizer_analysis.c
+++ b/Python/optimizer_analysis.c
@@ -21,6 +21,7 @@
#include "pycore_uop_metadata.h"
#include "pycore_dict.h"
#include "pycore_long.h"
+#include "pycore_interpframe.h" // _PyFrame_GetCode
#include "pycore_optimizer.h"
#include "pycore_object.h"
#include "pycore_dict.h"
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c
index ea7c39b..cfa0a73 100644
--- a/Python/optimizer_bytecodes.c
+++ b/Python/optimizer_bytecodes.c
@@ -546,10 +546,14 @@ dummy_func(void) {
}
}
- op (_PUSH_NULL_CONDITIONAL, ( -- null if (oparg & 1))) {
- int opcode = (oparg & 1) ? _PUSH_NULL : _NOP;
- REPLACE_OP(this_instr, opcode, 0, 0);
- null = sym_new_null(ctx);
+ op (_PUSH_NULL_CONDITIONAL, ( -- null[oparg & 1])) {
+ if (oparg & 1) {
+ REPLACE_OP(this_instr, _PUSH_NULL, 0, 0);
+ null[0] = sym_new_null(ctx);
+ }
+ else {
+ REPLACE_OP(this_instr, _NOP, 0, 0);
+ }
}
op(_LOAD_ATTR, (owner -- attr, self_or_null[oparg&1])) {
@@ -765,7 +769,7 @@ dummy_func(void) {
Py_UNREACHABLE();
}
- op(_PUSH_FRAME, (new_frame: _Py_UOpsAbstractFrame * -- unused if (0))) {
+ op(_PUSH_FRAME, (new_frame: _Py_UOpsAbstractFrame * -- )) {
SYNC_SP();
ctx->frame->stack_pointer = stack_pointer;
ctx->frame = new_frame;
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index 3f31590..fc70ee3 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -921,11 +921,15 @@
}
case _PUSH_NULL_CONDITIONAL: {
- JitOptSymbol *null = NULL;
- int opcode = (oparg & 1) ? _PUSH_NULL : _NOP;
- REPLACE_OP(this_instr, opcode, 0, 0);
- null = sym_new_null(ctx);
- if (oparg & 1) stack_pointer[0] = null;
+ JitOptSymbol **null;
+ null = &stack_pointer[0];
+ if (oparg & 1) {
+ REPLACE_OP(this_instr, _PUSH_NULL, 0, 0);
+ null[0] = sym_new_null(ctx);
+ }
+ else {
+ REPLACE_OP(this_instr, _NOP, 0, 0);
+ }
stack_pointer += (oparg & 1);
assert(WITHIN_STACK_BOUNDS());
break;
diff --git a/Python/optimizer_symbols.c b/Python/optimizer_symbols.c
index 8445546f..c50f98c 100644
--- a/Python/optimizer_symbols.c
+++ b/Python/optimizer_symbols.c
@@ -6,6 +6,7 @@
#include "pycore_frame.h"
#include "pycore_long.h"
#include "pycore_optimizer.h"
+#include "pycore_stats.h"
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include <stdbool.h>
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 8fe58c3..ed21fce 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -18,6 +18,7 @@
#include "pycore_long.h" // _PyLong_InitTypes()
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
#include "pycore_obmalloc.h" // _PyMem_init_obmalloc()
+#include "pycore_optimizer.h" // _Py_Executors_InvalidateAll
#include "pycore_pathconfig.h" // _PyPathConfig_UpdateGlobal()
#include "pycore_pyerrors.h" // _PyErr_Occurred()
#include "pycore_pylifecycle.h" // _PyErr_Print()