Commit 8301fa3
committed
typedef: stamp the metatype on builtin type objects built outside the registry
`w_type_new_builtin` allocates with `w_class` null, and the sweep at the end of
`init_typeobjects` fills the slot only for the types held in `TYPEOBJECT_CACHE`.
Four builder families construct builtin type objects that never enter that
registry — `getset_descriptor_type()`, `make_exc_class`, `posix.DirEntry`, and
the `py_class_typed!` / `#[pyre_class]` natives — so those type objects kept a
null `w_class`. `typedef::r#type` falls back to `gettypefor(ob_type)`, so the
null is not visible from Python.
Route the three `w_type_new_builtin` call sites through
`new_builtin_typeobject`, which stamps `w_class = w_type()`, and chain
`GETSET_DESCRIPTOR_TYPE` into the sweep for the one type built before the
`type` typeobject is published.
A hot `Cls.__name__` loop over 37 types read 10 of them at bridges_compiled=7 /
guard_failures=1480 where the registry-resident ones read 0 / 1; after the
change all 37 read 0 / 1. `synth/pypy_type_surface` moves from
bridges_compiled=102 guard_failures=20498 to bridges_compiled=5
guard_failures=1012 against a recorded 5 / 1011, and `pyre/check.py` reports
dynasm 405/405, cranelift 405/405, wasm 401/401.
Assisted-by: Claude1 parent 59d147b commit 8301fa3
1 file changed
Lines changed: 37 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1543 | 1543 | | |
1544 | 1544 | | |
1545 | 1545 | | |
1546 | | - | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
1547 | 1556 | | |
1548 | 1557 | | |
1549 | 1558 | | |
| |||
2219 | 2228 | | |
2220 | 2229 | | |
2221 | 2230 | | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
2222 | 2255 | | |
2223 | 2256 | | |
2224 | 2257 | | |
| |||
2235 | 2268 | | |
2236 | 2269 | | |
2237 | 2270 | | |
2238 | | - | |
| 2271 | + | |
2239 | 2272 | | |
2240 | 2273 | | |
2241 | 2274 | | |
| |||
2307 | 2340 | | |
2308 | 2341 | | |
2309 | 2342 | | |
2310 | | - | |
| 2343 | + | |
2311 | 2344 | | |
2312 | 2345 | | |
2313 | 2346 | | |
| |||
2398 | 2431 | | |
2399 | 2432 | | |
2400 | 2433 | | |
2401 | | - | |
| 2434 | + | |
2402 | 2435 | | |
2403 | 2436 | | |
2404 | 2437 | | |
| |||
0 commit comments