aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Tools
diff options
context:
space:
mode:
Diffstat (limited to 'Tools')
-rw-r--r--Tools/cases_generator/analyzer.py2
-rw-r--r--Tools/cases_generator/opcode_metadata_generator.py7
-rw-r--r--Tools/jit/_targets.py16
-rw-r--r--Tools/jit/build.py21
-rw-r--r--Tools/msi/dev/dev_files.wxs2
-rw-r--r--Tools/peg_generator/pegen/build.py2
6 files changed, 36 insertions, 14 deletions
diff --git a/Tools/cases_generator/analyzer.py b/Tools/cases_generator/analyzer.py
index 2b3a90c7db9..825c72eaa16 100644
--- a/Tools/cases_generator/analyzer.py
+++ b/Tools/cases_generator/analyzer.py
@@ -585,7 +585,7 @@ NON_ESCAPING_FUNCTIONS = (
"PyStackRef_CLOSE_SPECIALIZED",
"PyStackRef_DUP",
"PyStackRef_False",
- "PyStackRef_FromPyObjectImmortal",
+ "PyStackRef_FromPyObjectBorrow",
"PyStackRef_FromPyObjectNew",
"PyStackRef_FromPyObjectSteal",
"PyStackRef_IsExactly",
diff --git a/Tools/cases_generator/opcode_metadata_generator.py b/Tools/cases_generator/opcode_metadata_generator.py
index 620e4b6f1f4..10567204dcc 100644
--- a/Tools/cases_generator/opcode_metadata_generator.py
+++ b/Tools/cases_generator/opcode_metadata_generator.py
@@ -157,6 +157,13 @@ def generate_deopt_table(analysis: Analysis, out: CWriter) -> None:
if inst.family is not None:
deopt = inst.family.name
deopts.append((inst.name, deopt))
+ defined = set(analysis.opmap.values())
+ for i in range(256):
+ if i not in defined:
+ deopts.append((f'{i}', f'{i}'))
+
+ assert len(deopts) == 256
+ assert len(set(x[0] for x in deopts)) == 256
for name, deopt in sorted(deopts):
out.emit(f"[{name}] = {deopt},\n")
out.emit("};\n\n")
diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py
index 6ceb4404e74..d0a1c081ffe 100644
--- a/Tools/jit/_targets.py
+++ b/Tools/jit/_targets.py
@@ -47,6 +47,7 @@ class _Target(typing.Generic[_S, _R]):
debug: bool = False
verbose: bool = False
known_symbols: dict[str, int] = dataclasses.field(default_factory=dict)
+ pyconfig_dir: pathlib.Path = pathlib.Path.cwd().resolve()
def _get_nop(self) -> bytes:
if re.fullmatch(r"aarch64-.*", self.triple):
@@ -57,13 +58,13 @@ class _Target(typing.Generic[_S, _R]):
raise ValueError(f"NOP not defined for {self.triple}")
return nop
- def _compute_digest(self, out: pathlib.Path) -> str:
+ def _compute_digest(self) -> str:
hasher = hashlib.sha256()
hasher.update(self.triple.encode())
hasher.update(self.debug.to_bytes())
# These dependencies are also reflected in _JITSources in regen.targets:
hasher.update(PYTHON_EXECUTOR_CASES_C_H.read_bytes())
- hasher.update((out / "pyconfig.h").read_bytes())
+ hasher.update((self.pyconfig_dir / "pyconfig.h").read_bytes())
for dirpath, _, filenames in sorted(os.walk(TOOLS_JIT)):
for filename in filenames:
hasher.update(pathlib.Path(dirpath, filename).read_bytes())
@@ -125,7 +126,7 @@ class _Target(typing.Generic[_S, _R]):
f"-D_JIT_OPCODE={opname}",
"-D_PyJIT_ACTIVE",
"-D_Py_JIT",
- "-I.",
+ f"-I{self.pyconfig_dir}",
f"-I{CPYTHON / 'Include'}",
f"-I{CPYTHON / 'Include' / 'internal'}",
f"-I{CPYTHON / 'Include' / 'internal' / 'mimalloc'}",
@@ -193,20 +194,19 @@ class _Target(typing.Generic[_S, _R]):
def build(
self,
- out: pathlib.Path,
*,
comment: str = "",
force: bool = False,
- stencils_h: str = "jit_stencils.h",
+ jit_stencils: pathlib.Path,
) -> None:
"""Build jit_stencils.h in the given directory."""
+ jit_stencils.parent.mkdir(parents=True, exist_ok=True)
if not self.stable:
warning = f"JIT support for {self.triple} is still experimental!"
request = "Please report any issues you encounter.".center(len(warning))
outline = "=" * len(warning)
print("\n".join(["", outline, warning, request, outline, ""]))
- digest = f"// {self._compute_digest(out)}\n"
- jit_stencils = out / stencils_h
+ digest = f"// {self._compute_digest()}\n"
if (
not force
and jit_stencils.exists()
@@ -214,7 +214,7 @@ class _Target(typing.Generic[_S, _R]):
):
return
stencil_groups = ASYNCIO_RUNNER.run(self._build_stencils())
- jit_stencils_new = out / "jit_stencils.h.new"
+ jit_stencils_new = jit_stencils.parent / "jit_stencils.h.new"
try:
with jit_stencils_new.open("w") as file:
file.write(digest)
diff --git a/Tools/jit/build.py b/Tools/jit/build.py
index 49b08f477db..1afd0c76bad 100644
--- a/Tools/jit/build.py
+++ b/Tools/jit/build.py
@@ -8,7 +8,6 @@ import sys
import _targets
if __name__ == "__main__":
- out = pathlib.Path.cwd().resolve()
comment = f"$ {shlex.join([pathlib.Path(sys.executable).name] + sys.argv)}"
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
@@ -24,6 +23,20 @@ if __name__ == "__main__":
"-f", "--force", action="store_true", help="force the entire JIT to be rebuilt"
)
parser.add_argument(
+ "-o",
+ "--output-dir",
+ help="where to output generated files",
+ required=True,
+ type=lambda p: pathlib.Path(p).resolve(),
+ )
+ parser.add_argument(
+ "-p",
+ "--pyconfig-dir",
+ help="where to find pyconfig.h",
+ required=True,
+ type=lambda p: pathlib.Path(p).resolve(),
+ )
+ parser.add_argument(
"-v", "--verbose", action="store_true", help="echo commands as they are run"
)
args = parser.parse_args()
@@ -31,13 +44,13 @@ if __name__ == "__main__":
target.debug = args.debug
target.force = args.force
target.verbose = args.verbose
+ target.pyconfig_dir = args.pyconfig_dir
target.build(
- out,
comment=comment,
- stencils_h=f"jit_stencils-{target.triple}.h",
force=args.force,
+ jit_stencils=args.output_dir / f"jit_stencils-{target.triple}.h",
)
- jit_stencils_h = out / "jit_stencils.h"
+ jit_stencils_h = args.output_dir / "jit_stencils.h"
lines = [f"// {comment}\n"]
guard = "#if"
for target in args.target:
diff --git a/Tools/msi/dev/dev_files.wxs b/Tools/msi/dev/dev_files.wxs
index 4357dc86d9d..21f9c848cc6 100644
--- a/Tools/msi/dev/dev_files.wxs
+++ b/Tools/msi/dev/dev_files.wxs
@@ -3,7 +3,7 @@
<Fragment>
<ComponentGroup Id="dev_pyconfig">
<Component Id="include_pyconfig.h" Directory="include" Guid="*">
- <File Id="include_pyconfig.h" Name="pyconfig.h" Source="pyconfig.h" KeyPath="yes" />
+ <File Id="include_pyconfig.h" Name="pyconfig.h" Source="!(bindpath.src)PC\pyconfig.h" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
diff --git a/Tools/peg_generator/pegen/build.py b/Tools/peg_generator/pegen/build.py
index 41338c29bdd..be289c352de 100644
--- a/Tools/peg_generator/pegen/build.py
+++ b/Tools/peg_generator/pegen/build.py
@@ -108,6 +108,8 @@ def compile_c_extension(
extra_compile_args.append("-DPy_BUILD_CORE_MODULE")
# Define _Py_TEST_PEGEN to not call PyAST_Validate() in Parser/pegen.c
extra_compile_args.append("-D_Py_TEST_PEGEN")
+ if sys.platform == "win32" and sysconfig.get_config_var("Py_GIL_DISABLED"):
+ extra_compile_args.append("-DPy_GIL_DISABLED")
extra_link_args = get_extra_flags("LDFLAGS", "PY_LDFLAGS_NODIST")
if keep_asserts:
extra_compile_args.append("-UNDEBUG")