prepack/babel.config.js
Caleb Meredith 108dea533b Add serializer mode for test262 execution (#2290)
Summary:
I want to better understand the bugs we have in abstract evaluation. One of my ideas to do this is to replace all the literals in test262 tests with abstract values and see what our test coverage is. The first step to do this is to serialize the test262 sources after running them in Prepack and checking if their generated JavaScript runs correctly. This PR does that by adding a `--serializer` flag.

With my methodology, all test262 harnesses are serialized every time since they are in the global scope. This unfortunately seems to be unavoidable since doing otherwise would change program semantics and break the tests.

Running `time yarn test-test262` takes about 2 minutes and has a 98% pass rate. Running `time yarn test-test262 --serializer` takes about 5 minutes and has a 95% pass rate. [Here’s a diff of the two  results.](https://gist.github.com/calebmer/1c9fe396b63ba055458c599c2be18a58)

[Here is a selection of some of the bugs](https://gist.github.com/calebmer/1ac381096a4aa7be1fc7dc2163276ab4) in the serializer caught by running test262 with the Prepack serializer. I might open issues for these, but they can be a bit pedantic. I might fix some of them depending on how important they are to the React code we want to compile.

Notably we have:

- Lots of invariants being triggered. I particularly saw [a lot of this invariant](7d355ef4c5/src/serializer/ResidualHeapVisitor.js (L531)). (An example of this is [`07.md`](https://gist.github.com/calebmer/1ac381096a4aa7be1fc7dc2163276ab4#file-07-md).)
- Lots of values that are visited, but not serialized. (An example of this is [`01.md`](https://gist.github.com/calebmer/1ac381096a4aa7be1fc7dc2163276ab4#file-01-md).)
- Some incorrect outputs only caught by executing code. Could not be caught by static analysis. Particularly around class serialization.

I’ll build off this PR to get coverage for the abstract evaluator next, but I found these results interesting on their own so decided to do this in two PRs.
Pull Request resolved: https://github.com/facebook/prepack/pull/2290

Differential Revision: D8908479

Pulled By: calebmer

fbshipit-source-id: aa57d47611fbd92af33e4647fed7bf7990fb6de1
2018-07-18 18:54:51 -07:00

59 lines
1.3 KiB
JavaScript

/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
module.exports = function(api) {
api.cache(true);
const plugins = [
"@babel/plugin-syntax-flow",
"@babel/plugin-syntax-jsx",
"@babel/plugin-transform-flow-strip-types",
"@babel/plugin-transform-react-jsx",
"@babel/plugin-transform-react-display-name",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
];
// Webpack bundle
if (process.env.NODE_ENV === "production") {
return {
presets: [
[
"@babel/env",
{
targets: {
ie: "10",
},
forceAllTransforms: true,
},
],
"@babel/preset-flow",
],
plugins,
};
}
// Default
return {
presets: [
[
"@babel/env",
{
targets: {
node: "6.10",
},
},
],
"@babel/preset-flow",
],
plugins,
// `lib` files are already compiled with Babel. Don't try to compile them again.
ignore: ["lib/**/*.js"],
};
};