Skip to content

Commit 20fde38

Browse files
authored
Merge pull request #175 from facebookincubator/fixup-T271478273-meta/main
Re-sync with internal repository
2 parents 494f2e3 + 3a9d845 commit 20fde38

127 files changed

Lines changed: 52159 additions & 51995 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- 'main'
7+
- 'meta/main'
88
- '3.*'
99
pull_request:
1010
branches:

Include/internal/pycore_gc.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,55 @@ extern void _PyGC_VisitObjectsWorldStopped(PyInterpreterState *interp,
344344
gcvisitobjects_t callback, void *arg);
345345
#endif
346346

347+
struct _Ci_PyGCImpl;
348+
349+
/*
350+
* Collect cyclic garbage.
351+
*
352+
* impl - Pointer to the collection implementation.
353+
* tstate - Indirectly specifies (via tstate->interp) the interpreter
354+
for which collection should be performed.
355+
* generation - Collect generations <= this value
356+
* reason - Why we're collecting
357+
*/
358+
typedef Py_ssize_t (*Ci_gc_collect_t)(struct _Ci_PyGCImpl *impl, PyThreadState* tstate,
359+
int generation, _PyGC_Reason reason);
360+
361+
// Free a collector
362+
typedef void (*Ci_gc_finalize_t)(struct _Ci_PyGCImpl *impl);
363+
364+
// An implementation of cyclic garbage collection
365+
typedef struct _Ci_PyGCImpl {
366+
Ci_gc_collect_t collect;
367+
Ci_gc_finalize_t finalize;
368+
} _Ci_PyGCImpl;
369+
370+
struct _gc_runtime_state;
371+
372+
/*
373+
* Set the collection implementation.
374+
*
375+
* The callee takes ownership of impl.
376+
*
377+
* Returns a pointer to the previous impl, which the caller is responsible for freeing
378+
* using the returned impl's finalize().
379+
*/
380+
PyAPI_FUNC(_Ci_PyGCImpl *) _Ci_PyGC_SetImpl(struct _gc_runtime_state *gc_state, _Ci_PyGCImpl *impl);
381+
382+
/*
383+
* Returns a pointer to the current GC implementation but does not transfer
384+
* ownership to the caller.
385+
*/
386+
PyAPI_FUNC(_Ci_PyGCImpl *) _Ci_PyGC_GetImpl(struct _gc_runtime_state *gc_state);
387+
388+
/*
389+
* Clear free lists (e.g. frames, tuples, etc.) for the given interpreter.
390+
*
391+
* This should be called by GC implementations after collecting the highest
392+
* generation.
393+
*/
394+
PyAPI_FUNC(void) _Ci_PyGC_ClearFreeLists(PyInterpreterState* interp);
395+
347396
#ifdef __cplusplus
348397
}
349398
#endif

Include/internal/pycore_pystate.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ _Py_ThreadCanHandleSignals(PyInterpreterState *interp)
9090
and interpreter state */
9191

9292
#if !defined(Py_BUILD_CORE_MODULE)
93+
# if defined(Py_ENABLE_SHARED) && _Py__has_attribute(tls_model)
94+
__attribute__((tls_model("initial-exec")))
95+
# endif
9396
extern _Py_thread_local PyThreadState *_Py_tss_tstate;
97+
# if defined(Py_ENABLE_SHARED) && _Py__has_attribute(tls_model)
98+
__attribute__((tls_model("initial-exec")))
99+
# endif
94100
extern _Py_thread_local PyInterpreterState *_Py_tss_interp;
95101
#endif
96102

Include/patchlevel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define PY_RELEASE_SERIAL 0
2828

2929
/* Version as a string */
30-
#define PY_VERSION "3.16.0a0"
30+
#define PY_VERSION "3.16.0a0+meta"
3131
/*--end constants--*/
3232

3333

Include/pystate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
119119
*/
120120
PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
121121

122+
// Sets the thread state for multi-threaded GC
123+
PyAPI_FUNC(void) Ci_SetTStateForGC(PyThreadState *tstate);
122124

123125
/* PEP 788 -- Protection against interpreter finalization */
124126

Lib/site.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,15 @@ def main():
10811081
sethelper()
10821082
if not sys.flags.isolated:
10831083
enablerlcompleter()
1084+
# If we've been built with CinderX support there will be an init_cinderx.py
1085+
# included in the default module search path. In this case we import it
1086+
# which will have the side-effect of initializing CinderX. If this module
1087+
# is missing then we weren't build with CinderX so ignoring the import
1088+
# error is fine.
1089+
try:
1090+
import init_cinderx
1091+
except ImportError:
1092+
pass
10841093
execsitecustomize()
10851094
if ENABLE_USER_SITE:
10861095
execusercustomize()

0 commit comments

Comments
 (0)