Commit Graph

1596 Commits

Author SHA1 Message Date
Dan Abramov
574411bb62 Ignore test262 for Prettier (#2242)
Summary:
This will fix CI on master. I forgot it's possible to land a change internally without it passing the CI checks.
Pull Request resolved: https://github.com/facebook/prepack/pull/2242

Differential Revision: D8801741

Pulled By: gaearon

fbshipit-source-id: 454fcb29e023a502557b67e0ed12a304c4e5fabc
2018-07-11 07:23:38 -07:00
Dan Abramov
ec37b77b6e Run Prettier for serializer tests too (#2234)
Summary:
Follow-up to https://github.com/facebook/prepack/pull/2212.
Pull Request resolved: https://github.com/facebook/prepack/pull/2234

Differential Revision: D8788834

Pulled By: gaearon

fbshipit-source-id: 08937736bed3df0ea13d5e7a3925fb2f58633d5c
2018-07-11 03:55:11 -07:00
Herman Venter
8f3ce551f8 Small tweak to solve a pressing instance of a more general problem (#2239)
Summary:
Release note: none

Resolves #2238

This is a quick fix for the above issue. The underlying cause is that we do not construct completions with effects, but rely on incremental updates in special situations, such as the constructor for ForkedAbruptCompletions.

I'll try to fix the underlying cause in a subsequent PR.
Pull Request resolved: https://github.com/facebook/prepack/pull/2239

Differential Revision: D8795886

Pulled By: hermanventer

fbshipit-source-id: 677f2481ae3d6463a73f36a7e7106afbd92b068e
2018-07-10 17:40:29 -07:00
Nikolai Tillmann
f5c36ad249 Manually type all exported class methods. (#2231)
Summary:
Release notes: None

Found and fixed some minor issues.
This fixes #2177.
Pull Request resolved: https://github.com/facebook/prepack/pull/2231

Differential Revision: D8789870

Pulled By: NTillmann

fbshipit-source-id: 4ea3de2cbac08dbf6538af344eade1c45d9b9afd
2018-07-10 13:39:01 -07:00
Chris Blappert
91847ea6ba Make optimized functions produce compiler diagnostic on mutating non-… (#2175)
Summary:
…local state

The logic was already there for the React Compiler's invocations of evaluatePure, this PR just generalizes it a little to be used for optmized functions as well.

Additionally, adds the ability to check for compiler info/warning logs in test-runner + updates test-error-handler.

See #1589
Pull Request resolved: https://github.com/facebook/prepack/pull/2175

Differential Revision: D8786744

Pulled By: cblappert

fbshipit-source-id: 110a4732dd6bd129b4d91047c3c9a24f5249a5e9
2018-07-10 12:10:41 -07:00
Chris Blappert
c943ced74e Allow __optimize to work in conditional contexts (#2214)
Summary:
Release Notes: None

Before `__optimize` wouldn't work when called in a conditional context, now if `__optimize` is called in some conditional context, we extract the FunctionValue from the AbstractValue in the `__optimizedFunctions` map.

Also fixes a bug where __optimize would silently noop when given something other than an `ECMAScriptSourceFunctionValue` causing two tests to fail with `TypeError`. Issue #2213 is setup to track this.
Pull Request resolved: https://github.com/facebook/prepack/pull/2214

Differential Revision: D8785643

Pulled By: cblappert

fbshipit-source-id: 3db992d693dd431aa8a2c5e6eb7ad0a1ecb6b79e
2018-07-10 10:34:20 -07:00
Dan Abramov
66351887d3 Run Prettier checks on CI (#2212)
Summary:
This will fail CI if we forgot to run `yarn prettier` before committing.
We do the same in React repo. It prevents committing stale files that later cause unexpected changes.
Pull Request resolved: https://github.com/facebook/prepack/pull/2212

Differential Revision: D8784406

Pulled By: gaearon

fbshipit-source-id: ca948b8e088be8886c8ba865f280ba8d72750f69
2018-07-10 09:55:23 -07:00
Dominic Gannaway
bde8c2eb1e Move abstract Object.assign temporals into a helper function (#2232)
Summary:
Release notes: none

As per Nikolai's comment https://github.com/facebook/prepack/pull/2206#discussion_r201142434, this PR moves the creation of the `Object.assign` abstract temporals into their own static abstract value creation method `AbstractValue.createTemporalObjectAssign`.
Pull Request resolved: https://github.com/facebook/prepack/pull/2232

Differential Revision: D8782639

Pulled By: trueadm

fbshipit-source-id: 9a41a66d5b7e41982de96684e627ef5e103cc638
2018-07-10 07:27:46 -07:00
Guru107
7273bacc51 New color scheme for the website (#2225)
Summary:
Release note: new color scheme for the website 🔥
Pull Request resolved: https://github.com/facebook/prepack/pull/2225

Differential Revision: D8779444

Pulled By: NTillmann

fbshipit-source-id: 2c713d3a0a98dfc62f0a7cdf4e695a32c568fa05
2018-07-09 22:29:57 -07:00
Nikolai Tillmann
ca9246c270 Make explicit which path conditions apply to a Generator (#2224)
Summary:
Release notes: None

It used to be a case that the Generator constructor simply
harvested whatever was currently set in the realm as the current
path condition.

This makes it explicit, and fixes some places where likely the wrong
path condition was picked up. At least one place caused an issue in
InstantRender that is now fixed (but I couldn't extract a small repro).

Leaving behind a number of `TODO #2222`s in the code to review once more.
Pull Request resolved: https://github.com/facebook/prepack/pull/2224

Differential Revision: D8779258

Pulled By: NTillmann

fbshipit-source-id: a0f3dea4b03eaa71b12943f813eb7fc440d29fca
2018-07-09 21:24:14 -07:00
Nikolai Tillmann
d456e64116 Add ability to rewrite generated code via global.__output (#2218)
Summary:
Release notes: Add ability to rewrite generated code via global.__output

When a special global variable __output is set to an object,
then all global generator entries are forgotten
and replaced by a series of assignments to reflecting the key-value
pairs of the __output object.

This is needed for instant render to emit single render functions only.
Pull Request resolved: https://github.com/facebook/prepack/pull/2218

Differential Revision: D8778269

Pulled By: NTillmann

fbshipit-source-id: 1dbc5ddd68aa5fd7845da8a7f551c8c7ba2b8919
2018-07-09 19:09:51 -07:00
Nikolai Tillmann
9f7d1bd425 Updating Flow to .76 (#2229)
Summary:
Release notes: None

Also removed timeout limit as we routinely exceed the default.
Pull Request resolved: https://github.com/facebook/prepack/pull/2229

Differential Revision: D8775206

Pulled By: NTillmann

fbshipit-source-id: 70f8521c7cd3c4de9b97bc9cb3c2c6694d7e1616
2018-07-09 17:25:15 -07:00
Nikolai Tillmann
0f4d651c0c Annotate exported function return types. (#2227)
Summary:
Release notes: None

I manually reviewed and annotated all exported function return types.
Still TODO: Same for class methods, and then we need some enforcement mechanism.
Pull Request resolved: https://github.com/facebook/prepack/pull/2227

Differential Revision: D8775279

Pulled By: NTillmann

fbshipit-source-id: 31aca088384657d7b398c758ab7eb42d3c4fa001
2018-07-09 17:09:17 -07:00
Dominic Gannaway
db5ed0c7d3 Optimize Object.assign calls by merging the temporal entries together where possible (#2206)
Summary:
Release notes: adds an optimization to Object.assign that attempts to merge calls together where possible

I frequently see `Objet.assign` calls litter our internal bundle. Many of them can actually be merged together to reduce bloat and runtime overhead (on that matter, `Object.assign` isn't a cheap call). We do this by adding a new `TemporalObjectAssignEntry` entry, that allows us to add some fine-tuning of Object.assign temporal entries we create.

The new `TemporalObjectAssignEntry` entry has an optimization that aims to merge entries by checking if linked nodes, specifically the `Object.assign` calls `to` field, to see if it can literally merge the arguments of many `Object.assign`s together. If a `to` is visited and can't be omitted, it doesn't try to apply this optimization. What we end up with, is a single `Object.assign` call and the others all get dead-code eliminated away because of the `mutatesOnly` logic from earlier.
Pull Request resolved: https://github.com/facebook/prepack/pull/2206

Reviewed By: NTillmann

Differential Revision: D8775391

Pulled By: trueadm

fbshipit-source-id: 41e5d6bb1d51fcfff66b2fe758bd51492ec472d9
2018-07-09 16:54:43 -07:00
Herman Venter
dd1f18da0c Parameterize test262-runner with the expected counts required (#2228)
Summary:
Release note: Added --expectedCounts parameter to test262-runner so that success can depend on the value of the time-out and the version of the test suite that is used.
Pull Request resolved: https://github.com/facebook/prepack/pull/2228

Differential Revision: D8775828

Pulled By: hermanventer

fbshipit-source-id: 284bdb3526467f634f41a151e3995719af751e49
2018-07-09 16:54:38 -07:00
Caleb Meredith
85b70951d9 Fix React library visiting logic (#2223)
Summary:
> I’m learning the Prepack/React Fusion codebase, so incorrect assumptions and limited a understanding of systems on my part are both very likely.

While I was experimenting with the React Compiler codebase I found the following invariant violation with the test case after that when using `create-element` as the `reactOutput`.

```
Invariant Violation: value must have been visited
```

```js
const React = require("react");

__evaluatePureFunction(() => {
  function Foo(props) {
    return <React.Fragment />;
  }

  __optimizeReactComponentTree(Foo);

  module.exports = Foo;
});
```

[[Prepack REPL]](https://prepack.io/repl.html#MYewdgzgLgBASgUwIbFgXhgJwQRwK4CW2AFAETYpSkCUA3AFD0D6TCAbkgDZ5JQIAKebADE8YVAXDFi1GGgB8MAN70YMAGZiJ4GMJAhiAB0whDEWSrVrsUIWBgAeRJQB0wzEgDmAWwRhYAPTyDGoAvoxqLKZQBN4EAF4IzqgAwiDehuB+UAAq2AjEeiB0ETDeIAAmeJwILggAHpmYUBByuvoMoSVAA)

After digging in more, I discovered that this was the same issue which required some clowniness in the React Compiler tests to workaround.

e3f4262c9d/test/react/setupReactTests.js (L116-L119)

The problem with my example is that the React library was not being visited when a `React.Fragment` appeared even though the serializer needed the library to be visited to output code.

This diff makes sure we visit the React library when we see a `React.Fragment` and makes sure we don’t over visit the React library in `jsx` mode.

I also refactored this area of the code and added comments. Let me know if my refactors or comments don’t make sense.
Pull Request resolved: https://github.com/facebook/prepack/pull/2223

Reviewed By: trueadm

Differential Revision: D8774047

Pulled By: calebmer

fbshipit-source-id: 775a626b8a6bd33a5366e6dae6727350835b060e
2018-07-09 16:04:03 -07:00
Herman Venter
e3f4262c9d Traverse all normal paths when pushing path conditions (#2201)
Summary:
Release note: none

Resolves: #2207

When a PossiblyNormalCompletion has more than one normal path, it is not correct to push only the path leading to the nominally normal completion. Surprisingly, this has not caused all sorts of havoc so far, but clearly this needs fixing.

Interestingly, these changes did uncover some latent bugs, hence the additional changes here.

Testing this more thoroughly will be much easier once PNC composition is fixed. That will take a while, but this PR will help facilitate that.
Pull Request resolved: https://github.com/facebook/prepack/pull/2201

Differential Revision: D8754966

Pulled By: hermanventer

fbshipit-source-id: 220ddc80eaff69b8ee93f75c1943ee1a16adcdee
2018-07-06 15:10:12 -07:00
Herman Venter
366eca6ee1 Update the test262 submodule (#2216)
Summary:
Release note: Updated the test262 submodule to latest version

Also updated test262-runner.js to deal with time out errors showing up as diagnostics.

Filter out new tests that depend on errors being generated during the parsing phase. Since we depend on Babel for parsing, such issues are out of scope for us.
Pull Request resolved: https://github.com/facebook/prepack/pull/2216

Differential Revision: D8755005

Pulled By: hermanventer

fbshipit-source-id: 0c929904984d13efccbd3ad1ca125137ca275ef0
2018-07-06 15:10:10 -07:00
Nikolai Tillmann
e680248655 Tighten types of derived values (#2210)
Summary:
Release notes: None

If concrete, it can only be an object.
Pull Request resolved: https://github.com/facebook/prepack/pull/2210

Differential Revision: D8752067

Pulled By: NTillmann

fbshipit-source-id: 207c3a6e055924290029e770528dc24df1023ffe
2018-07-06 14:40:20 -07:00
Sebastian Markbage
36b322b250 Enforce types of ValuesDomain getElements (#2211)
Summary:
I found this working on another PR but might as well fix it here first.

This wasn't previously enforced and now we are forced to deal with the whether something is a primitive or object as well as some other places we had bugs covered up by `any`.
Closes https://github.com/facebook/prepack/pull/2211

Differential Revision: D8751674

Pulled By: sebmarkbage

fbshipit-source-id: d1445530e53d88a08f3d2652dffd26bcf339d4f3
2018-07-06 14:25:55 -07:00
Herman Venter
7aa5455148 Update test262 submodule hash
Summary: Update the test262 submodule to the latest version.

Reviewed By: cblappert

Differential Revision: D8753974

fbshipit-source-id: 6ba4904969dbe3c529dd73e1d20d227bf6e5c226
2018-07-06 14:25:54 -07:00
Herman Venter
1034e4a5cf New Alpha
Summary: 0.2.43-alpha.0

Reviewed By: simonhj

Differential Revision: D8739217

fbshipit-source-id: eeb42cfb6741aa14fde21f806a39fbaca4335153
2018-07-05 14:39:38 -07:00
Herman Venter
244f2525f8 Weekly release v0.2.42: Debugability, speed, bug fixes
Summary:
Improved source location information
Only havoc abstract value args when really necessary
Debugger recognizes sourcemaps and opens the correct file/line when debugging in Nuclide.
Make React tests fast
Special case an expression simplification for Instant Render
Fix temporal assignments to intrinsics that happen inside non deterministic loops
Enhanced handling of Array.map applied to abstract arrays
Support dynamic invariants via __assume
We got a logo!
Add React Native mocks to Prepack

Reviewed By: simonhj

Differential Revision: D8739156

fbshipit-source-id: d535dfe0c5bcbee4aaed28f75d45cbedcc51344b
2018-07-05 14:39:38 -07:00
Sapan Bhatia
92c4db7483 Narrow type of PropertyBinding.object and eliminate unnecessary checks (#2208)
Summary:
Release notes: None

This came about as an offshoot of #2185. PropertyBinding.object cannot be of type AbstractObjectValue. This change narrows its type to ObjectValue, and eliminates checks that become unnecessary.

Outcome of a manual search via Grasp: PropertyBinding.object is assigned at two points - in methods/properties.js and react/util.js. There are also invariants at two places to guard this condition (object instanceof ObjectValue.) yarn flow does not report errors.
Closes https://github.com/facebook/prepack/pull/2208

Differential Revision: D8738889

Pulled By: sb98052

fbshipit-source-id: 52807e28a699b95934b8d53f0c81ccc6b06a79bb
2018-07-05 14:11:26 -07:00
Dominic Gannaway
3cd3dd8431 Reduce React bloat on equivalent objects with similar temporal alias trees (#2193)
Summary:
Release notes: none

In an attempt to pull out some of the work from https://github.com/facebook/prepack/pull/2148 to make things easier to consume and review. This PR is one part, where we check the temporal alias values (if an object value has it) and see if we can dedupe the trees. Example below:
Closes https://github.com/facebook/prepack/pull/2193

Differential Revision: D8732542

Pulled By: trueadm

fbshipit-source-id: 352d0048acfef69b5a257c0fe280435fa7baaa7f
2018-07-05 05:09:30 -07:00
Dominic Gannaway
ef7e1873fa Support React keys in array branches, fixes #2139 (#2157)
Summary:
Release notes: none

Add logic to support adding keys when inlining arrays. Fixes https://github.com/facebook/prepack/issues/2139.
Closes https://github.com/facebook/prepack/pull/2157

Differential Revision: D8732339

Pulled By: trueadm

fbshipit-source-id: cfb1fe8725522e3eba5e1061832ddba8359484bb
2018-07-04 08:23:26 -07:00
Dominic Gannaway
2c79cb103d Ensure we handle numeric properties on $GetPartial path (#2205)
Summary:
Release notes: none

We were missing logic for handling abstract arrays with unknown numeric properties when we attempt to get a partial value on the array. I've added a regression test too.
Closes https://github.com/facebook/prepack/pull/2205

Differential Revision: D8732181

Pulled By: trueadm

fbshipit-source-id: 6002eac4b7d4d0b842407a3bb9ea9bcec19f486b
2018-07-04 07:39:05 -07:00
Dominic Gannaway
8b6307a121 Add fb-www Jest testing config/dependencies to do local snapshot testing (#2202)
Summary:
Release notes: none

Make it easier to do local development testing of our internal bundle without having to hack the settings each time.
Closes https://github.com/facebook/prepack/pull/2202

Differential Revision: D8731922

Pulled By: trueadm

fbshipit-source-id: 71d92c3b90f448667c4a9ada1f1b0848ece5003b
2018-07-04 05:38:38 -07:00
Dominic Gannaway
5f444abbda @allow-large-files [prepack][PR] Adds React native mocks (#2096)
Summary:
Release notes: adds React Native mocks to Prepack

This adds React Native mocks to Prepack and a few basic tests to demonstrate inlining of `View` and `Text`.
Closes https://github.com/facebook/prepack/pull/2096

Differential Revision: D8723932

Pulled By: NTillmann

fbshipit-source-id: 38bd265cd8935ebdf30266ec337378b4ea5b09d6
2018-07-03 14:44:41 -07:00
Nikolai Tillmann
c9fc143f5b Adding raw Prepack Logo assets (#2189)
Summary:
Release notes: We got a logo!

Updating README to include logo.
Will create an issue to update website accordingly.
Closes https://github.com/facebook/prepack/pull/2189

Differential Revision: D8725906

Pulled By: NTillmann

fbshipit-source-id: 2f9b3b1d4afbd4fc42f137fcda9e4edac390d272
2018-07-03 12:45:47 -07:00
Sapan Bhatia
e9ef64da0e Support injection of residual statements. Support dynamic invariants. (#2195)
Summary:
Release notes: Support dynamic invariants via __assume

Resolves #2171. Implements an __assume primitive that injects dynamic invariants into the code.

Source:
```js
x = __abstract("number", "5");
__invariant(x==5, "x should be 5");
```

Generated:
```js
(function () {
  var _$0 = this;
  var _0 = 5;
  _$0.x = _0;

  var _1 = _0 == 5;
  if (!_1) {
    throw new Error("x should be 5");
  }
}).call(this);
```
Closes https://github.com/facebook/prepack/pull/2195

Reviewed By: hermanventer

Differential Revision: D8725726

Pulled By: sb98052

fbshipit-source-id: 28db3272199cdb9ae669062344eb82f0ef619bd4
2018-07-03 12:09:49 -07:00
Guru107
2f470b319c Add the right command in README to generate prepack.min.js (#2200)
Summary:
Release note: none

`yarn build-bundle` needs `lib` directory present else it breaks.
Closes https://github.com/facebook/prepack/pull/2200

Differential Revision: D8725631

Pulled By: hermanventer

fbshipit-source-id: d577b4cf6de2b29a2f5fc7a8b1ba2dc36694c9db
2018-07-03 11:56:09 -07:00
Dominic Gannaway
8e37b36191 Removes temporalAliasArgs for an existing approach using the preludeGenerator (#2199)
Summary:
Release notes: none

As pointed out by Herman in https://github.com/facebook/prepack/pull/2193#discussion_r199628160. We don't need `temporalAliasArgs`, so this PR removes it from the codebase and uses the existing way via the preludeGenerator.

This also adds a helper function to make it easier to relate derived abstract values to their temporal args. Furthermore, `derivedIds` now stores the `TemporalBuildNodeEntryArgs` rather than `Array<Value>`, as the follow up PRs for doing the React related logic need to access more than just the array of args, it also needs access to `isPure`, `skipInvariant` etc so it can properly clone derived abstract values.
Closes https://github.com/facebook/prepack/pull/2199

Differential Revision: D8724017

Pulled By: trueadm

fbshipit-source-id: 3ad72d3b230f1d2dc7f81c2a8d07dd33d0c7aa5c
2018-07-03 08:09:47 -07:00
Herman Venter
f12e0369f0 Do not always give up when running Array.map over an abstract array. (#2173)
Summary:
Release note: Enhanced handling of Array.map applied to abstract arrays

Fixes #2169.

If an abstract array is the join or a few concrete arrays, we apply the map over all of the concrete arrays and join the results. This is a bit of a hack, much like what we have for switch statements. The code from the latter has been factored out and reused for this.
Closes https://github.com/facebook/prepack/pull/2173

Differential Revision: D8721507

Pulled By: hermanventer

fbshipit-source-id: e08f2dc1d7e78c7b59f9ff7c76ad54b398b8afe9
2018-07-02 19:23:38 -07:00
Herman Venter
b6ce555f37 Ensure temporal assignments are not lost when the value does not change. (#2197)
Summary:
Release note: Fix temporal assignments to intrinsics that happen inside non deterministic loops

Tweak the property set logic to not short circuit when the target object is intrinsic and the RH value is the same as the current (tracked) property value.

Also fix the code generator for loop bodies to not get upset when the lh side is temporal, but rh side is not widened (because it is a constant).
Closes https://github.com/facebook/prepack/pull/2197

Differential Revision: D8721001

Pulled By: hermanventer

fbshipit-source-id: d38565a40fa7ab8b4e30596f0e1dcfc655a4fb5e
2018-07-02 17:55:04 -07:00
Herman Venter
466d19ddfd Special case "x === undefined || x === null" kind of expressions (#2188)
Summary:
Release note: special case expression simplification for Instant Render

When instant render is enabled turn x === undefined || x === null into __cannotBecomeObject(x) so that Instant Render can easily compile it down to a single byte code.
Closes https://github.com/facebook/prepack/pull/2188

Differential Revision: D8716594

Pulled By: hermanventer

fbshipit-source-id: bbcb25462f79852d8deac29bfed62e86745e5589
2018-07-02 13:39:35 -07:00
Dominic Gannaway
67a47fd48f Improve fb-www mocks objectWithoutProperties value by ensuring we store known values (#2194)
Summary:
Release notes: none

When the `objectWithoutProperties` mock was originally created, my knowledge of Prepack's internals wasn't as good as it was now. Now that I understand how AbstractObjectValues work, we can safely add the known values in `objectWithoutProperties` to the abstract backing object. The backing object was missing these values before and was an empty empty that was partial. This should give more data and value on our internal bundle, where before the values would be lost unnecessarily.
Closes https://github.com/facebook/prepack/pull/2194

Differential Revision: D8716289

Pulled By: trueadm

fbshipit-source-id: 451065473ea09943831f75c0bc15490e73c8d947
2018-07-02 13:11:28 -07:00
Dan Abramov
5159b0d832 Make React tests fast (#2187)
Summary:
Currently we have a single giant file with all tests, and a giant snapshot. This is both slow, and hard to work with and iterate on.

In this PR I will refactor our test setup.

- [x] Split it up into multiple files (gets the test running from 45s to 27s)
- [x] Run Prettier on test files
- [x] Split tests further for better performance
- [x] Make it possible to run one test file
- [x] Fix the issue with double test re-runs in watch mode on changes in the test file
- [x] Refactor error handling
- [x] Run Prettier on fixtures
- [x] Add a fast mode with `yarn test-react-fast <Filename>`
- [x] Fix double reruns on failure

Potential followups:
- [x] Figure out why test interruption broke (need https://github.com/facebook/jest/issues/6599 and https://github.com/facebook/jest/issues/6598 fixed)
- [x] Revisit weird things like `this['React']` assignment with a funny comment in every test
Closes https://github.com/facebook/prepack/pull/2187

Differential Revision: D8713639

Pulled By: gaearon

fbshipit-source-id: 5edbfa4e61610ecafff17c0e5e7f84d44cd51168
2018-07-02 11:25:58 -07:00
David Cai
e79def7cd2 Debugger sourcemaps (#2154)
Summary:
Release Notes:
- Debugger recognizes sourcemaps and opens the correct file/line when debugging in Nuclide.
    - Explanation of how sourcemap translation works in [this Quip](https://fb.quip.com/0uQCAtkuPAHF). This is probably useful to read before attempting to read the changes to `Debugger.js` and `PathNormalizer.js`.
- Removed unnecessary abstractions in `IsStatement` and `DebuggerOptions`.
- Refactored multi-file support to conform to Nuclide initialization protocol
- Refactored `DebuggerConfigArguments` so as to pass sourceFiles without increase Flow cycle length.

Example of FatalError on FB4A: https://www.dropbox.com/s/ig8vrlpcazbygo3/Prepack%20Fatal%20Diagnostic%20on%20FB4A.mov?dl=0

NOTE: Apologies for the large number of commits -- I incorrectly pulled in some from master when rebasing
Closes https://github.com/facebook/prepack/pull/2154

Differential Revision: D8707082

Pulled By: caiismyname

fbshipit-source-id: 812610c0345536a1ad9b480449c16f34018040c3
2018-06-29 20:24:59 -07:00
Sebastian Markbage
3240eae91b Only havoc abstract value args when really necessary (#2184)
Summary:
Fixes #2179

In #2179 I describe why we might need to havoc some args to abstract values sometimes. This adds an invariant to ensure that we always have args in the cases we need to havoc.

If this abstract value cannot be an object, then we don't need to havoc since there's nothing that can be mutated.

If this has a known values domain, then we know the possible objects. We only need to havoc those, not the args.
Closes https://github.com/facebook/prepack/pull/2184

Differential Revision: D8701601

Pulled By: sebmarkbage

fbshipit-source-id: d5fecbed4cff8013bc768cb6e277094d9ff16d9c
2018-06-29 15:10:22 -07:00
Herman Venter
3deb5e2885 Fix problem with stack location entries (#2183)
Summary:
Release note: Improve source location information

Changes to make sure that the source location of the call expression appears in the corresponding execution context record. Also emit execution records with no source location from stack traces. These are due to calls to internal helper methods for iterating over objects and arrays for argument destructuring.

Finally fix a CompilerDiagnostic construction call to include a source location.
Closes https://github.com/facebook/prepack/pull/2183

Differential Revision: D8698271

Pulled By: hermanventer

fbshipit-source-id: 10f77f718db645a4784723c3eca4bd4e06eb43f8
2018-06-29 11:56:22 -07:00
Dan Abramov
0e09f6f986 Increasing version number
Summary: The usual.

Reviewed By: trueadm

Differential Revision: D8694035

fbshipit-source-id: 7ceb3359f3a6729a7d08f3e2fd4841121b163edd
2018-06-29 07:24:14 -07:00
Dan Abramov
03cd572617 Weekly release v0.2.41
Summary:
- Bugfixes
- Improve `switch` evaluation performance
- Don't emit unnecessary calls

Reviewed By: trueadm

Differential Revision: D8694028

fbshipit-source-id: f43138b799905f98c11af1ebeaf82ff0216ab30b
2018-06-29 07:24:14 -07:00
Nikolai Tillmann
2e2b92eec0 Adding --instantRender mode. (#2178)
Summary:
Release notes: None

Tweaking some behaviors to help with Instant Render automation.
This leaves behind some TODOs in the code, but unblock me for now.
Closes https://github.com/facebook/prepack/pull/2178

Differential Revision: D8689796

Pulled By: NTillmann

fbshipit-source-id: f919a8b6bbfb63513bb9467027676e0ba7d4230e
2018-06-28 20:53:43 -07:00
Chris Blappert
bb49439adf Fix require/define detection (#2168)
Summary:
Release Notes: None

It is okay for a define call to happen within a require call so long as the define call has happened by the time the require call has returned (since all define calls should have the same effect and only happen once). Previously if we encountered a module required before it was defined (or defined in a nested partial evaluation scope), we would not record it in ModuleTracer logic.
Closes https://github.com/facebook/prepack/pull/2168

Differential Revision: D8688788

Pulled By: cblappert

fbshipit-source-id: 6696ea54ed9ae7a3d7e8a944c45e14feccf3139b
2018-06-28 18:39:26 -07:00
Dominic Gannaway
9905f613d6 Fixes nested evaluatePure calls and React nested optimized closure side-effect detection (#2166)
Summary:
Release notes: none

Fixes nested `evaluatePure` calls, where before they would collide and overwrite one another. Also ensure React reconciler uses side-effect detection on nested optimized closures. This fixes a React test which should have been failing before, but wasn't.
Closes https://github.com/facebook/prepack/pull/2166

Differential Revision: D8681422

Pulled By: trueadm

fbshipit-source-id: 8941812407d1bda5af0343a09210aeff24a36cff
2018-06-28 13:26:00 -07:00
Dominic Gannaway
7c63a7cd42 Add mutatesOnly feature the generator entries (#2132)
Summary:
Release notes: adds `mutatesOnly` to generator entries to better allow for DCE

This PR adds a new option that can be passed as an optional arg to `generator.deriveAbstract` called `mutatesOnly `. See https://github.com/facebook/prepack/pull/2132#pullrequestreview-130509488 for details. With it, we can better dead-code eliminate generator entries when the value entries that are flagged as mutating are dead code.

The test showing this is below:

Input:
```js
global.f = function() {
  var x = global.__abstract ? global.__abstract({}, "({})") : {};
  global.__makeSimple && __makeSimple(x);
  Object.assign({}, x);
  return 1;
};

if (global.__optimize) __optimize(f);
```

Output (with master):
```js
  var _$2 = this;

  var _$3 = _$2.Object;
  var _$4 = _$3.assign;

  var _0 = function () {
    var _$0 = _$4({}, {});

    return 1;
  };
```

Output (with the changes in this PR):
```js
  var _0 = function () {
    return 1;
  };

  var _2 = function () {
    return global.f();
  };
```
Closes https://github.com/facebook/prepack/pull/2132

Differential Revision: D8667764

Pulled By: trueadm

fbshipit-source-id: 5121da7d73330befeb5a39ea50d7b773256d70bc
2018-06-27 13:09:30 -07:00
Herman Venter
fa4b52f573 Distribute equality checks if that allows simplification (#2174)
Summary:
Release note: More simplification of equality expressions

Resolves issue: #2172

Expressions like (c ? x : y) === null can sometimes be simplified by first rewriting them as (c ? x === null : y === null). Add such a case to the simplifier.
Closes https://github.com/facebook/prepack/pull/2174

Differential Revision: D8666251

Pulled By: hermanventer

fbshipit-source-id: 5b0d56fb091e25bfcdf879be3403cb5a982375ae
2018-06-27 12:10:01 -07:00
Peter van der Zee
30f07ead22 Upgrade Prettier to 1.13.6 on fbsource
Reviewed By: zertosh

Differential Revision: D8638504

fbshipit-source-id: c6991b2e884e14868ddc1d9047a78191219d673f
2018-06-27 03:40:12 -07:00
Chris Blappert
938a9dc241 Fix inefficient loop in switch statements (#2161)
Summary:
Release Notes: None

Dan Caspi's change to internal test case created a giant switch statement, increasing evaluation time from 5.9s > 224s. This change brings it down to 6.2s by using `push` instead of `concat` in 2 places.
Closes https://github.com/facebook/prepack/pull/2161

Differential Revision: D8649236

Pulled By: cblappert

fbshipit-source-id: a0af4a7c4eaff30e6e8a7708006d84773a25517f
2018-06-26 13:25:13 -07:00