Skip to content

Commit 5584fec

Browse files
Reduce restrict use even more, reduce usage
1 parent 66d6c39 commit 5584fec

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

Include/internal/pycore_ceval.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ _PyForIter_VirtualIteratorNext(PyThreadState* tstate, struct _PyInterpreterFrame
391391
#define SPECIAL___AEXIT__ 3
392392
#define SPECIAL_MAX 3
393393

394-
/* Special counterparts of ceval functions for performance reasons */
394+
// Special counterparts of ceval functions for performance reasons
395395
PyAPI_FUNC(int) _PyEval_Mapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **result);
396396

397397
#if defined(_MSC_VER) && !defined(__clang__) && _Py_TAIL_CALL_INTERP
@@ -400,17 +400,18 @@ PyAPI_FUNC(int) _PyEval_Mapping_GetOptionalItem(PyObject *obj, PyObject *key, Py
400400
# define Py_NO_INLINE_MSVC_TAILCALL
401401
#endif
402402

403+
// Tells the compiler that this variable cannot be alised.
403404
#if defined(_MSC_VER) && !defined(__clang__)
404-
# define Py_MSVC_RESTRICT restrict
405+
# define Py_UNALIASED(var) restrict var
405406
#else
406-
# define Py_MSVC_RESTRICT
407+
# define Py_UNALIASED(var) var
407408
#endif
408409

409-
// Just a scope. Hints to the programmer
410+
// Just a scope. Hints to the programmer and compiler
410411
// That any local variable defined within this block MUST
411412
// not escape from the current definition.
412-
# define Py_BEGIN_LOCALS_MUST_NOT_ESCAPE() {
413-
# define Py_END_LOCALS_MUST_NOT_ESCAPE() }
413+
# define Py_BEGIN_LOCALS_MUST_NOT_ESCAPE {
414+
# define Py_END_LOCALS_MUST_NOT_ESCAPE }
414415

415416
#ifdef __cplusplus
416417
}

Objects/abstract.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ PyMapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **result)
225225
}
226226

227227
Py_NO_INLINE_MSVC_TAILCALL int
228-
_PyEval_Mapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **Py_MSVC_RESTRICT result)
228+
_PyEval_Mapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **Py_UNALIASED(result))
229229
{
230230
return PyMapping_GetOptionalItem(obj, key, result);
231231
}

Python/bytecodes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ dummy_func(
22282228
// handle any case whose performance we care about
22292229
PyObject *super;
22302230
Py_BEGIN_LOCALS_MUST_NOT_ESCAPE;
2231-
PyObject *Py_MSVC_RESTRICT stack[] = {class, self};
2231+
PyObject *stack[] = {class, self};
22322232
super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL);
22332233
Py_END_LOCALS_MUST_NOT_ESCAPE;
22342234
if (opcode == INSTRUMENTED_LOAD_SUPER_ATTR) {
@@ -2291,7 +2291,7 @@ dummy_func(
22912291
int method_found = 0;
22922292
PyObject *attr_o;
22932293
Py_BEGIN_LOCALS_MUST_NOT_ESCAPE;
2294-
int *Py_MSVC_RESTRICT method_found_ptr = &method_found;
2294+
int *method_found_ptr = &method_found;
22952295
attr_o = _PySuper_Lookup(cls, self, name,
22962296
Py_TYPE(self)->tp_getattro == PyObject_GenericGetAttr ? method_found_ptr : NULL);
22972297
Py_END_LOCALS_MUST_NOT_ESCAPE;
@@ -3519,7 +3519,7 @@ dummy_func(
35193519
(void)lasti; // Shut up compiler warning if asserts are off
35203520
PyObject* res_o;
35213521
Py_BEGIN_LOCALS_MUST_NOT_ESCAPE;
3522-
PyObject *Py_MSVC_RESTRICT stack[5] = {NULL, PyStackRef_AsPyObjectBorrow(exit_self), exc, val_o, tb};
3522+
PyObject *stack[5] = {NULL, PyStackRef_AsPyObjectBorrow(exit_self), exc, val_o, tb};
35233523
int has_self = !PyStackRef_IsNull(exit_self);
35243524
res_o = PyObject_Vectorcall(exit_func_o, stack + 2 - has_self,
35253525
(3 + has_self) | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);

Python/executor_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)