Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d4a734e

Browse files
committedSep 5, 2024·
Bytecode DSL interpreter migration
1 parent 5bfb7f9 commit d4a734e

File tree

92 files changed

+12229
-1115
lines changed

Some content is hidden

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

92 files changed

+12229
-1115
lines changed
 

‎ci.jsonnet

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "97e6428bf1021ee69147c0229bb5f7808c3a0430" }
1+
{ "overlay": "d3a703a390f4a053de7253588661f5c87306275f" }

‎graalpython/com.oracle.graal.python.frozen/freeze_modules.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def relpath_for_posix_display(path, base):
154154
#######################################
155155
# specs
156156

157-
def parse_frozen_specs():
157+
def parse_frozen_specs(suffix):
158158
seen = {}
159159
for section, specs in FROZEN:
160160
parsed = _parse_specs(specs, section, seen)
@@ -163,7 +163,7 @@ def parse_frozen_specs():
163163
try:
164164
source = seen[frozenid]
165165
except KeyError:
166-
source = FrozenSource.from_id(frozenid, pyfile)
166+
source = FrozenSource.from_id(frozenid, suffix, pyfile)
167167
seen[frozenid] = source
168168
else:
169169
assert not pyfile or pyfile == source.pyfile, item
@@ -271,11 +271,11 @@ def iter_subs():
271271
class FrozenSource(namedtuple('FrozenSource', 'id pyfile frozenfile deepfreezefile')):
272272

273273
@classmethod
274-
def from_id(cls, frozenid, pyfile=None):
274+
def from_id(cls, frozenid, suffix, pyfile=None):
275275
if not pyfile:
276276
pyfile = os.path.join(STDLIB_DIR, *frozenid.split('.')) + '.py'
277277
#assert os.path.exists(pyfile), (frozenid, pyfile)
278-
frozenfile = resolve_frozen_file(frozenid, FROZEN_MODULES_DIR)
278+
frozenfile = resolve_frozen_file(frozenid, FROZEN_MODULES_DIR, suffix)
279279
return cls(frozenid, pyfile, frozenfile, STDLIB_DIR)
280280

281281
@classmethod
@@ -311,7 +311,7 @@ def isbootstrap(self):
311311
return self.id in BOOTSTRAP
312312

313313

314-
def resolve_frozen_file(frozenid, destdir):
314+
def resolve_frozen_file(frozenid, destdir, suffix):
315315
"""Return the filename corresponding to the given frozen ID.
316316
317317
For stdlib modules the ID will always be the full name
@@ -324,7 +324,7 @@ def resolve_frozen_file(frozenid, destdir):
324324
raise ValueError(f'unsupported frozenid {frozenid!r}')
325325
# We use a consistent naming convention for all frozen modules.
326326
frozen_symbol = FrozenSource.resolve_symbol(frozenid)
327-
frozenfile = f"Frozen{frozen_symbol}.bin"
327+
frozenfile = f"Frozen{frozen_symbol}.{suffix}"
328328

329329
if not destdir:
330330
return frozenfile
@@ -634,11 +634,17 @@ def main():
634634
STDLIB_DIR = os.path.abspath(parsed_args.python_lib)
635635
FROZEN_MODULES_DIR = os.path.abspath(parsed_args.binary_dir)
636636

637+
if __graalpython__.is_bytecode_dsl_interpreter:
638+
suffix = "bin_dsl"
639+
assert os.path.isdir(parsed_args.binary_dir), "Frozen modules for the DSL should be built after the manual bytecode interpreter."
640+
else:
641+
suffix = "bin"
642+
shutil.rmtree(parsed_args.binary_dir, ignore_errors=True)
643+
os.makedirs(parsed_args.binary_dir)
644+
637645
# create module specs
638-
modules = list(parse_frozen_specs())
646+
modules = list(parse_frozen_specs(suffix))
639647

640-
shutil.rmtree(parsed_args.binary_dir, ignore_errors=True)
641-
os.makedirs(parsed_args.binary_dir)
642648
# write frozen module binary files containing the byte code and class files
643649
# used for importing the binary files
644650
for src in _iter_sources(modules):

0 commit comments

Comments
 (0)