Skip to content

Shape tree C3 codegen remainder: eager shape-id stamping + PIC id compare (#6759/#6798) #6804

Description

@proggeramlug

The runtime half of #6759 Phase C3 landed via #6801 + #6803 (stable process-global shape ids, header stamps in parent_class_id for plain objects, id-keyed FIELD_CACHE, PIC shared-only priming). This issue tracks the codegen remainder, which per the plan (docs/shape-tree-plan.md, "C3-codegen") gets its own design review before landing:

  1. Eager stamping at allocation: codegen knows the literal shape at compile time (the transient shape_id → prebuilt keys_array machinery); stamping parent_class_id at inline allocation makes ids present from birth. This unblocks typed_feedback::object_shape() canonicalizing its observation token on ids — with LAZY stamping, pre-stamp and post-stamp observations of one logical shape produce two tokens per site and read as spurious polymorphism (why perf(runtime): #6759 C3c-r — header-stamped stable shape ids, id-keyed FIELD_CACHE, PIC ABA fix #6803 deliberately left the token on the keys address; see the note in object_shape).
  2. PIC compares the header id: the per-site cache holds (shape_id, slot) and the emitted IR compares the u32 at header offset 8. Needs a discriminated compare: the generic PIC also serves class instances (e.g. the World.commandBuffer case in ic_miss.rs), whose parent_class_id is real inheritance data — the id range (0x8000_0000..0xC000_0000, disjoint from all class ids) makes the discrimination a single range test, but the class-instance arm must keep the keys-pointer compare. ILP32 note: offset-8 u32 loads are fine on arm64_32; do NOT fuse into a 4-aligned i64 load (i64:64 datalayout).
  3. Transition edges shape-resident: fold the transition cache's (prev_keys, key) → (next_keys, slot) edges onto ids once both ends are stamped eagerly.

Acceptance: the #6759 micro table (read/write/define/in/Object.keys ≤1.5× node; babel-class init ≤2× node), measured against the merged #6800#6803 baseline.

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