Skip to content

Support classes that operate like structs/value-types on the stack #2254

@leighmcculloch

Description

@leighmcculloch

Something that would be useful for some applications of wasm modules is to be able to define structured types that are stored on the stack.

This is also useful in cases when it is desirable to avoid use of the heap/linear-memory, but code structure would benefit from storing multiple values inside a structure together, like a class.

This could be a decorator, similar to @unmanaged. It's worth noting that @unmanaged gets us part-way in that the memory the type uses on the heap is smaller and doesn't have the GC header.

It might look like this.

@stack
class Config {
  constructor(public field: u64) { }
}

I imagine there are a few terms that would suit, such as:

  • @stack
  • @struct
  • @valueType

Related to #2253

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions