Stream: cranelift

Topic: cranelift and interrupt flags


view this post on Zulip Alex Crichton (Apr 07 2020 at 21:22):

I was wondering recently about how interrupting wasm code works in cranelift (I thought it wasn't implemented but turns out it was!) and I was looking at the spidermonkey integration for this. I see that in loop headers an interrupt flag is checked, but I wasn't actually able to find anywhere else that interrupt flags were checked. Do others know where the interrupt flag is checked for things like function exits/entries?

Read-only Git mirror of the Mercurial gecko repositories at https://hg.mozilla.org. How to contribute: http://bit.ly/contribute-code - mozilla/gecko-dev

view this post on Zulip Dan Gohman (Apr 07 2020 at 21:36):

SpiderMonkey has its own function prologue which it inserts before Cranelift's prologue.

view this post on Zulip Alex Crichton (Apr 07 2020 at 21:38):

@Dan Gohman do you know where that code lives?

view this post on Zulip fitzgen (he/him) (Apr 07 2020 at 21:39):

I think https://searchfox.org/mozilla-central/source/js/src/wasm/WasmIonCompile.cpp#933

view this post on Zulip fitzgen (he/him) (Apr 07 2020 at 21:39):

er wait that's ion

view this post on Zulip Chris Fallin (Apr 07 2020 at 21:40):

perhaps starting from here? https://searchfox.org/mozilla-central/source/js/src/wasm/WasmFrameIter.cpp#559

view this post on Zulip Dan Gohman (Apr 07 2020 at 21:43):

Yeah, that's it, though I'm forgetting how interrupt checking happens offhand

view this post on Zulip Alex Crichton (Apr 07 2020 at 21:44):

@fitzgen (he/him) I saw that yeah but it was only called from loop headers as well, @Chris Fallin thanks! I'll investigate from there

view this post on Zulip fitzgen (he/him) (Apr 07 2020 at 21:46):

fwiw, I recommend using searchfox, since you can jump to definition, find all uses, etc

view this post on Zulip Dan Gohman (Apr 07 2020 at 21:47):

It may just be that until we support tail calls, you don't need to check for interrupts in function headers because any loop would eventually run out of stack space anyway.

view this post on Zulip fitzgen (he/him) (Apr 07 2020 at 21:47):

there's also interruptTlsOffset which is seemingly unused, but seems like the thing that would be used: https://searchfox.org/mozilla-central/search?q=symbol:F_%3CT_CraneliftStaticEnvironment%3E_interruptTlsOffset&redirect=false

view this post on Zulip Alex Crichton (Apr 07 2020 at 21:48):

@Dan Gohman I thought that too but this wasm module executes effectively infinitely in bounded stack

GitHub Gist: instantly share code, notes, and snippets.

view this post on Zulip Alex Crichton (Apr 07 2020 at 21:49):

yeah I cant seem to find this in WasmFrameIter.cpp either...

view this post on Zulip Alex Crichton (Apr 07 2020 at 21:54):

oh it's the stack limit

view this post on Zulip Alex Crichton (Apr 07 2020 at 21:55):

all spidermonkey functions check the stack limit before doing the call

view this post on Zulip Alex Crichton (Apr 07 2020 at 21:55):

and interruption sets the interrupt flag as well as the stack limit -- https://searchfox.org/mozilla-central/source/js/src/wasm/WasmTypes.cpp#963

view this post on Zulip Alex Crichton (Apr 07 2020 at 21:55):

which kills loops and kills function calls


Last updated: Oct 23 2024 at 20:03 UTC