Commit Graph

1376 Commits

Author SHA1 Message Date
Dominic Gannaway
87591341b1 Add __doNotRender flag to React reconcilation
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
2018-05-23 11:53:46 -07:00
Dominic Gannaway
f3582d0156 If left and right in createFromConditionalOp are equal, do early return
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
2018-05-23 09:10:24 -07:00
Dominic Gannaway
cde1af298d Do not mutate arrays or ReactElements during React reconciliation
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
2018-05-22 16:35:40 -07:00
Sapan Bhatia
373c6d917d Fix nit that crept through
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
2018-05-22 15:54:22 -07:00
Dominic Gannaway
393eba15ad Ensures all serializer test case output passes linting validation
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
2018-05-22 15:41:31 -07:00
Dominic Gannaway
195f68209a Always emit globals safe for strict mode
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
2018-05-22 09:37:11 -07:00
Herman Venter
c83d8a350b Update build command to explictly invoke yarn build
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
2018-05-22 04:31:58 -07:00
Dominic Gannaway
b3018aa6af Trigger invariant upon the React reconciler detecting an object without its bindings
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
2018-05-22 02:40:26 -07:00
Herman Venter
b6536991b0 Stack completion saved effects
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
2018-05-21 21:55:56 -07:00
Nikolai Tillmann
9c26f640ab Support for --delayInitializations for optimized functions
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
2018-05-21 21:07:57 -07:00
Dominic Gannaway
73aa511413 Ensure unknown array values are emitted into the right target body
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
2018-05-21 15:58:33 -07:00
Tim Seckinger
dd63339992 fix: coerce abstract values into strings for the Error constructor
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
2018-05-21 15:58:33 -07:00
Herman Venter
21c19dac17 0.2.36-alpha.0
Summary: New Alpha version 0.2.36

Reviewed By: simonhj

Differential Revision: D8048556

fbshipit-source-id: c2b2c45949b80bd74845856693404ba195044e04
2018-05-21 13:09:48 -07:00
Herman Venter
87ab20e2c2 Weekly release v0.x.y: speed ups, new features, bug fixes
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
2018-05-21 10:39:29 -07:00
Dominic Gannaway
3545cd8327 Render optimized react-dom/server renderToString ahead of time
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
2018-05-21 08:59:20 -07:00
Dominic Gannaway
e78c69c28a Skip check on elementTypes in CreateListFromArrayLike if parameter is default
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
2018-05-20 13:59:03 -07:00
Dominic Gannaway
4dda80e5be Add no-use-before-define to debug-fb-www script
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
2018-05-18 02:16:46 -07:00
Herman Venter
21cb2b4da5 Avoid redundant conversions to object
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
2018-05-18 01:19:22 -07:00
Dominic Gannaway
da243f5b48 Fix bug with arrays with widened numeric properties
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
2018-05-17 14:22:26 -07:00
Herman Venter
529ea0d760 Don't rotate effects trees
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
2018-05-17 11:45:18 -07:00
Dominic Gannaway
b9d43d5e7d Move React side-effect logic in to the ThrowCompletion
Summary:
Release notes: none

This moves the side-effect detection logic for React component renders into the ThrowCompletion itself.
Closes https://github.com/facebook/prepack/pull/1977

Differential Revision: D8031923

Pulled By: trueadm

fbshipit-source-id: 189a2c7b729276193344a926db8f5a747460a8da
2018-05-16 14:08:52 -07:00
Xun Li
1f02f31308 Fix issue #1841.
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
2018-05-16 11:56:50 -07:00
Tim Seckinger
5df51ac6f4 stop the prototype cycle check if an object uses non-ordinary prototype methods
Summary:
Release Notes: stop the prototype cycle check if an object (e.g. proxy) uses non-ordinary prototype methods

Fixes #1017
Closes https://github.com/facebook/prepack/pull/1976

Differential Revision: D8027102

Pulled By: NTillmann

fbshipit-source-id: 886e6ce474255dadf937662e30a65adbfac5a1f1
2018-05-16 11:06:51 -07:00
Dylan
9eefb43b42 Implement const/let pattern declarations (ES6 destructuring)
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
2018-05-16 10:33:19 -07:00
Dominic Gannaway
f807a17b74 Further follow-up Array.from fixes
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
2018-05-16 05:15:03 -07:00
Nikolai Tillmann
ea0624b108 Distribute conditionals in certain relational expressions
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
2018-05-15 23:56:32 -07:00
Nikolai Tillmann
1d8e2d935e Move evaluateWithAbstractConditional
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
2018-05-15 16:54:57 -07:00
Victor Hom
62bbdd4aee update the --timeout error
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
2018-05-15 16:33:23 -07:00
Nikolai Tillmann
505aa2bb28 Better crash logging
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
2018-05-15 14:05:45 -07:00
Dominic Gannaway
41df8539d8 General clean up of React reconciler + serializer code
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
2018-05-15 09:38:44 -07:00
Dominic Gannaway
c114aa6acd Add all missing console methods
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
2018-05-15 06:52:50 -07:00
Nikolai Tillmann
3b3c4f371c Simplifying some code.
Summary:
Release notes: None

It seemed overly complicated; so I deleted some code.
Everything still seems to work.
Closes https://github.com/facebook/prepack/pull/1965

