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.

Regular and "array nested" optimized functions don't work together #2566

@NTillmann

Description

@NTillmann

Prepacking this, with --instantRender (to trigger realm.arrayNestedOptimizedFunctionsEnabled, which is not otherwise directly exposed via the CLI)...

function f(a) {
  return Array.from(a).map(function() {
    function g() { return 21 + 21; }
    __optimize(g);
    return g;
  });
}
__optimize(f);

...results in...

var f;
(function () {
  var _$2 = this;
  var _$3 = _$2.Array;
  var _$4 = _$3.from;
  var _1 = function (a) {
    var _5 = function () {
      var _8 = function () {
        return 21 + 21;
      };
      return _8;
    };
    var _$0 = _$4(a);
    var _$1 = _$0.map(_5);
    return _$1;
  };
  _$2.f = _1;
}).call(this);

Note that _8 did NOT get optimized!

Also note that this message was produced:

In input file /tmp/test.js(3:5) RecoverableError PP1008: Called __optimize on function in failed speculative context (https://github.com/facebook/prepack/wiki/PP1008)

Not helpful, rather confusing, but likely related?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions