RESOLVED FIXED 148705
[ES6] Implement ModuleNamespaceObject
https://bugs.webkit.org/show_bug.cgi?id=148705
Summary [ES6] Implement ModuleNamespaceObject
Yusuke Suzuki
Reported 2015-09-01 23:29:37 PDT
Implement ModuleNamespaceObject.
Attachments
Patch (31.75 KB, patch)
2015-09-02 13:16 PDT, Yusuke Suzuki
no flags
Patch (32.65 KB, patch)
2015-09-02 14:17 PDT, Yusuke Suzuki
no flags
Patch (33.62 KB, patch)
2015-09-03 21:51 PDT, Yusuke Suzuki
no flags
Patch (33.62 KB, patch)
2015-09-03 22:00 PDT, Yusuke Suzuki
ggaren: review+
Yusuke Suzuki
Comment 1 2015-09-02 13:16:41 PDT
Yusuke Suzuki
Comment 2 2015-09-02 13:21:52 PDT
Yusuke Suzuki
Comment 3 2015-09-02 14:17:11 PDT
Yusuke Suzuki
Comment 4 2015-09-03 21:30:21 PDT
Let's rebase it.
Yusuke Suzuki
Comment 5 2015-09-03 21:51:38 PDT
Yusuke Suzuki
Comment 6 2015-09-03 22:00:29 PDT
Yusuke Suzuki
Comment 7 2015-09-03 22:00:53 PDT
Slightly clean up the comment. Now patch is ready for review.
Geoffrey Garen
Comment 8 2015-09-04 14:19:41 PDT
Comment on attachment 260564 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=260564&action=review > Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp:64 > +{ > + // http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects > + // Quoted from the spec: > + // A List containing the String values of the exported names exposed as own properties of this object. > + // The list is ordered as if an Array of those String values had been sorted using Array.prototype.sort using SortCompare as comparefn. > + // > + // Sort the exported names by the code point order. > + Vector<UniquedStringImpl*> temporaryVector(exports.size(), nullptr); > + std::transform(exports.begin(), exports.end(), temporaryVector.begin(), [](const RefPtr<WTF::UniquedStringImpl>& ref) { > + return ref.get(); > + }); > + std::sort(temporaryVector.begin(), temporaryVector.end(), [] (UniquedStringImpl* lhs, UniquedStringImpl* rhs) { > + return codePointCompare(lhs, rhs) < 0; > + }); > + for (auto* identifier : temporaryVector) > + m_exports.add(identifier); This stuff should move into finishCreation. A JS object constructor should only do the bare minimum to default initialize fields in order to avoid crashing during GC. We do all meaningful work inside finishCreation in order to avoid problems that we might cause by triggering GC during a constructor. (I can see by reading this code that it doesn't cause GC, but it is preferable style to favor finishCreation so we don't have to do that reading.) > Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp:114 > + // If the value is filled with TDZ value, throw the reference error. the => a
Yusuke Suzuki
Comment 9 2015-09-04 14:55:02 PDT
Comment on attachment 260564 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=260564&action=review Thank you for your review! I'll revise the patch based on your review and land it :D >> Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp:64 >> + m_exports.add(identifier); > > This stuff should move into finishCreation. A JS object constructor should only do the bare minimum to default initialize fields in order to avoid crashing during GC. We do all meaningful work inside finishCreation in order to avoid problems that we might cause by triggering GC during a constructor. (I can see by reading this code that it doesn't cause GC, but it is preferable style to favor finishCreation so we don't have to do that reading.) Make sense. Moving the above code to the finishCreation. >> Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp:114 >> + // If the value is filled with TDZ value, throw the reference error. > > the => a Thank you! Fixed.
Yusuke Suzuki
Comment 10 2015-09-05 00:23:05 PDT
Note You need to log in before you can comment on or make changes to this bug.