Skip to content

Commit 01f4143

Browse files
committed
Don't pass reason to unspecialize
1 parent e11e0ae commit 01f4143

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

Python/specialize.c

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,82 +1530,85 @@ specialize_load_global_lock_held(
15301530
_PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)(instr + 1);
15311531
assert(PyUnicode_CheckExact(name));
15321532
if (!PyDict_CheckExact(globals)) {
1533-
unspecialize(instr, SPEC_FAIL_LOAD_GLOBAL_NON_DICT);
1534-
return;
1533+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_LOAD_GLOBAL_NON_DICT);
1534+
goto fail;
15351535
}
15361536
PyDictKeysObject * globals_keys = ((PyDictObject *)globals)->ma_keys;
15371537
if (!DK_IS_UNICODE(globals_keys)) {
1538-
unspecialize(instr, SPEC_FAIL_LOAD_GLOBAL_NON_STRING_OR_SPLIT);
1539-
return;
1538+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_LOAD_GLOBAL_NON_STRING_OR_SPLIT);
1539+
goto fail;
15401540
}
15411541
Py_ssize_t index = _PyDictKeys_StringLookup(globals_keys, name);
15421542
if (index == DKIX_ERROR) {
1543-
unspecialize(instr, SPEC_FAIL_EXPECTED_ERROR);
1544-
return;
1543+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_EXPECTED_ERROR);
1544+
goto fail;
15451545
}
15461546
PyInterpreterState *interp = _PyInterpreterState_GET();
15471547
if (index != DKIX_EMPTY) {
15481548
if (index != (uint16_t)index) {
1549-
unspecialize(instr, SPEC_FAIL_OUT_OF_RANGE);
1550-
return;
1549+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_RANGE);
1550+
goto fail;
15511551
}
15521552
uint32_t keys_version = _PyDict_GetKeysVersionForCurrentState(
15531553
interp, (PyDictObject*) globals);
15541554
if (keys_version == 0) {
1555-
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
1556-
return;
1555+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_VERSIONS);
1556+
goto fail;
15571557
}
15581558
if (keys_version != (uint16_t)keys_version) {
1559-
unspecialize(instr, SPEC_FAIL_OUT_OF_RANGE);
1560-
return;
1559+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_RANGE);
1560+
goto fail;
15611561
}
15621562
cache->index = (uint16_t)index;
15631563
cache->module_keys_version = (uint16_t)keys_version;
15641564
specialize(instr, LOAD_GLOBAL_MODULE);
15651565
return;
15661566
}
15671567
if (!PyDict_CheckExact(builtins)) {
1568-
unspecialize(instr, SPEC_FAIL_LOAD_GLOBAL_NON_DICT);
1569-
return;
1568+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_LOAD_GLOBAL_NON_DICT);
1569+
goto fail;
15701570
}
15711571
PyDictKeysObject * builtin_keys = ((PyDictObject *)builtins)->ma_keys;
15721572
if (!DK_IS_UNICODE(builtin_keys)) {
1573-
unspecialize(instr, SPEC_FAIL_LOAD_GLOBAL_NON_STRING_OR_SPLIT);
1574-
return;
1573+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_LOAD_GLOBAL_NON_STRING_OR_SPLIT);
1574+
goto fail;
15751575
}
15761576
index = _PyDictKeys_StringLookup(builtin_keys, name);
15771577
if (index == DKIX_ERROR) {
1578-
unspecialize(instr, SPEC_FAIL_EXPECTED_ERROR);
1579-
return;
1578+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_EXPECTED_ERROR);
1579+
goto fail;
15801580
}
15811581
if (index != (uint16_t)index) {
1582-
unspecialize(instr, SPEC_FAIL_OUT_OF_RANGE);
1583-
return;
1582+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_RANGE);
1583+
goto fail;
15841584
}
15851585
uint32_t globals_version = _PyDict_GetKeysVersionForCurrentState(
15861586
interp, (PyDictObject*) globals);
15871587
if (globals_version == 0) {
1588-
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
1589-
return;
1588+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_VERSIONS);
1589+
goto fail;
15901590
}
15911591
if (globals_version != (uint16_t)globals_version) {
1592-
unspecialize(instr, SPEC_FAIL_OUT_OF_RANGE);
1593-
return;
1592+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_RANGE);
1593+
goto fail;
15941594
}
15951595
uint32_t builtins_version = _PyDict_GetKeysVersionForCurrentState(
15961596
interp, (PyDictObject*) builtins);
15971597
if (builtins_version == 0) {
1598-
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
1599-
return;
1598+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_VERSIONS);
1599+
goto fail;
16001600
}
16011601
if (builtins_version > UINT16_MAX) {
1602-
unspecialize(instr, SPEC_FAIL_OUT_OF_RANGE);
1603-
return;
1602+
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_OUT_OF_RANGE);
1603+
goto fail;
16041604
}
16051605
cache->index = (uint16_t)index;
16061606
cache->module_keys_version = (uint16_t)globals_version;
16071607
cache->builtin_keys_version = (uint16_t)builtins_version;
16081608
specialize(instr, LOAD_GLOBAL_BUILTIN);
1609+
return;
1610+
fail:
1611+
unspecialize(instr);
16091612
}
16101613

16111614
void

0 commit comments

Comments
 (0)