Summary:
Release note: none
After recent refactorings in Nuclide, we don't need to build the debugger differently anymore. We can use our transpiled code directly into Nuclide.
This undoes #1240
Closes https://github.com/facebook/prepack/pull/1274
Differential Revision: D6579982
Pulled By: JWZ2018
fbshipit-source-id: 58b487b3f1f020be27fc569c4f5219c660c1aad5
Summary:
Release note: none
This PR aims to do a few optimizations in terms of how JSX/React Elements are handled.
I've introduced a `ReactElementSet` class that aims to handle matching similar React Element/JSX structures by deeply iterating through the various properties on a JSX element. It uses a linked hash map, with the keys being the reference to the specific internal Prepack value. It handles objects, arrays, functions and React element structures.
These optimizations only happen on evaluated component trees.
```jsx
// before:
function MyComponent(props) {
return <div><span>Hello world</span><span>Hello world</span></div>
}
// after:
function MyComponent(props) {
var _0 = <span>Hello world</span>
var _1 = <div>{_0}{_0}</div>
return _1;
}
```
```jsx
// before:
function OtherComponent() {
// ...
}
function MyComponent(props) {
return <div><OtherComponent data={{a: 1, b: 2}} /></div>
}
// after
function OtherComponent() {
// ...
}
function MyComponent(props) {
_1 === void 0 && $f_0();
return _1
}
function $f_0() {
_1 = <div><OtherComponent data={{a: 1, b: 2}} /></div>
}
var _1;
```
Closes https://github.com/facebook/prepack/pull/1196
Differential Revision: D6578563
Pulled By: trueadm
fbshipit-source-id: 2f617fd80d4540228fcb60403cb97e672763876b
Summary:
Release notes: none
When working with the name generator and creating instinct names that include invalid characters, I noticed the output included these characters. Instead they should be replaced like other characters have.
Closes https://github.com/facebook/prepack/pull/1267
Differential Revision: D6577946
Pulled By: trueadm
fbshipit-source-id: 07db9e9cfd519cea128623df41dee35d60b8f8f3
Summary:
Release note: Basic support for do while loops with abstract bounds. Issue #1229
Take properties into account when doing fix point computation. Use property paths rather than phi nodes. Simplify code for local variables as well.
Closes https://github.com/facebook/prepack/pull/1255
Differential Revision: D6576293
Pulled By: hermanventer
fbshipit-source-id: 9e19704cbf5c8cbcc937bd99ec32af9ffe577ebf
Summary:
Release note: add heap graph visualization to website
Moved from #1243
- read in the heap graph data from prepackSources result
- display the graph using [visjs](http://visjs.org/)
Closes https://github.com/facebook/prepack/pull/1265
Differential Revision: D6571860
Pulled By: JWZ2018
fbshipit-source-id: 4c2d9bae91eaffff58df8909214d4c7bc56d1359
Summary:
Release Notes: none
Addresses issue #1244. Now we will put modifications to bindings just before the return statement of the additional function.
Also contains some minor refactors.
Closes https://github.com/facebook/prepack/pull/1251
Differential Revision: D6568331
Pulled By: cblappert
fbshipit-source-id: ea3ae2a783355175f0f23f82bce6543ac535b214
Summary:
Release note: Use conditional returns to refine the path condition. Fixes#1182
When one branch of a conditional is an abrupt completion add the join condition to the path condition. The previous path condition is stored in the saved completion and restored at join point.
Closes https://github.com/facebook/prepack/pull/1212
Reviewed By: hermanventer
Differential Revision: D6562943
Pulled By: simonhj
fbshipit-source-id: fcf53a7c54118628bd3f62e5010f4c1046fd1145
Summary:
Release note: none
- Nuclide does not expect the first stop event from the debug adapters
- caused a bug where the state information is not shown on the first stop in Nuclide
- Remove sending a stopped event on entry
Closes https://github.com/facebook/prepack/pull/1256
Differential Revision: D6561599
Pulled By: JWZ2018
fbshipit-source-id: 942f644ce54e9b52fb5acbd3b217b210bf71b2b3
Summary:
Release Note: none
Remove scopes parameter from _getTarget() so that it is easier to use.
Closes https://github.com/facebook/prepack/pull/1254
Differential Revision: D6557152
Pulled By: yinghuitan
fbshipit-source-id: 7ceb9dc1799fc7960765ad816e73cd0a478a5712
Summary:
Release note: Fix bug #1262
The saved completion that is present before a function call should not be incorporated into the saved completion that is created inside the call, until after return completions have been appropriately joined and applied.
Closes https://github.com/facebook/prepack/pull/1263
Differential Revision: D6560937
Pulled By: hermanventer
fbshipit-source-id: 76e8d67f0ad2227dec9cf54f5f035a34f1941be3
Summary:
Hi all,
It was a good way to get started on contributing.
Closes https://github.com/facebook/prepack/pull/1259
Differential Revision: D6558546
Pulled By: hermanventer
fbshipit-source-id: 815380c88aad36a7e1b34928b4eb6927a7c9d461
Summary:
Release notes: Percentage output of passing tests (passed tests / total tests) should be rounded down instead of up.
From an example I encountered earlier, when we had number of tests passed = 1157 and total tests = 1159, we would display, "Passed: 1157/1159 100%". We should instead display "Passed: 1157/1159 99%"
Closes https://github.com/facebook/prepack/pull/1260
Reviewed By: hermanventer
Differential Revision: D6558323
Pulled By: jhalley
fbshipit-source-id: 01751bacb83760ae49a56a9ef56983fee94487d2
Summary:
Release notes: none
This adds detection support for the legacy `React.createClass`/`create-react-class` API so that we can safely bail out.
Closes https://github.com/facebook/prepack/pull/1257
Differential Revision: D6556374
Pulled By: trueadm
fbshipit-source-id: c71dcd3792be56c7134e743206c5830f1f46ae0d
Summary:
Release note: Changed some erroneous console.log statements to console.error
This addresses issue https://github.com/facebook/prepack/issues/1201. Went through all uses of console.log in the codebase and converted them to console.error if that's what they're supposed to be.
Closes https://github.com/facebook/prepack/pull/1253
Reviewed By: hermanventer
Differential Revision: D6550963
Pulled By: jhalley
fbshipit-source-id: aec0f2f9a0e5745f563628b849fde110388b12cd
Summary:
Release note: Debugger is available!
- remove the flag that hides the debugger
- to check whether to invoke the debugger:
- inFilePath and outFilePath are specified when starting prepack (check in prepack-node.js)
- if so, DebugChannel will read from inFile to see if debugger is attached
Closes https://github.com/facebook/prepack/pull/1249
Differential Revision: D6548604
Pulled By: JWZ2018
fbshipit-source-id: 1d4bee80d95c91da9853871b117cb8a939f4797b
Summary:
Release note: none
To address issue #956 .
The idea is to have all documentation (aka "the website") in a single `docs/` directory on the `master` branch like [Jest](https://github.com/facebook/jest/tree/master/docs) and [Relay](https://github.com/facebook/relay/tree/master/docs) do. This directory then serves as a single source of truth to publish the `gh-pages` branch.
This PR:
- Moves the current content of the `gh-pages` branch to a `docs/` directory in `master`
- Provides a bash script for maintainers to easily publish the `gh-pages` branch from the `docs/` directory. The script also builds `prepack.min.js` from master to make sure gh-pages always has the latest version of prepack.
Additionally, I noticed the `gh-pages` branch had two `prepack.min.js` files (one in `./` and one in `./js/`). I removed the first one because it is apparently not used but it may break other websites if they references that file.
0. Fork the repo to avoid modifying the real website
1. Change the site
`> git checkout master`
`> echo ".nav { background-color: chartreuse; }" >> docs/css/style.css`
`> git add docs/css/style.css`
`> commit -m "The navigation bar looks better in green"`
`> git push`
2. Run the publication script:
`> ./scripts/publish-gh-pages.sh`
3. Verify that the gh-pages has been updated:
`> git checkout gh-pages`
`> git pull`
`> git diff HEAD~ # should show the line you added`
Closes https://github.com/facebook/prepack/pull/1223
Differential Revision: D6547395
Pulled By: j-nolan
fbshipit-source-id: 6e6d3aec97c0bcc2555c421d6f4a889bcd8df208
Summary:
Release notes: none
This addresses the --simpleClosures case mentioned in #1238 (but not the other case where we delay closure scope creation).
Prepend additional functions prelude *after* splicing in function declarations,
otherwise the ordering of the insertions is messed up.
Adding regression test.
Closes https://github.com/facebook/prepack/pull/1241
Differential Revision: D6546269
Pulled By: NTillmann
fbshipit-source-id: eb12c5bbba1b542c4e69599e5abf961359d41652
Summary:
Release note: Handle do-while loops with abstract bounds, for loop bodies only involving locals.
Issue: #1174
This adds a simple fixed point computation for do-while loops only. Currently only loops that updated only local variables and that have no abrupt exits are supported.
This is deliberately as minimal as possible to make review easier. Given the complexity of this feature, thoughtful review would be great.
Closes https://github.com/facebook/prepack/pull/1229
Differential Revision: D6546405
Pulled By: hermanventer
fbshipit-source-id: 205c336a83c17d03344941b13f0a5c6af7989131
Summary:
Release note: none
The debugger needs to be built differently from the rest of Prepack to be compatible with Nuclide. This PR makes building the debugger into a separate command while still keeping the original command to build Prepack.
- make separate envs for building debugger and the rest of Prepack
- add `yarn build-debugger` command
Closes https://github.com/facebook/prepack/pull/1240
Differential Revision: D6534794
Pulled By: JWZ2018
fbshipit-source-id: 384dfbb7d77d46564e028c00a79e97b3657616b5
Summary:
Release Note: add serialized identifier to heap graph label.
Also did a small refactoring to NameGenerator to make it easier to reuse.
Closes https://github.com/facebook/prepack/pull/1236
Differential Revision: D6537426
Pulled By: yinghuitan
fbshipit-source-id: d2eef16c204c466689e2be9471ffd53e4c79459a
Summary:
PrePack generates duplicate argument names when inlining expressions. Take for instance the test in test/serializer/basic/CapturedScope.js. PrePacked with --inlineExpressions it generates several functions like
```
var $_1 = function (c, __scope_2, __scope_2) {
var __captured__scope_2 = __scope_1(__scope_2);
var __captured__scope_2 = __scope_1(__scope_2);
__captured__scope_2[1]++;
__captured__scope_2[2]++;
return c();
};
```
Closes https://github.com/facebook/prepack/pull/1218
Reviewed By: hermanventer
Differential Revision: D6536751
Pulled By: lukas1994
fbshipit-source-id: 8752964d7c099476a4cda3d42996c0aa77cbb5b9
Summary:
Release note: none
- change heap graph data to be in the format expected by visjs
- add colors to each type of node
Closes https://github.com/facebook/prepack/pull/1242
Differential Revision: D6534752
Pulled By: JWZ2018
fbshipit-source-id: 74f8d7296ad5399014e9f60af3d86ea3ebf5102f
Summary:
Fixes#1222 by refusing to emit `.bind` calls when the arguments of the `.bind` would be identifiers for functions that have been generated by the ResidualFunctions code (because we can't guarantee that the ordering will be correct).
Closes https://github.com/facebook/prepack/pull/1227
Differential Revision: D6527609
Pulled By: cblappert
fbshipit-source-id: 55953c70eca5f230e5a9e371ac07219e7cafaa61
Summary:
Release notes: none
Towards closing #1226.
Add regression test case.
Note that simple-closures doesn't work together with delay-initializations,
so delay-initializations now gets silently disabled when needed.
Closes https://github.com/facebook/prepack/pull/1237
Differential Revision: D6526798
Pulled By: NTillmann
fbshipit-source-id: 1b21961aaadd98af9503846b065689db38bd5302
Summary:
Release Note: N/A
getSerializeObjectIdentifierOptional() relies on the internal identifier map to check if a value has been serialized and with identifier. I am going to change this assumption in later PR so refactor the code to remove this API.
Introduce new _serializedValueWithIdentifiers data structure to serve getSerializeObjectIdentifierOptional() API purpose.
Closes https://github.com/facebook/prepack/pull/1232
Differential Revision: D6520560
Pulled By: yinghuitan
fbshipit-source-id: 08a187a4a27c681f39187a14872bcd6919a55a26
Summary:
After testing this in JS environments that don't support `Symbol`, React falls back to using `0xeac7`.
```js
const REACT_ELEMENT_TYPE = hasSymbol ? Symbol["for"]("react.element") : 0xeac7;
```
This adds detection for this.
I've also excluded `_store` from being visited on ReactElement. This was picked up when evaluated DEV React bundles (where `_store` is set on the object).
Closes https://github.com/facebook/prepack/pull/1234
Differential Revision: D6520491
Pulled By: trueadm
fbshipit-source-id: c01b31e22f4f45a5e1933affd4b8c86c6bc72c41
Summary:
Release note: introduce Prepack heap objects graph.
This is the first PR to introduce prepack heap objects graph. The visualization is basic now(no coloring, legend for the nodes) and we need to figure out how best show the ref count.
I would like to land this first so that JWZ2018 can start integrate this into REPL website.
Later I am going to add the final identifier name into the node label.
Closes https://github.com/facebook/prepack/pull/1221
Differential Revision: D6520646
Pulled By: yinghuitan
fbshipit-source-id: 8cc0713b5d3fad82fb685dceeb7875894f908dbe
Summary:
Release notes: Adding option --simpleClosures to eagerly allocate space for captured variables.
This addresses #1226.
Adding option --simpleClosures, and brought back code that avoids delaying closure creation.
Adding test case.
From here, we could tweak the logic that triggers this behavior.
Closes https://github.com/facebook/prepack/pull/1228
Differential Revision: D6516797
Pulled By: NTillmann
fbshipit-source-id: 9c556036f8dd64c4c6004a436c3a391ca428eda9
Summary:
The serializer is optimistically running code that can fail with a runtime error, without first setting up a context. When this fails, throw an error instead of asserting.
Closes https://github.com/facebook/prepack/pull/1225
Reviewed By: hermanventer
Differential Revision: D6510958
Pulled By: simonhj
fbshipit-source-id: 33523f6c1e66aeec460d386f211de6e76963cdf8
Summary:
Release note: none
Summary;
- split debugger directory into `server`, `common`, and, `adapter`
- `adapter` and `common` have no dependencies on Prepack and can be moved into Nuclide
- make a copy of invariant.js into `common`
- make `FileIOWrapper` take in an absolute path so it can be used in both server and adapter sides
- Turn relative path into absolute path inside adapter channel
- Create debug communication files if they don't exist
With this refactoring, I can move the `adapter` and `common` directories into Nuclide and submit the code there too
Closes https://github.com/facebook/prepack/pull/1224
Differential Revision: D6510721
Pulled By: JWZ2018
fbshipit-source-id: 2a3f62392187924637aef7fa14260475f4db5de8
Summary:
Related to https://github.com/facebook/prepack/issues/1213
- [x] Added a command line option for printing out the version.
- [x] Added prepackVersion getter to Prepack object.
If it's fine for you I can take a task to display the version in prepack.io website
Closes https://github.com/facebook/prepack/pull/1220
Differential Revision: D6505466
Pulled By: hermanventer
fbshipit-source-id: 81efa8e2fcc39e2c777c4e67a20640be6fcc6f4d
Summary:
Release note: none
- refactor stepping manager and breakpoint managers to return the stoppable object
- implement a stop event manager to handle the results of other two managers and decide whether a stop should happen
- remove onDebuggeeStop methods
Closes https://github.com/facebook/prepack/pull/1216
Differential Revision: D6500168
Pulled By: JWZ2018
fbshipit-source-id: 006632086ae52e2fa322637aefbc6ca2f9114365
Summary:
Attempts fix for #1109 Awaiting feedback for the tests that have been written.
Closes https://github.com/facebook/prepack/pull/1211
Differential Revision: D6498825
Pulled By: hermanventer
fbshipit-source-id: 6bc6def013890561c70b77db6ba582902d677bcf
Summary:
Move the implementations of the to methods behind an interface so that we can reduce the Flow cycle length (as well as avoiding increasing it when a planned future request adds a new import to to.js).
This is a mechanical refactor with no new functionality.
Closes https://github.com/facebook/prepack/pull/1219
Differential Revision: D6494524
Pulled By: hermanventer
fbshipit-source-id: b5dbe45155e0276a9d42f2b26a90bb9b220ac1ea
Summary:
Release note: Adds support for folding simple React class components
This PR adds the concept of "simple" class components. A "simple" class component is defined as:
- having only a "render" method or many method, i.e. `render()`, `_renderHeader()`, `_renderFooter()`
- having no lifecycle events
- having no state
- having no instance variables
The only things a class component should be able to access on "this" are:
- `this.props`
- `this.context`
- `this._someRenderMethodX()` etc
It does this by first attempting to evaluate any class component with the heuristics as if it were a simple class component. If that throws an error (entirely expected for most class components), it catches the error and falls back to trying to use the "complex" class component route for evaluation instead.
Furthermore, I've added "transforms". This allows post-transforms of the serialized AST for additional functions. The simple class component adds a transform to convert AST nodes of `this.props` to `props` and `this.context` to `context` respectfully – whilst adding arguments to the function; something that is necessary to convert simple class component render methods to functional components.
This PR also adds logic to squash simple class components into functional components at the root (as simple class components are easily convertible to functional components).
Closes https://github.com/facebook/prepack/pull/1204
Differential Revision: D6485508
Pulled By: trueadm
fbshipit-source-id: 06ebeebad5d23c0677a0e3f0cb8dd23c45735429
Summary:
Not sure why I didn't do it this way in the first place. Instead of applying babel to the prepacked code, apply it to them input source code. Make it an apples to apples comparison
Closes https://github.com/facebook/prepack/pull/1166
Differential Revision: D6360177
Pulled By: simonhj
fbshipit-source-id: 9c9a137178d54a36dc146e18c47b161426f09b5c
Summary:
Release note: none
-refactor step manager to account for other types of steppers
-add step over class
-setup pipeline to make stepover requests
Closes https://github.com/facebook/prepack/pull/1207
Differential Revision: D6480818
Pulled By: JWZ2018
fbshipit-source-id: 90b7e5ddb48576dfc9139238514c3fac3dabd71b
Summary:
It seems that the numbers were meant for another version of the test262 repository.
The original pull request updated the test262 repository label, but the bot that synchronizes GitHub with our internal repo removed that update. That also causes the new test runner to fail, so disable that until we update the label properly.
Closes https://github.com/facebook/prepack/pull/1215
Differential Revision: D6477069
Pulled By: hermanventer
fbshipit-source-id: ed17b12c1e81d51465f9c4b76adf684961390fb0