This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Adrian Wielgosik, Demur Rumed, mark.dickinson, serhiy.storchaka, vstinner, ztane
Date 2016-05-25.07:01:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464159692.43.0.255007199107.issue27097@psf.upfronthosting.co.za>
In-reply-to
Content
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);
History
Date User Action Args
2016-05-25 07:01:32vstinnersetrecipients: + vstinner, mark.dickinson, serhiy.storchaka, ztane, Demur Rumed, Adrian Wielgosik
2016-05-25 07:01:32vstinnersetmessageid: <1464159692.43.0.255007199107.issue27097@psf.upfronthosting.co.za>
2016-05-25 07:01:32vstinnerlinkissue27097 messages
2016-05-25 07:01:32vstinnercreate