Summary:
Release notes: None
For historical and apparently no longer needed reasons,
we used to forget about modified bindings when execution
leaves scopes.
However, this means that the binding no longer properly participates
in state tracking, which is conceptually dubious.
While by itself, it didn't seem to cause much (or any?) harm,
it turned out to be a blocker for #2125, where the initial state
of a binding becomes important when joining partially leaked bindings.
Closes https://github.com/facebook/prepack/pull/2136
Reviewed By: hermanventer
Differential Revision: D8528939
Pulled By: NTillmann
fbshipit-source-id: 0890c32d55f6b498cb4613171eee54ff9b445730
Summary:
Release Notes: None
Follow up on #2110, this PR makes progress towards unifying PossiblyNormalCompletion and ForkedAbruptCompletion as well as unifying completion and effects.
Introduces `updateConsequentKeepingCurrentEffects` for a common pattern of updating one of the completions for a PNC/FAC and fixing up the effects.
Closes https://github.com/facebook/prepack/pull/2134
Differential Revision: D8525738
Pulled By: cblappert
fbshipit-source-id: c415eea47cd786e39820138f84213c2cc9d5e891
Summary:
Release Notes: None
In an effort to unify Completions and Effects (many completions are tied to effects whose result should be the completion), I change evaluateForEffects to return a `NormalCompletion` whereever it would otherwise return a `Value`. Now all `EvaluationResults` are `Completions` or `References`.
Fairly mechanical refactor (except slightly tricky because PossiblyNormalCompletions are NormalCompletions, so instead of checking `instanceof Value` you should check `instanceof NormalCompletion && ! instanceof PossiblyNormalCompletion`).
Closes https://github.com/facebook/prepack/pull/2110
Differential Revision: D8431970
Pulled By: cblappert
fbshipit-source-id: d70d6c5d4100eec52f60b8e4328f2a0b4afabbed
Summary:
Release notes: none
There was a bug, where React abstract object values with the same intrinsic name were incorrectly being de-duped and re-used. This is a normal expected Prepack optimization, but it actually breaks React components that expect to be able to create many values with the same intrinsic name. We now mark such objects and ensure they do not correctly return `true` from `equals()`. Fixes https://github.com/facebook/prepack/issues/2089
Closes https://github.com/facebook/prepack/pull/2126
Differential Revision: D8448171
Pulled By: trueadm
fbshipit-source-id: d21fddd70576e6e55c41070ac43ce2f58a059e7a
Summary:
Release notes: none
This PR moves the logic of sanitizing ReactElements for `firstRenderOnly` mode to the serialization phase instead of during reconciliation. The plan is to create a follow up PR that introduces a new phase after the visitor phase, that skips values that were detected as dead code once the visitor stage finishes, but that's not in scope for this PR.
Closes https://github.com/facebook/prepack/pull/2123
Differential Revision: D8435440
Pulled By: trueadm
fbshipit-source-id: f442525e663a7bc0f9608b96eb7d7a2389a707b7
Summary:
Release notes: fixes serialization of bindings when shared between optimized functions
This PR fixes a long standing bug with nested optimized functions where bindings would incorrectly serialize to the main body scope when the binding was shared between nested optimized functions and their parent optimized function scopes. This allows us to not skip 2 React tests and I also added a serializer regression test that demonstrates the same problem so we don't regress.
Closes https://github.com/facebook/prepack/pull/2117
Differential Revision: D8408712
Pulled By: trueadm
fbshipit-source-id: 0e0a306f9195fcb5b57fa7f8cef1c65dbef4998f
Summary:
Release notes: None
In particular, no longer claim that there were "errors" when there in fact none.
Closes https://github.com/facebook/prepack/pull/2104
Differential Revision: D8371246
Pulled By: NTillmann
fbshipit-source-id: b33519bf8a2b53150b24ea6f7db9b43b20e7dd1f
Summary:
Release Note: none
This is regarding #2072
Instead of spitting back Invariant Violation: undefined in this case, it will give back the trace error.
Also the Invariant Violation: undefined is misleading. The undefined is coming from the invariant format parameter when format isn't supplied. The fix is to add an empty string to format so it won't show undefined.
Questions: would you want to separate that throw into a separate util method like invariant?
Closes https://github.com/facebook/prepack/pull/2106
Differential Revision: D8394381
Pulled By: NTillmann
fbshipit-source-id: 3ed418c335b7db6d88bb1cca5dcc9ac69fed6b5d
Summary:
Release notes: none
When we create temporals that are pure, let's mark them as pure and also skip creating invariants for them too. Making these changes allows the serializer to not emit temporals that never end up getting used, reducing the output and also making it easier to debug the output (less spam of temporals).
Closes https://github.com/facebook/prepack/pull/2097
Differential Revision: D8329043
Pulled By: trueadm
fbshipit-source-id: f1ef4185793115dd7982b8162a7e3dc4038a15f9
Summary:
Emit PrePack info into the generated bundle. The intention is for this to include information about enabled prepack options. Currently it only includes a flag if lazy objects are enabled.
Its emitted as global which is somewhat intrusive so its guarded by a flag currently and defaults to false.
Example:
```
var __PREPACK__ = {lazyObjects: false}
```
Reviewed By: NTillmann
Differential Revision: D8321765
fbshipit-source-id: 03a41b2cef84ea44c02c71e233b407e3ddc1197d
Summary:
Release notes: none
This is a long standing fix, where ReactElements should be created lazily but are currently not done so. To do this, we now use the `temporalAlias` code paths on lazy branched ReactElements to ensure they are emitted as temporal entries when we "branch" (i.e. conditional) and have many possible routes where ReactElements may or may not be created.
Fixes https://github.com/facebook/prepack/issues/2113. Depends on https://github.com/facebook/prepack/pull/2112
Closes https://github.com/facebook/prepack/pull/2107
Differential Revision: D8383327
Pulled By: trueadm
fbshipit-source-id: bbcff45ddd07406b18bcddce2de0279fb52da1a1
Summary:
Release notes: improves ReactElement creation by re-using ReactElement nodes where possible
We already have a pretty good ReactElement equivalence system to re-use ReactElements. We weren't using it to its full power though. When we have nested ReactElements, we don't use the equivalence system at all, meaning we duplicate lots of ReactElements when we can re-use.
This is a nice performance optimization. I've added a test that should prevent regressions here too.
Closes https://github.com/facebook/prepack/pull/2114
Differential Revision: D8381595
Pulled By: trueadm
fbshipit-source-id: befabd04326a162f8ab6a00e089cdada052cf6c8
Summary:
Release notes: none
When working on https://github.com/facebook/prepack/pull/2107, I noticed that we weren't cloning `temporalAlias` values, which is the wrong approach. We instead were re-using them on cloned ReactElements. The current approach worked fine with concrete ReactElement values, but when we introduce temporal ReactElement values that have dependencies on a shared `temporalAlias`, we run into very complex problems.
This PR makes it so we can clone `temporalAlias` values on `ObjectValues` (used for snapshotting). This only used for React code – so it should not affect the other parts of Prepack. I've tested this on our internal bundle and our tests and they all pass, we create more code – but this is a *better* approach. We can remove the bloated code at a later point, but this aims to keep our approach consistent.
Closes https://github.com/facebook/prepack/pull/2112
Differential Revision: D8379812
Pulled By: trueadm
fbshipit-source-id: 04bf133be7a97cec3389a99584be1c042371ee07
Summary:
Release notes: Speeding up visiting phase.
While there was already some batching in place, lumping together all actions associated with a particular final generator, the batching did not take into account the inherent tree structure of the generator effects. This is now being fixed.
Also added logging when in React verbose mode.
This change dramatically speeds up internal benchmarks.
However, the fixed point computation is still an intolerable bottleness.
Future changes can or should include some dependency tracking during the fixed point computation. Right now, each item is a block box, and it is not clear whether it needs to be re-run, so it is re-run.
(Created issue #2111 to track this opportunity.)
This speeds up an internal React benchmark from 261s to 193s.
Closes https://github.com/facebook/prepack/pull/2105
Differential Revision: D8370641
Pulled By: NTillmann
fbshipit-source-id: 8fcc499c6f56f2a63fc05417f53d5ebdc746347e
Summary:
Release notes: none
I noticed that we weren't visiting the dependencies of temporalAlias values, nor were we visiting ReactElements. Visiting both seems to improve visitor performance locally for me on our bundle.
Closes https://github.com/facebook/prepack/pull/2108
Differential Revision: D8359160
Pulled By: trueadm
fbshipit-source-id: 1d9cc0f1855772a46721b1675649269628062113
Summary:
Release Notes: Full integration with Nuclide UI coming in next PR. This PR sets up a pipeline for passing configs to the debugger, and uses that pipeline to specify what level of CompilerDiagnostic the debugger should break at. The debugger's diagnostic check sits within the `handleError` function and occurs before Prepack takes its own action.
Current CLI experience:
<img width="1680" alt="dbg-cli-example" src="https://user-images.githubusercontent.com/15720289/41180054-bd45d39e-6b21-11e8-8a24-9626adab737f.png">
Closes https://github.com/facebook/prepack/pull/2088
Differential Revision: D8355227
Pulled By: caiismyname
fbshipit-source-id: 3ca457bcbb7697fd39073c3d2ddc88be92bfc662
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