Calling functions with unused upvars results in js_NewGCObject

NEW
Unassigned

Status

()

Core
JavaScript Engine
6 years ago
3 years ago

People

(Reporter: Mardak, Unassigned)

Tracking

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
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.)
> I'm still not sure what the js_NewGCObject is being called for exactly

The Call object, presumably.
(Assignee)

Updated

3 years ago
Assignee: general → nobody
You need to log in before you can comment on or make changes to this bug.