Skip to content

Verify the junk dispatch slot and record why it stays - #1247

Open
Frotty wants to merge 1 commit into
masterfrom
fix/junk-dispatch-slot
Open

Verify the junk dispatch slot and record why it stays#1247
Frotty wants to merge 1 commit into
masterfrom
fix/junk-dispatch-slot

Conversation

@Frotty

Copy link
Copy Markdown
Member

Backlog only — no behaviour change. Item 15 said a specialised class carries one dead dispatch slot and that fixing it risks more than it saves. Both halves are now verified rather than assumed, and the second turned out to be more true than the note knew.

It is dead

In the Lua for FastHashMap<int, int>:

FastHashMap_specialized_integer__integer.FastHashMap_specialized_integer__integer_integer
= FastHashMap_get_specialized

Assigned once, bound to the alphabetically first method, never called — the only method calls in that script are :create( and :create1(. The name is the owner's plus the segment after the last underscore of the method's, and for a specialised method that segment is the type argument, so every method of the class composes the same name.

Suppressing it in one composer is not enough

I changed addDirectAliases to drop a composed name which more than one method of the same class produces, on the grounds that a name meaning "one of these, arbitrarily" is worse than a name meaning nothing. All Lua dispatch, FastHashMap and type class tests passed — and the slot was still emitted.

LuaTranslator.collectDispatchSlotNames composes it independently, from the cross product of the class names in the hierarchy and the semantic names of the method group. It is called per group of same-named methods, so it cannot see that a sibling group composes the same name without class-level knowledge it is not given.

So a real fix needs a shared notion of ambiguity across both composers. That is the coordinated change the note weighed against the benefit, and the benefit is still one unused table key per specialised class. Reverted.

What a fix would need

Recorded in the item, together with the earlier attempt: using the declared name instead collapses overloads, which two existing tests exist to prevent. Both sources of a semantic name are wrong in opposite directions — the mangled trailing segment collides across the siblings of one specialisation, the declared name across overloads — so the name has to separate both, in both composers. The declared name together with the dispatch signature key would.

Confirmed dead: in the Lua for FastHashMap<int, int> the slot is assigned once,
bound to the alphabetically first method, and never called - the only method
calls in that script are the two constructors.
Confirmed harder to remove than the note implied. addDirectAliases was changed
to drop a composed name which more than one method of the class produces, on
the grounds that a name meaning one of these arbitrarily is worse than a name
meaning nothing, and the slot was still emitted: collectDispatchSlotNames
composes it independently from the cross product of hierarchy class names and
the group's semantic names, and being called per group it cannot see the
sibling collision without class-level knowledge it is not given.
So a fix needs a shared notion of ambiguity across both composers, which is the
coordinated change the note weighed against the benefit, and the benefit is
still one unused table key per specialised class. Reverted, and the item now
carries what was verified rather than what was assumed.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Frotty