py/persistentcode: Move loading of rodata/bss to before obj/raw-code.

This makes the loading of viper-code-with-relocations a bit neater and
easier to understand, by treating the rodata/bss like a special object to
be loaded into the constant table (which is how it behaves).
This commit is contained in:
Damien George
2019-12-16 21:53:43 +11:00
parent 04e7aa0563
commit 0bd7d1f7f0
2 changed files with 28 additions and 27 deletions

View File

@@ -765,14 +765,6 @@ class MPYOutput:
self.write_uint(len(s) << 1)
self.write_bytes(s)
def write_obj(self, o):
if o is Ellipsis:
self.write_bytes(b'e')
return
else:
# Other Python types not implemented
assert 0
def write_reloc(self, base, offset, dest, n):
need_offset = not (base == self.prev_base and offset == self.prev_offset + 1)
self.prev_offset = offset + n - 1
@@ -845,17 +837,11 @@ def build_mpy(env, entry_offset, fmpy, native_qstr_vals, native_qstr_objs):
out.write_uint(scope_flags)
# MPY: n_obj
out.write_uint(bool(len(env.full_rodata)) + bool(len(env.full_bss)))
out.write_uint(0)
# MPY: n_raw_code
out.write_uint(0)
# MPY: optional bytes object with rodata
if len(env.full_rodata):
out.write_obj(Ellipsis)
if len(env.full_bss):
out.write_obj(Ellipsis)
# MPY: rodata and/or bss
if len(env.full_rodata):
rodata_const_table_idx = 1