diff options
| -rw-r--r-- | ASimpleReply/ASimpleReplyChain.md | 11 | ||||
| -rw-r--r-- | ASimpleReply/DadalReply2.md | 53 |
2 files changed, 64 insertions, 0 deletions
diff --git a/ASimpleReply/ASimpleReplyChain.md b/ASimpleReply/ASimpleReplyChain.md index 2d2a31ca..6d62afb1 100644 --- a/ASimpleReply/ASimpleReplyChain.md +++ b/ASimpleReply/ASimpleReplyChain.md @@ -19,6 +19,17 @@ https://gist.github.com/DadaIsCrazy/8ce07d409f8f74bad7b36e74b77a3129 https://github.com/SeaOfNodes/Simple/blob/main/ASimpleReply/ASimpleReply2.md +### Dadal's Reply(2): + +https://studio.youtube.com/channel/UCbutMk6cKrH8q4sJyQHGPVQ/comments/inbox?filter=%5B%5D +https://github.com/SeaOfNodes/Simple/blob/main/ASimpleReply/DadalReply2.md + + +### Cliff's Reply(3) + +https://github.com/SeaOfNodes/Simple/blob/main/ASimpleReply/ASimpleReply2.md + + [room for more conversations] diff --git a/ASimpleReply/DadalReply2.md b/ASimpleReply/DadalReply2.md new file mode 100644 index 00000000..99d8e84b --- /dev/null +++ b/ASimpleReply/DadalReply2.md @@ -0,0 +1,53 @@ + +This is Dadal's reply from U-tube, recreated here (permission pending) so its +both easier to find and not lost if U-tube changes their mind. + +The original link I copied from: + +https://studio.youtube.com/channel/UCbutMk6cKrH8q4sJyQHGPVQ/comments/inbox?filter=%5B%5D + + +Type checks: to give an example: + +``` +foo(o) { + let x = o.x; + .... + let y = o.y; +} +``` + +Assuming polymorphic feedback (which is very frequent in JS), this will become something like (using JS-like syntax, but this happening inside the compiler of course) +``` +foo (o) { + let x; + if (o.map == Map1) { + x = RawLoad(o, offset=8); + } else if (o.map == Map2) { + x = RawLoad(o, offset=16); + } else if (o.map == Map3) { + x = RawLoad(o, offset=12); + } + .... + let y; + if (o.map == Map1) { + y = RawLoad(o, offset=0); + } else if (o.map == Map2) { + y = RawLoad(o, offset=20); + } else if (o.map == Map3) { + y = RawLoad(o, offset=4); + } +} +``` + +Here, it's not like any of the type-checks when loading `y` could be removed. Well, in some cases, we do things like double-diamond elimination to remove some checks, but often it's not possible. + +For monomorphic cases, subsequent checks will be removed when possible, but objects can change shapes in JavaScript. This means that if you have something like +``` +foo (o) { + let x = o.x; + bar(); + let y = o.y; +} +``` +If `bar` isn't inlined, then we have to assume that `bar` could change the shape of `o`, and thus a type-check is needed before loading `y`. Oh, and `bar` could be changing the shape of `o` only some times, so `o.x` could have monomorphic feedback while `o.y` could have polymorphic feedback. Or the other way around :) |
