Closed
Bug 1134865
Opened 10 years ago
Closed 10 years ago
Add constructor name to JS::ubi::Node and entries in the allocations log
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla40
Tracking | Status | |
---|---|---|
firefox40 | --- | fixed |
People
(Reporter: fitzgen, Assigned: fitzgen)
References
(Blocks 1 open bug)
Details
Attachments
(3 files, 8 obsolete files)
(deleted),
patch
|
fitzgen
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
fitzgen
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
fitzgen
:
review+
|
Details | Diff | Splinter Review |
Kannan tells me we can get this information pretty easily via the JIT's type objects -> ... something ... -> JSScript of constructor -> displayAtom.
This would be awesome, and it would be cool to use this as a potential grouping for JSObjects in takeCensus.
Assignee | ||
Updated•10 years ago
|
Blocks: memory-platform
Assignee | ||
Comment 1•10 years ago
|
||
So I tried to figure out how to get this info given any old JSObject, and I couldn't find any way to get the JSScript it was new'd in (assuming it was created with new).
I used the implementation of |obj instanceof Func| as it seems like it would be doing similar things. Unfortunately, it just grabs Func.prototype and then walks obj's prototype chain to see if it finds Func.prototype.
Kannan, is this information no longer easily accessible?
Flags: needinfo?(kvijayan)
Assignee | ||
Comment 2•10 years ago
|
||
(s/used the implementation/looked at the implementation/)
Comment 3•10 years ago
|
||
It's a bit roundabout. From the object, you can get the ObjectGroup. Now, if the object was constructed using 'new F()' for some scripted function F, then the ObjectGroup will contain an Addendum_NewScript, referring to a TypeNewScript. The TypeNewScript contains a reference to the JSFunction that is the constructor. You can get the JSScript from that.
Flags: needinfo?(kvijayan)
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → nfitzgerald
Status: NEW → ASSIGNED
Assignee | ||
Comment 4•10 years ago
|
||
Hm so I think `JSObject::makeLazyGroup` can GC (mrgiggles is seriously out of date), so if the object's group is lazy, it isn't safe for ubi::Node to get the object's constructor name (ubi::Nodes are invalidated if their referent moves).
When are groups lazy? Is it only for lazy functions? It looks like `ObjectGroupCompartment::makeGroup` can probably GC, too. No bueno.
What would the ramifications be if we only yielded constructor names for objects without a lazy group?
Flags: needinfo?(kvijayan)
Assignee | ||
Comment 5•10 years ago
|
||
https://dxr.mozilla.org/mozilla-central/source/js/src/vm/ObjectGroup.h#158-161
> * Object groups which represent at most one JS object are constructed lazily.
> * These include groups for native functions, standard classes, scripted
> * functions defined at the top level of global/eval scripts, and in some
> * other cases.
Hm. Sounds like that is a whole lot of different things that get lazy groups, but also specifically doesn't include the set of objects that are likely to take up most of your heap or be most of your allocations.
Assignee | ||
Comment 6•10 years ago
|
||
Assignee | ||
Comment 7•10 years ago
|
||
(In reply to Nick Fitzgerald [:fitzgen] from comment #6)
> Created attachment 8595111 [details] [diff] [review]
> Part 1: Add JSObject::constructorDisplayAtom
WIP patch that adds `JSObject::constructorDisplayAtom` and doesn't address the GC concerns.
Assignee | ||
Comment 8•10 years ago
|
||
Attachment #8595111 -
Attachment is obsolete: true
Attachment #8595663 -
Flags: review?(kvijayan)
Assignee | ||
Comment 9•10 years ago
|
||
Attachment #8595664 -
Flags: review?(kvijayan)
Assignee | ||
Comment 10•10 years ago
|
||
Attachment #8595665 -
Flags: review?(kvijayan)
Assignee | ||
Comment 11•10 years ago
|
||
(In reply to Nick Fitzgerald [:fitzgen] from comment #4)
> Hm so I think `JSObject::makeLazyGroup` can GC (mrgiggles is seriously out
> of date), so if the object's group is lazy, it isn't safe for ubi::Node to
> get the object's constructor name (ubi::Nodes are invalidated if their
> referent moves).
>
> When are groups lazy? Is it only for lazy functions? It looks like
> `ObjectGroupCompartment::makeGroup` can probably GC, too. No bueno.
>
> What would the ramifications be if we only yielded constructor names for
> objects without a lazy group?
(In reply to Nick Fitzgerald [:fitzgen] from comment #5)
> https://dxr.mozilla.org/mozilla-central/source/js/src/vm/ObjectGroup.h#158-
> 161
>
> > * Object groups which represent at most one JS object are constructed lazily.
> > * These include groups for native functions, standard classes, scripted
> > * functions defined at the top level of global/eval scripts, and in some
> > * other cases.
>
> Hm. Sounds like that is a whole lot of different things that get lazy
> groups, but also specifically doesn't include the set of objects that are
> likely to take up most of your heap or be most of your allocations.
Talked to Shu today and he confirmed that (a) lazy objects groups for only a single JS object are not as important as non-lazy object groups for many objects (intuitively, the latter are what you will see a lot more of in the heap), and (b) some information is better than none in this case.
Note that this no-GC stuff only applies to JS::ubi::Node, not the allocations log.
Flags: needinfo?(kvijayan)
Assignee | ||
Comment 12•10 years ago
|
||
Assignee | ||
Updated•10 years ago
|
Summary: Add JS::ubi::Node::constructorName JSObject ubi::Nodes → Add constructor name to JS::ubi::Node and entries in the allocations log
Comment 13•10 years ago
|
||
Comment on attachment 8595663 [details] [diff] [review]
Part 1: Add JSObject::constructorDisplayAtom
Review of attachment 8595663 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/jsobj.cpp
@@ +4102,5 @@
> +
> +static JSAtom*
> +displayAtomFromObjectGroup(ObjectGroup& group)
> +{
> + auto script = group.newScript();
Don't use |auto| here. It's better to have explicit type declarations that tell the reader clearly what type is being retrieved.
@@ +4112,5 @@
> +
> +bool
> +JSObject::constructorDisplayAtom(JSContext* cx, js::MutableHandleAtom name)
> +{
> + auto *g = getGroup(cx);
Same as above.
Attachment #8595663 -
Flags: review?(kvijayan) → review+
Updated•10 years ago
|
Attachment #8595664 -
Flags: review?(kvijayan) → review+
Updated•10 years ago
|
Attachment #8595665 -
Flags: review?(kvijayan) → review+
Assignee | ||
Comment 14•10 years ago
|
||
Attachment #8595663 -
Attachment is obsolete: true
Attachment #8596161 -
Flags: review+
Assignee | ||
Comment 15•10 years ago
|
||
Attachment #8595664 -
Attachment is obsolete: true
Attachment #8596162 -
Flags: review+
Assignee | ||
Comment 16•10 years ago
|
||
Attachment #8595665 -
Attachment is obsolete: true
Attachment #8596163 -
Flags: review+
Assignee | ||
Comment 17•10 years ago
|
||
Assignee | ||
Comment 18•10 years ago
|
||
Attachment #8596161 -
Attachment is obsolete: true
Attachment #8596679 -
Flags: review+
Assignee | ||
Comment 19•10 years ago
|
||
Attachment #8596162 -
Attachment is obsolete: true
Attachment #8596680 -
Flags: review+
Assignee | ||
Comment 20•10 years ago
|
||
Attachment #8596163 -
Attachment is obsolete: true
Attachment #8596681 -
Flags: review+
Assignee | ||
Comment 21•10 years ago
|
||
Didn't like AutoCompartment in the header -- moved it out to the cpp file.
New try push: https://treeherder.mozilla.org/#/jobs?repo=try&revision=dcc4015d1da7
Assignee | ||
Comment 22•10 years ago
|
||
Attachment #8596681 -
Attachment is obsolete: true
Attachment #8596920 -
Flags: review+
Assignee | ||
Comment 23•10 years ago
|
||
Was missing an include of UniquePtr.h
https://treeherder.mozilla.org/#/jobs?repo=try&revision=64cfc40cc44f
Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Comment 24•10 years ago
|
||
Hi, part 3 fails to apply:
renamed 1134865 -> Bug-1134865---Part-3-Add-JSubiNodejsObjectConstruc.patch
applying Bug-1134865---Part-3-Add-JSubiNodejsObjectConstruc.patch
patching file js/public/UbiNode.h
Hunk #5 succeeded at 591 with fuzz 1 (offset -1 lines).
patching file js/src/vm/UbiNode.cpp
Hunk #3 FAILED at 224
1 out of 3 hunks FAILED -- saving rejects to file js/src/vm/UbiNode.cpp.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working dir
errors during apply, please fix and refresh Bug-1134865---Part-3-Add-JSubiNodejsObjectConstruc.patch
could you take a look, thx!
Flags: needinfo?(nfitzgerald)
Keywords: checkin-needed
Assignee | ||
Comment 25•10 years ago
|
||
remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/50dedbefd46e
remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/626f0dd608b0
remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/ada25868ffa6
Flags: needinfo?(nfitzgerald)
Comment 26•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/50dedbefd46e
https://hg.mozilla.org/mozilla-central/rev/626f0dd608b0
https://hg.mozilla.org/mozilla-central/rev/ada25868ffa6
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
status-firefox40:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in
before you can comment on or make changes to this bug.
Description
•