Skip to content

make boxes self-describing #1493

Closed
Closed
@nikomatsakis

Description

Today we have a map that maps from each box allocation to a type descriptor describing its payload. This requires hashtable lookups on malloc/free and seems inefficient. However, to do cycle collection or any form of GC, boxes DO need to be self-describing. Therefore, I propose we layout a box like this:

struct box {
    tydesc *desc;
    int refcnt;
    <payload>
}

This has a few advantages:

  • no more map lookups on alloc, free; also memory consumption is surely lower
  • the desc and refcnt are always at known offsets, regardless of the alignment of payload
  • we can unify the paths for opaque types like closures, objects, and ifaces. They should also begin with a type descriptor.

I think it would be best if the type descriptor describes the entire box (including the desc and refcnt fields). The reason is that this avoids the need to consider the alignment of payload when finding the offset of the data described by the type descriptor.

Metadata

Assignees

Labels

I-slowIssue: Problems and improvements with respect to performance of generated code.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions