Skip to content

Commit 0a74052

Browse files
committed
Don't optimize during quickening
1 parent 17d6dd6 commit 0a74052

File tree

1 file changed

+1
-69
lines changed

1 file changed

+1
-69
lines changed

Python/specialize.c

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -447,25 +447,6 @@ do { \
447447
# define SPECIALIZATION_FAIL(opcode, kind) ((void)0)
448448
#endif
449449

450-
#define NUM_VARS 256
451-
452-
static inline void
453-
set_mutated(bool *mutated, int i)
454-
{
455-
if (i < NUM_VARS) {
456-
mutated[i] = true;
457-
}
458-
}
459-
460-
static inline bool
461-
get_mutated(bool *mutated, int i)
462-
{
463-
if (i > NUM_VARS) {
464-
return true;
465-
}
466-
return mutated[i];
467-
}
468-
469450
// Initialize warmup counters and optimize instructions. This cannot fail.
470451
void
471452
_PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters)
@@ -482,32 +463,11 @@ _PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters
482463
}
483464
int opcode = 0;
484465
int oparg = 0;
485-
bool mutated[NUM_VARS];
486-
for (int i = 0; i < NUM_VARS; i++) {
487-
mutated[i] = false;
488-
}
489466
/* The last code unit cannot have a cache, so we don't need to check it */
490-
for (Py_ssize_t i = 0; i < size; i++) {
467+
for (Py_ssize_t i = 0; i < size-1; i++) {
491468
opcode = instructions[i].op.code;
492469
int caches = _PyOpcode_Caches[opcode];
493470
oparg = (oparg << 8) | instructions[i].op.arg;
494-
switch (opcode) {
495-
case LOAD_FAST_AND_CLEAR:
496-
case DELETE_FAST:
497-
case MAKE_CELL:
498-
case STORE_FAST:
499-
set_mutated(mutated, oparg);
500-
break;
501-
case STORE_FAST_STORE_FAST:
502-
set_mutated(mutated, oparg >> 4);
503-
set_mutated(mutated, oparg & 15);
504-
break;
505-
case STORE_FAST_LOAD_FAST:
506-
set_mutated(mutated, oparg >> 4);
507-
break;
508-
default:
509-
break;
510-
}
511471
if (caches) {
512472
// The initial value depends on the opcode
513473
switch (opcode) {
@@ -530,34 +490,6 @@ _PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters
530490
oparg = 0;
531491
}
532492
}
533-
534-
/* The last code unit cannot have a cache, so we don't need to check it */
535-
opcode = 0;
536-
oparg = 0;
537-
int eligible = 0;
538-
int total = 0;
539-
for (Py_ssize_t i = 0; i < size; i++) {
540-
opcode = instructions[i].op.code;
541-
oparg = (oparg << 8) | instructions[i].op.arg;
542-
if (opcode == LOAD_FAST) {
543-
total++;
544-
if (!get_mutated(mutated, oparg)) {
545-
instructions[i].op.code = LOAD_FAST_BORROW;
546-
eligible++;
547-
}
548-
}
549-
else if (opcode == LOAD_FAST_LOAD_FAST) {
550-
total++;
551-
if (!get_mutated(mutated, oparg >> 4) && !get_mutated(mutated, oparg & 15)) {
552-
instructions[i].op.code = LOAD_FAST_BORROW_LOAD_FAST_BORROW;
553-
eligible++;
554-
}
555-
}
556-
if (opcode != EXTENDED_ARG) {
557-
oparg = 0;
558-
}
559-
}
560-
// fprintf(stderr, "== LF_SPEC %d %d\n", eligible, total);
561493
#endif /* ENABLE_SPECIALIZATION_FT */
562494
}
563495

0 commit comments

Comments
 (0)