Summary:
Release notes: none
Whilst working on adding React Native mocks, I ran into cases where context should be inlining but it wasn't. It now is inlining far better, with more test coverage. Furthermore, we now have a new config flag to pass to `__optimizeReactComponentTree`, in the case of `isRoot` to state that the tree is a root component tree (rather than a a branch of another tree).
Closes https://github.com/facebook/prepack/pull/2098
Differential Revision: D8348381
Pulled By: trueadm
fbshipit-source-id: 5e01bd77437e8bc3d1f22ff47d668897152203a0
Summary:
Turns out os.cpus() can return [] and undefined.
Additionally, it seems to me like any number below 4 could lead to an empty pool so I tried to address that too.
Reviewed By: NTillmann
Differential Revision: D8332896
fbshipit-source-id: 60e082a4f0d18e72f95b76732a50adeccb2d333d
Summary:
Release note: none
Effects objects are currently stateful: If you apply the effects it becomes an undo map and if you undo the effects, it becomes a redo map.
In most situations this is just fine since apply and undo are usually nicely paired. In some situations, however, we end up applying or undoing the same effects object twice in a row. This causes issues that are extremely hard to debug. I've tried to purge the code base of all such cases, but they just keep coming up. In essence, I am trying to maintain a very subtle invariant that is quite hard to check and I am failing.
I now give up on this invariant and am making Effects into an object that is immutable except when being constructed incrementally. This is the first step towards that.
Closes https://github.com/facebook/prepack/pull/2099
Differential Revision: D8334815
Pulled By: hermanventer
fbshipit-source-id: ab508ed6c6c42969c8fda842fa20b55f7773c2cc
Summary:
The code didn't work without it sometimes because conceptually all code outside of `getTrials` is an isolated "bundle". We can only access its internals through the `Root` reference. This fixes the tests to follow this constraint and removes the hack.
Closes https://github.com/facebook/prepack/pull/2102
Differential Revision: D8333634
Pulled By: gaearon
fbshipit-source-id: 1fb24751490042beae55a133f64351a9be9f903c
Summary:
Release note: Migrate to CircleCI 2.0
Hey everyone,
If you don't know, CircleCI 1.0 [is being EOL'd](https://circleci.com/blog/sunsetting-1-0/) at the end of August. I noticed that this project uses CircleCI 1.0 and so in the spirit of open source I wanted to submit a PR to do the migration.
The **TL:DR;** of this PR is that it converts the CircleCI 1.0 configuration file into the equivalent CircleCI 2.0 configuration file. I'd say that the new config file is 99% the same software-wise. Here's the two changes:
- the Yarn version was bumped from v1.1.0 to the current version on the Docker Library Node images, which is v1.3.
- I split the running of tests and checks from a single, sequential build into 3 separate jobs.
For that latter point, I noticed that if you averaged the CircleCI 1.0 build time for this project for the last 3 passing `master` builds, the average build time is **32m 49s**. I ran this PR on CircleCI 2.0 and the average build time for the last 3 passing builds is **13m 22s**.
Basically, this PR allows this project to migrate to CircleCI 2.0 before the August 2018 EOL of 1.0 as well as decrease build times by 49%.
I'm happy to answer any questions or help with any tweaks to get this PR merged if you choose to do so.
Closes https://github.com/facebook/prepack/pull/2094
Differential Revision: D8324655
Pulled By: NTillmann
fbshipit-source-id: 239410c21fa035923ffb81f53d094c542837ab77
Summary:
There is a case when prepack emits non-computed member expressions in `rebuildObjectProperty` for properties which cannot be used this way. This PR is to fix#2084 .
Closes https://github.com/facebook/prepack/pull/2093
Differential Revision: D8319018
Pulled By: hotsnr
fbshipit-source-id: a27b943b541f6210d44c1e9a5887915eec5c6359
Summary:
A quick fix to make prepack not crash with the new switch statement structure of the bundle.
This is a dup of D8269827, which, for some reason, `jf get` failed to import.
Reviewed By: NTillmann
Differential Revision: D8298075
fbshipit-source-id: 4572bfd918e73e5bf95fde736e9daf44f15d5de8
Summary: Drop eslint-plugin-babel because the plugin doesn't appear to be used at all in this project.
Reviewed By: mjesun
Differential Revision: D8298145
fbshipit-source-id: 4c81abc838cdc6619e8f900d032057ec7008c623
Summary:
@public
Bump Prettier to use version 1.13.4
All code changes are caused by running Prettier and should only affect files that have an `format` header.
All other changes caused by yarn.
Reviewed By: ryanmce
Differential Revision: D8251255
fbshipit-source-id: 0b4445c35f1269d72730f2000002a27c1bc35914
Summary:
Release notes: none
This fixes an issue where `createDefaultPropsHelper` gets created in a branch of effects, and is cached on the `realm`. Instead `createDefaultPropsHelper` should get created during the init phase, so the function is accessible throughout the entire lifecycle of the realm.
Closes https://github.com/facebook/prepack/pull/2087
Differential Revision: D8290010
Pulled By: trueadm
fbshipit-source-id: 324035cdd3c8a951c44849e1ccbfca9798a551b0
Summary:
Release note: none
Rewrite joinPossiblyNormalCompletions to be much simpler and to not do any rotations.
There are some bug fixes to come that will need this. I'm breaking this out separately to make it more understandable.
Closes https://github.com/facebook/prepack/pull/2086
Differential Revision: D8288110
Pulled By: hermanventer
fbshipit-source-id: 66cc7ac3b578100daaf84a659cde0024ddae5b66
Summary:
Release note: none
This is a mechanical rename refactor and dead/redundant code deletion that makes no semantic changes.
Closes https://github.com/facebook/prepack/pull/2076
Differential Revision: D8267651
Pulled By: hermanventer
fbshipit-source-id: b47cf58202135c8af9c0701921889469280b2a08
Summary:
Release Notes: Implemented step out feature in debugger
Changes are inspired by 994daf7924
Started a test/debugger directory for debugger tests. Currently just aggregating test cases in there until I have time to write a debugger specific test runner.
Closes https://github.com/facebook/prepack/pull/2062
Differential Revision: D8266175
Pulled By: caiismyname
fbshipit-source-id: 2da775ac23ac09800565f21d2e62d68864009e5a
Summary:
For reference, the commit with the release version can be seen here: 7e9e713b3a
Closes https://github.com/facebook/prepack/pull/2079
Differential Revision: D8248778
Pulled By: sb98052
fbshipit-source-id: 3f6533e8e083adfb0b964a5d4e7657964f93da96
Summary:
Fixing some incompatibility between heapGraph and `__optimize()`.
Essence of the issue was an implicit assumption that only one visitor would visit certain entries.
Original Issue: https://github.com/facebook/prepack/issues/1732
Closes https://github.com/facebook/prepack/pull/2021
Reviewed By: trueadm
Differential Revision: D8248761
Pulled By: caiismyname
fbshipit-source-id: dd27487b490e3924fdc0fe6aaca7f1c103e137cb
Summary:
Release notes: fixes a range of spread bugs with ReactElements
This is a very important PR for React reconciliation, it fixes many undiscovered bugs and adds a huge amount of test coverage that was previously missing.
Whilst testing quite complex cases of JSX spreads in combination with defaultProps on our internal bundle I noticed that there were some bugs appearing, but because the branches where these bugs were appearing were not used on firstRender, it meant we got away with it on our internal tests.
We now use snapshotting and properly evaluateForEffects when recovering from `Object.assign` with ReactElement creation of config/props. We also properly use the `temporalAlias` to ensure we reference the correct object.
Closes https://github.com/facebook/prepack/pull/2070
Differential Revision: D8243793
Pulled By: trueadm
fbshipit-source-id: e8c37aa6750c0a6d41f12249d8872004da3ab3a6
Summary:
Release note: none
Quite a few of the outstanding issues arise because generators are either deleted or duplicated. After spending much time debugging such issues, I've realized that the code is not making a clear distinction between forking and joining and as a result we sometimes join when we should fork and this leads to problems.
I'm now systematically going through all the methods in Join and making sure they do the right thing in a less mysterious way. The subject of this pull request is method joinPossiblyNormalCompletionWithAbruptCompletion. The result of this method should be a just a fork because a join may not be required or desirable. The name is thus not helpful and so I've renamed it to replacePossiblyNormalCompletionWithForkedAbruptCompletion.
This broke some use cases that require the result to be joined. They had to be rewritten to use extractAndJoinCompletionsOfType to join just those parts of the fork that actually join at those code constructs.
While debugging the tests that inevitably broke while making these changes, a few other issues were uncovered that are also fixed in this PR. One of them involves specializing the result value of the abrupt completion that is being spliced into possibly normal completion (because a join is being composed into a fork).
Closes https://github.com/facebook/prepack/pull/2074
Differential Revision: D8244536
Pulled By: hermanventer
fbshipit-source-id: eded7e7233101ad5c288cd8730bf6fd3cbf82904
Summary:
Release note: Rename refactor make it clearer that forks are not joins
Mechanical refactor to help with future documentation.
To come in a future PR: making sure forks are not joined except by means of extractAndJoinCompletionsOfType.
Closes https://github.com/facebook/prepack/pull/2063
Differential Revision: D8226967
Pulled By: hermanventer
fbshipit-source-id: 9c6d6cb300a82ae0f7c26284ee4a60ae6edebd03
Summary:
Release notes:
This PR is a follow up to https://github.com/facebook/prepack/pull/2051, which we found to have issues and had to be reverted. The main cause of the issue in the previous PR was that `realm.evaluateWithAbstractConditional` was being given a `ReturnCompletion`, which are a type of `AbruptCompletion`. There is logic to correctly throw such completions. So instead of passing a `ReturnCompletion` to `realm.evaluateWithAbstractConditional`, we instead pass the value and then wrap the `realm.evaluateWithAbstractConditional` call with a function that adds back on the `ReturnCompletion`.
Fixing this brought about a bunch of deeper issues that were causing tests to fail (regression tests added) around the unknown array and its prototype methods. We were only handling a handful of methods before, but that was fragile. So this PR now adds support for all the of current prototype methods on `Array` for unknown arrays – following the spec as to what the return value should be in each case.
Finally, a change was made to the React reconciler to ensure that we return the unknown array in cases where it is passed an unknown array without a ReactHint (which is expected, but was missed and thus a regression from a previous PR).
Closes https://github.com/facebook/prepack/pull/2061
Differential Revision: D8229848
Pulled By: trueadm
fbshipit-source-id: 02dbd1c7e1cd03de4f6745daed57d13ea24537a8
Summary:
Release Notes: none
I made more files flow strict, to move forward on https://github.com/facebook/prepack/issues/1941.
I'm using `/* flow strict-local */` to avoid the problem with importing non-strict files for now.
I created a small utility to check for an undefined type or null value, but am wondering if it is a bit pointless. Would like some feedback on that. Thanks!
Closes https://github.com/facebook/prepack/pull/2048
Differential Revision: D8225232
Pulled By: hermanventer
fbshipit-source-id: b4d29d170722a6652f0c3428949b296273a9d953
Summary:
Since #1837 and #1848 got fixed at some point, this adds tests to verify they don't regress.
Closes https://github.com/facebook/prepack/pull/2066
Differential Revision: D8221658
Pulled By: gaearon
fbshipit-source-id: a31fc733964ae697252225993b813e8d5a445ed1
Summary:
Release notes: none
When in strict mode, emitting property assignments to a frozen object (ReactElement in this case) causes a runtime error. We shouldn't be emitting ReactElement properties when we havoc the object. Unfortunately, we can't do this to all final objects, because our internal snapshot test fails when doing this (because the final object has properties that are conditional and thus delayed, so we need all its bindings to be "flushed" at the point of havocing). As a more thorough future fix, we should probably add a separate codepath for serializing objects that are final (we delay the entire object being emitted until all its properties are ready, like the ReactElement serializer does).
Interestingly, the output contains an unused variable that should be removed NTillmann?
```js
var _0 = function (props, context) {
"use strict";
var _J = props;
var _$0 = _J.b;
var _1 = _$0 !== null;
if (_1) {
var _$1 = _J.b;
var _$2 = _$1.x;
var _5 = _$2 !== null;
if (_5) {
var _$3 = _J.b;
var _$4 = _$3.x;
}
}
var _$5 = _J.c;
var _$6 = _J.someAbstractFunction;
var _A = _1 ? _5 ? _$4 : null : null;
var _8 = { // <-- why has this not been removed? can we not mark the entry as "pure"
a: 1,
b: _A,
c: _$5
};
_8.a = 1;
_8.b = _A;
_8.c = _$5;
var _F = <div a={1} b={_A} c={_$5} />;
var _$7 = props.someAbstractFunction(_F);
return _F;
};
```
Closes https://github.com/facebook/prepack/pull/2065
Differential Revision: D8221498
Pulled By: trueadm
fbshipit-source-id: e508cba2e930bec9c913efae3c653637671098c6
Summary:
Release note: none
joinPossiblyNormalCompletionWithAbruptCompletion said that it always returned effects with completions of type JoinedAbruptCompletions. Some callers took it at is word. Turns out it was lying.
Fixed things so that the advertising is correct. Also fixed an issue with a generator being lost during joining. (This was a latent bug uncovered by this fix.)
Refactored the code that fails when a loop body contains both break and continue completions governed by abstract conditions.
Closes https://github.com/facebook/prepack/pull/2030
Reviewed By: trueadm
Differential Revision: D8188966
Pulled By: gaearon
fbshipit-source-id: 7b74d63ee34b6492614a4386e6ad7955c96cbf78
Summary:
Release notes: Improvements towards fully supporting havocing object property bindings.
This fixes#2013 and fixes#2017.
There are varios TODOs in the new code; whatever didn't violate any existing tests throws a FatalError,
while the other cases still silently do the wrong thing.
Once this PR lands, I'll file issues for the various TODOs which can then be worked on separately.
In any case, the changes in this PR are strictly making things better.
Adding regression tests from the fixed issues.
Closes https://github.com/facebook/prepack/pull/2023
Reviewed By: trueadm
Differential Revision: D8174176
Pulled By: NTillmann
fbshipit-source-id: 299af8546ea7474a67fc0d75ce6ad8649b060db7
Summary:
Release notes: adds `reactOptimizeNestedFunctions` flag to enable nested optimized functions from React components
This PR adds output for components that fail to inline (during evaluation process) and adds a flag so we can enable/disable nested optimized functions in React components (from things like unknown array map functions).
Closes https://github.com/facebook/prepack/pull/2054
Differential Revision: D8202653
Pulled By: trueadm
fbshipit-source-id: 9ea95720e5296e602068ca4fe111ab303b8b24fc
Summary:
Release notes: none
This PR is a general spring cleaning of all the React logic. Nothing is fixed, but the logic for many of the aspects of the React reconciliation have been simplified and tidied up.
- I've removed all cases of mutating ReactElements, we now create new ReactElements instead of mutating – because, well, ReactElements are immutable (as are props).
- Removed ReactSerializerState and moved the logic that previous existed into `realm.react`.
- Simplified the branching logic of the reconciler so we no longer need to pass around state and instead use the existing conditional logic.
Manually tested on all our internal bundles are we have no failures.
Closes https://github.com/facebook/prepack/pull/2039
Reviewed By: gaearon
Differential Revision: D8205619
Pulled By: trueadm
fbshipit-source-id: a84c363038086b490d761dbe18711d617058f05c
Summary:
Release note: none
This PR remove `firstRenderOnly` from a bunch of tests that shouldn't have had it and adds a new test for a big with `props` being incorrectly marked for `refuseSerialization` – `props` can be serialialized without the ReactElement, and the test shows how this might happen.
Closes https://github.com/facebook/prepack/pull/2057
Differential Revision: D8203483
Pulled By: gaearon
fbshipit-source-id: fbfb9cc3bbdadaba5884f87319cb5b54e4a0657a
Summary: It caused some regressions but we're not sure why. Need to increase test coverage first. Reverting for now.
Reviewed By: trueadm
Differential Revision: D8205062
fbshipit-source-id: fe03f8ea9e8c3d85b3ce96912c5135019f407a56
Summary:
Release notes: support call expressions where the base might be an abstract conditional
This PR is a follow up on a TODO I left in last week. We currently don't fully use the power of Prepack around abstract conditional function calls. This adds support for them when calling NativeFunctionValues. For example:
```js
function fn(a) {
var array = (a === null ? [1,2,3] : [4,5,6]);
return array.join("-");
}
global.__optimize && __optimize(fn);
```
Now becomes:
```js
var _1 = function (a) {
return a === null ? "1-2-3" : "4-5-6";
};
```
Beforehand, it compiled to:
```js
var _1 = function (a) {
var _$0 = (a === null ? [1, 2, 3] : [4, 5, 6]).join("-");
return _$0;
};
```
Closes https://github.com/facebook/prepack/pull/2051
Differential Revision: D8201793
Pulled By: trueadm
fbshipit-source-id: c9a570ef9da844d84d0d5548b5c2d7b600dd4226
Summary:
Release note: none
Fix lint errors that came our way via an internal check in.
Closes https://github.com/facebook/prepack/pull/2052
Differential Revision: D8197681
Pulled By: hermanventer
fbshipit-source-id: fdc481228239dcc1eeafc904536188e25289162a
Summary:
Release note: Made ThrowCompletion constructor consistent with other completions
extractAndJoinCompletionsOfType assumes that all completions can be constructed by supplying only a value as parameter. ThrowCompletion needs to conform to this expectation.
This is a refactor towards some bug fixes where this matters. Test coverage will come with those fixes.
Closes https://github.com/facebook/prepack/pull/2050
Differential Revision: D8196790
Pulled By: hermanventer
fbshipit-source-id: d2eae166675d8835e8465b6db6f3856382dc59ba
Summary: This ensures failing output for Prepack gets proxied into the actual logs in terminal and Sandcastle. That was the case for Jest, but not for Prepack itself. This surfaces the real error in D8188966, for example.
Reviewed By: sophiebits
Differential Revision: D8191668
fbshipit-source-id: d0e3e9ddc1f7b38157fc57a010026de9bb0ec79a