Closed
Bug 927318
Opened 11 years ago
Closed 8 years ago
Allocate function objects in the nursery
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla52
Tracking | Status | |
---|---|---|
firefox52 | --- | fixed |
People
(Reporter: jonco, Assigned: jonco)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
patch
|
jandem
:
review+
|
Details | Diff | Splinter Review |
At the moment we always tenure function objects, presumable because their address may be baked into JIT code. It would be nice if we could find a way to allocate these in the nursery if possible.
Comment 1•11 years ago
|
||
For some reason it's fine allocating lambda functions in the nursery, so we should figure out why, or just do it and see what the impact is.
Updated•11 years ago
|
Summary: GenerationalGC: Allocate function objects in the nursery → Allocate function objects in the nursery
Comment 2•11 years ago
|
||
Ion is doing this already AFAICS, it'd be good to have the same behavior everywhere.
Comment 3•8 years ago
|
||
AFAICT, the code in jsfun.cpp is just passing through the newKind it's given, so I'm pretty sure that we're not intentionally pre-tenuring these anymore.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WORKSFORME
Comment 4•8 years ago
|
||
We still pretenure all native functions - see https://hg.mozilla.org/mozilla-central/file/9796ed81f17a/js/src/jsfun.cpp#l1977
This hurts Promise performance substantially: while we allocate Promise instances themselves in the nursery, the resolve and reject functions that are passed to the callback function script passes to the Promise constructor are native functions, so they're tenured. This causes the store buffer to fill up very quickly, because the functions and the promise have references to each other.
This code should demonstrate the issue:
new Promise(function(resolve, reject) {});
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
Assignee | ||
Comment 5•8 years ago
|
||
Here's a patch to remove the logic in NewFunctionWithProto that makes native functions SingletonObjects (mostly) and instead make this the default for calls to new NewNativeFunction and NewNativeConstructor. I adjusted the callers where necessary so that the behaviour was the same afterwards, with the exception of CreateResolvingFunctions in Promise.cpp which no longer get singleton objects as requested.
Assignee: nobody → jcoppeard
Attachment #8804797 -
Flags: review?(jdemooij)
Comment 6•8 years ago
|
||
Comment on attachment 8804797 [details] [diff] [review]
bug927318-native-functions
Review of attachment 8804797 [details] [diff] [review]:
-----------------------------------------------------------------
In FunctionConstructor, we call NewFunctionWithProto with TenuredObject, I think that should be GenericObject. Follow-up is fine though.
::: js/src/jsfun.cpp
@@ -1995,5 @@
> - // Don't mark asm.js module functions as singleton since they are
> - // cloned (via CloneFunctionObjectIfNotSingleton) which assumes that
> - // isSingleton implies isInterpreted.
> - if (native && !IsAsmJSModuleNative(native))
> - newKind = SingletonObject;
This was really confusing, thanks for removing it.
Attachment #8804797 -
Flags: review?(jdemooij) → review+
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/472b12f33ecb
Make native functions singletons by default but make promise resolving functions generic objects r=jandem
Assignee | ||
Comment 8•8 years ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #6)
> In FunctionConstructor, we call NewFunctionWithProto with TenuredObject, I
> think that should be GenericObject. Follow-up is fine though.
I tried this and it causes assertion failures e.g. in the ObjectBox constructor where we assert that the function is tenured. I think this will cause problems with minor GC since IIRC we don't trace the contents of these in that case.
Comment 9•8 years ago
|
||
bugherder |
Status: REOPENED → RESOLVED
Closed: 8 years ago → 8 years ago
status-firefox52:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
You need to log in
before you can comment on or make changes to this bug.
Description
•