Closed
Bug 1410640
Opened 7 years ago
Closed 7 years ago
Allow nursery allocation for arrow functions?
Categories
(Core :: JavaScript: GC, enhancement, P2)
Core
JavaScript: GC
Tracking
()
RESOLVED
FIXED
mozilla58
Tracking | Status | |
---|---|---|
firefox58 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
1.07 KB,
patch
|
jonco
:
review+
|
Details | Diff | Splinter Review |
bug 989414 only enabled nursery allocation for normal functions, so currently arrow functions are still always allocated in the tenured heap. Is there any technical limitation which prohibits nursery allocation of arrow functions? And if there's no technical limitation, does it make sense to allow nursery allocation of arrow functions resp. is more useful not to allow nursery allocation of arrow functions?
Comment 1•7 years ago
|
||
I haven't looked but don't see why there should be any reason not to do this. Thanks for pointing this out.
Comment 2•7 years ago
|
||
Does this refer to the function closure object itself or allocations that the arrow function performs?
Priority: -- → P2
Assignee | ||
Comment 3•7 years ago
|
||
To the arrow function itself. Specifically I was wondering if we can align the CloneFunctionObjectIfNotSingleton calls in js::Lambda [1] and js::LambdaArrow [2].
[1] https://searchfox.org/mozilla-central/rev/8a6a6bef7c54425970aa4fb039cc6463a19c0b7f/js/src/vm/Interpreter.cpp#4401
[2] https://searchfox.org/mozilla-central/rev/8a6a6bef7c54425970aa4fb039cc6463a19c0b7f/js/src/vm/Interpreter.cpp#4414-4415
Comment 4•7 years ago
|
||
Good find, we should fix this. André can you take this? Else I can do it.
Assignee | ||
Comment 5•7 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/8c234572141a2593807d8ff5960f6c7789305da7 only changed js::Lambda(...) to enable nursery allocation of normal functions, so I assume for arrow functions we also just need to adjust js::LambdaArrow(...)?
The patch improves this µ-benchmark from 360ms to 20ms for me:
var q = 0;
var t = dateNow();
for (var i = 0; i < 1000000; ++i) {
q += (() => i)();
}
print(dateNow() - t, q);
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #8921411 -
Flags: review?(jcoppeard)
Comment 6•7 years ago
|
||
Comment on attachment 8921411 [details] [diff] [review]
bug1410640.patch
Review of attachment 8921411 [details] [diff] [review]:
-----------------------------------------------------------------
Great, thanks for fixing this.
Attachment #8921411 -
Flags: review?(jcoppeard) → review+
Comment 7•7 years ago
|
||
(In reply to André Bargull [:anba] from comment #5)
> The patch improves this µ-benchmark from 360ms to 20ms for me:
>
> var q = 0;
> var t = dateNow();
> for (var i = 0; i < 1000000; ++i) {
> q += (() => i)();
> }
> print(dateNow() - t, q);
Is this with Ion disabled? Ion should do nursery allocation inline in CodeGenerator::visitLambdaArrow so I wonder if that's not working...
Flags: needinfo?(andrebargull)
Comment 8•7 years ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #7)
> Is this with Ion disabled? Ion should do nursery allocation inline in
> CodeGenerator::visitLambdaArrow so I wonder if that's not working...
Oh maybe we fill up the nursery and then keep calling LambdaArrow OOL without collecting the nursery?
Assignee | ||
Comment 9•7 years ago
|
||
The actual test case I used was:
```
function f() {
var q = 0;
var t = dateNow();
for (var i = 0; i < 1000000; ++i) {
q += (() => i)();
}
return [dateNow() - t, q];
}
for (var i = 0; i < 10; ++i) print(f());
```
Running only the function content of |f| in global scope is already fast without this patch:
```
var q = 0;
var t = dateNow();
for (var i = 0; i < 1000000; ++i) {
q += (() => i)();
}
print(dateNow() - t, q);
```
So there seems to be a difference whether or not the benchmark code is run within another function?
Flags: needinfo?(andrebargull)
Comment 10•7 years ago
|
||
(In reply to André Bargull [:anba] from comment #9)
> So there seems to be a difference whether or not the benchmark code is run
> within another function?
When we run it in the global scope, |i| is a global name and we can optimize away the arrow allocation. When the code is in a function, we have to get |i| from the arrow's environment chain and we don't optimize away the arrow allocation.
Assignee | ||
Comment 11•7 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=67c9b7e427125fafea5b1cfda4babd45760fd039
Keywords: checkin-needed
Comment 12•7 years ago
|
||
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1f17f122eb7c
Enable nursery allocation of arrow functions. r=jonco
Keywords: checkin-needed
Comment 13•7 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in
before you can comment on or make changes to this bug.
Description
•