RESOLVED FIXED 155438
Need to distinguish between Symbol() and Symbol("").
https://bugs.webkit.org/show_bug.cgi?id=155438
Summary Need to distinguish between Symbol() and Symbol("").
Mark Lam
Reported 2016-03-14 07:48:08 PDT
While toString of both Symbol() and Symbol("") yields "Symbol()", Function.name should yield "" and "[]" respectively. Hence, we need to tell between the two.
Attachments
proposed patch. (7.59 KB, patch)
2016-03-14 07:56 PDT, Mark Lam
no flags
proposed patch applying Geoff's feedback. (8.95 KB, patch)
2016-03-14 15:17 PDT, Mark Lam
saam: review+
Mark Lam
Comment 1 2016-03-14 07:56:35 PDT
Created attachment 273973 [details] proposed patch.
Geoffrey Garen
Comment 2 2016-03-14 09:53:06 PDT
Comment on attachment 273973 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=273973&action=review Can we use some mechanism other than a new flag to indicate that the Symbol is null? How about setting m_data8/m_data16 to nullptr? > Source/WTF/wtf/text/StringImpl.h:305 > + CreateEmptySymbol = StringEmptySymbol There's no need to make this enumeration equal another enumeration. This would be clearer without the =. In String and StringImpl, we call String("") "empty" and we call String() "null". Therefore, this new kind of Symbol is the *null* Symbol, not the empty Symbol.
Mark Lam
Comment 3 2016-03-14 15:17:47 PDT
Created attachment 274034 [details] proposed patch applying Geoff's feedback. (In reply to comment #2) > Can we use some mechanism other than a new flag to indicate that the Symbol > is null? How about setting m_data8/m_data16 to nullptr? There are lot of assertions in StringImpl that suggests that it is an expected invariant that m_data8 / m_data16 are never null. That said, there is a better implementation that I can use that does not require changing the flags i.e. to use a singleton null StringImpl. > > Source/WTF/wtf/text/StringImpl.h:305 > > + CreateEmptySymbol = StringEmptySymbol > > There's no need to make this enumeration equal another enumeration. This > would be clearer without the =. Removed in the new patch. > In String and StringImpl, we call String("") "empty" and we call String() > "null". > > Therefore, this new kind of Symbol is the *null* Symbol, not the empty > Symbol. "Symbol()" being called "empty" preceded this patch. My new patch will rename SymbolEmpty to be a NullSymbol.
Saam Barati
Comment 4 2016-03-14 15:48:29 PDT
Comment on attachment 274034 [details] proposed patch applying Geoff's feedback. View in context: https://bugs.webkit.org/attachment.cgi?id=274034&action=review > Source/WTF/wtf/text/StringStatics.cpp:46 > + static NeverDestroyed<StringImpl>nullString(ConstructEmptyString); style: space between ">" and "n"
Mark Lam
Comment 5 2016-03-14 16:17:04 PDT
Thanks for the review. The mac test failure was pre-existing: See https://build.webkit.org/builders/Apple%20El%20Capitan%20Debug%20WK1%20%28Tests%29/builds/3689. I'll land shortly.
Mark Lam
Comment 6 2016-03-14 16:20:47 PDT
Note You need to log in before you can comment on or make changes to this bug.