8000 Introduce abstraction (like pointer indirection) for memory read/write? · Issue #4140 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content
Introduce abstraction (like pointer indirection) for memory read/write? #4140
Closed
@adritium

Description

@adritium

Memory read/write abstraction - pointer indirection - has been mentioned as a possible route #1168 to implement precise garbage collector but I think introducing such a thing has additional uses.

Remember that micropython is often run on bare-metal (cc @peterhinch ) and we're using C to implement it so we don't have the nifty tricks of operator overloading of C++ (sigh) i.e. we cannot redefine the * dereferencing operator.

Executing from flash

In #4124 I inquire of the possibility of running a .mpy from flash and @dpgeorge answers with a straightforward solution. However there is a large constraint:

The other big issue to solve would be making sure that .mpy's live in a location that is 1) memory mapped to the CPU; 2) contiguous.

If we had indirection, the code wouldn't have to be contiguous because the VM code's reading of the opcodes - switch (*ip++) - would be replaced with switch(GET(ip)) (or something).

Once you can execute from ANY flash location you can save the mp_raw_code_t to flash after you import.

RAM! (my precious)

Everyone wants to save RAM by any tricks in .py code but parsing and compilation are a huge low-ish hanging fruit. We could save the parse-tree and other artifacts in flash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0