Closed
Bug 1643750
Opened 4 years ago
Closed 4 years ago
Optimize Object.prototype.toString for primitives
Categories
(Core :: JavaScript Engine, task, P3)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla79
Tracking | Status | |
---|---|---|
firefox79 | --- | fixed |
People
(Reporter: tcampbell, Assigned: tcampbell)
Details
Attachments
(1 file)
This is a bit silly, but there is noticeable time on sites like reddit spent converting primitives to objects in order to call toString
.
eg.
function c(e) {
return "[object Object]" === Object.prototype.toString.call(e);
}
We currently handle this by calling obj_toString
but this is allocating objects. As a short-term fix, I'll add a fast path there. In the future with WarpBuilder, we should be able to do a better job.
Assignee | ||
Comment 1•4 years ago
|
||
While this is a bit silly, the code does come up in the wild. We avoid
allocating objects for primitives we can can show that the global prototypes
were not tampered with.
Assignee | ||
Comment 2•4 years ago
|
||
Here is a patch that improves that case. It became more complex than I wanted though. In future it would be good to have a transpile-able IC
Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8c3873698dcb
Optimize Object.prototype.toString for primitives. r=jandem
Comment 4•4 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 4 years ago
status-firefox79:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
You need to log in
before you can comment on or make changes to this bug.
Description
•