Open
Bug 500874
Opened 15 years ago
Updated 2 years ago
Static analysis to find heap allocations that could be stack allocations
Categories
(Developer Infrastructure :: Source Code Analysis, enhancement)
Developer Infrastructure
Source Code Analysis
Tracking
(Not tracked)
NEW
People
(Reporter: jruderman, Unassigned)
References
Details
(Keywords: perf)
Attachments
(2 files, 1 obsolete file)
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
text/plain
|
Details |
new & delete in same function --> probably safe to use a stack variable or alloca() (suggested by pav when i asked "what static analyses could we do to find patterns that are common performance issues?")
Reporter | ||
Comment 2•15 years ago
|
||
Dynamically-sized (alloca) stack allocations require case-by-case reasoning about whether it's safe. Other than that, I believe there's plenty of room on the stack.
Comment 3•15 years ago
|
||
(In reply to comment #2) > Dynamically-sized (alloca) stack allocations require case-by-case reasoning > about whether it's safe. Other than that, I believe there's plenty of room on > the stack. is that portable? Or should this be about looking for malloc/free with a constant size?
Reporter | ||
Comment 4•15 years ago
|
||
We can start by just looking at constant-size mallocs. If fixing those goes well, we can try variable-size mallocs and see how many of them are safe to convert to alloca.
Comment 5•15 years ago
|
||
> safe to use a stack variable or alloca() i don't think this is good idea. alloca(rand()) crashes. dynamic alloca is dangerous - no overflowing check. > I believe there's plenty of room on the stack. don't think so. i have seen crashes caused by recursion - to fix them i needed |ulimit -s BIG| <-- this sets the stack size.
I, Sunita E, am a student of SJCE,Mysore ,India and would like to take up this bug.
Reporter | ||
Comment 7•15 years ago
|
||
Thanks, Sunita. I suggest reading https://developer.mozilla.org/en/Dehydra and asking any questions you have in irc.mozilla.org #static.
Updated•15 years ago
|
Assignee: nobody → sunsai16
Updated•15 years ago
|
Attachment #441706 -
Attachment mime type: application/octet-stream → text/plain
Comment 9•15 years ago
|
||
(In reply to comment #8) > Created an attachment (id=441706) [details] > script to match new and delete calls in a function > > please take a look at the attachment.I need guidance to go further. Look for new* calls that take a constant as an argument.
Comment 10•15 years ago
|
||
Changes: Added check for arguments: if(rhs[0].arguments[0].value) { //... } This makes sure that the values of arguments are constant or in other words available at compile time.
Comment 11•15 years ago
|
||
Could you please go through the latest attachment. If its acceptable, I shall add the necessary warning statements.
Comment 12•15 years ago
|
||
Sunita, you need to request review/feedback from a particular person, probably dwitte or taras.
Comment 13•15 years ago
|
||
(In reply to comment #12) > Sunita, you need to request review/feedback from a particular person, probably > dwitte or taras. Sure.Thank you.
Attachment #441706 -
Attachment is obsolete: true
Attachment #443297 -
Attachment is patch: true
Attachment #443297 -
Attachment mime type: application/javascript → text/plain
Attachment #443297 -
Flags: feedback?(tglek)
Updated•15 years ago
|
Attachment #443297 -
Flags: feedback?(tglek)
Comment 14•15 years ago
|
||
Comment on attachment 443297 [details] [diff] [review] Looks for new calls that have constant argument >var allocs = [] > >function process_function(decl, body) { > > for (var i in body) { > for (var j in body[i].statements) { Instead of looping directly over body, use iterate_vars() like in bug 522776. Otherwise the code doesn't matter, it's just a tool to produce a report. Run it on mozilla, see what sort of code it flags and refine the code until it seems to flag reasonable problems. To proceed with the bug I recommend that you run this on mozilla, produce a report. Then inspect it to see if the analysis produces too many false positives, if so refine the script. Once you are sure that the analysis might be showing up likely candidates, attach a report to this bug.
Comment 15•14 years ago
|
||
Almost all the warnings have been generated in cases with conditions i.e within if statements.I would like to know what should/can be done.
Attachment #458281 -
Flags: review?(tglek)
Updated•14 years ago
|
Attachment #458281 -
Flags: review?(tglek)
Updated•7 years ago
|
Product: Core → Firefox Build System
Updated•6 years ago
|
Assignee: sunsai16 → nobody
Updated•2 years ago
|
Product: Firefox Build System → Developer Infrastructure
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•