RESOLVED FIXED204028
[WebAssembly] LLIntGenerator should not retain VirtualRegisters used for constants
https://bugs.webkit.org/show_bug.cgi?id=204028
Summary [WebAssembly] LLIntGenerator should not retain VirtualRegisters used for cons...
Tadeu Zagallo
Reported 2019-11-08 16:09:21 PST
...
Attachments
Patch (6.96 KB, patch)
2019-11-08 16:24 PST, Tadeu Zagallo
no flags
Patch (7.77 KB, patch)
2019-11-08 17:48 PST, Tadeu Zagallo
no flags
Patch for landing (7.57 KB, patch)
2019-11-08 22:20 PST, Tadeu Zagallo
no flags
Tadeu Zagallo
Comment 1 2019-11-08 16:24:03 PST
Saam Barati
Comment 2 2019-11-08 16:30:30 PST
Comment on attachment 383176 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=383176&action=review > Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp:272 > + StdUnorderedMap<uint64_t, VirtualRegister> m_constantMap; why StdUnorderedMap? Just because zero might be a key? > Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp:519 > + target->setConstant(); this feels like a lie. I don't get it.
Yusuke Suzuki
Comment 3 2019-11-08 16:40:35 PST
Comment on attachment 383176 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=383176&action=review Commented about RegisterID's m_isConstant flag. > Source/JavaScriptCore/bytecompiler/RegisterID.h:68 > + , m_isConstant(false) Let's put it in field's initializer, like, `bool m_isConstant { false }`. We could also refactor `m_refCount` and `m_isTemporary` fields. And this constructor can delegate to `RegisterID(VirtualRegister virtualRegister)` like, `: RegisterID(VirtualRegister(index))`. > Source/JavaScriptCore/bytecompiler/RegisterID.h:136 > + bool m_isConstant; It is a bit scary to me. I assume RegisterID is immutable one so long as it is live. So it looks strange to me when `isConstant()` starts returning different value in different code point for the exact same RegisterID. Can we track this status differently instead of having it in RegisterID?
Saam Barati
Comment 4 2019-11-08 16:42:25 PST
Comment on attachment 383176 [details] Patch discussed offline with Tadeu. This isn't sound, since a local can be written to with a non constant. It's not a static property of a local
Tadeu Zagallo
Comment 5 2019-11-08 17:48:40 PST
Yusuke Suzuki
Comment 6 2019-11-08 17:57:41 PST
Comment on attachment 383188 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=383188&action=review r=me with nit. > Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp:510 > + if (auto it = m_constantMap.find(value); it != m_constantMap.end()) > + source = it->second; > + else { > + source = VirtualRegister(FirstConstantRegisterIndex + m_codeBlock->m_constants.size()); > + m_codeBlock->m_constants.append(value); > + m_constantMap.emplace(value, source); > + } We are looking up dictionary twice and it is unnecessary, (1) one for m_constantMap.find, and (2) one for m_constantMap.emplace. You can use the return-value of std::unrodered_map::emplace to avoid looking up unordered_map twice here, since emplace does nothing if entry already exists.
Tadeu Zagallo
Comment 7 2019-11-08 22:20:55 PST
Created attachment 383202 [details] Patch for landing
WebKit Commit Bot
Comment 8 2019-11-08 23:05:23 PST
Comment on attachment 383202 [details] Patch for landing Clearing flags on attachment: 383202 Committed r252306: <https://trac.webkit.org/changeset/252306>
WebKit Commit Bot
Comment 9 2019-11-08 23:05:25 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 10 2019-11-11 17:04:22 PST
Note You need to log in before you can comment on or make changes to this bug.