Closed Bug 779975 Opened 9 years ago Closed 9 years ago

ref count ScriptSource

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: Benjamin, Assigned: Benjamin)

References

Details

Attachments

(1 file)

Right now, ScriptSource is hacked onto the GC. This creates icky things like attachToRuntime and the IGC hacks in JSScript::setScriptSource. Since ScriptSource doesn't contain any structs, it would be easier to reference count script sources. Reference counting would also free the source as soon as the last script owning it disappeared instead of waiting for full GC.
The only slightly tricky part is that MemoryMetrics has to use a HashSet to avoid counting the same source multiple times.
Assignee: general → bpeterson
Attachment #648471 - Flags: review?(jorendorff)
Comment on attachment 648471 [details] [diff] [review]
implementing ref counting

Review of attachment 648471 [details] [diff] [review]:
-----------------------------------------------------------------

Wonderful. This is so much better than the GC hack.

My experience is, anything like this eventually gets turned into a real GC-thing; but if that happens in time, fine, and there's no rush.

::: js/src/jsscript.cpp
@@ +1293,2 @@
>      JS_ASSERT(ready());
>      // data is a union, but both members are pointers to allocated memory, so

Pre-existing style nit: while you're in here, please put a blank line before this comment (since it is not at the top of a block)
Attachment #648471 - Flags: review?(jorendorff) → review+
https://hg.mozilla.org/mozilla-central/rev/fa77c8c2a346
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.