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
Summary:
Release notes: None
This fixes#1856, at least in the sense that Prepack won't silently generate wrong code.
Instead, Prepack will now issue an error indicating that a Prepack limitation was hit.
Adding error-handler regression test.
Also fixed reference to PP1023 (no wiki page) to be PP0023 (matching wiki page) instead.
Closes https://github.com/facebook/prepack/pull/1929
Differential Revision: D7954903
Pulled By: NTillmann
fbshipit-source-id: f9676f33e74ff36067832333a7ee9a26ec77126d
Summary:
Release notes: the React reconciler now throw a FatalError upon encountering side-effects in a render
This PR revamps the current React system's restrictions for what you can and can't do during the React reconcilation phase. This is a pretty large update but provides much better boundaries between what is "safe" and not "safe", thus reducing the constraints.
1. A new error `ReconcilerRenderBailOut` is thrown if something occurs in the React reconciliation that causes the render to fail and it's a hard fail – no recovering and continuing.
2. If you mutate a binding/object outside the render phase, given the React component render phase is meant to be "pure", a `ReconcilerRenderBailOut` will be thrown.
3. If you `throw` during the React reconciliation phase, again a `ReconcilerRenderBailOut` will be thrown.
In the future, we should maybe loosen the constraints around all this and maybe allow `throw`, but right now it's causing too much friction. We should attempt to make React components render phase as pure as possible – as it results in much better optimizations by a compiler because we can assert far more without things tripping us up.
Another point, regarding (1), is that we should ideally be able to recover from the error thrown in Prepack. The reason we can't and is something that might be a very deep issue in Prepack, is that effects don't properly restore when we have nested PossiblyNormalCompletions at work. Bindings get mutated on records from changes made within `evaluateForEffects` but never get reset when in nested PossiblyNormalCompletion. If I remove all the things that can cause `PossiblyNormalCompletion`s then everything works fine and bindings do get restored. We can remove the constraint on (1) once we've found and fixed that issue.
Closes https://github.com/facebook/prepack/pull/1860
Differential Revision: D7950562
Pulled By: trueadm
fbshipit-source-id: 4657e68b084c7069622e88c9655823b5f1f9386f
Summary:
Release Note: none
Addresses #1870 by making `emitConditionalThrow` use `joinGenerators` rather than `_deconstruct` (which is then also no longer referenced).
Resulting code for example in issue:
``` JS
(function () {
var $$0 = {
enumerable: false,
configurable: true,
writable: true
};
var _$0 = this;
var _$1 = _$0.Error;
var _$2 = _$1.prototype;
var _$3 = _$0.Object;
var _$4 = _$3.defineProperty;
var _4 = function () {
return 42;
};
var __constructor = function () {};
inspect = _4;
var _0 = false;
var _3 = _$2;
if (_0) {
var _1 = (__constructor.prototype = _3, new __constructor());
$$0.value = "Error\n at no-filename-specified:4:18\n at no-filename-specified:1:1", _$4(_1, "stack", $$0);
throw _1;
}
}).call(this);
```
Closes https://github.com/facebook/prepack/pull/1889
Differential Revision: D7946748
Pulled By: olydis
fbshipit-source-id: d760b66405b55edc7967e31abd2d81596d7090a5
Summary:
Release note: None
ESLint crashes with the flow fix I did earlier. Turns out updating ESLint to latest version fixed it.
Closes https://github.com/facebook/prepack/pull/1927
Reviewed By: NTillmann
Differential Revision: D7946856
Pulled By: yinghuitan
fbshipit-source-id: 44995ed89b516651d85918c6b08b6048916bbb09
Summary:
Release note: none
Resolves issue #1865
Abstract values that are known to result in objects (of unknown identity) should not be eligible for Common Subexpression Elimination (CSE).
Closes https://github.com/facebook/prepack/pull/1925
Differential Revision: D7941893
Pulled By: hermanventer
fbshipit-source-id: 454e26c6d042093b9fbae06d73110202083731b6
Summary:
Release notes: none
Fix for a try/catch block that should rethrow an error if it cannot handle it.
Closes https://github.com/facebook/prepack/pull/1922
Differential Revision: D7937748
Pulled By: trueadm
fbshipit-source-id: 19c5ff60b3bba51ae444053dc3dc3ece21aa4336
Summary:
Release notes: None
This was just wrong (result of a bad merge).
I don't know how this could have Flow type checked.
Code only runs with --debugScopes.
Closes https://github.com/facebook/prepack/pull/1918
Differential Revision: D7936513
Pulled By: NTillmann
fbshipit-source-id: 1062dba0db3fd3690da149814217015623adfbcc
Summary:
Release notes: None
Besides general deep AST traversals, the only other thing that shows up high in the profiler is setting up bindings.
This change tries to make it a bit more efficient.
Also cleans up types.
Closes https://github.com/facebook/prepack/pull/1720
Differential Revision: D7936521
Pulled By: NTillmann
fbshipit-source-id: a759a976dd80a5176022e566e0f832e1e9fc39a2
Summary:
Release notes: fixes an issue with getOwnPropertyDescriptor when dealing with a native prototype function
This PR fixes#1285, specifically when using `Object.getOwnPropertyDescriptor` on a native prototype function, we have to resort to returning a temporal abstract as this function isn't available at build time. I also renamed all the tests with typos in them.
cc anilanar
Closes https://github.com/facebook/prepack/pull/1913
Differential Revision: D7935215
Pulled By: trueadm
fbshipit-source-id: d7e33cf8bd73aa2c1156966ad86e9da9fb0404e4
Summary:
Release note: Do not generate code for unreachable global code statements
Resolves issue #1906
If an unconditional throw is encountered, it does not make sense to keep processing top level statements.
Closes https://github.com/facebook/prepack/pull/1908
Differential Revision: D7934963
Pulled By: hermanventer
fbshipit-source-id: d6e6b26d7ad7c54a065e43a74ad1b27959159c7a