Reviewed By: trueadm

Differential Revision: D8004394

Pulled By: NTillmann

fbshipit-source-id: 37a7e2b97fdb1796684883d0399504441ecac4b4
2018-05-15 05:20:35 -07:00
Nikolai Tillmann
6b3866885f Fixing AbstractObjectValue's $Get
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
2018-05-14 18:03:46 -07:00
Dominic Gannaway
0e74417689 Make React component state final as its immutable
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
2018-05-14 15:02:34 -07:00
Nikolai Tillmann
ad9ed9ba97 Don't treat original constructor specially in the visitor.
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
2018-05-14 13:55:47 -07:00
Herman Venter
770bfef8ca Objects that are temporal should set _isScopedTemplate to true
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
2018-05-14 13:55:46 -07:00
Nikolai Tillmann
9685f866ce Fix frozen lazy objects
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
2018-05-14 13:05:44 -07:00
Paulo Cunha
3e88d55ca3 Refactor effects.data into properties
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
2018-05-14 13:05:44 -07:00
Dan Abramov
f3fe533480 Follow up to ConditionalExpression changes
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
2018-05-14 12:19:19 -07:00
Dan Abramov
b594b283c2 Don't treat makePartial() as a mutation in havoc checker
Summary:
Fixes https://github.com/facebook/prepack/issues/1931.

The issue is that this call may happen on a havoced object:

41e9dcb398/src/intrinsics/ecma262/Object.js (L98-L100)

That fails. But I'm not sure it makes sense to even check havocing for internal properties like `_isPartial_binding`.

Maybe there's a deeper problem here. I don't see it but at least this gets the ball rolling.
Closes https://github.com/facebook/prepack/pull/1955

Differential Revision: D7992958

Pulled By: gaearon

fbshipit-source-id: 3e843ae159896c15b8f9dc2fd6956b148a2ef44f
2018-05-14 11:59:52 -07:00
Nikolai Tillmann
287aab9bcd Replace expensive second babel-traverse pass with fast custom visitor.
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
2018-05-14 11:59:51 -07:00
Dan Abramov
200b5c5f59 Conditional return completions might need to be dereferenced
Summary:
Fixes https://github.com/facebook/prepack/issues/1953.

We used to delegate handling of conditional expression to `IfStatement`. But this is not entirely accurate because conditional expression completion might be an identifier. `IfStatement` rules are too restrictive.

I copy pasted the code from IfStatement and added `GetValue` dereferencing [to match the specification](http://www.ecma-international.org/ecma-262/7.0/#sec-conditional-operator-runtime-semantics-evaluation). I also removed `UpdateEmpty()` calls which seem to only be relevant to `IfStatement` evaluation.

Adds a regression test.
Closes https://github.com/facebook/prepack/pull/1954

Differential Revision: D7988920

Pulled By: gaearon

fbshipit-source-id: ac130076dbaa04d5d661adb984b408b4d3b57fa3
2018-05-14 08:09:16 -07:00
Dan
41e9dcb398 Fix havoc logic for conditional abstracts
Summary:
Fixes https://github.com/facebook/prepack/issues/1883.

As I noted there,

>This seems to happen because the logic in `visitObjectPropertiesWithComputedNames` hasn't been updated in the same way that [its twin in the residual heap visitor has been](aa700a2667/src/serializer/ResidualHeapVisitor.js (L361-L388)).

This brings them in line.

Regression case included. It used to fail with bad output even after this change, but https://github.com/facebook/prepack/pull/1937 fixed that, so now it passes.
Closes https://github.com/facebook/prepack/pull/1942

Reviewed By: trueadm

Differential Revision: D7987993

Pulled By: gaearon

fbshipit-source-id: 1ebda0c38f2f932aa18872bfc9a919938fc2ef96
2018-05-14 02:52:09 -07:00
saigowthamr
f720dab2a5 Matching end tags Errors fixed
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
2018-05-13 09:38:09 -07:00
Paulo Cunha
afca7d742c make some files flow strict
Summary:
Release Notes: none

Made some files flow strict, where there weren't complicated dependencies to solve.
It's low hanging fruit for https://github.com/facebook/prepack/issues/1941.
Closes https://github.com/facebook/prepack/pull/1949

Differential Revision: D7985674

Pulled By: NTillmann

fbshipit-source-id: b20a94dccf540798e2e724499f3d2e65847e73f6
2018-05-13 09:26:00 -07:00
Victor Hom
7e3209b701 add reading wiki link to places
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
2018-05-13 09:25:59 -07:00
Manas
5185a3557a Adds support for spread syntax
Summary:
Addresses #927
Adds support for spread syntax
Closes https://github.com/facebook/prepack/pull/1932

Differential Revision: D7976863

Pulled By: sebmarkbage

fbshipit-source-id: 05836c8398df4699729a1b697b5da0c90df1b992
2018-05-11 14:40:30 -07:00
Nikolai Tillmann
aa700a2667 Don't insist on giving all abstract values unique names.
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
2018-05-11 11:18:18 -07:00
Dan Abramov
20683624ab Put EmptyValue into correct join branch
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
2018-05-11 07:07:02 -07:00
Xun Li
306ea4f625 Update Flow version
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
2018-05-10 20:11:23 -07:00