RESOLVED FIXED 190057
Verify the contents of AssemblerBuffer on arm64e
https://bugs.webkit.org/show_bug.cgi?id=190057
Summary Verify the contents of AssemblerBuffer on arm64e
Saam Barati
Reported 2018-09-27 14:43:19 PDT
....
Attachments
WIP (26.04 KB, patch)
2018-09-27 14:45 PDT, Saam Barati
no flags
patch (32.24 KB, patch)
2018-09-27 17:14 PDT, Saam Barati
no flags
patch (33.40 KB, patch)
2018-09-27 17:25 PDT, Saam Barati
no flags
patch (33.33 KB, patch)
2018-09-27 18:45 PDT, Saam Barati
mark.lam: review+
patch for landing (34.66 KB, patch)
2018-09-27 21:15 PDT, Saam Barati
no flags
Saam Barati
Comment 1 2018-09-27 14:45:39 PDT
Saam Barati
Comment 2 2018-09-27 16:47:57 PDT
Saam Barati
Comment 3 2018-09-27 17:14:19 PDT
Saam Barati
Comment 4 2018-09-27 17:25:20 PDT
EWS Watchlist
Comment 5 2018-09-27 17:27:07 PDT
Attachment 351029 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:964: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:992: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/JavaScriptCore/assembler/LinkBuffer.cpp:196: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/LinkBuffer.cpp:197: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/LinkBuffer.cpp:198: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/ARM64Assembler.h:333: Wrong number of spaces before statement. (expected: 16) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/assembler/AssemblerBuffer.h:44: Code inside a namespace should not be indented. [whitespace/indent] [4] ERROR: Source/JavaScriptCore/assembler/AssemblerBuffer.h:178: Wrong number of spaces before statement. (expected: 20) [whitespace/indent] [4] Total errors found: 8 in 13 files If any of these errors are false positives, please file a bug against check-webkit-style.
Mark Lam
Comment 6 2018-09-27 18:10:57 PDT
Comment on attachment 351029 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=351029&action=review LGTM but I would like to read through it one more time tonight before r+ing. Some comments and suggestions for now. > Source/JavaScriptCore/assembler/ARM64Assembler.h:329 > + ARM64Assembler( > +#if CPU(ARM64E) > + unsigned randomNumber > +#endif > + ) nit: How about express this as: ARM64Assembler(unsigned randomNumber = 0) I think the compiler will optimize the argument out if not used. > Source/JavaScriptCore/assembler/ARM64Assembler.h:337 > { > } ... and add UNUSED_PARAM(randomNumber) here? > Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:994 > + , m_assembler( > +#if CPU(ARM64E) > + random() > +#endif > + ) nit: this looks so wonky. IMHO, I think it's easier to read if you express it as: #if CPU(ARM64E) , m_assembler(random()) #else , m_assembler() #endif > Source/JavaScriptCore/assembler/AssemblerBuffer.h:174 > + AssemblerBuffer( > +#if CPU(ARM64E) > + unsigned randomNumber > +#endif > + ) nit: consider expressing as: AssemblerBuffer(unsigned randomNumber = 0) > Source/JavaScriptCore/assembler/AssemblerBuffer.h:181 > { > } ... and add UNUSED_PARAM(randomNumber) here? > Source/JavaScriptCore/assembler/AssemblerBuffer.h:291 > + ARM64EHash hash() const > + { > + return m_hash; > + } nit: just make this one line: ARM64EHash hash() const { return hash; } > Source/JavaScriptCore/assembler/AssemblerBuffer.h:294 > +#if !CPU(ARM64) // If we were to define this on arm64e, we'd need a way to update the hash as we wrote directly into the buffer. /wrote/write/. > Source/JavaScriptCore/assembler/AssemblerBuffer.h:298 > + void* data() const > + { > + return m_storage.buffer(); > + } Ditto: can be single line. > Source/JavaScriptCore/assembler/LinkBuffer.cpp:211 > +#if CPU(ARM64E) > + unsigned index = readPtr; > +#endif > + > + for (size_t i = 0; i < bytes; i += sizeof(InstructionType)) { > + InstructionType insn = *src++; > +#if CPU(ARM64E) > + verifyUncompactedHash.update(insn, index); > + index += sizeof(InstructionType); > +#endif > + *dst++ = insn; > + } How about put this whole thing in #if CPU(ARM64E), and have an #else memcpy(dst, src, bytes); > Source/JavaScriptCore/assembler/LinkBuffer.cpp:220 > +#if CPU(ARM64E) > + if (verifyUncompactedHash.hash() != assemblerBufferHash.hash()) { > + dataLogLn("Hashes don't match: ", RawPointer(bitwise_cast<void*>(verifyUncompactedHash.hash())), " ", RawPointer(bitwise_cast<void*>(assemblerBufferHash.hash()))); > + dataLogLn("Crashing!"); > + CRASH(); > + } > +#endif You can move this blob into the #if CPU(ARM64E) blob above right after the for loop.
Saam Barati
Comment 7 2018-09-27 18:36:33 PDT
Comment on attachment 351029 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=351029&action=review >> Source/JavaScriptCore/assembler/ARM64Assembler.h:329 >> + ) > > nit: How about express this as: > ARM64Assembler(unsigned randomNumber = 0) > > I think the compiler will optimize the argument out if not used. I think that's worse than this. >> Source/JavaScriptCore/assembler/AssemblerBuffer.h:174 >> + ) > > nit: consider expressing as: > > AssemblerBuffer(unsigned randomNumber = 0) same
Saam Barati
Comment 8 2018-09-27 18:44:00 PDT
Comment on attachment 351029 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=351029&action=review >> Source/JavaScriptCore/assembler/LinkBuffer.cpp:211 >> + } > > How about put this whole thing in #if CPU(ARM64E), and have an #else > memcpy(dst, src, bytes); I'd rather have this code be shared on all archs that do branch compaction.
Saam Barati
Comment 9 2018-09-27 18:45:31 PDT
EWS Watchlist
Comment 10 2018-09-27 18:48:47 PDT
Attachment 351035 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:964: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/LinkBuffer.cpp:196: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/LinkBuffer.cpp:197: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/LinkBuffer.cpp:198: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/ARM64Assembler.h:333: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/assembler/AssemblerBuffer.h:44: Code inside a namespace should not be indented. [whitespace/indent] [4] ERROR: Source/JavaScriptCore/assembler/AssemblerBuffer.h:178: Wrong number of spaces before statement. (expected: 20) [whitespace/indent] [4] Total errors found: 7 in 13 files If any of these errors are false positives, please file a bug against check-webkit-style.
Mark Lam
Comment 11 2018-09-27 20:49:56 PDT
Comment on attachment 351035 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=351035&action=review r=me with remaining issues resolved. I think you missed the ARMv7Assembler::fillNops(). Incidentally, the ARMv7 port does use the copy function in fillNops() and needs a fix. > Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:973 > AssemblerType::fillNops(static_cast<char*>(buffer.data()) + startCodeSize, memoryToFillWithNopsInBytes, isCopyingToExecutableMemory); I think you need to update this to use the new fillNops() with memcpy. Strange, how did this build for x86_64 or any other non ARM64 build? Oh, I get it. The copyFunction argument's type is templated, and on all those platforms, the argument happens to be unused. Hence, x86_64 doesn't care that we passed it a boolean instead. I think it's misleading to leave this code in this state. We should make it pass memcpy for the 3rd arg here. > Source/JavaScriptCore/assembler/AssemblerBuffer.h:174 > + ) Fix indentation.
Saam Barati
Comment 12 2018-09-27 21:15:09 PDT
Created attachment 351048 [details] patch for landing
EWS Watchlist
Comment 13 2018-09-27 21:16:14 PDT
Attachment 351048 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:964: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/LinkBuffer.cpp:196: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/LinkBuffer.cpp:197: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/LinkBuffer.cpp:198: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] ERROR: Source/JavaScriptCore/assembler/ARM64Assembler.h:333: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/assembler/AssemblerBuffer.h:44: Code inside a namespace should not be indented. [whitespace/indent] [4] Total errors found: 6 in 14 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 14 2018-09-27 22:34:45 PDT
Comment on attachment 351048 [details] patch for landing Clearing flags on attachment: 351048 Committed r236589: <https://trac.webkit.org/changeset/236589>
WebKit Commit Bot
Comment 15 2018-09-27 22:34:47 PDT
All reviewed patches have been landed. Closing bug.
Guillaume Emont
Comment 16 2018-09-28 09:49:34 PDT
This breaks compilation on Armv7. I created Bug 190080 to address this.
Note You need to log in before you can comment on or make changes to this bug.