Closed
Bug 195385
Opened 22 years ago
Closed 22 years ago
jsparse.c suggestion: avoid recursion in RecycleTree
Categories
(Core :: JavaScript Engine, enhancement, P1)
Tracking
()
VERIFIED
FIXED
mozilla1.4alpha
People
(Reporter: user, Assigned: brendan)
Details
(Keywords: js1.5)
Attachments
(2 files, 1 obsolete file)
6.08 KB,
patch
|
shaver
:
review+
|
Details | Diff | Splinter Review |
5.34 KB,
patch
|
shaver
:
review+
|
Details | Diff | Splinter Review |
Currently RecycleTree uses recursion to flatten a parse subtree into a recycled
list. But this uncontrolled recursion that can trigger potentially a stack
overflow can be avoided if tree flattening will be delayed until the subtree
root is reused.
To implement this, RecycleTree can simply append the subtree root to the
recycled tree and only when the root node will re-used, its direct children will
be recycled.
This setup will bring another advantages if the parser recycles more nodes then
it needs, since during recycling the children of unused subtree roots will not
be touched at all.
Reporter | ||
Comment 1•22 years ago
|
||
I tried to preserve the current assertion checks semantics and recycling debug
counting in RecycleTree with the patch, but I may miss something in this area.
Comment 2•22 years ago
|
||
Reassigning, and cc'ing Brendan for consideration of this patch -
Assignee: rogerl → khanson
Assignee | ||
Comment 3•22 years ago
|
||
Igor, great idea. I took your patch and reduced old open-coded
JS_ARENA_ALLOCATE macro calls (my fault) further, to avoid both
ConsumeRecycledHead and its callers having to load tc->nodeList, and then do the
arena allocation if that list is empty. I also fixed the METER_PARSENODES code
that lacked a pn-> in front of pn_count ;-). Patch (diff -u and -wu) in a moment.
/be
Assignee: khanson → brendan
Priority: -- → P1
Target Milestone: --- → mozilla1.4alpha
Assignee | ||
Comment 4•22 years ago
|
||
Attachment #115852 -
Attachment is obsolete: true
Assignee | ||
Comment 5•22 years ago
|
||
For easier reviewing, but I'll request r=shaver on the last patch.
/be
Assignee | ||
Updated•22 years ago
|
Attachment #115947 -
Flags: review?(shaver)
Comment 6•22 years ago
|
||
The patch passes the JS testsuite on both WinNT and Linux.
I ran it in both the debug and optimized JS shells.
No test regressions were observed -
Comment 7•22 years ago
|
||
Comment on attachment 115948 [details] [diff] [review]
diff -w version of last patch
I like it. I'd like it more if we inlined RecycleNode, since it's so tiny, but
we don't have a good JS_INLINE to use, so I'll live.
r=shaver.
Attachment #115948 -
Flags: review+
Comment 8•22 years ago
|
||
Comment on attachment 115947 [details] [diff] [review]
my take on Igor's patch
I meant to r+ this one, alas.
Attachment #115947 -
Flags: review?(shaver) → review+
Assignee | ||
Comment 9•22 years ago
|
||
Inlining can blow your icache; I'll let compilers be brave about it, if not
smart (a static function whose address is not taken can be inlined everywhere
that it's called if the compiler thinks that wins).
I did make one more change: I eliminated the static forward prototype for
NewOrRecycledNode, by moving RecycleTree and NewOrRecycledNode up above the
latter's first caller, NewParseNode (where the static forward was).
Thanks again to Igor, and thanks to shaver for the review+ -- checked in.
/be
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 10•22 years ago
|
||
Checkin verified; passes the JS testsuite on Linux and WinNT -
Status: RESOLVED → VERIFIED
Updated•19 years ago
|
Flags: testcase-
You need to log in
before you can comment on or make changes to this bug.
Description
•