RESOLVED FIXED 170219
WebAssembly: option to crash if no fast memory is available
https://bugs.webkit.org/show_bug.cgi?id=170219
Summary WebAssembly: option to crash if no fast memory is available
JF Bastien
Reported 2017-03-28 17:22:24 PDT
.
Attachments
patch (4.92 KB, patch)
2017-03-28 17:24 PDT, JF Bastien
mark.lam: review+
patch (4.97 KB, patch)
2017-03-28 20:20 PDT, JF Bastien
no flags
JF Bastien
Comment 1 2017-03-28 17:24:01 PDT
Mark Lam
Comment 2 2017-03-28 17:29:03 PDT
Comment on attachment 305680 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=305680&action=review r=me > Source/JavaScriptCore/wasm/WasmMemory.cpp:124 > + if (!fastMemoryEnabled()) nit: if (UNLIKELY(... > Source/JavaScriptCore/wasm/WasmMemory.cpp:128 > + if (!vm.getCTIStub(throwExceptionFromWasmThunkGenerator).size()) nit: if (UNLIKELY(... > Source/JavaScriptCore/wasm/WasmMemory.cpp:129 > + goto fail; "goto"! One of my favorite coding constructs that gets so little use because peeps don't know how to use it right, and fear it. > Source/JavaScriptCore/wasm/WasmMemory.cpp:139 > + if (dequeFastMemory()) nit: if (LIKELY(... > Source/JavaScriptCore/wasm/WasmMemory.cpp:153 > + if (memory) nit: if (LIKELY(memory))
JF Bastien
Comment 3 2017-03-28 20:20:19 PDT
Created attachment 305700 [details] patch > > Source/JavaScriptCore/wasm/WasmMemory.cpp:139 > > + if (dequeFastMemory()) > > nit: if (LIKELY(... > > > Source/JavaScriptCore/wasm/WasmMemory.cpp:153 > > + if (memory) > > nit: if (LIKELY(memory)) I don't know that these two are unlikely: they're not options or odd things. They're certainly undesirable, but I wouldn't call them unlikely. The others you pointed out definitely are, so I marked them appropriately. > > Source/JavaScriptCore/wasm/WasmMemory.cpp:129 > > + goto fail; > > "goto"! One of my favorite coding constructs that gets so little use > because peeps don't know how to use it right, and fear it. Am I using it right? :-p
Mark Lam
Comment 4 2017-03-28 20:48:08 PDT
(In reply to JF Bastien from comment #3) > Created attachment 305700 [details] > patch > > > > Source/JavaScriptCore/wasm/WasmMemory.cpp:139 > > > + if (dequeFastMemory()) > > > > nit: if (LIKELY(... > > > > > Source/JavaScriptCore/wasm/WasmMemory.cpp:153 > > > + if (memory) > > > > nit: if (LIKELY(memory)) > > I don't know that these two are unlikely: they're not options or odd things. > They're certainly undesirable, but I wouldn't call them unlikely. I said "LIKELY", not "UNLIKELY". That's because the alternative is to fail and crash. They better be LIKELY. > The others you pointed out definitely are, so I marked them appropriately. > > > > Source/JavaScriptCore/wasm/WasmMemory.cpp:129 > > > + goto fail; > > > > "goto"! One of my favorite coding constructs that gets so little use > > because peeps don't know how to use it right, and fear it. > > Am I using it right? :-p Totally. =)
JF Bastien
Comment 5 2017-03-28 20:55:19 PDT
> > I don't know that these two are unlikely: they're not options or odd things. > > They're certainly undesirable, but I wouldn't call them unlikely. > > I said "LIKELY", not "UNLIKELY". That's because the alternative is to fail > and crash. They better be LIKELY. It'll only crash if the option is set though. If unset, it'll just return false and generate a slow-mode memory. It's totally normal for this to fail, I just want an option to catch when it does so that I can benchmark knowing we used the fast version! > > The others you pointed out definitely are, so I marked them appropriately. > > > > > > Source/JavaScriptCore/wasm/WasmMemory.cpp:129 > > > > + goto fail; > > > > > > "goto"! One of my favorite coding constructs that gets so little use > > > because peeps don't know how to use it right, and fear it. > > > > Am I using it right? :-p > > Totally. =) 🎉
WebKit Commit Bot
Comment 6 2017-03-28 21:02:20 PDT
Comment on attachment 305700 [details] patch Clearing flags on attachment: 305700 Committed r214526: <http://trac.webkit.org/changeset/214526>
WebKit Commit Bot
Comment 7 2017-03-28 21:02:23 PDT
All reviewed patches have been landed. Closing bug.
Saam Barati
Comment 8 2017-03-29 01:24:38 PDT
(In reply to JF Bastien from comment #3) > Created attachment 305700 [details] > patch > > > > Source/JavaScriptCore/wasm/WasmMemory.cpp:139 > > > + if (dequeFastMemory()) > > > > nit: if (LIKELY(... > > > > > Source/JavaScriptCore/wasm/WasmMemory.cpp:153 > > > + if (memory) > > > > nit: if (LIKELY(memory)) > > I don't know that these two are unlikely: they're not options or odd things. > They're certainly undesirable, but I wouldn't call them unlikely. > > The others you pointed out definitely are, so I marked them appropriately. > > > > Source/JavaScriptCore/wasm/WasmMemory.cpp:129 > > > + goto fail; > > > > "goto"! One of my favorite coding constructs that gets so little use > > because peeps don't know how to use it right, and fear it. > > Am I using it right? :-p I think more idiomatic JSC style would be to name a lambda fail, and 'return fail()' everywhere you 'goto fail'
Saam Barati
Comment 9 2017-03-29 01:25:15 PDT
Comment on attachment 305680 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=305680&action=review >> Source/JavaScriptCore/wasm/WasmMemory.cpp:129 >> + goto fail; > > "goto"! One of my favorite coding constructs that gets so little use because peeps don't know how to use it right, and fear it. I don't think this is why people don't use "goto"
Mark Lam
Comment 10 2017-03-29 07:08:37 PDT
(In reply to Saam Barati from comment #9) > >> Source/JavaScriptCore/wasm/WasmMemory.cpp:129 > >> + goto fail; > > > > "goto"! One of my favorite coding constructs that gets so little use because peeps don't know how to use it right, and fear it. > > I don't think this is why people don't use "goto" This was a semi-joke, and I was being over the top. My point was that there are valid uses for it, and this was the main one IMHO. Or at least, it was until ... (In reply to Saam Barati from comment #8) > I think more idiomatic JSC style would be to name a lambda fail, and 'return > fail()' everywhere you 'goto fail' I agree with this. This is a much better solution. I knew I should have scratch my head a little longer before saying yes to the gotos.
Saam Barati
Comment 11 2017-03-29 08:26:29 PDT
(In reply to Mark Lam from comment #10) > (In reply to Saam Barati from comment #9) > > >> Source/JavaScriptCore/wasm/WasmMemory.cpp:129 > > >> + goto fail; > > > > > > "goto"! One of my favorite coding constructs that gets so little use because peeps don't know how to use it right, and fear it. > > > > I don't think this is why people don't use "goto" > > This was a semi-joke, and I was being over the top. Yeah I know :) My response is a bit of a tease as well. > are valid uses for it, and this was the main one IMHO. Or at least, it was > until ... > > (In reply to Saam Barati from comment #8) > > I think more idiomatic JSC style would be to name a lambda fail, and 'return > > fail()' everywhere you 'goto fail' > > I agree with this. This is a much better solution. I knew I should have > scratch my head a little longer before saying yes to the gotos. Just to clarify, I'm not trying to argue that one is better than the other. (I could make the argument that LLVM probably produces better code for what we care about in a function like this using the goto variant. It'll either produce smaller code, or code with one fewer function call.) I'm just arguing it's more in line with JSC style not to use goto.
JF Bastien
Comment 12 2017-03-29 09:04:56 PDT
(In reply to Saam Barati from comment #11) > (In reply to Mark Lam from comment #10) > > (In reply to Saam Barati from comment #9) > > > >> Source/JavaScriptCore/wasm/WasmMemory.cpp:129 > > > >> + goto fail; > > > > > > > > "goto"! One of my favorite coding constructs that gets so little use because peeps don't know how to use it right, and fear it. > > > > > > I don't think this is why people don't use "goto" > > > > This was a semi-joke, and I was being over the top. > Yeah I know :) My response is a bit of a tease as well. > > > are valid uses for it, and this was the main one IMHO. Or at least, it was > > until ... > > > > (In reply to Saam Barati from comment #8) > > > I think more idiomatic JSC style would be to name a lambda fail, and 'return > > > fail()' everywhere you 'goto fail' > > > > I agree with this. This is a much better solution. I knew I should have > > scratch my head a little longer before saying yes to the gotos. > Just to clarify, I'm not trying to argue that one is better than the other. > (I could make the argument that LLVM probably produces better code for what > we care about in a function like this using the goto variant. It'll either > produce smaller code, or code with one fewer function call.) I'm just > arguing it's more in line with JSC style not to use goto. Lambda is indeed nicer. Will fix: https://bugs.webkit.org/show_bug.cgi?id=170242 goto is just a reflex for my 2000-era C++, and years of C programming :) I can post-modernize my C++.
Note You need to log in before you can comment on or make changes to this bug.