RESOLVED FIXED 221380
[JSC] Implement Object.entries in C++
https://bugs.webkit.org/show_bug.cgi?id=221380
Summary [JSC] Implement Object.entries in C++
Yusuke Suzuki
Reported 2021-02-03 21:35:31 PST
[JSC] Implement Object.entries in C++
Attachments
Patch (19.60 KB, patch)
2021-02-03 21:53 PST, Yusuke Suzuki
ashvayka: review+
ews-feeder: commit-queue-
Patch (12.08 KB, patch)
2021-02-03 22:28 PST, Yusuke Suzuki
no flags
Patch (14.24 KB, patch)
2021-02-03 22:29 PST, Yusuke Suzuki
no flags
Patch (13.08 KB, patch)
2021-02-03 23:07 PST, Yusuke Suzuki
no flags
Yusuke Suzuki
Comment 1 2021-02-03 21:40:13 PST
*** Bug 221233 has been marked as a duplicate of this bug. ***
Yusuke Suzuki
Comment 2 2021-02-03 21:53:15 PST
Alexey Shvayka
Comment 3 2021-02-03 22:08:49 PST
Comment on attachment 419230 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=419230&action=review Neatly done! r=me with nits. > Source/JavaScriptCore/runtime/ObjectConstructor.cpp:436 > + if (propertyName.isSymbol()) Given PropertyNameMode::Strings, I am pretty sure we can assert that `propertyName` is not a symbol. > Source/JavaScriptCore/runtime/ObjectConstructor.cpp:-410 > - auto addValue = [&] (PropertyName propertyName) { Since we are modifying the signature, maybe we should consider more descriptive name? add{Value,Entry} does not always add a value/entry.
Alexey Shvayka
Comment 4 2021-02-03 22:14:54 PST
Comment on attachment 419230 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=419230&action=review > Source/JavaScriptCore/runtime/ObjectConstructor.cpp:434 > + for (unsigned i = 0, numProperties = properties.size(); i < numProperties; i++) { I wonder if it's measurably faster than using `for (const auto& propertyName : properties)`?
Yusuke Suzuki
Comment 5 2021-02-03 22:26:22 PST
Comment on attachment 419230 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=419230&action=review Thanks! >> Source/JavaScriptCore/runtime/ObjectConstructor.cpp:434 >> + for (unsigned i = 0, numProperties = properties.size(); i < numProperties; i++) { > > I wonder if it's measurably faster than using `for (const auto& propertyName : properties)`? I don't think there is any perf difference. Changed to for (const auto& propertyName : properties). >> Source/JavaScriptCore/runtime/ObjectConstructor.cpp:436 >> + if (propertyName.isSymbol()) > > Given PropertyNameMode::Strings, I am pretty sure we can assert that `propertyName` is not a symbol. Right! Fixed. >> Source/JavaScriptCore/runtime/ObjectConstructor.cpp:-410 >> - auto addValue = [&] (PropertyName propertyName) { > > Since we are modifying the signature, maybe we should consider more descriptive name? add{Value,Entry} does not always add a value/entry. OK, changed.
Yusuke Suzuki
Comment 6 2021-02-03 22:28:15 PST
Yusuke Suzuki
Comment 7 2021-02-03 22:29:31 PST
Yusuke Suzuki
Comment 8 2021-02-03 23:04:47 PST
Comment on attachment 419235 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=419235&action=review > Source/JavaScriptCore/runtime/ObjectConstructor.cpp:429 > + MarkedArgumentBuffer args; > + args.append(jsOwnedString(vm, propertyName.uid())); > + args.append(value); > + JSArray* entry = constructArray(globalObject, static_cast<ArrayAllocationProfile*>(nullptr), args); Slightly optimized it with { ObjectInitializationScope initializationScope(vm); if ((entry = JSArray::tryCreateUninitializedRestricted(initializationScope, nullptr, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous), 2))) { entry->initializeIndex(initializationScope, 0, key); entry->initializeIndex(initializationScope, 1, value); } } if (!entry) { throwOutOfMemoryError(globalObject, scope); return; }
Yusuke Suzuki
Comment 9 2021-02-03 23:07:20 PST
EWS
Comment 10 2021-02-04 02:42:27 PST
Committed r272364: <https://trac.webkit.org/changeset/272364> All reviewed patches have been landed. Closing bug and clearing flags on attachment 419238 [details].
Radar WebKit Bug Importer
Comment 11 2021-02-04 02:43:14 PST
Note You need to log in before you can comment on or make changes to this bug.