Closed Bug 1154079 Opened 9 years ago Closed 9 years ago

[jsdbg2] Consider adding [[Class]] name to allocations log

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: fitzgen, Assigned: fitzgen)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

Should be easily accessible. Whether it is that useful is another question...
Assignee: nobody → nfitzgerald
Status: NEW → ASSIGNED
Comment on attachment 8591988 [details] [diff] [review]
Add the allocated object's [[class]] name to the allocations log

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

r=me with question about the metadata callback answered.

::: js/src/jscompartment.cpp
@@ +708,5 @@
>      objectMetadataTable = nullptr;
>  }
>  
>  void
> +JSCompartment::setNewObjectMetadata(JSContext* cx, HandleObject obj)

I'm unsure on the invariant requirements of the metadata callback though. Are both GC and JS reentry disallowed, or is only JS reentry disallowed? If GC is disallowed, why the change from JSObject* to HandleObject here?

::: js/src/vm/Debugger.h
@@ +258,5 @@
>      {
> +        AllocationSite(HandleObject frame, int64_t when, const char* className)
> +            : frame(frame)
> +            , when(when)
> +            , className(className)

I think SM still uses

: a(a),
  b(b)
Attachment #8591988 - Flags: review?(shu) → review+
(In reply to Shu-yu Guo [:shu] from comment #2)
> ::: js/src/jscompartment.cpp
> @@ +708,5 @@
> >      objectMetadataTable = nullptr;
> >  }
> >  
> >  void
> > +JSCompartment::setNewObjectMetadata(JSContext* cx, HandleObject obj)
> 
> I'm unsure on the invariant requirements of the metadata callback though.
> Are both GC and JS reentry disallowed, or is only JS reentry disallowed? If
> GC is disallowed, why the change from JSObject* to HandleObject here?

JS reentry is disallowed and GC is suppressed. I made the change because the handlers do things that could otherwise GC (if it weren't suppressed) and I think the hazard analysis will complain because someone could call the metadata handler outside of the AutoEnterAnalysis's AutoSuppressGC that it is usually called with. Seemed simpler than rooting at the top of SavedStacksMetadataCallback.

I guess an alternative would be to pass around a reference to the AutoEnterAnalysis (or its AutoSuppressGC?) that is up the stack to the metadata callback?
(In reply to Nick Fitzgerald [:fitzgen] from comment #3)
> (In reply to Shu-yu Guo [:shu] from comment #2)
> > ::: js/src/jscompartment.cpp
> > @@ +708,5 @@
> > >      objectMetadataTable = nullptr;
> > >  }
> > >  
> > >  void
> > > +JSCompartment::setNewObjectMetadata(JSContext* cx, HandleObject obj)
> > 
> > I'm unsure on the invariant requirements of the metadata callback though.
> > Are both GC and JS reentry disallowed, or is only JS reentry disallowed? If
> > GC is disallowed, why the change from JSObject* to HandleObject here?
> 
> JS reentry is disallowed and GC is suppressed. I made the change because the
> handlers do things that could otherwise GC (if it weren't suppressed) and I
> think the hazard analysis will complain because someone could call the
> metadata handler outside of the AutoEnterAnalysis's AutoSuppressGC that it
> is usually called with. Seemed simpler than rooting at the top of
> SavedStacksMetadataCallback.
> 
> I guess an alternative would be to pass around a reference to the
> AutoEnterAnalysis (or its AutoSuppressGC?) that is up the stack to the
> metadata callback?

Since the object metadata hook always needs both GC and JS reentry suppressed, could you move the AutoEnterAnalysis to be inside the hook? If this is incorrect, just add an AutoSuppressGCAnalysis inside.
(That was just a tiny fix for the silly rooting hazard that showed up in the try push)
https://hg.mozilla.org/mozilla-central/rev/1be627f24c4a
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: