Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Mini-MVP Design #73

Closed
Closed
@RossTate

Description

@RossTate

Here's the Stage 1 design I had in mind for the strategy in #72. I debated making a pull request describing it in more detail, but decided an issue would be better so that we're focusing on high-level aspects rather than syntactic details. This design expects typed function references to already be in place.

First, one specifies a gc-``table'' (in the general sense of the word) whose rows are of the form:

gcidx parent slots array-slots
<int> <gcidx>? <fieldtype>* <fieldtype>+?

This table is valid if, whenever a row has a specified parent, the parent's gcidx is smaller than the row's own index (which is its own gcidx) and the appropriate subtyping/prefixing of the slots and array-slots hold. (A row can have array-slots even if its parent does not.) The gcidx of a row is not explicitly specified but instead corresponds to the row's position in the table.

Second, the grammar of types is extended to include ngcref <gcidx>, which represents a possibly null reference to a gc-structure allocated by this module instance (where gcidx is an ancestor of the value's actual index), and which is only valid if there is a row in the table corresponding to gcidx. Subtyping is extended so that ngcref <gcidx1> is a subtype of ngcref <gcidx2> if gcidx1's parent is gcidx2. The grammar of types is also extended to include nullgcref, which is a subtype of ngcref <gcidx> for all gcidx. (To clarify, these new types are usable within the fieldtype's in the gc-table.)

Third, instructions are extended to include the obvious getters and setters (and indexed getters and setters as well as array length in the case of array-slots), explicitly indexed allocation of ngcrefs, the singleton nullref value, null-checking, and equality comparison. There are also instructions for casting/testing whether a given ngcref <gcidx> value in fact has a more precise runtime index (which must be a descendent of <gcidx>).

I think that's about it. Is it perfect? No. Is it easy to translate to something better when something better comes along? Yes. Does it impose any long-term backwards compatibility constraints besides syntactic support? Not really. Are most gc languages going to be able to compile to this and get reasonable/acceptable/tolerable performance? Running through the many candidates I know, it seems so.

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