Summary:
Release notes: opt out of optimizing a React component in a tree with `__doNotRender`
This PR makes it possible to opt out of a single component in a React component tree by detecting a `__doNotRender` flag. For example:
```js
function MyComponent(props) {
...
}
MyComponent.__doNotRender = true;
class MyComponent extends React.Component {
render() {
...
}
}
MyComponent.__doNotRender = true;
```
Closes https://github.com/facebook/prepack/pull/2004
Differential Revision: D8123009
Pulled By: trueadm
fbshipit-source-id: d5fc54aea2ea1253e260e41c1fb7d4f2d4717ffd
Summary:
Release notes: none
Do early return if both `left` and `right` values in `createFromConditionalOp` are equal. This improves performance quite a bit on some complex paths when running on our internal bundle.
Closes https://github.com/facebook/prepack/pull/2002
Differential Revision: D8117179
Pulled By: trueadm
fbshipit-source-id: c198d7270745447dba7c5523abc0907d693bcd45
Summary:
Release notes: none
This fixes an issue that we were experiencing, that turned out to be the correct fix after looking at https://github.com/facebook/prepack/pull/1997. We shouldn't mutate arrays in the reconciliation process, instead we should create new ones when we have new values. Also, we should ensure that we don't mutate ReactElements during reconciliation too, instead we should just create new ones. Mutating existing objects and values breaks down completely when we enter nested effects that need to re-evaluate the same original values, so this fixes a bunch of internal issues we were seeing on our internal FB bundle.
Closes https://github.com/facebook/prepack/pull/1999
Differential Revision: D8105499
Pulled By: trueadm
fbshipit-source-id: 4e6ceb8b02c886c42156a8903c347765f101c840
Summary:
This line that refers to a missing variable slipped though a previous commit.
Closes https://github.com/facebook/prepack/pull/1988
Reviewed By: trueadm
Differential Revision: D8105162
Pulled By: sb98052
fbshipit-source-id: 6e35b882f0af94c2acd8096f955bd9ab7275ed77
Summary:
Release notes: all serializer tests now get linted via ESlint for correct output
This PR is pretty gigantic, but almost 99% of it is changing all the serializer tests so they pass the linting rules – which means that there must be no undefined variables or if they are, they are explicitly accesses via `global`. Furthermore, the linting also checks to ensure that all variables are defined before they are used.
Also I added a regression test `conditions3` that further validates some complex cases I was seeing fail in other cases. The ESlint config is also in its own module so it can be shared between `debug-fb-www`.
Closes https://github.com/facebook/prepack/pull/1998
Differential Revision: D8099445
Pulled By: trueadm
fbshipit-source-id: 4a03c57beb51e394bc7b334728090b9fc515eca8
Summary:
Release notes: all globals emitted reference the global identifier
This is a PR to replace https://github.com/facebook/prepack/pull/1894 that fixes#1890. I found a much simpler fix was to ensure we always treat emitted globals as safe for strict mode regardless. I had to change a test that went against this assumption, but we end up with code that better conforms to strict mode without large changes under the hood to Prepack.
Closes https://github.com/facebook/prepack/pull/1911
Differential Revision: D8095772
Pulled By: trueadm
fbshipit-source-id: d4ed65ba8d52cdb0c8f2171d3f3c02bdd265c32d
Summary:
Release note: none
yarn install used to also invoke the build step. This changed a while ago, but this script was not updated accordingly. Apparently no-one noticed until now.
Closes https://github.com/facebook/prepack/pull/1990
Differential Revision: D8081630
Pulled By: hermanventer
fbshipit-source-id: 87a1f6b340010d27a76da39bb5569ffcb3f7a5b8
Summary:
Release notes: none
During React reconciliation, detect objects whose bindings have not been correctly applied with the right effects and trigger an invariant as this will result in broken output.
Closes https://github.com/facebook/prepack/pull/1992
Differential Revision: D8088640
Pulled By: trueadm
fbshipit-source-id: 36e9ec74a513643f638f02c88d86b86068adb14b
Summary:
Release note: none
When forking the normal branch of a PossiblyNormalCompletion into yet another PossiblyNormalCompletion, push the current effects onto a stack of effects, rather than just continuing to use the currently active effects. Not doing so, causes mismatched undo operations.
The modified test case would fail and print 2 for y, without this change.
Closes https://github.com/facebook/prepack/pull/1993
Differential Revision: D8087175
Pulled By: hermanventer
fbshipit-source-id: 6b857b9885aa79a8e90b90e365a2b9688a34152d
Summary:
Release notes: Support for --delayInitializations for optimized functions
Supporting this removes a TODO and is in response to #1973 (although more of a work-around than the actual fix).
Added tests.
Closes https://github.com/facebook/prepack/pull/1994
Differential Revision: D8087001
Pulled By: NTillmann
fbshipit-source-id: 572f41ffc024bef7954ebd88068f350fe08a84dc
Summary:
Release notes: none
This adds some code that was missed from https://github.com/facebook/prepack/pull/1970 in regards to getting the right target body for unknown array values. This fixes a bug internally that I was unable to repro.
Closes https://github.com/facebook/prepack/pull/1991
Differential Revision: D8083045
Pulled By: trueadm
fbshipit-source-id: e5d0152b98a7026ec73e960af925c7d07ef07d9d
Summary:
Release Notes: Fix abstract values not being coerced into strings for the Error constructor
Fixes#1827 NTillmann
The exact example from the issue now prepacks to
```javascript
(function () {
var _0 = function () {
return 42;
};
inspect = _0;
})();
```
I'm new here, so if this approach is completely wrong, please do notify me and guide me the way to a better one ;)
Closes https://github.com/facebook/prepack/pull/1960
Differential Revision: D8043199
Pulled By: NTillmann
fbshipit-source-id: 9c67fc2ab882398a20e6313b2894b5357b5ef038
Summary:
Support switch statements where the switch value is abstract and one or more cases throw.
Fixed bug with implicitly converting unknown values to Object.
The React reconciler now throw a FatalError upon encountering side-effects in a render.
Fix while and for loops with unlabeled breaks
Removing --simpleClosures option.
Improve code generation in presence of exceptions.
Default to StrictMode when mixed StrictMode is serialized between function entries.
Better debug logging with --debugScopes
Allocate by using `new Array(n)`.
Fix problems with duplicated and missing statements.
Do not generate code for unreachable global code statements.
Simplify the ToObject serialization output.
Serialization outputFixes an issue with getOwnPropertyDescriptor when dealing with a native prototype function.
More compact code generation by avoiding introducing local variables for abstract values when possible.
Fixes problem with result of Array.filter (and similar) applied to arrays with unknown properties.
Adds support for spread syntax.
Speeding up Prepack by 22%, saving 8% memory.
Add reading wiki link to places.
Make some files flow strict.
Better crash logging.
Provide error feedback when timing out.
Implement const/let pattern declarations.
Adds support for more console methods.
More simplification rules.
Stop the prototype cycle check if an object (e.g. proxy) uses non-ordinary prototype methods.
Fix numerous problems with code ordering.
issues fixed
Reviewed By: simonhj
Differential Revision: D8048481
fbshipit-source-id: 36a464feb74233f68f3476c74f4070103e6a2584
Summary:
Release notes: adds experimental `react-dom/server` ahead-of-time rendering to string
This PR was part of a small 1-2 day hackathton to see the applicability of creating a server-side renderer based almost entirely to be a 1:1 of `ReactDOMServer` from `react-dom/server` package. This is by no means a full, complete server renderer but is the foundations for us to do further work on this path in the future. Currently, it consists of a single Jest test, to ensure the output of the Hacker News benchmark matches that of the current ReactDOMServer `renderToString` output.
The performance results look very promising (there are some `console.time` lines you can comment out in the test to see the performance for yourself). This implantation essentially compiles away `react` and `react-dom/server` and instead injects runtime helper functions that do things that cannot be statically determined ahead of time.
Lots of features are missing behind `invariant` TODOs. This was done intentionally.
Closes https://github.com/facebook/prepack/pull/1940
Differential Revision: D8075964
Pulled By: trueadm
fbshipit-source-id: 33b3c7ba26b41871ccd15ad8bde4ad257009fed6
Summary:
Release notes: none
When we create an array with `CreateListFromArrayLike`, if the `elementTypes` parameter is left undefined, then skip the check that might throw an invariant if the passed in value is abstract.
Closes https://github.com/facebook/prepack/pull/1986
Differential Revision: D8071410
Pulled By: trueadm
fbshipit-source-id: f5944ecfc928fb9efe9120153e102faec9d5e2b6
Summary:
Release notes: none
This adds the `no-use-before-define` rule to `debug-fb-www` script. `variables` and `functions` are set to false, which allows them to be skipped if defined in a parent scope or if the function is in the same scope (as it gets hoisted), see: https://github.com/eslint/eslint/pull/7948/files. With our current internal bundle and latest master, this brings about a new error that wasn't previously emitted: `'_$Fg' was used before it was defined. (5525:15)`. Fixes https://github.com/facebook/prepack/issues/1982
Closes https://github.com/facebook/prepack/pull/1984
Differential Revision: D8055274
Pulled By: trueadm
fbshipit-source-id: 93a672dd22bce8cd798ebbb7ed90536a847f9ecb
Summary:
Release note: none
When debugging another issue, I noticed that member expressions do explicit conversions of abstract base objects to object and that call expressions obtain a temporal value for the function but then go ahead without it, leaving a useless assignment in the timeline.
Closes https://github.com/facebook/prepack/pull/1983
Reviewed By: trueadm
Differential Revision: D8055038
Pulled By: hermanventer
fbshipit-source-id: 4dd394bb0c4df2f9656be453b8feae57cc0db516
Summary:
Release notes: none
This PR fixes a bug where prototype methods on unknown arrays with widened numeric properties were incorrectly being used instead of following the route to filter which methods were safe or not. The functionality and logic for this was pulled out, into its own function so it can be re-used in places and tidied up.
Closes https://github.com/facebook/prepack/pull/1981
Differential Revision: D8043347
Pulled By: trueadm
fbshipit-source-id: 05415e5bdcb85818681a72323df16711a89f7c5c
Summary:
Release note: fix numerous problems with code ordering
Closes: #1914
We've been seeing an endless stream of bugs where code is either missing or in the wrong place. A lot of these were due to the complexity of joinEffectsAndPromoteNested and some more are due to a fundamental flaw in its algorithm: it rotates branches of the effects tree in order to group together all completions of a given type. That can cause generators to end up in the wrong place in the temporal sequence.
We also had a problem with generators being duplicated in the tree.
This pull request introduces a new algorithm for doing what joinEffectsAndPromoteNested does. This too is complicated and I spent days on debugging and fixing many subtle issues. So, for now, I'm only doing it for calls. More will come in later pull requests.
I am not super confident that I've found and addressed all subtle bugs. I think we can expect to run into quite a few more of those. I am, however, reasonably confident that we now have the right approach to dealing with abrupt control flow.
Please have a careful look, but let's get this landed as soon as possible because it is on the critical path.
Closes https://github.com/facebook/prepack/pull/1979
Differential Revision: D8044482
Pulled By: hermanventer
fbshipit-source-id: 317402c5601fdea7366c9daf7762af0217302b54
Summary:
When either name or msg of Error is abstract, we do not want to partially evaluate it because the checks on string emptiness can be overwhelming, and better done in the VM than in JS.
Added a test to check these cases.
(I messed up my previous pull request. Sending a new one here.)
Closes https://github.com/facebook/prepack/pull/1974
Differential Revision: D8028508
Pulled By: lxfind
fbshipit-source-id: 8e1d1f2151e0b08b519935387298d4ffcd579f9b
Summary:
This should resolve#415.
Relevant part of the spec here: https://www.ecma-international.org/ecma-262/6.0/#sec-let-and-const-declarations-runtime-semantics-evaluation
For `// 3. Let env be the running execution context’s LexicalEnvironment.`, I assumed that the `env` variable passed to the function already fulfills and it's not necessary to retrieve it here.
I've omitted the `ReturnIfAbrupt(Value)` steps from the spec, as this is also done for the rest of the implementation in this file.
test262 has one additional test pass as a result of this change, though somewhat surprisingly it's for `for`.
I've verified in the command line REPL that destructuring assignment works as expected in the basic case.
Closes https://github.com/facebook/prepack/pull/1967
Differential Revision: D8027013
Pulled By: NTillmann
fbshipit-source-id: 845527bcca55c845aca993fd2c97349efcbd5f59
Summary:
Release notes: none
This is a follow up to the changes in https://github.com/facebook/prepack/pull/1926. This PR correctly fixes the derived values for waiting and ensures that the unknown array objects have their dependencies properly resolved. This fixes part of the issue in https://github.com/facebook/prepack/issues/1962, but it brought about another issue that this PR doesn't aim to solve – dependencies on an abstract function call's unbound/bound bindings.
Closes https://github.com/facebook/prepack/pull/1970
Differential Revision: D8024402
Pulled By: trueadm
fbshipit-source-id: b9f9e725b7b22241209ef5a6f3b29dc0f2eeddeb
Summary:
Release notes: More simplification rules
The existing simplifier would never go into relational expressions
and distribute conditional expressions. It does now.
With this change, `AbstractValue.createFromBinaryOp` joins many other
value factory functions that may return non-abstract values.
This caused various changes downstream in types, and dealing with concrete
instead of abstract values.
Adding regression test.
Closes https://github.com/facebook/prepack/pull/1972
Differential Revision: D8023363
Pulled By: NTillmann
fbshipit-source-id: a3cd6f7752ba24d039c6085bec2ee93f7587af26
Summary:
Release notes: None
All other evaluate... functions are in Realm, so this is moving evaluateWithAbstractConditional there.
Closes https://github.com/facebook/prepack/pull/1971
Differential Revision: D8018543
Pulled By: NTillmann
fbshipit-source-id: 4690cd6b85e3c8e3c7afa82d8b18908c4b36b46c
Summary:
Release Note: none
this is to fix issue #1952 where the --timeout throws a fatal error without more information
Would need to add a new error number to the wiki, unless there is an existing one that I should use instead.
Closes https://github.com/facebook/prepack/pull/1966
Differential Revision: D8017667
Pulled By: NTillmann
fbshipit-source-id: 8978092c3d4b505463850a5598f5eeaabcbffe1b
Summary:
Release notes: None
Provide a more insightful way of logging rich abstract values
for debugging.
Closes https://github.com/facebook/prepack/pull/1964
Differential Revision: D8015093
Pulled By: NTillmann
fbshipit-source-id: 47d9b42470df79133e90f44fb1e23fd8bf40f254
Summary:
Release notes: none
This is a tidy up of the React reconciler and optimization code. I've removed the React logic from `serializer/functions.js` and put it all in its own module so that it's easier to debug and read the React specific code from generic Prepack optimization code. Furthermore, I took some time to rename `render` in reconciler to `resolve` as it's not actually doing any "rendering".
Closes https://github.com/facebook/prepack/pull/1968
Differential Revision: D8010381
Pulled By: trueadm
fbshipit-source-id: c61bdfec91f250f898d54623d92c20a545b965d7
Summary:
Release notes: adds support for more `console` methods
This adds all the other console methods that I could see on MDN.
Closes https://github.com/facebook/prepack/pull/1969
Differential Revision: D8009408
Pulled By: trueadm
fbshipit-source-id: cb75730f1b84e8b4812187a288c3eec0f3b7ef51
Summary:
Release notes: None
It used to bail out for conditional abstract values when accessing
a prototype that existed on neither side of the condition. No more.
Also, things used to be wrong in the presence of object prototypes.
That's also getting fixed.
Adding regression tests.
Closes https://github.com/facebook/prepack/pull/1963
Differential Revision: D8000539
Pulled By: NTillmann
fbshipit-source-id: 5214f213ea49c63e9637126360d3c90aace92d20
Summary:
Release notes: none
Two things are in this PR:
- The `setState` implementation now correctly assigns the state to a new object rather than mutating the existing state.
- The state object from React component is made final, like `props` are.
Closes https://github.com/facebook/prepack/pull/1961
Differential Revision: D7996744
Pulled By: trueadm
fbshipit-source-id: 10a4c9d735c146dff9ce87292344e9c9ccbf93d1
Summary:
Release notes: None
This fixes#1957.
Turns out that the special case is no longer needed, and just removing that code fixes the issue now.
Adding regression test.
Closes https://github.com/facebook/prepack/pull/1958
Differential Revision: D7995563
Pulled By: NTillmann
fbshipit-source-id: 6822c5433679fd88bd5a052ca23824cb3f3eabba
Summary:
Release note: Fixes problem with result of Array.filter (and similar) applied to arrays with unknown properties
Closes: #1924
Generator.deriveConcrete can result in temporal object values. These must be marked with _isScopedTemplate to prevent them from being hoisted.
Closes https://github.com/facebook/prepack/pull/1926
Reviewed By: trueadm
Differential Revision: D7949463
Pulled By: hermanventer
fbshipit-source-id: 2f15117725c37e9b09cae8ac469ee5b2eb481b6c
Summary:
Release notes: None
The `Object.freeze` command (or similar) was put into the body
where the object was allocated, not where it got initialized.
This would cause the initialization code to silently fail later on when the object was used for the first time.
This fixes it, and adds a regression test.
Closes https://github.com/facebook/prepack/pull/1936
Differential Revision: D7994911
Pulled By: NTillmann
fbshipit-source-id: 6ec0706357706f7bf80f62690be9aea1f30f8a72
Summary:
Release Note: none
Hi! I started trying to learn this codebase today and found this TODO from cblappert in `realm.js`:
aa700a2667/src/realm.js (L88)
Sounded like a good task to get into, so I went through the codebase and did the necessary replacements. If this wasn't the intent, please disregard this PR.
Closes https://github.com/facebook/prepack/pull/1943
Differential Revision: D7994498
Pulled By: hermanventer
fbshipit-source-id: 58292d4d0969408bdb03a2461b6edb9a47f4238f
Summary:
Followup to https://github.com/facebook/prepack/pull/1954 comments.
Also changes `IfStatement` to use `evaluateCompletion()` instead of `evaluate()` since presumably that was the original intent (?) If not then we should remove the `AbruptCompletion` check.
Closes https://github.com/facebook/prepack/pull/1956
Differential Revision: D7993877
Pulled By: gaearon
fbshipit-source-id: f3078da8fb7fadf1d1b6d03ff6375e2e0926ddd9
Summary:
Release notes: Speeding up Prepack by 22%, saving 8% memory.
This closes#1812.
This completely refactors the `ClosureRefReplacer` into a new
standalone `ResidualFunctionInstantiator`.
By avoiding babel-traverse, this visitor implementation is way faster.
Also, it only clones those nodes which are being changes, preserving all others,
insteading of cloning an entire function if any node needs to change; in this way,
memory is saved as well.
On a large internal benchmark (27MB minified JavaScript bundle with 31MB sourcemaps file), this change reduces overall time from 200s down to 157s: 22% faster. This due to savings during serialization, which goes down from 71s to 23s (while making the visitor 6s slower due to additional work).
Also, overall memory usage goes down from 3582MB to 3307MB, a 8% savings. Again, mostly due to savings in serialization, where surviving allocations going down from 337MB to 51MB, while slightly increasing allocations in the visitor.
Closes https://github.com/facebook/prepack/pull/1947
Differential Revision: D7990897
Pulled By: NTillmann
fbshipit-source-id: 93ffa0a06e75566db1d5564924c3f840cc2262df
Summary:
Corrected matching end tags div and p tags fixed
Closes https://github.com/facebook/prepack/pull/1907
Differential Revision: D7925198
Pulled By: NTillmann
fbshipit-source-id: b92c2dbaada71e9afdd0193692b1ec2e401999e4
Summary:
Release Note: none
I just wanted to add the reading links as suggested in #1887
arrived to the wiki from Twitter -> the issue -> to the Wiki :)
Let me know if you want the copy updated and shifted around anywhere.
Closes https://github.com/facebook/prepack/pull/1948
Differential Revision: D7985678
Pulled By: NTillmann
fbshipit-source-id: 22cd999bf4ff8dd26618b06d94f751834533b726
Summary:
Release notes: More compact code generation by avoiding introducing local variables for abstract values when possible.
This fixes#1765.
Closes https://github.com/facebook/prepack/pull/1921
Differential Revision: D7946593
Pulled By: NTillmann
fbshipit-source-id: a33a9cbe8ffcd9ca43afa4101954c9b59401fb4c
Summary:
Fixes https://github.com/facebook/prepack/issues/1935.
The issue was that we'd always put `EmptyValue` into the right branch even if it happened in the left one.
Adds a regression test.
Closes https://github.com/facebook/prepack/pull/1937
Reviewed By: trueadm
Differential Revision: D7967344
Pulled By: gaearon
fbshipit-source-id: ece8550787679e2fc33f040989ceae0cf3a7c2a2
Summary:
Update to 72. Run yarn flow and verify it's all good
Closes https://github.com/facebook/prepack/pull/1939
Differential Revision: D7961902
Pulled By: lxfind
fbshipit-source-id: 246d8abef788685d4d6e57406e15f8f8e56650c2