Repository navigation
Commit 0060e21
committed
feat(runtime): plain canaries keep their JS properties in the state only
Under the canary wrapper lifetime mode with scope "all", wrappers of
plain (not JS-extended) objects now carry a non-masking forwarding
handler set (getter, setter, query, deleter, enumerator, definer and
descriptor) instead of the masking mirror. Their JS properties live in
the object's state object only, so a new wrapper for the object needs no
copy, and native calls and native property stores never reach the
handler. JS-extended instances keep the masking mirror, and
allowShadowingNativeMembers keeps plain wrappers on it too.
Names the prototype chain has never reach a non-masking handler: an
instance assignment or Object.defineProperty over an inherited data
property (a native method, toString, valueOf, constructor, a member JS
added to a prototype) stays on that wrapper and is gone with it, deleting
such a name deletes nothing, and a state property whose name the chain
gains later is hidden. A state accessor reached through another receiver
(a Proxy, Reflect with a receiver, an inheriting object) runs with the
wrapper as `this` and its setter is skipped. These are documented
limitations.
The setter honours read-only properties and getter-only accessors in the
state, which v8::Object::Set would report as written. A record that dies
under a live forwarding canary (objc_removeAssociatedObjects) keeps its
state while the canary holds it, the leak probe still sees it, and the
canary's next write moves the state object, weak-collection key included,
into a new record; it is let go once the canary is collected or released.
A released forwarding canary gets the state's properties, accessors and
attributes included, copied onto it.
Release simulator build, plain NSObject, forwarding vs masking: expando
read 64 vs 19 ns, miss 47 vs 20, `in` 111 vs 21, expando rewrite 81 vs
105, first write 544 vs 676, UIView tag store 112 vs 219, rebuilding a
wrapper with five properties 903 vs 2496 (925 without state).1 parent 3f25671 commit 0060e21
9 files changed
Lines changed: 758 additions & 48 deletions
File tree
- NativeScript/runtime
- TestRunner/app/tests
- docs
- knowledge
- types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1341 | 1341 | | |
1342 | 1342 | | |
1343 | 1343 | | |
1344 | | - | |
1345 | | - | |
| 1344 | + | |
| 1345 | + | |
1346 | 1346 | | |
1347 | | - | |
| 1347 | + | |
1348 | 1348 | | |
1349 | 1349 | | |
1350 | 1350 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
865 | 865 | | |
866 | 866 | | |
867 | 867 | | |
| 868 | + | |
868 | 869 | | |
| 870 | + | |
869 | 871 | | |
870 | 872 | | |
871 | 873 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
| 280 | + | |
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
| |||
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
| 289 | + | |
288 | 290 | | |
| 291 | + | |
289 | 292 | | |
290 | 293 | | |
291 | 294 | | |
| |||
313 | 316 | | |
314 | 317 | | |
315 | 318 | | |
316 | | - | |
| 319 | + | |
317 | 320 | | |
318 | 321 | | |
319 | 322 | | |
| |||
380 | 383 | | |
381 | 384 | | |
382 | 385 | | |
383 | | - | |
| 386 | + | |
384 | 387 | | |
385 | 388 | | |
386 | 389 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
38 | 54 | | |
39 | 55 | | |
40 | 56 | | |
| |||
97 | 113 | | |
98 | 114 | | |
99 | 115 | | |
100 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
101 | 119 | | |
102 | 120 | | |
103 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
104 | 128 | | |
105 | 129 | | |
106 | 130 | | |
107 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
108 | 135 | | |
109 | | - | |
110 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
111 | 140 | | |
112 | 141 | | |
113 | 142 | | |
| |||
124 | 153 | | |
125 | 154 | | |
126 | 155 | | |
127 | | - | |
128 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
129 | 159 | | |
130 | 160 | | |
131 | 161 | | |
| |||
0 commit comments