Closed
Bug 1069666
Opened 11 years ago
Closed 9 years ago
Implement a proper WeakSet
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla57
| Tracking | Status | |
|---|---|---|
| firefox57 | --- | fixed |
People
(Reporter: evilpies, Assigned: anba)
Details
Attachments
(1 file, 1 obsolete file)
|
40.86 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
Right now our WeakSet implementation is based on a WeakMap. While this is easy to implement and prevents bugs, it seems like a proper WeakSet would be more efficient and use less memory.
| Assignee | ||
Comment 1•9 years ago
|
||
To reduce code duplications I've added the WeakCollectionObject class to act as an abstract super-class for WeakMapObject and WeakSetObject. The rest was more or less simply a matter of translating the WeakSet methods from self-hosted JS to C++.
I've also moved some function declarations from jsweakmap.h to WeakMapObject.h, because the definitions are in WeakMapObject.cpp. And I've updated method-called-on-incompatible.js to test error reporting for another self-hosted function, now that WeakSet.prototype.add is no longer implemented in self-hosted JS.
Constructing an empty WeakSet is now roughly 30% faster when tested in this µ-benchmark:
var t = dateNow();
for (var i = 0; i < 1000000; ++i) {
new WeakSet();
}
print(dateNow() - t);
The WeakSet methods are just a bit faster, because we only save the function call to the corresponding WeakMap method.
Comment 2•9 years ago
|
||
Comment on attachment 8901183 [details] [diff] [review]
bug1069666.patch
Review of attachment 8901183 [details] [diff] [review]:
-----------------------------------------------------------------
Thank you, this is very nice!
Attachment #8901183 -
Flags: review?(till) → review+
| Assignee | ||
Comment 3•9 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=852f43a29022ae32c759b79f0fd9db2579e9a1c0
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/645be0c7780a
Implement WeakSet as proper class instead of delegating to WeakMap. r=till
Keywords: checkin-needed
Comment 5•9 years ago
|
||
Backed out for breaking non-unified build at js/src/builtin/WeakMapObject-inl.h:19:
https://hg.mozilla.org/integration/mozilla-inbound/rev/05f088f22a02191c1d406a195637ca82416e188f
Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=126456747&repo=mozilla-inbound
/home/worker/workspace/build/src/js/src/builtin/WeakMapObject-inl.h:19:18: error: 'ProxyObject' was not declared in this scope
/home/worker/workspace/build/src/js/src/builtin/WeakMapObject-inl.h:19:31: error: no matching function for call to 'JSObject::is()'
/home/worker/workspace/build/src/js/src/builtin/WeakMapObject-inl.h:19:31: error: template argument 1 is invalid
/home/worker/workspace/build/src/js/src/builtin/WeakMapObject-inl.h:20:18: error: the value of 'ProxyObject' is not usable in a constant expression
/home/worker/workspace/build/src/js/src/builtin/WeakMapObject-inl.h:20:31: error: no matching function for call to 'JSObject::as()'
/home/worker/workspace/build/src/js/src/jsobj.h:571:51: error: 'class_' is not a member of 'js::WeakCollectionObject'
Flags: needinfo?(andrebargull)
| Assignee | ||
Comment 6•9 years ago
|
||
(In reply to Sebastian Hengst [:aryx][:archaeopteryx] (needinfo on intermittent or backout) from comment #5)
> Backed out for breaking non-unified build at
> js/src/builtin/WeakMapObject-inl.h:19:
>
Ugh, sorry for that!
Flags: needinfo?(andrebargull)
| Assignee | ||
Comment 7•9 years ago
|
||
Add missing includes for non-unified builds to WeakMapObject-inl.h and WeakMapObject.cpp. Carrying r+ from till.
Attachment #8901183 -
Attachment is obsolete: true
Attachment #8901947 -
Flags: review+
| Assignee | ||
Comment 8•9 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=d04e43a137b716892cd3c505cf4d71e71984cff8
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b534df0d1ef0
Implement WeakSet as proper class instead of delegating to WeakMap. r=till
Keywords: checkin-needed
Comment 10•9 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox57:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in
before you can comment on or make changes to this bug.
Description
•