Commit Graph

9059 Commits

Author SHA1 Message Date
Mark Shannon 81c739e2dc
GH-120024: Tidy up case generator code a bit. (GH-122780) 2024-08-08 10:57:59 +01:00
Tian Gao 57d7c3e78f
gh-122247: Move instruction instrumentation sanity check after tracing check (#122251) 2024-08-07 21:30:14 -07:00
Serhiy Storchaka 540fcc62f5
gh-118814: Fix the TypeVar constructor when name is passed by keyword (GH-122664)
Fix _PyArg_UnpackKeywordsWithVararg for the case when argument for
positional-or-keyword parameter is passed by keyword.
There was only one such case in the stdlib -- the TypeVar constructor.
2024-08-07 23:30:10 +03:00
Sam Gross 3e753c689a
gh-118926: Spill deferred references to stack in cases generator (#122748)
This automatically spills the results from `_PyStackRef_FromPyObjectNew`
to the in-memory stack so that the deferred references are visible to
the GC before we make any possibly escaping call.

Co-authored-by: Ken Jin <kenjin@python.org>
2024-08-07 13:23:53 -04:00
sobolevn 61a8bf2853
gh-122759: Remove `assert` from `RERAISE` error handling (#122760) 2024-08-07 17:25:25 +03:00
Sam Gross 674a50ef2f
gh-117139: Fix an incorrect borrow in bytecodes.c (#122318)
`_PyDict_SetItem_Take2` steals both the key (i.e., `sub`) and the value.
2024-08-07 19:06:19 +05:30
Victor Stinner 4767a6e31c
gh-122728: Fix SystemError in PyEval_GetLocals() (#122735)
Fix PyEval_GetLocals() to avoid SystemError ("bad argument to
internal function"). Don't redefine the 'ret' variable in the if
block.

Add an unit test on PyEval_GetLocals().
2024-08-06 23:01:44 +02:00
Sam Gross dc09301067
gh-122417: Implement per-thread heap type refcounts (#122418)
The free-threaded build partially stores heap type reference counts in
distributed manner in per-thread arrays. This avoids reference count
contention when creating or destroying instances.

Co-authored-by: Ken Jin <kenjin@python.org>
2024-08-06 14:36:57 -04:00
Mark Shannon 4c31791848
GH-120024: Move three more escaping calls out of conditional statements (GH-122734) 2024-08-06 14:14:52 +01:00
Mark Shannon a8be8fc6c4
GH-120024: Refactor code a bit so that escaping calls can be wrapped in spill code in code generator (GH-122693) 2024-08-06 08:40:39 +01:00
Serhiy Storchaka e74680b718
gh-122595: Add more error checks in the compiler (GH-122596) 2024-08-06 08:59:44 +03:00
Mark Shannon 5bd72912a1
GH-122616: Simplify LOAD_ATTR_WITH_HINT and STORE_ATTR_WITH_HINT (GH-122620) 2024-08-05 16:27:48 +01:00
Serhiy Storchaka efcd65cd84
gh-122313: Clean up deep recursion guarding code in the compiler (GH-122640)
Add ENTER_RECURSIVE and LEAVE_RECURSIVE macros in ast.c, ast_opt.c and
symtable.c. Remove VISIT_QUIT macro in symtable.c.

The current recursion depth counter only needs to be updated during
normal execution -- all functions should just return an error code
if an error occurs.
2024-08-03 12:45:45 +03:00
Mark Shannon 7aca84e557
GH-117224: Move the body of a few large-ish micro-ops into helper functions (GH-122601) 2024-08-02 16:31:17 +01:00
Irit Katriel 498376d7a7
gh-122445: populate only modified fields in __static_attributes__ (#122446) 2024-08-02 15:40:42 +01:00
neonene 9fc1c992d6
gh-122334: Fix crash when importing ssl after re-initialization (#122481)
* Fix crash when importing ssl after re-initialization
2024-08-02 19:06:20 +05:30
Serhiy Storchaka 03b88522f5
gh-122188: Remove _imp.pyc_magic_number (GH-122503)
_imp.pyc_magic_number_token should be enough.
2024-08-02 13:12:19 +03:00
Jelle Zijlstra 8234419c32
gh-122562: Remove ste_free and ste_child_free from symtable (#122563) 2024-08-01 16:28:25 -07:00
Mark Shannon df13a1821a
GH-118095: Add tier two support for BINARY_SUBSCR_GETITEM (GH-120793) 2024-08-01 16:19:05 -07:00
Victor Stinner fda6bd842a
Replace PyObject_Del with PyObject_Free (#122453)
PyObject_Del() is just a alias to PyObject_Free() kept for backward
compatibility. Use directly PyObject_Free() instead.
2024-08-01 14:12:33 +02:00
Mark Shannon a9d56e38a0
GH-122155: Track local variables between pops and pushes in cases generator (GH-122286) 2024-08-01 09:27:26 +01:00
jianghuyiyuan 46f5a4f9e1
Fix typos in docs, error messages and comments (#122502)
Signed-off-by: jianghuyiyuan <shuangcui@live.com>
2024-08-01 00:26:09 +00:00
Michael Droettboom af0a00f022
gh-122188: Move magic number to its own file (#122243)
* gh-122188: Move magic number to its own file

* Add versionadded directive

* Do work in C

* Integrate launcher.c

* Make _pyc_magic_number private

* Remove metadata

* Move sys.implementation -> _imp

* Modernize comment

* Move _RAW_MAGIC_NUMBER to the C side as well

* _pyc_magic_number -> pyc_magic_number

* Remove unused import

* Update docs

* Apply suggestions from code review

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>

* Fix typo in tests

---------

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-07-30 15:31:05 -04:00
Sam Gross 2b163aa9e7
gh-117657: Avoid race in `PAUSE_ADAPTIVE_COUNTER` in free-threaded build (#122190)
The adaptive counter doesn't do anything currently in the free-threaded
build and TSan reports a data race due to concurrent modifications to
the counter.
2024-07-30 13:53:47 -04:00
Brandt Bucher 7797182b78
GH-118093: Improve handling of short and mid-loop traces (GH-122252) 2024-07-29 14:49:17 -07:00
Brandt Bucher 15d4cd0967
GH-116090: Fire RAISE events from _FOR_ITER_TIER_TWO (GH-122413) 2024-07-29 12:17:47 -07:00
Petr Viktorin 89fa05fdce
gh-122234: Add DECREFs to error paths (#122406)
Co-Authored-By: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-07-29 16:10:25 +00:00
Sergey B Kirpichev 169e7138ab
gh-122234: fix accuracy issues for sum() (#122236)
* Use compensated summation for complex sums with floating-point items.
  This amends #121176.

* sum() specializations for floats and complexes now use
  PyLong_AsDouble() instead of PyLong_AsLongAndOverflow() and
  compensated summation as well.
2024-07-29 05:56:40 +02:00
Jelle Zijlstra ae192262ad
gh-119180: Add evaluate functions for type params and type aliases (#122212) 2024-07-27 17:24:10 +00:00
Mark Shannon 1ca99ed240
Manually override bytecode definition in optimizer, to avoid build error (GH-122316) 2024-07-26 18:38:52 +01:00
Sam Gross c557ae97d6
gh-122201: Lock mutex when setting handling_thread to NULL (#122204)
In the free-threaded build, we need to lock pending->mutex when clearing
the handling_thread in order not to race with a concurrent
make_pending_calls in the same interpreter.
2024-07-26 13:06:07 -04:00
Brandt Bucher 64857d849f
GH-122294: Burn in the addresses of side exits (GH-122295) 2024-07-26 09:40:15 -07:00
Irit Katriel bc94cf7e25
gh-122245: move checks for writes and shadowing of __debug__ to symtable (#122246) 2024-07-26 14:39:56 +01:00
Mark Shannon 95a73917cd
GH-122029: Break INSTRUMENTED_CALL into micro-ops, so that its behavior is consistent with CALL (GH-122177) 2024-07-26 14:35:57 +01:00
Mark Shannon afb0aa6ed2
GH-121131: Clean up and fix some instrumented instructions. (GH-121132)
* Add support for 'prev_instr' to code generator and refactor some INSTRUMENTED instructions
2024-07-26 12:24:12 +01:00
Brandt Bucher d9efa45d74
GH-118093: Add tier two support for BINARY_OP_INPLACE_ADD_UNICODE (GH-122253) 2024-07-25 14:45:07 -07:00
Brandt Bucher 5f6001130f
GH-118093: Add tier two support for LOAD_ATTR_PROPERTY (GH-122283) 2024-07-25 10:45:28 -07:00
Mark Shannon 5e686ff57d
GH-122034: Add StackRef variants of type checks to reduce the number of PyStackRef_AsPyObjectBorrow calls (GH-122037) 2024-07-25 18:32:43 +01:00
Mark Shannon 2e14a52cce
GH-122160: Remove BUILD_CONST_KEY_MAP opcode. (GH-122164) 2024-07-25 16:24:29 +01:00
Irit Katriel 9ac606080a
gh-121404: extract compiler_lookup_arg out of compiler_make_closure (#122181) 2024-07-24 17:22:18 +01:00
Brandt Bucher 794546fd53
GH-118093: Remove invalidated executors from side exits (GH-121885) 2024-07-24 09:16:30 -07:00
Tian Gao e91ef13861
gh-122029: Log call events in sys.setprofile when it's a method with c function (GH-122072)
Log call events in sys.setprofile when it is a method with a C function.
2024-07-23 15:25:26 -07:00
Jelle Zijlstra 7b7b90d1ce
gh-119180: Add `annotationlib` module to support PEP 649 (#119891)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-07-23 21:16:50 +00:00
Jelle Zijlstra 2762c6cc5e
gh-121637: Syntax error for optimized-away incorrect await (#121656)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-07-22 14:12:43 -07:00
Irit Katriel d5a12b4440
gh-121404: move calculation of module start location from compiler_body up to compiler_codegen (#122127) 2024-07-22 17:48:30 +01:00
Sam Gross 5716cc3529
gh-100240: Use a consistent implementation for freelists (#121934)
This combines and updates our freelist handling to use a consistent
implementation. Objects in the freelist are linked together using the
first word of memory block.

If configured with freelists disabled, these operations are essentially
no-ops.
2024-07-22 12:08:27 -04:00
mpage e059aa6b01
gh-120973: Fix thread-safety issues with `threading.local` (#121655)
This is a small refactoring to the current design that allows us to
avoid manually iterating over threads.

This should also fix gh-118490.
2024-07-19 13:22:02 -04:00
Serhiy Storchaka 1a0c7b9ba4
gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) 2024-07-19 08:06:02 +00:00
Brandt Bucher 7b36b67b1e
GH-118093: Add tier two support to several instructions (GH-121884) 2024-07-18 14:24:58 -07:00
Mark Shannon 3eacfc1a4d
GH-121784: Generate an error during code gen if a variable is marked `unused`, but is used and thus cached in a prior uop. (#121788)
* Reject uop definitions that declare values as 'unused' that are already cached by prior uops

* Track which variables are defined and only load from memory when needed

* Support explicit `flush` in macro definitions. 

* Make sure stack is flushed in where needed.
2024-07-18 12:49:24 +01:00