prepack appears to fail

Created on 4 May 2017  路  6Comments  路  Source: facebook/prepack

$ npm run prepack ~/workspace/freecell-web/resources/public/js/compiled/app.js 

> [email protected] prepack /home/mike/workspace/prepack
> node lib/prepack-cli.js "/home/mike/workspace/freecell-web/resources/public/js/compiled/app.js"

No sourcemap found at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js.map.
This operation is not yet supported on abstract value  
__IntrospectionError
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:37:23764
    at call (native)
    at o (/home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:840)
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:899
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:37:11740
    at call (native)
    at o (/home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:840)
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:899
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:38:3190
    at call (native)
    at o (/home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:840)
    at e (/home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:1015)
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:596
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:572
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:299
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:273
    at /home/mike/workspace/freecell-web/resources/public/js/compiled/app.js:36:2

app.js may be found at https://michaelblume.github.io/js/compiled/app.js

question

Most helpful comment

I'm trying something like this:

__assumeDataProperty(global, "a", __abstract('number'));

(function() {
  if (a === 1) {
    console.log(a + 23)
  }
}())

What I get is:

(function () {
  var _0 = this;

  var _1 = _0.a;

  if (_0.a !== _1) { // Not sure what this is, but seems like a bug
    throw new Error("Prepack model invariant violation: " + _0.a);
  }

  if (_1 === 1) {
    console.log(_1 + 23); // I would expect this to be folded
  }
}).call(this);

All 6 comments

Prepack is quite limited in what it can do with abstract values. The error message is telling you where in your code the construct is that Prepack cannot handle just yet. Feel free to extract a smallish test case from your code and opening a more specific issue.

Prepack is quite limited in what it can do with abstract values

@hermanventer is there an example of what prepack can do? I tried a bunch of things and seems that it mostly either throws or ignores expressions with abstract values.

Abstract values can be passed through. I.e. they can be stored in the heap for use by the residual functions. When the heap is constructed by the prepack produced deserialization code, the real values will get stored in the heap.

Beyond that, simple expressions involving abstract values work and you can also use abstract values in (non loop) conditions.

I'm trying something like this:

__assumeDataProperty(global, "a", __abstract('number'));

(function() {
  if (a === 1) {
    console.log(a + 23)
  }
}())

What I get is:

(function () {
  var _0 = this;

  var _1 = _0.a;

  if (_0.a !== _1) { // Not sure what this is, but seems like a bug
    throw new Error("Prepack model invariant violation: " + _0.a);
  }

  if (_1 === 1) {
    console.log(_1 + 23); // I would expect this to be folded
  }
}).call(this);

I created #610 to track the issue with the meaningless invariant. The opportunity to do constant folding is there indeed, but goes way beyond what Prepack can do today. #597 describes a path to that future. In any case, closing this issue as the original question isn't actionable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NTillmann picture NTillmann  路  3Comments

vojtechkral picture vojtechkral  路  5Comments

kabirbaidhya picture kabirbaidhya  路  6Comments

bevacqua picture bevacqua  路  8Comments

NTillmann picture NTillmann  路  8Comments