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
Summary:
This method provides an alternative way to run Test262 through a
stream of compiled test contents for each scenario (default, strict
mode), including all the necessary harness contents.
The logic to capture an execution success or failure is similar to
the original one - from scripts/test262-runner.js - and improvements
should be done as follow ups.
The filtering system is now done through a configuration yaml file,
using tests metadata and path locations. This filter is used as an
object that can be extended with further logic, but still offers a
single point to check for filtering.
The report system requires some improvements and these should also
be done as follow-ups. For now they provide a report for each
folder and the total results. Although, the results data contain
enough information to highly expand the report.
Some further improvements are expected and planned, this work
should be at least ready for an initial round for feedback review.
Closes https://github.com/facebook/prepack/pull/1122
Reviewed By: cblappert
Differential Revision: D6456700
Pulled By: hermanventer
fbshipit-source-id: ba56efcaa4eab847594cb7c1fbc908cf1fc66a80
Summary:
When we catch an error in the cli and output it, we should be outputting to stderr and failing the prepack command.
Closes https://github.com/facebook/prepack/pull/1200
Reviewed By: hermanventer
Differential Revision: D6450152
Pulled By: cblappert
fbshipit-source-id: 9707ffe118b8740a36e3385998d7a71cf2c9471e
Summary:
Release Note: preserve residual functions' original source ordering.
We serialize the residual functions in random order(based on the visitor's discovery of residual function order) which may result in very bad code locality in real world app.
Add the feature to preserve residual functions' original source ordering.
Note:
1. I did not make an option for this feature because I think it should do this by default.
2. To gain better perf, we may introduce some profiler guided optimization in future.
Closes https://github.com/facebook/prepack/pull/1163
Differential Revision: D6437299
Pulled By: yinghuitan
fbshipit-source-id: 9c0a93a10862b0d8c96bfccb38238c497e4012e7
Summary:
Release Note: Fix lazy object identifier inside ConditionalAssignmentBranch
Fix#1187. The lazy object identifier logic explicitly checks if the serialization body is lazy object initializer; however, it's possible that object is serializing inside a nested ConditionalAssignmentBranch which the logic will fail.
To fix this issue, I added a "parentBody" field to all serializerBody which chains the serialized body as a chain so that we can check the nested children body cases.
Also, add the remaining 3 hook methods in proxy hook which failed because of this bug.
Closes https://github.com/facebook/prepack/pull/1198
Differential Revision: D6427510
Pulled By: yinghuitan
fbshipit-source-id: 39bde34bd508045b9c4dd109538a905a203a0dfe
Summary:
hermanventer suggests use Proxy to mock test-runner hydration for Lazy Objects which is very promising. Here are the improvements using proxy hook mocking:
1. More accurate hydration simulation
2. The 4 failed tests all succeed now.
3. All test mocking support are in test-runner now. No need to serialize ugly test runner comment.
4. I find real bugs after switching to Proxy simulation.
I also changed the test-runner a bit to output full runnable code when test-runner failed. This makes lazy object debugging much easier.
Closes https://github.com/facebook/prepack/pull/1188
Differential Revision: D6402100
Pulled By: yinghuitan
fbshipit-source-id: 1f9ebff99e4b23ff614d8d82fedd112ab8848a75
Summary:
Another installment in the quest to move all exported functions in src/methods behind interfaces.
Closes https://github.com/facebook/prepack/pull/1172
Differential Revision: D6390760
Pulled By: hermanventer
fbshipit-source-id: 3a7cf2d6efac1d5b54f6bb53ea7b23b877f137c0
Summary:
This diff removes CS from RN main bundles. This is very important because any CS change right now triggers all builds from RN, greatly slowing down land times.
I've attempted to find all the correct places to change, but please flag if I'm missing any.
Reviewed By: kathryngray
Differential Revision: D6091082
fbshipit-source-id: b0f5708dfadc353ff56d3d1ab9a8d9d65005b7b2
Summary:
Some versions of test262 include comments in yaml blocks that cannot parse correctly.
Make sure that the test262-runner exits with nonzero code when one of the workers throws an exception so that it is friendly to invocation from shell scripts.
Closes https://github.com/facebook/prepack/pull/1167
Differential Revision: D6359879
Pulled By: cblappert
fbshipit-source-id: f507cc1a7e28c0930df1dc4c6e574b4d8ed58b6d
Summary:
Currently, you can only fold functional components. This PR aims to allow functional component folding directly into a class component. Essentially, this is an incremental step to adding full class component folding.
Closes https://github.com/facebook/prepack/pull/1135
Differential Revision: D6347566
Pulled By: trueadm
fbshipit-source-id: 18cfe3b9583334d4e3500004b562adec3fa9ecee
Summary:
Included:
1) New command line param to the test runner for supplying the entry point for the lazy api.
2) Don't add the mock lazy when shelling out to inferior repl.
3) Don't add the mock when not doing lazy objs.
Closes https://github.com/facebook/prepack/pull/1162
Differential Revision: D6339208
Pulled By: simonhj
fbshipit-source-id: c466d44475034631117502d13d2b51f83ae6fe87
Summary:
Part 3 of the big refactor. Move all the exported functions in environment.js to a class outside of the big cycle.
Closes https://github.com/facebook/prepack/pull/1161
Differential Revision: D6342263
Pulled By: hermanventer
fbshipit-source-id: 194bb689c8b69fd432290583d14bb379fe188a5c
Summary:
Release Note: None.
After lazy object mode is introduced in test-runner, there is a weird line break in the test runner report. Turns out we used util.inspect() to print the options which seem to introduce line break when the object has more than two fields.
Using JSON.stringify() fixed the issue.
Closes https://github.com/facebook/prepack/pull/1157
Differential Revision: D6335667
Pulled By: yinghuitan
fbshipit-source-id: 3265ff81b51e873b00eccd17aace7dc91cc5836e
Summary:
There's a lot of code in function.js. Move it behind an interface so that it no longer forms part of the giant cycle.
Closes https://github.com/facebook/prepack/pull/1143
Differential Revision: D6333759
Pulled By: hermanventer
fbshipit-source-id: 26506e332e9d128d629a4c360ab08ca73641734c
Summary:
Release Note: enable lazy objects mode in test-runner.
Note: I will try hermanventer's suggestion to move all lazy objects creation to prelude and hydrate them after that in future PR for a better way to deal with lazy objects testing issue.
1. Enables lazy objects mode in test runner.
2. For JSON.stringify() and for...in constructs that hydrate lazy objects in global code, I added "force hydrate lazy objects" attribute in the generated code telling test-runner to hydrate the objects immediately
3. Disable lazy objects mode for 3 factorify tests and 4 abstract tests.
4. Skip lazy objects mode for react compiler, additional function tests.
5. Fix a bug which only shows up in lazy objects mode: a) if the target body is non-generator body and delay reason is generator body there is no need to wait for it. b) we should use targetBody instead of this._body in emitter if delayReason is a Value.
Closes https://github.com/facebook/prepack/pull/1147
Differential Revision: D6326474
Pulled By: yinghuitan
fbshipit-source-id: 84fd8d3550ea4685da418224c28247ad330da8bf
Summary:
After adding some tests, it turns out that logic to apply keys to arrays was un-needed. This was because, after running the same code through React, the same errors occur when keys are omitted from arrays. We don't need to do any clever tricks to add keys, as it might actually break logic on things that don't need them. I've added the relevant tests and removed the key adding logic, which should help us with the de-duping work (https://github.com/facebook/prepack/issues/1150).
Closes https://github.com/facebook/prepack/pull/1151
Differential Revision: D6323878
Pulled By: trueadm
fbshipit-source-id: ec3fa90c48332ef0715e94335c558570040ed81c
Summary:
Release note: Adds experimental React functional component folding optimizations
This PR is stacked upon PRs #1118 and #1117. Thus, those PRs should be merged before this PR is merged to reduce noise in the diff.
This PR adds a new React Reconciler into Prepack's serialization process, so that React components trees can be folded/inlined into a single component at build time. To fold a component tree, it must be explicitly done via `__registerReactComponentRoot(nameOfComponent)`.
This PR only attempts to fold React functional components, not React ES2015 class components (that will come in another PR at a later date). Furthermore, the `props` parameter on a root component must contain Flow type annotations (otherwise we will have no idea what the values might be). Support flow `propTypes` might also be an addition, but not for this PR.
If the reconciler comes across a component that it cannot fold/inline, it will "bail-out" and try and continue the process without that particular component being folded into the tree.
An example of how this all works (input):
```jsx
function App(props: {title: string}) {
return (
<div>
<ChildComponent title={props.title} />
</div>
);
}
function ChildComponent(props) {
return (
<span>
<SubChildComponent {...props} />
</span>
);
}
function SubChildComponent(props) {
return <span>{props.title.toString()}</span>
}
__registerReactComponentRoot(App);
global.App = App;
```
Output:
```jsx
(function () {
"use strict";
var _$1 = this;
var _0 = function (props) {
var _$0 = props.title;
return <div><span><span>{_$0}</span></span></div>;
};
_$1.App = _0;
}).call(this);
```
Closes https://github.com/facebook/prepack/pull/1120
Differential Revision: D6237333
Pulled By: trueadm
fbshipit-source-id: b58c7d8979ca79a766bb2ee2eb01a380d37c3101
Summary:
Release note: none
This PR adds the React/Jest testing infrastructure to Prepack and is stacked on the PR https://github.com/facebook/prepack/pull/1117. Thus, that PR should be merged before this PR is merged to reduce noise in the diff.
This will allow us to test various runtime outputs of React 16 when running original source vs Prepacked source to see if there are any issues/differences that might have an impact on applications. The primary reason for this is to track regressions for the component folding PRs that will land in the future.
Please note, this PR does not contain any reconciler changes, thus `__registerReactComponentRoot(App);` has been commented out of tests to ensure they don't prematurely fail. A follow up PR will enable them once the other React functional component folding PRs get landed.
This PR also adds some mock React globals to be used within tests (and maybe to be further integrated into folding at a future point too). The mocks include `React.Component` and `React.cloneElement` for now.
Furthermore, a `utils/json.js` utility file exists to help normalize the results from the React test renderer so that adjacent JSON text nodes get merged, which is something that may exist because of how the reconciler (once the PR lands) handles inlining of child nodes.
The command to run React tests is `yarn test-react`.
Closes https://github.com/facebook/prepack/pull/1118
Reviewed By: cblappert
Differential Revision: D6208263
Pulled By: trueadm
fbshipit-source-id: d54f3b0e1cc3240e1f142d3da08bc279e4153889
Summary:
Define two new flags for test-runner.js:
--repl <path> : If present the, the prepack sources of test are evaluated
using by piping to the process instead of in a new node context.
--es5 : run babel on tests, used if the repl does not support es6.
To further deal with es6 a new test header flag is introduced, es6. If a test is
not relevant in a non es6 world, the test is skipped if the es5 flag is also set.
This flag has been added to some tests.
Running subprocess for each test is obviously more expensive so the default
behavior is unchanged and still uses a new context.
Closes https://github.com/facebook/prepack/pull/1103
Differential Revision: D6192670
Pulled By: simonhj
fbshipit-source-id: 35e4b819d863634f3273a4da7984c7a71d8c4fb9
Summary:
Instead of delaying modules that throw conditionally, let the exception bubble up to the require call and then forget it (after emitting a warning). This allows more global state to be optimized and should be OK if it is understood that throwing an unhandled exception in module initialization code is not a supported scenario.
Probably, the temporal point where the require call happens should contain a conditional throw statement, which would be equivalent to current behavior. For now, this causes invariants to fire in the serializer, probably because of bugs in how the state at the time of the exception is restored and presented to the throw statement.
It is also an option to let the exception escape the require call itself and possibly bubble all the way to the top level. This would be more correct than the current behavior since it should match the runtime behavior of the unprepacked code. This too is currently buggy. It also a bit of performance concern because it uses much more saved state.
Closes https://github.com/facebook/prepack/pull/1104
Differential Revision: D6189032
Pulled By: hermanventer
fbshipit-source-id: 71c6352eddca4d88ae030fdcbfb76e7a39839e73
Summary: Adds new `test-coverage-all` command to `package.json` which will run and compose all test coverage information into one html.
Reviewed By: hermanventer
Differential Revision: D6052366
fbshipit-source-id: 208259fa79185267f6c7a51ca8baf08ffb707e97
Summary:
Release note: Generate code for uncaught exceptions
This is a high priority fix for a land blocking issue. Please review ASAP.
Exceptions that (conditionally or unconditionally) propagate to the top level program used to cause Prepack to fail.
The new behavior is to generate top level code that will (conditionally) throw the exceptions at runtime.
Closes https://github.com/facebook/prepack/pull/1083
Differential Revision: D6050038
Pulled By: hermanventer
fbshipit-source-id: 666c058befdebf2ed5f97bed74818db57b86f34b
Summary:
This seems to have been added to the standard since the last time a looked. Re-enable a test that was already looking for it. Mask "caller" for non strict functions, lest more tests fall over.
Closes https://github.com/facebook/prepack/pull/1049
Differential Revision: D5984228
Pulled By: hermanventer
fbshipit-source-id: 430a5c85b211cb0c5cfb8429c2713246892bebb5
Summary:
Updated todo comments with task numbers.
Not included in this list:
1) node related todos: Sebastian should do that
2) serializer related todos: Nikolai should do that
3) partial evaluator todos: I should do that, but it will take some time.
Closes https://github.com/facebook/prepack/pull/1024
Differential Revision: D5950510
Pulled By: hermanventer
fbshipit-source-id: 131601c18115d5bf8c1a4e1f6a87e45619acc0ba
Summary:
Currently works for all test cases except `noconflict-existantobject.js`.
There are a couple things that are dubious in the current implementation that I will address as I iterate on it:
* We don't visit things correctly in the visitor or the serializer -- we should be visiting only:
* generator entries in effects
* Bindings, PropertyBindings in effects not relating to CreatedObjects
* There is currently no way to emit to the main body after the main generator has been serialized -- we may need to if a value is only reachable from one of the additional functions.
* More thought needs to go into how this interacts with
* speculative initialization
* require optimization
* inlining
Closes https://github.com/facebook/prepack/pull/912
Differential Revision: D5859741
Pulled By: cblappert
fbshipit-source-id: 9fe7bd4429ad53629582f9fb7154a28971159554
Summary:
Issue: #520
Check if components of priorEffects are null when referenced.
Add a maximum stack depth with a default value of 225 and check stack size against this.
Allow the stack depth to be customizable via the command line.
Reran all tests via yarn validate.
Closes https://github.com/facebook/prepack/pull/960
Differential Revision: D5810838
Pulled By: JWZ2018
fbshipit-source-id: e676c3600d936411d9e82b2849912e60f6729eb9
Summary:
Treat `void 0` (and similar patterns) as a simple value that factorifyObject can operate on.
This slightly reduces code size with no adverse effects.
Closes https://github.com/facebook/prepack/pull/909
Differential Revision: D5675928
Pulled By: NTillmann
fbshipit-source-id: 399de8bc71e18ee4aa5aada8ca6e093bcb839fc5
Summary:
Set up an evaluation environment before parsing since the parse helper expects to be able to turn syntax errors into runtime errors.
Catch such errors and report them via handleError when not running eval.
Fixes issue: #900
Closes https://github.com/facebook/prepack/pull/916
Differential Revision: D5689361
Pulled By: hermanventer
fbshipit-source-id: b43a5c6b30e3e93d9e8fb3cc746cbb11f7951bae
Summary:
Internal data indicates that doing two passes to eliminate unneeded identifiers does not help performance or code size at the bytecode level.
Therefore, I swap the default, and rename the option.
--singlePass is no longer an option, and instead, the old two-pass behavior can be triggered via
--inlineExpressions.
Tweaked test runner to run all serialization tests with inline expressions and without,
marked one test that required inline expressions for its test objective.
This addresses #848.
Closes https://github.com/facebook/prepack/pull/894
Differential Revision: D5650410
Pulled By: NTillmann
fbshipit-source-id: 81d79ac042598d7fdc080a0f1798f68d97f8288b
Summary:
I needed this for an investigation and it seems like a useful thing to have.
Closes https://github.com/facebook/prepack/pull/896
Differential Revision: D5637604
Pulled By: hermanventer
fbshipit-source-id: 0abbc56ad3e84ac696a625b8d438c5ff4d8f45d7
Summary:
FunctionValues should not be compared with `===` from the model. Add an option to disable this invariant.
Closes https://github.com/facebook/prepack/pull/881
Differential Revision: D5626447
Pulled By: cblappert
fbshipit-source-id: 3f0bb71cd6dd0b556e46df85658c715798fa0204
Summary:
By allowing prepack CLI to prepack multiple files, user can specify separate model file together with source file. Also, it can allow pre-bundled files to be prepacked together.
I also removed prepackString() API to prefer prepackSources() because they are almost identical logic while prepackSources() API supports multiple files.
Closes https://github.com/facebook/prepack/pull/865
Differential Revision: D5566968
Pulled By: yinghuitan
fbshipit-source-id: ce00087e444b5cdf34b5cfb6913062fc0ee440b7
Summary:
- Clean up options and create new `prepack-options.js` file
- Add `PartialEvaluatorOptions` type which contains only `sourceMaps`
- Fix test code related to above change
https://github.com/facebook/prepack/issues/841
Closes https://github.com/facebook/prepack/pull/878
Reviewed By: NTillmann
Differential Revision: D5605347
Pulled By: cblappert
fbshipit-source-id: 024284a9904dff765417c2c849c4642e781affb3
Summary:
The rest runner did double counting that went awry when certain tests were either just ES5 or just ES6. I just go annoyed at the lack of precision while debugging test failures and this has been lying around on my machine for far too long.
Closes https://github.com/facebook/prepack/pull/874
Differential Revision: D5586527
Pulled By: hermanventer
fbshipit-source-id: 561743c545ec8c54b64a0b96d972b3de31807b3e
Summary:
Added more invariants calls to better enforce the global invariant requiring abstract values with non functional builders to have no arguments.
Also added a way to suppress extraneous errors that may arise while traversing additional function bodies to find read/write conflicts. Fixed the initial traversals to report errors and now pass in parameter needed to allow delayed requires inside these functions.
Fixed a bug in generator where it created an abstract value with a non functional builder and some arguments. Then fixed a bug in JSON.parse where it special cased abstract values produced the wrong way.
Added some logic to test-internal to invoke prepack with specified additional functions if the test case has a particular name. This test has to be run manually since it takes a rather long time to complete.
Added logic to populate CompilerDiagnostic objects with a callStack property so that it is easier to find the ultimate source of a prepack error.
Closes https://github.com/facebook/prepack/pull/869
Differential Revision: D5581023
Pulled By: hermanventer
fbshipit-source-id: 37d7cffe32135b95939b3da81de2a5b3c9df26c4
Summary:
Introspection errors no longer show up as completions, so any time we evaluate a node that might cause an introspection error, we should expect to catch and handle a FatalError.
Also tweaked package.json to allow longer stack traces when running test-serializer and tweaked test-internal to output error messages that do not have associated source locations. (The latter should not happen in practice but could happen when things go wrong.)
Closes https://github.com/facebook/prepack/pull/866
Differential Revision: D5563965
Pulled By: hermanventer
fbshipit-source-id: e2a74ec19314703526ebd35f7b8e694c19d82ab0
Summary:
`Date.now()` and `Math.random()` calls emitted into the generator now no longer get serialized if their results are not used. In principle this is safe for any pure definitions of AbstractValues emitted to the generator but that is too hard to determine for most cases.
Adds a test case verifying that extra `Date.now()` calls are eliminated.
See #543 for more detail.
Closes https://github.com/facebook/prepack/pull/822
Differential Revision: D5537430
Pulled By: cblappert
fbshipit-source-id: 4f3e12eee65fdbea7504d73399eddde5a1e93703
Summary:
Additional functions may be properties of global objects, so just parse the option string as an expression and evaluate it in the global environment.
Closes https://github.com/facebook/prepack/pull/858
Differential Revision: D5541434
Pulled By: hermanventer
fbshipit-source-id: b0b39f2b0ff072ebafeba3e33cd2cd1365dfd4b8
Summary:
If one additional function reads a property that is written by another additional function, it becomes potentially dependent on the other function running before it does. Additional functions are supposed to be independent of each other, so we now detect this and report errors.
Closes https://github.com/facebook/prepack/pull/850
Differential Revision: D5529672
Pulled By: hermanventer
fbshipit-source-id: f810d27d1fbf03d6538d70e61a1d9e7c0fe55309
Summary:
Introduce ECMAScriptFunctionValue and move many fields of FunctionValue down to ECMAScriptFunctionValue. FunctionValue becomes the abstract base class:
1. Use invariant(F instanceof ECMAScriptFunctionValue) if only ECMAScriptFunctionValue is valid in that code path to make flow happy.
2. Replace "F.getType() === FunctionValue" with Value.isTypeCompatibleWith(F.getType(), FunctionValue)
3. $ScriptOrModule may also be able to move down to ECMAScriptFunctionValue, but I am not 100% positive so leave it in FunctionValue for now.
Closes https://github.com/facebook/prepack/pull/824
Differential Revision: D5527976
Pulled By: yinghuitan
fbshipit-source-id: 017748d67c31aa121c35b28b43cef026e904a412
Summary:
Provide a new option to specify a number of additional functions to prepack (in addition to the global code "function", that is). These functions need to exist in the global scope, have no parameters, be well behaved (never throw an exception) and should not depend on each other (the order in which they get called should not matter).
At the moment there are checks only for existence, good behavior and no write-write conflicts. Also, the functions are not actually prepacked yet.
Closes https://github.com/facebook/prepack/pull/846
Differential Revision: D5514569
Pulled By: hermanventer
fbshipit-source-id: e2e343d9eed4772fc11810d91293facdafca8fcb
Summary:
That will allow to determine their perf implications.
Cleaned up --help text a bit.
Change serializer test runner to run each test twice, with delaying of initialization and without.
This also effectively re-enables fixed point check, as it is currently disabled whenever the
delaying of initializations kicks in. (See issue #835.)
Closes https://github.com/facebook/prepack/pull/842
Differential Revision: D5504808
Pulled By: NTillmann
fbshipit-source-id: e470d5b7d3b48b2e44819a4e859c48983a887d74
Summary:
If a test case fails but there were delayedValues it was previously failing
Closes https://github.com/facebook/prepack/pull/834
Differential Revision: D5494450
Pulled By: Kishore-B-Rao
fbshipit-source-id: 4dcacaa4384dd4febb57aa191ba122fd9aa6b416
Summary:
Update Babylon and adjust expected pass count to match what I see on my laptop.
The difference was due to my version of Babylon (which is the latest for some or other reason I don't understand) giving a syntax error that did not occur with the version on the CI machine. Updating the yarn lock file gets the CI machine in sync with my laptop with respect to those tests.
Note that some String.prototype tests only pass with recent versions of Node.
Closes https://github.com/facebook/prepack/pull/831
Differential Revision: D5489742
Pulled By: hermanventer
fbshipit-source-id: 5732e47718c53d9f20de04fd64c1389524f33309