8000 wrong target body for values used in multiple optimized functions · Issue #2399 · facebookarchive/prepack · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
wrong target body for values used in multiple optimized functions #2399
Closed
@NTillmann

Description

@NTillmann

Prepacking this...

(function () {
  function outer(cond) {
    if (cond) {
      var value = 42;
      function inner1() { return value; }
      function inner2() { return value; }
      __optimize(inner1);
      __optimize(inner2);
      return [inner1, inner2];
    }
  }
  global.outer = outer;
  __optimize(outer);
})();

produces the following.

(function () {
  var _$0 = this;

  var _1 = function (cond) {
    var _6 = function () {
      return _8;
    };

    var _7 = function () {
      return _8;
    };

    return cond ? [_6, _7] : void 0;
  };

  var _8 = cond ? 42 : void 0;

  _$0.outer = _1;
}).call(this);

Note that _8 is defined in the global code, but refers to cond which is only defined in the outer function. The issue stems for various problems in _getTarget when it comes to optimized functions (some TODOs are present, some more things are implicitly wrong).

Metadata

Metadata

Assignees

Labels

bugoptimized functionsIssues around optimizing not global code, but additional functions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0