Last Comment Bug 637553 - Calling functions with unused upvars results in js_NewGCObject
: Calling functions with unused upvars results in js_NewGCObject
Status: NEW
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: x86 Mac OS X
: -- normal with 1 vote (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-28 18:50 PST by Ed Lee :Mardak
Modified: 2014-07-24 11:07 PDT (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Ed Lee :Mardak 2011-02-28 18:50:49 PST
I've been looking at object allocation for my add-on with a custom build that prints out when/where js_NewGCObject is called (thanks philikon, gal! bug 636304 comment 3)
http://hg.mozilla.org/try/rev/7a2ee58f7c13

I noticed that there's a new object being created at the entry to certain functions unrelated to what's actually on the first line of the function.

Turns out an object is being created for upvars that are assigned from an inner function:

function outer() {
  return;
  let val;
  let noHoist = function() {
    val = 0;
  };
}

I'm still not sure what the js_NewGCObject is being called for exactly, but it only appears if I declare a local variable (including function parameter names) and have a line in an inner function that assigns to it. This happens even if the inner function has no way of being called. (My example code here always returns, but my actual code conditionally returns.)
Comment 1 Boris Zbarsky [:bz] 2011-02-28 18:55:42 PST
> I'm still not sure what the js_NewGCObject is being called for exactly

The Call object, presumably.

Note You need to log in before you can comment on or make changes to this bug.