Skip to content
This repository has been 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 opened this issue Aug 8, 2018 · 0 comments
Closed

wrong target body for values used in multiple optimized functions #2399

NTillmann opened this issue Aug 8, 2018 · 0 comments
Assignees
Labels
bug optimized functions Issues around optimizing not global code, but additional functions

Comments

@NTillmann
Copy link
Contributor

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).

@NTillmann NTillmann added bug optimized functions Issues around optimizing not global code, but additional functions labels Aug 8, 2018
facebook-github-bot pushed a commit that referenced this issue Aug 15, 2018
Summary:
Fixes #2151 #2222 #2279 #2393 #2399 #2404 #2411 #2414 #2415
Added a fuzz testing tool
Added test cases
Turn crash in JSON.stringify into a diagnostic
Adds a `arrayNestedOptimizedFunctionsEnabled` flag to enable nested optimized functions derived from Array.prototype methods (like `map`) and Array.from
Refactor assignment on partial or possibly deleted property
Rewrote the joining logic to always do a full join at every join point
Removed last remnants of delayUnsupportedRequires

Reviewed By: cblappert

Differential Revision: D9349841

fbshipit-source-id: 74a16dbb015777d59d23fdfde77abbe2489c292a
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug optimized functions Issues around optimizing not global code, but additional functions
Projects
None yet
Development

No branches or pull requests

2 participants