RESOLVED FIXED 152337
Add "explicit operator bool" to ScratchRegisterAllocator::PreservedState
https://bugs.webkit.org/show_bug.cgi?id=152337
Summary Add "explicit operator bool" to ScratchRegisterAllocator::PreservedState
Saam Barati
Reported 2015-12-16 08:52:14 PST
We should assert we only get valid PreservedStates in restore reused registers.
Attachments
patch (3.21 KB, patch)
2015-12-16 09:15 PST, Saam Barati
mark.lam: review+
Saam Barati
Comment 1 2015-12-16 09:15:23 PST
Mark Lam
Comment 2 2015-12-16 09:17:51 PST
Comment on attachment 267460 [details] patch r=me
Darin Adler
Comment 3 2015-12-16 09:18:31 PST
Comment on attachment 267460 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=267460&action=review > Source/JavaScriptCore/jit/ScratchRegisterAllocator.cpp:130 > + RELEASE_ASSERT(!!preservedState); Really surprised that we need !! here. I think that means there is something wrong with the RELEASE_ASSERT macro. > Source/JavaScriptCore/jit/ScratchRegisterAllocator.h:82 > + explicit operator bool() const { return numberOfBytesPreserved != std::numeric_limits<unsigned>::max(); } I am interested to learn that this is sufficient by itself without also defining operator! for the class. I think this means we can remove many of our operator! definitions throughout the WebKit project.
Saam Barati
Comment 4 2015-12-16 09:38:19 PST
Comment on attachment 267460 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=267460&action=review >> Source/JavaScriptCore/jit/ScratchRegisterAllocator.cpp:130 >> + RELEASE_ASSERT(!!preservedState); > > Really surprised that we need !! here. I think that means there is something wrong with the RELEASE_ASSERT macro. We don't. I just do this for stylistic reasons (or lack thereof). I happen to like the explicitness of how !! looks when testing the truthiness of something. This is probably overkill inside an assert. >> Source/JavaScriptCore/jit/ScratchRegisterAllocator.h:82 >> + explicit operator bool() const { return numberOfBytesPreserved != std::numeric_limits<unsigned>::max(); } > > I am interested to learn that this is sufficient by itself without also defining operator! for the class. I think this means we can remove many of our operator! definitions throughout the WebKit project. I think one of the main benefits of "explicit operator bool" is that it eliminates most of the need for operator!.
Saam Barati
Comment 5 2015-12-16 10:37:09 PST
Note You need to log in before you can comment on or make changes to this bug.