RESOLVED FIXED 139621
Move JavaScriptCore/yarr to std::unique_ptr
https://bugs.webkit.org/show_bug.cgi?id=139621
Summary Move JavaScriptCore/yarr to std::unique_ptr
Gyuyoung Kim
Reported 2014-12-13 08:00:34 PST
SSIA
Attachments
Patch (17.63 KB, patch)
2014-12-13 08:02 PST, Gyuyoung Kim
no flags
Archive of layout-test-results from ews100 for mac-mountainlion (349.06 KB, application/zip)
2014-12-13 08:44 PST, Build Bot
no flags
Archive of layout-test-results from ews106 for mac-mountainlion-wk2 (363.49 KB, application/zip)
2014-12-13 08:46 PST, Build Bot
no flags
Patch (17.51 KB, patch)
2014-12-25 23:57 PST, Gyuyoung Kim
no flags
Patch (17.81 KB, patch)
2014-12-28 21:42 PST, Gyuyoung Kim
no flags
Patch (17.62 KB, patch)
2014-12-28 22:20 PST, Gyuyoung Kim
no flags
Gyuyoung Kim
Comment 1 2014-12-13 08:02:21 PST
Build Bot
Comment 2 2014-12-13 08:43:57 PST
Comment on attachment 243256 [details] Patch Attachment 243256 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/5965336272699392 Number of test failures exceeded the failure limit.
Build Bot
Comment 3 2014-12-13 08:44:00 PST
Created attachment 243257 [details] Archive of layout-test-results from ews100 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Build Bot
Comment 4 2014-12-13 08:46:09 PST
Comment on attachment 243256 [details] Patch Attachment 243256 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/6544379468578816 Number of test failures exceeded the failure limit.
Build Bot
Comment 5 2014-12-13 08:46:11 PST
Created attachment 243258 [details] Archive of layout-test-results from ews106 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
Gyuyoung Kim
Comment 6 2014-12-25 23:57:26 PST
Anders Carlsson
Comment 7 2014-12-28 09:03:32 PST
Comment on attachment 243759 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=243759&action=review > Source/JavaScriptCore/yarr/YarrPattern.h:271 > PatternAlternative* alternative = new PatternAlternative(this); > - m_alternatives.append(adoptPtr(alternative)); > + m_alternatives.append(std::unique_ptr<PatternAlternative>(alternative)); You can write this as m_alternatives.append(std::make_unique<PatternAlternative>(this));
Darin Adler
Comment 8 2014-12-28 11:10:13 PST
Comment on attachment 243759 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=243759&action=review >> Source/JavaScriptCore/yarr/YarrPattern.h:271 >> + m_alternatives.append(std::unique_ptr<PatternAlternative>(alternative)); > > You can write this as > > m_alternatives.append(std::make_unique<PatternAlternative>(this)); If we do that, where do we get the return value? It seems wasteful to have to write: return m_alternatives.last().get(); But I think that’s what would be required. Unless we change Vector::append to return a reference to the thing that was appended. Then it could be: return m_alternatives.append(std::make_unique<PatternAlternative>(this)).get(); > Source/JavaScriptCore/yarr/YarrPattern.h:340 > - m_userCharacterClasses.append(adoptPtr(newlineCached = newlineCreate())); > + m_userCharacterClasses.append(std::unique_ptr<CharacterClass>(newlineCached = newlineCreate())); The right way to do this is to change the create function to return a unique_ptr, not to adopt it from the returned pointer. But we have the same issue here with getting the pointer value as in the other Vector::append call above.
Darin Adler
Comment 9 2014-12-28 11:10:41 PST
Adding Anders to the cc list so he sees my comments.
Gyuyoung Kim
Comment 10 2014-12-28 17:58:19 PST
Comment on attachment 243759 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=243759&action=review >>> Source/JavaScriptCore/yarr/YarrPattern.h:271 >>> + m_alternatives.append(std::unique_ptr<PatternAlternative>(alternative)); >> >> You can write this as >> >> m_alternatives.append(std::make_unique<PatternAlternative>(this)); > > If we do that, where do we get the return value? It seems wasteful to have to write: > > return m_alternatives.last().get(); > > But I think that’s what would be required. Unless we change Vector::append to return a reference to the thing that was appended. Then it could be: > > return m_alternatives.append(std::make_unique<PatternAlternative>(this)).get(); If we used std::make_unique<> instead of std::unique_ptr, layout test was broken. You can see the broken in previous patch. That's why I use std::unique_ptr<> instead of std::make_unique<>. BTW, should I change that Vector class returns a reference in this patch ?
Gyuyoung Kim
Comment 11 2014-12-28 21:42:27 PST
Gyuyoung Kim
Comment 12 2014-12-28 22:20:44 PST
Gyuyoung Kim
Comment 13 2014-12-28 22:41:59 PST
(In reply to comment #8) > Comment on attachment 243759 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=243759&action=review > > >> Source/JavaScriptCore/yarr/YarrPattern.h:271 > >> + m_alternatives.append(std::unique_ptr<PatternAlternative>(alternative)); > > > > You can write this as > > > > m_alternatives.append(std::make_unique<PatternAlternative>(this)); > > If we do that, where do we get the return value? It seems wasteful to have > to write: > > return m_alternatives.last().get(); > > But I think that’s what would be required. Unless we change Vector::append > to return a reference to the thing that was appended. Then it could be: > > return > m_alternatives.append(std::make_unique<PatternAlternative>(this)).get(); In latest patch, I use below codes as you suggested. { m_alternatives.append(std::make_unique<PatternAlternative>(this)); return static_cast<PatternAlternative*>(m_alternatives.last().get()); } > > Source/JavaScriptCore/yarr/YarrPattern.h:340 > > - m_userCharacterClasses.append(adoptPtr(newlineCached = newlineCreate())); > > + m_userCharacterClasses.append(std::unique_ptr<CharacterClass>(newlineCached = newlineCreate())); > > The right way to do this is to change the create function to return a > unique_ptr, not to adopt it from the returned pointer. But we have the same > issue here with getting the pointer value as in the other Vector::append > call above. To change to return a unique_ptr in fooCreate(), I have to modify "create_regex_tables". I would do this after landing this patch in Bug 139983.
WebKit Commit Bot
Comment 14 2014-12-29 18:59:33 PST
Comment on attachment 243790 [details] Patch Clearing flags on attachment: 243790 Committed r177820: <http://trac.webkit.org/changeset/177820>
WebKit Commit Bot
Comment 15 2014-12-29 18:59:37 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.