On 02/18/2014 12:49 PM, Nicholas Nethercote wrote:
On Tue, Feb 18, 2014 at 1:57 AM, Nicolas B. Pierron
<nicolas.b.pier...@mozilla.com> wrote:

I think it might make sense to special case the JSFunction class, such as we
can get the object prototype name in addition to the JSFunction class.

Interesting idea. What's the exact code for getting the object
prototype name from a JSFunction?

The corresponding JS code would be:

  obj.__proto__.constructor

obj.__proto__    maps to  JSObject::getProto(cx, obj, &proto)
   .constructor  maps to  JS_GetConstructor(cx, proto)

Then, if this is a JSFunction, then you can extract the

RootedAtom name(cx);
if (constructor->is<JSFunction>())
    name = constructor->as<JSFunction>().displayAtom()

Which would be either the name of the function, or it's inferred name.

This way, for the following code:

function Foo() {}
var x = new Foo();

We should be able to display "Foo" in the memory reporter.

--
Nicolas B. Pierron

_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to