STINNER Victor added the comment:

Demur: "This patch [ ushort.patch ] seeks to be a minimal change to achieve the 
desired aligned/batched memory read behavior of NEXTOP/NEXTARG."

We are concerned by undefined behaviours in CPython for portability reasons. 
Using a "unsigned short*" pointer avoids the undefined behaviour.

I'm talking about unsigned char* => unsigned short* conversion followed by a 
dereference:

+#define NEXTOPARG()     (oparg = *(unsigned short*)next_instr, opcode = 
OPOF(oparg), oparg = ARGOF(oparg), next_instr += 2)

With ushort2.patch, the risk is reduced at once place which is now "protected" 
by an assertion:

+    assert(_Py_IS_ALIGNED(PyBytes_AS_STRING(co->co_code), unsigned short));
+    first_instr = (unsigned short*) PyBytes_AS_STRING(co->co_code);

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27097>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to