Commit Graph

1576 Commits

Author SHA1 Message Date
Dominic Gannaway
608b6529c4 Fix for ReactElement temporals in React branches (#2597)
Summary:
Release notes: none

This fixes a React reconciliation bug where lazy ReactElement temporals were not correctly being put into the correct branches. Previously, `wrapReactElementInBranchOrReturnValue` was only called on the "result" of an `applyBranchedLogicValue` where it should have been applied after each ReactElement creation given that `applyBranchedLogicValue` is recursive.
Pull Request resolved: https://github.com/facebook/prepack/pull/2597

Differential Revision: D10298262

Pulled By: trueadm

fbshipit-source-id: 4868ab7f2514734913a626e4e7e7e3259e4199b5
2018-10-10 06:54:57 -07:00
Dominic Gannaway
224ca4a0d0 Adds createdAbstracts Set to effects/realm for tracking (#2593)
Summary:
Release notes: adds `createdAbstracts` `Set` to both `Effects` and `Realm`.

For a feature I'm working on, where we can optionally inline function calls depending on a bunch of pre-defined heuristics, I've run into the need for a feature for tracking abstract values. When we use `evaluateForEffects` we currently get quite a bit of information of what occurred, nicely packaged up in effects. One of those is `createdObjects`, which is super useful for many cases, but I believe we also need, is a way of knowing what `AbstractValue`s were created in effects too. This PR adds that functionality.
Pull Request resolved: https://github.com/facebook/prepack/pull/2593

Differential Revision: D10276125

Pulled By: trueadm

fbshipit-source-id: 299b0f91d93b1491987b10e769ca77f17e64716d
2018-10-09 15:38:37 -07:00
Chris Blappert
6347397ee2 Allow speculative module intialization to take file (#2590)
Summary:
Release Notes: `--initializeMoreModules` can take a JSON file of module ids to initialize

Allows testing this in `test-internal` with a new `.modules` file.

Also fixes ReproPackageManager to not exit prepack if a file can't be found while zipping a repro.
Pull Request resolved: https://github.com/facebook/prepack/pull/2590

Differential Revision: D10208977

Pulled By: cblappert

fbshipit-source-id: 7a5620f16829c39f2d8f936c6beb8b66e7c102be
2018-10-09 13:12:46 -07:00
Nikolai Tillmann
b942cd9635 Making peephole optimization in _getPropertyAssignmentStatement aware of implied conditions (#2592)
Summary:
Release notes: None

Added regression test.
Pull Request resolved: https://github.com/facebook/prepack/pull/2592

Differential Revision: D10227678

Pulled By: NTillmann

fbshipit-source-id: abeedaa43ce688fa9cb4ea095b3d7180a545fba5
2018-10-05 17:25:56 -07:00
Nikolai Tillmann
5828c0a666 Disable generation of .bind() calls instead of wrapper functions (#2577)
Summary:
Release notes: None

Large internal benchmarks triggered a bug with this optimization.
Pull Request resolved: https://github.com/facebook/prepack/pull/2577

Differential Revision: D10226968

Pulled By: NTillmann

fbshipit-source-id: bc5c962f9e45913d0844ad12321a2ff68eb71d44
2018-10-05 16:56:45 -07:00
Sapan Bhatia
31697d5de0 Support optimized Array.filter and make filter-map compositions correct (#2582)
Summary:
Adds optimized operator support for `Array.filter`, and makes compositions in which `Array.filter` is called on a mapped array correct. Aliasing information kept in the mapped array is exposed to the `Array.filter` call, which collects it in the resulting array.

Resolves #2580
Pull Request resolved: https://github.com/facebook/prepack/pull/2582

Differential Revision: D10204091

Pulled By: sb98052

fbshipit-source-id: a365d3d7120cbae344c64c540e5b63a889b6c699
2018-10-04 14:19:03 -07:00
Dan Abramov
8ca388ab0e New weekly branch: 0.2.55-alpha.0
Summary: 0.2.55-alpha.0

Reviewed By: trueadm

Differential Revision: D10191871

fbshipit-source-id: 27fcfbc607c0f92761495c241ded23dd16e92476
2018-10-04 08:10:02 -07:00
Dan Abramov
8c92608360 Weekly release v0.2.54
Summary:
* Fix referentialization of optimized functions
* Fix serialization issues for nested optimized functions
* Model aliasing effects for array loop operators
* Fix dependency issues with cyclic prototype dependencies
* Fix problem where a bind call can use a variable before its definition
* Speed up visitor by skipping redundant generator scopes

Reviewed By: trueadm

Differential Revision: D10191866

fbshipit-source-id: 669d6c7a49f10f3222c3dd56537e0f76a4e9d2c6
2018-10-04 08:10:00 -07:00
Dominic Gannaway
1f5664ff15 Adds RCTActivityIndicatorView literal reference (#2588)
Summary:
Release notes: none

When testing our internal React Native bundle, we need to supply a string reference to `RCTActivityIndicatorView` for JSX elements.
Pull Request resolved: https://github.com/facebook/prepack/pull/2588

Differential Revision: D10193281

Pulled By: trueadm

fbshipit-source-id: ce7785d9c71ea4c278118e08c1438dbb5259f8b8
2018-10-04 06:39:47 -07:00
Chris Blappert
473470a9a5 Filter ModifiedBindings by environment's creating optimized function (#2551)
Summary:
Release Notes: None

Changes the logic for determining which ModifiedBindings need serialization to work properly in the face of nested optimized functions. We should only serialize `ModifiedBinding`s if their environment was not created by the optimized function or its children (i.e. the binding should not be local to the optimized function).

This also solves the issue that React components don't have a parent chain which is important for properly handling nested optimized functions. Solves #2550.

Solves #2430, Solves #2426, Solves #2423, Solves #2422 (some were solved by previous PRs, just adding the tests here as well).
Pull Request resolved: https://github.com/facebook/prepack/pull/2551

Differential Revision: D10010048

Pulled By: cblappert

fbshipit-source-id: 2a855017514832a70d024f1ae9a91e9f07736ce0
2018-10-03 11:25:04 -07:00
Dominic Gannaway
7f0c13a680 Fixes a bug in evaluatePure (#2585)
Summary:
Release notes: none

When working on a separate issue that involved touching `evaluatePure`, I ran into a bug where `createdObjectsTrackedForLeaks` were not being populated by any objects returned from nested `evalautePure` calls. This fixes it and adds a helper function to `__evaluatePureFunction ` for testing this.
Pull Request resolved: https://github.com/facebook/prepack/pull/2585

Differential Revision: D10162545

Pulled By: trueadm

fbshipit-source-id: a2fcdcf19545a036aa5fbd003ea0929722ab7bde
2018-10-03 07:39:42 -07:00
Sapan Bhatia
ffd230e4d5 Model aliasing effects for array loop operators (#2570)
Summary:
This PR guarantees the correctness of optimized `Array.map` operators, even in the face of aliasing effects. It does four things:

1. Trigger generic leaking if an array operator is re-specialized in the non-Instant Render use case.
2. Tracks aliasing effects created by specialized operators, and triggers leaking or materialization when needed to ensure correct behavior
3. Deactivates immediate transitive materialization following the use of specialized operators, instead deferring this to the leaking implementation. The leaking implementation reaches aliased objects via a new arg added to widened numeric arrays. The arg is an abstract value of kind "mayAliasSet" that is set to top, but whose may alias set is tracked. If leaking does not happen, then materialization is avoided.
4. It permits benign mutations in Instant Render, where the mutations do not cause references to non-final snapshots of the object.

Follow up:
- Model aliasing effects losslessly via widened objects: #2569
- Add support for `filter` and `reduce`

Resolves #2449
Pull Request resolved: https://github.com/facebook/prepack/pull/2570

Differential Revision: D10149117

Pulled By: sb98052

fbshipit-source-id: eb686982574c8ef868934472903c405f3d63bbed
2018-10-02 12:39:46 -07:00
Dominic Gannaway
4f250d11e1 Remove side-effects from react-mocks (#2584)
Summary:
Release notes: none

Some internal changes to the `react-mocks` where side-effects were observed in small cases that needed tweaking (only affects internal React testing).
Pull Request resolved: https://github.com/facebook/prepack/pull/2584

Differential Revision: D10147064

Pulled By: trueadm

fbshipit-source-id: bb4c196ae6f03abdc1c2e39b27b740a21989b61f
2018-10-02 11:11:17 -07:00
Dominic Gannaway
5fc6feeeb2 Unify logic for checking for intrinsic objects that have been derived (#2581)
Summary:
Release notes: none

This PR cleans up some of the `onArrayWithWidenedNumericProperty` logic, making it more generic for cases where we want to use concrete derived object values. Furthermore, it strengthens the validation process by checking for existence of `isScopedTemplate` on the internal object.
Pull Request resolved: https://github.com/facebook/prepack/pull/2581

Differential Revision: D10141954

Pulled By: trueadm

fbshipit-source-id: 8de828080b8a41357830cdbf7e49359512bc7244
2018-10-02 03:41:39 -07:00
Dominic Gannaway
ed784d6899 Add abstract support to Object.getOwnPropertySymbols (#2575)
Summary:
Release notes: none

Fixes https://github.com/facebook/prepack/issues/2574. This PR adds abstract value support to `Object.getOwnPropertySymbols` like we have done other internal methods (like `Object.keys` and `Array.from`) where we know the internal method creates an array with unknown numeric properties.
Pull Request resolved: https://github.com/facebook/prepack/pull/2575

Differential Revision: D10114237

Pulled By: trueadm

fbshipit-source-id: 07301147e2dff1ab370243a8dc9648745bbbbb96
2018-09-28 16:11:27 -07:00
Chris Blappert
0ef3c43563 Change initializeMoreModules to modulesToInitialize allowing you to s… (#2576)
Summary:
…pecify modules

Release Notes: None

Sometimes it'll be useful to allow the user to specify which specific modules you want to speculatively execute. This allows that by turning `--initializeMoreModules` into `--modulesToInitialize <ALL | comma separated list of modules>`

Updated tests as well.
Pull Request resolved: https://github.com/facebook/prepack/pull/2576

Differential Revision: D10092554

Pulled By: cblappert

fbshipit-source-id: bf601e14c2be59c865ae9513c914f39325521945
2018-09-27 15:10:17 -07:00
Dominic Gannaway
47cb48b438 Adds support for abstract length arrays in React reconcilation and serialization (#2571)
Summary:
Release notes: none

This PR fixes issues with the React hoisting and equivalence system mechanics and serialization where previous, there was no support for abstract length arrays. This includes an optimization for when the React serializer outputs ReactElement children that are conditionals with one side being an empty value (in this case, we can use an empty string instead).

Tests attached that focus on the areas covered in this PR.
Pull Request resolved: https://github.com/facebook/prepack/pull/2571

Differential Revision: D10082133

Pulled By: trueadm

fbshipit-source-id: d7de1834e10a5c4b3f35a90b9676ec72c6e797e2
2018-09-27 00:50:24 -07:00
Sapan Bhatia
9681e2eeee Expand x==null using a disjunction (#2572)
Summary:
Fixes #2563, #2564
Pull Request resolved: https://github.com/facebook/prepack/pull/2572

Differential Revision: D10027955

Pulled By: sb98052

fbshipit-source-id: 4023e3c32362cb95f477d4d990dd9b8edb5a963c
2018-09-25 06:25:02 -07:00
Nikolai Tillmann
7f3b5d4caf Make sure all optimized functions are included in IR dumping (#2568)
Summary:
Release notes: None

Dumping happened before `processCollectedNestedOptimizedFunctions`,
which caused them to not be included. This is being fixed, plus some
minor refactoring to hide implementation details.
Pull Request resolved: https://github.com/facebook/prepack/pull/2568

Differential Revision: D10023363

Pulled By: NTillmann

fbshipit-source-id: 6abe2b5358f23705b501fc818536fb30d42a3b17
2018-09-24 19:33:51 -07:00
Dominic Gannaway
0e52d02190 Adds React pe-functional-components benchmark and some React SSR changes (#2560)
Summary:
Release notes: none

All these changes are only internal changes related to React.

This PR adds the `pe-functional-components` benchmark as tests to the React reconciler. The test was taken from: https://github.com/facebook/react/tree/master/scripts/bench/benchmarks/pe-functional-components.

In order to make the server side renderer test pass, a few TODOs had to be filled in (logic was missing) and the JSON logic has to be updated to account for empty strings in children that the compiler merges.
Pull Request resolved: https://github.com/facebook/prepack/pull/2560

Differential Revision: D10008375

Pulled By: trueadm

fbshipit-source-id: 3b39a3e6387e23e17532a2343bd84ebebb7ee9cd
2018-09-24 03:56:52 -07:00
Nikolai Tillmann
465b8defba Speeding up visitor by skipping redundant generator scopes (#2562)
Summary:
Release notes: None

There's no need to re-visit deep value chains in nested generators,
if a value was already visited in a parent generator.
This greatly speeds up certain internal RN scenarios.
Pull Request resolved: https://github.com/facebook/prepack/pull/2562

Differential Revision: D10001612

Pulled By: NTillmann

fbshipit-source-id: a4f66b1a4835121cef4e3bc424f507f5b2c843f9
2018-09-21 19:11:06 -07:00
Chris Blappert
d3ca583d46 Bump flow version (#2557)
Summary:
Release Notes: None

Bump flow version to newest version to stop Nuclide and `yarn flow` from fighting locally.
Pull Request resolved: https://github.com/facebook/prepack/pull/2557

Reviewed By: QueryConnectionException

Differential Revision: D9952840

Pulled By: cblappert

fbshipit-source-id: 2b52c04abd79a645b772c3a45d6ec81c831a27d3
2018-09-20 13:58:44 -07:00
Nikolai Tillmann
4b911f2138 Refactoring of Generator DAG to Generator Tree. (#2434)
Summary:
Release notes: None

To avoid all kinds of serialization issues, generators should form
a tree, and not a DAG. This is an attempt to establish that.
Pull Request resolved: https://github.com/facebook/prepack/pull/2434

Differential Revision: D9887684

Pulled By: NTillmann

fbshipit-source-id: c11c50c56dcd6eff02bd03448756bf79f6e2c820
2018-09-20 10:09:19 -07:00
Herman Venter
0dced15809 Fix problem where a bind call can use a variable before its definition (#2558)
Summary:
Release note: none

A large internal test case came up with a situation where an optimized function is rewritten with a version that early binds a yet to be declared value to one of its parameters.

This should probably never happen, so the if condition guarding this code path has been strengthened to prevent this.
Pull Request resolved: https://github.com/facebook/prepack/pull/2558

Reviewed By: trueadm

Differential Revision: D9967064

Pulled By: hermanventer

fbshipit-source-id: bf56872ea42ee8faefc347a6393cdcd9b3c518e9
2018-09-20 05:25:32 -07:00
Nikolai Tillmann
cd7cfb45c9 Fixing dependency issues with cyclic prototype dependencies. (#2556)
Summary:
Release notes: none

This fixes #2555.
We were waiting on the wrong thing in the serializer.
Adding regression tests.
Pull Request resolved: https://github.com/facebook/prepack/pull/2556

Differential Revision: D9949808

Pulled By: NTillmann

fbshipit-source-id: a4ef5ece8c5dab6fa579a20dbb35ce7bf794bfc0
2018-09-20 05:25:31 -07:00
Chris Blappert
feb0c2831f Attach Path Condition to Optimized Functions (#2537)
Summary:
Release Notes: None

Optimized functions will now be evaluated with the path condition at the time of function closure creation.

Resolves issue #2422
Pull Request resolved: https://github.com/facebook/prepack/pull/2537

Differential Revision: D9886282

Pulled By: cblappert

fbshipit-source-id: cae0282903d639ff0d94d0f4091c6f8ef9ef9a98
2018-09-19 18:11:38 -07:00
Chris Blappert
571dc330bb Fix referentialization of optimized functions (#2544)
Summary:
Release Notes: None

Before, during referentialization, we would always default to the global scope if the value was accessed in more than one optimized function scope. Now we look for the outermost optimized function.

This logic already existed in ResidualHeapSerializer, so I refactored it out into `serializer/utils.js`.

Fixes #2428
Pull Request resolved: https://github.com/facebook/prepack/pull/2544

Differential Revision: D9926077

Pulled By: cblappert

fbshipit-source-id: c4ee6c07c7409534e9be14df25b582078a7ec77c
2018-09-19 18:11:37 -07:00
Chris Blappert
48802fc106 New Prepack Alpha
Summary: New Prepack alpha v0.2.54-alpha.0

Reviewed By: gaearon

Differential Revision: D9927381

fbshipit-source-id: 7028459c6eafc38420579b8f656bed582a0a3dde
2018-09-19 17:04:39 -07:00
Chris Blappert
df84eff5bb New Prepack Version v0.2.53
Summary:
New Prepack version:
- Bugfixes
- User-level stack overflows no longer crash prepack
- Website shows warnings when Prepack produces diagnostics

Reviewed By: gaearon

Differential Revision: D9927380

fbshipit-source-id: 519d7f04b65228ba78d2febc5309492ff8315a4e
2018-09-19 17:04:36 -07:00
Sapan Bhatia
827146302a Helper to inspect values at a particular AST node (#2554)
Summary:
This is a helper for inspecting values at a particular node in the AST. E.g.

```js

let n = global.__abstract ? __abstract("number", "10") : 10;
let x = {foo:1};
let y = {foo:2};
let c = __abstract("boolean", "c");

let i = 0;
let obj = {};
do {
  i++;
  obj.j = i;
  obj.foo = c ? x : y;
} while (i < n);

__debugValue(obj);        // Breaks with obj in context

inspect = function() {
  return i + " " + obj.j;
};
```
Pull Request resolved: https://github.com/facebook/prepack/pull/2554

Differential Revision: D9922908

Pulled By: sb98052

fbshipit-source-id: dab9cae64a461283d8dec7f0bb7f8fae87a01c78
2018-09-18 13:55:33 -07:00
Caleb Meredith
a4620bd4bf Support constructor returning an unknown abstract value (#2535)
Summary:
The following test case currently fails:

```js
function F() {
  this.a = 1;
  this.b = 2;
  if (global.__abstract) return global.__abstract(undefined, "undefined");
}

const result = new F();

global.inspect = () => JSON.stringify(result);
```

We hit this bug in our internal React Native bundle. I only added support for `base` construction kinds since the template for `derived` construction kinds would get more complicated.
Pull Request resolved: https://github.com/facebook/prepack/pull/2535

Differential Revision: D9906309

Pulled By: trueadm

fbshipit-source-id: 49a71ceaf30a851075879295e63e98ce7e1bbe2d
2018-09-18 05:25:19 -07:00
Rafael Oleza
781cae5b38 Use caret to depend on Babel@7
Summary: Now that babel 7 is stable we can use caret as we use from other tools (like Metro). `yarn.lock will make sure it does not get updated until we want

Reviewed By: pvdz

Differential Revision: D9861594

fbshipit-source-id: 9d27d9c91f2b4e28d8a3c914e9b578eb9f0dc90e
2018-09-18 04:24:39 -07:00
Nikolai Tillmann
6b34650aed Fixing handling of stack overflows. (#2553)
Summary:
Release notes: User-level stack overflows no longer crash Prepack.

This fixes #2552, and actually a bit more:
- We used to piggy-back on `pushContext` to count stack frames. However, there is no one-to-one correspondance of calls and context, so that wasn't a very good proxy. (In fact, there seem to be calls that don't push a context.) So we now count calls and constructs explicitly.
- Instead of just throwing a `FatalError` when the stack space is exceeded, which in turn causes an invariant violation since there must not be a `FatalError` thrown without a compiler diagnostics having beein issue. Now there is a regular error code PP0045.

Added error handler regression test.
Pull Request resolved: https://github.com/facebook/prepack/pull/2553

Differential Revision: D9889090

Pulled By: NTillmann

fbshipit-source-id: f6f863ee9ef73f258692f215ef75b63b737f5394
2018-09-17 18:55:30 -07:00
Sapan Bhatia
2ad7ac2fe7 Enable and constrain optimized array operator support for InstantRender (#2547)
Summary:
This change ensures that the code generated via optimized array loop operators is correct in the InstantRender setting. It enables the optimization of such functions when the `--instantRender` option is set. Materialization is prevented by ensuring that post-optimization, objects that are reachable from the function are not mutated. Recoverable errors are issued. We also degrade all InstantRender bailouts to recoverable errors, to facilitate debugging. We add a constraint that optimized functions may not be reused.

Resolves #2451 #2448
Pull Request resolved: https://github.com/facebook/prepack/pull/2547

Differential Revision: D9816268

Pulled By: sb98052

fbshipit-source-id: 2112b199de50b80a7a9852a794c082be3bf122e9
2018-09-17 14:55:58 -07:00
Sapan Bhatia
47f6f4b495 Return correct recovery code for FatalError (#2548)
Summary:
In support of #2547. Sometimes, it is more desirable (less costly, better for debugging) to flag a warning for a possibly anomalous condition, than to assume that it is anomalous and enforce it as an error. This change exposes warnings that a user upgrades to errors, so that they can then be enforced as such.
Pull Request resolved: https://github.com/facebook/prepack/pull/2548

Differential Revision: D9884632

Pulled By: sb98052

fbshipit-source-id: c47b57a21aa047b0f3fa2672508f8fb23c04942a
2018-09-17 14:39:36 -07:00
Herman Venter
8ba4fbc916 Make sure that adding a path condition clears negative caches. (#2549)
Summary:
Release note: none

When a new path condition is added to an existing path conditions object, the negative caches must be cleared since the new condition might allow previously failed implications to now succeed. This was already done in one case, but a few others were missed. The clearing code is now centralized and all cases go through it.

While debugging the internal test case that failed because of the caching mistake, I also realized that PathConditions.implies and PathConditions.impliesNot can profitably deconstruct expressions of the form !x before doing the implication check. This also has the advantage that it eliminates a subtle endless recursion situation in a nicer way than the current code.

I've also added some comments in places that caught my eye during debugging.
Pull Request resolved: https://github.com/facebook/prepack/pull/2549

Differential Revision: D9883127

Pulled By: hermanventer

fbshipit-source-id: 06faa709dfecaa4f98b7d0ce5e1c7a9efb6b805f
2018-09-17 14:09:15 -07:00
Enzo Ferey
ee291d19dc Website code and warnings (#2528)
Summary:
cc NTillmann

Following up https://github.com/facebook/prepack/issues/2285, website shows the generated coded even when there are some warnings.

Lot of changes because prettier wasn't applied to the files, but I basically only checked for the error buffer containing only items with `severity === 'Warning'` and create the `warning` result type to behave the same than `success` one.

Next step would be to show the code AND warning messages. Either using the same display than error messages or creating a variation of it (changing text color to yellow for example). I can do it if you want.

Let me know if this is what you were looking for.

Have a nice day !

P.S: not sure if this PR was supposed to be into `gh-pages` or `master`. Let me know if that needs to be changed.
Pull Request resolved: https://github.com/facebook/prepack/pull/2528

Differential Revision: D9882040

Pulled By: NTillmann

fbshipit-source-id: bc8266a673e6def023bfa65b93b94ea9c7ad5b1d
2018-09-17 14:01:43 -07:00
Jeffrey Tan
1c1af96cf9 New alpha release
Summary: New alpha release

Reviewed By: sb98052

Differential Revision: D9831316

fbshipit-source-id: 8fdb5c1c36037164cc62b74c94143c001da1f1fa
2018-09-14 11:40:35 -07:00
Jeffrey Tan
9738707e08 Weekly release 0.2.52
Summary:
* Let prepack CLI fail in the presence of recoverable errors.
* providing __replaceFunctionImplementation_unsafe built-in
* Substitute `v8-profiler` with `v8-profiler-node8`
* Fixes invariant violation regression when using webpack-prepack-plugin

Reviewed By: sb98052

Differential Revision: D9831305

fbshipit-source-id: c0ec1f199d8baa462bcbfe0c6aac379a4774c987
2018-09-14 11:40:35 -07:00
Chris Blappert
c210fc7d9b Eliminate child-parent read-write conflict errors (#2542)
Summary:
Release Notes: None

This PR makes it so we no longer report conflicts for child optimized functions reading from values that their parents have written.

Couple of things for discussion:
- This creates somewhat confusing behavior because the child functions will take the concrete value after the parent functions' effects have been applied:
```javascript
(function () {
    let obj = {p: 42};
    function f() {
        obj.p += 3;
        function g() { return obj.p; } // Will optimize to `return 47;`
        obj.p += 1;
        __optimize(g);
        obj.p += 1;
        return g;
    }
    __optimize(f);
    global.f = f;
})();
```
- This PR creates the Parent/Child relationship based off `AdditionalFunctionEffects.parentAdditionalFunction` which goes off of syntactic nesting of functions instead of nesting of `__optimize` calls as in the issue. I believe basing the nesting off of `__optimize` calls could lead to somewhat unintuitive results (especially considering we store `parentAdditionalFunction` in `AdditionalFunctionEffects` to be the syntactic parent).

I am not sure if it is needed by Instant Render NTillmann? If it is, we may want to consider changing `AdditionalFunctionEffects.parentAdditionalFunction` to be based off of `__optimize` call nesting as well for consistency.

As an example a slight modification on the example above:
```javascript
(function () {
    let obj = {p: 42};
    function g() { return obj.p; }
    function f() {
        obj.p += 3;
        __optimize(g);
        obj.p += 1;
        return [g, obj];
    }
    __optimize(f);
    global.f = f;
})();
```
With this PR, we report an error. Based off of `__optimize` nesting, we would optimize `g` to `return 46;`. I would expect to see `return 42;` `return 45;` or `return obj.p;` in this case.

- To resolve the above issues, in the future, we could make any values modified by parent optimized functions into abstract values during evaluation for child optimized functions to force their accesses to be recorded in generators .

Resolves #2351
Pull Request resolved: https://github.com/facebook/prepack/pull/2542

Differential Revision: D9803741

Pulled By: cblappert

fbshipit-source-id: baca233c8de81633332b25f0776ed1a9d6c95a60
2018-09-12 17:24:48 -07:00
giftkugel
0b434790d3 Bad command-line for debugDiagnosticSeverity does not crashes Prepack anymore (#2545)
Summary:
This can be a possible fix for https://github.com/facebook/prepack/issues/2509

I have removed the `invariant` method call and added a value check as used for the _invariantMode_ option.

`node lib/prepack-cli.js --debugDiagnosticSeverity foo`

will now generate

`Unsupported debugDiagnosticSeverity: foo`
Pull Request resolved: https://github.com/facebook/prepack/pull/2545

Differential Revision: D9800485

Pulled By: hermanventer

fbshipit-source-id: edc24b4a812b4e32f9c48e05a0799bf4af431991
2018-09-12 15:31:13 -07:00
Nikolai Tillmann
1e1c03c533 Check invariant that path conditions no longer get mutated after being used as a base (#2538)
Summary:
Release notes: None

Otherwise, this could cause issues, as path conditions get captured e.g. in generators.
Pull Request resolved: https://github.com/facebook/prepack/pull/2538

Reviewed By: hermanventer

Differential Revision: D9762541

Pulled By: NTillmann

fbshipit-source-id: 4d12681e3921d2c0f10f3c9f3f0702823a2b0d99
2018-09-10 19:06:10 -07:00
Nikolai Tillmann
a973f896ac Fixing regression with default options. (#2541)
Summary:
Release notes: Fixes invariant violation regression when using webpack-prepack-plugin

This fixes #2540.
I didn't actually test it end-to-end webpack-prepack-plugin, would be great if someone could do that. We need some kind of end-to-end test for this to avoid regressions in the future.
Pull Request resolved: https://github.com/facebook/prepack/pull/2541

Differential Revision: D9756803

Pulled By: NTillmann

fbshipit-source-id: 2bded0dcb0a16369f3d3ff41c2f4d5181c75d67c
2018-09-10 14:27:33 -07:00
kdex
eef69b9463 Substitute v8-profiler with v8-profiler-node8 (#2525)
Summary:
This commit addresses issue #2520. In brief, `v8-profiler` fails to build on recent node versions.
Pull Request resolved: https://github.com/facebook/prepack/pull/2525

Reviewed By: hermanventer

Differential Revision: D9689106

Pulled By: NTillmann

fbshipit-source-id: 9169321bdc23dfbfdf24b50fe7885dab36c5322e
2018-09-07 16:39:23 -07:00
Nikolai Tillmann
59c7677b8c When encountering an internal error, make printing of diagnostics summary consistent with failing. (#2534)
Summary:
Release notes: None
Pull Request resolved: https://github.com/facebook/prepack/pull/2534

Differential Revision: D9729267

Pulled By: NTillmann

fbshipit-source-id: ea011056486447136dea4de8e44ead2192db4875
2018-09-07 15:55:54 -07:00
Herman Venter
2457103e19 Compose without tail duplication (#2523)
Summary:
Release note: none

Closes #2435
Closes #1829

Join.composeWithEffects composes a forked completion with subsequent effects. When two or more forks could end normally, this could result in shallow copies of the subsequent effects. These were then joined together and applied, so it was mostly OK. The generator of the subsequent effects, however, ended up being joined with itself and thus transformed the generator tree to a DAG, which is not desirable for the serializer.

The new approach is to extract a join condition from the forked completion and using it to join the subsequent effects with a newly constructed empty effects. The condition ensures that the subsequent effects are applied only in situations where the forked completion is not abrupt.
Extracting this condition makes for complicated abstract expressions and this uncovered some existing bugs and limitations that are also addressed in this pull request. As a side effect, path conditions are now longer and the time to compile unrolled loops with conditional abrupt completions inside their bodies has gone up so much that the unroll limit had to be lowered.

Please note that the expected output React tests has changed because of re-ordering. I'm none too sure that this re-ordering is necessarily benign, so please review carefully.
Pull Request resolved: https://github.com/facebook/prepack/pull/2523

Differential Revision: D9623729

Pulled By: hermanventer

fbshipit-source-id: 737096bba54a7a2ad300dc29882ea1b7829ac745
2018-09-06 21:55:22 -07:00
Nikolai Tillmann
1d4bd237d4 adding new __replaceFunctionImplementation_unsafe built-in (#2533)
Summary:
Release notes: providing __replaceFunctionImplementation_unsafe built-in

This new built-in allows replacing the method implementation (capture environment, body, ...) of source functions.

As a result, all method calls executed by the Prepack interpreter will be redirected,
and the replacement will carry over to the prepacked code.
Pull Request resolved: https://github.com/facebook/prepack/pull/2533

Reviewed By: hermanventer

Differential Revision: D9693654

Pulled By: NTillmann

fbshipit-source-id: bd28997965e641f58f89f7119fa477c535c0e539
2018-09-06 19:09:26 -07:00
Herman Venter
96174b5ebf Clean up implication logic and do more caching (#2530)
Summary:
Release note: none

This attempts to reduce exponential blowup in the simplifier by doing more caching while computing implications and by imposing a depth limit on the number of simplify and implies calls.

It also tries to make implies and impliesNot more symmetrical, so that things are less ad-hoc.
Pull Request resolved: https://github.com/facebook/prepack/pull/2530

Differential Revision: D9664026

Pulled By: hermanventer

fbshipit-source-id: f7a9135b06298a2b77ad05bf377982a9b37e4ad1
2018-09-06 15:26:24 -07:00
Nikolai Tillmann
f319df5d8c Let prepack CLI fail in the presence of recoverable errors. (#2522)
Summary:
Release notes: Let prepack CLI fail in the presence of recoverable errors.
Pull Request resolved: https://github.com/facebook/prepack/pull/2522

Reviewed By: trueadm

Differential Revision: D9615735

Pulled By: NTillmann

fbshipit-source-id: b90deb174b47f0b9b8886be41e7752eade99b916
2018-09-06 13:57:57 -07:00
Dominic Gannaway
4f0bce54c9 Fix reactFailOnUnsupportedSideEffects (#2532)
Summary:
Release notes: none

Fixes a bug where `reactFailOnUnsupportedSideEffects` should evaluate to `false` if passed as false. Also fixes a lint issue on `master`.
Pull Request resolved: https://github.com/facebook/prepack/pull/2532

Differential Revision: D9662462

Pulled By: trueadm

fbshipit-source-id: 1ffeea55e55a2bde9f1d44c64ac85d7e1b1727cf
2018-09-05 13:58:34 -07:00