Commit Graph

115 Commits

Author SHA1 Message Date
Herman Venter
cb78d1cedf Update expected number of test262 passes
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
2017-12-04 16:12:01 -08:00
Leo Balter
df0f9e16ae Use integration api to run Test262 tests
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
2017-12-01 17:46:29 -08:00
Chris Blappert
13f94fa1ba Change cli stdout output to stderr for exceptional cases
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
2017-11-30 12:55:59 -08:00
Jeffrey Tan
e03c61c29f Preserve residual funciton original ordering
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
2017-11-29 11:08:38 -08:00
Jeffrey Tan
1af3bc012d Fix lazy object identifier inside ConditionalAssignmentBranch
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
2017-11-28 12:55:04 -08:00
Jeffrey Tan
efa13054b3 Better lazy objects mock test runner support
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
2017-11-22 17:08:24 -08:00
Wuhan Zhou
3cd5ca1a89 Fix lint on master
Summary:
Release note: none
Closes https://github.com/facebook/prepack/pull/1185

Differential Revision: D6397761

Pulled By: JWZ2018

fbshipit-source-id: 85e4c3fcf7f837ed3dad9729e5f18e5bf0c17ca3
2017-11-22 11:06:59 -08:00
Herman Venter
dd8c39ee19 Make create.js private
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
2017-11-21 15:55:00 -08:00
Brian Shin
389d49657c Remove ComponentScript from Core App RN bundles
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
2017-11-21 15:23:10 -08:00
Herman Venter
89e945ec3e Make join.js private
Summary:
Another installment in moving functions behind interfaces.
Closes https://github.com/facebook/prepack/pull/1164

Differential Revision: D6360625

Pulled By: hermanventer

fbshipit-source-id: 5c5b53d9d927d9419b545a790356ddfc315eaede
2017-11-17 11:28:47 -08:00
Chris Blappert
9dc60da9f5 Fix yaml errors ending test262 execution
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
2017-11-17 10:41:45 -08:00
Dominic Gannaway
4569636fe4 Fold functional component trees that have a class component as root
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
2017-11-16 05:23:48 -08:00
Simon Jensen
8849382d85 Make the name of the lazy obj runtime a cmd parameter for the test-runner
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
2017-11-15 17:51:23 -08:00
Herman Venter
38ebd22f92 Make the implementation of environment.js private.
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
2017-11-15 16:28:01 -08:00
Jeffrey Tan
c3873061d4 Fix test runner line break issue
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
2017-11-15 08:04:23 -08:00
Herman Venter
beee1bba59 Make the implementation of function.js private.
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
2017-11-14 22:28:28 -08:00
Jeffrey Tan
08f3922e60 Enable lazy objects mode in test runner
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
2017-11-14 12:14:11 -08:00
Dominic Gannaway
03750d1b3b Removes un-needed React JSX key handling
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
2017-11-14 07:38:33 -08:00
Dominic Gannaway
810056d1ec Add React functional component folding
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
2017-11-06 05:07:36 -08:00
Dominic Gannaway
e63daa5585 Add React/Jest testing infrastructure
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
2017-11-02 04:40:33 -07:00
Simon Jensen
0a3e23eeb0 Support running tests in inferior JavaScript repl.
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
2017-10-30 17:29:46 -07:00
Herman Venter
80b0757f67 Allow required modules to throw conditionally
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
2017-10-30 13:00:01 -07:00
Herman Venter
d7a60ebd35 Fix prettier and lint failures
Summary:
Fix build.
Closes https://github.com/facebook/prepack/pull/1098

Differential Revision: D6122926

Pulled By: hermanventer

fbshipit-source-id: 3cf74746fa5db5b6fdf84fb923cb87af0c2e19f5
2017-10-23 00:00:47 -07:00
Chris Blappert
37fa45bf12 New code coverage step
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
2017-10-19 17:58:26 -07:00
Dominic Gannaway
cfc6993e9c Basic JSX/ReactElement support
Summary:
Release notes: adds JSX and ReactElement evaluation/serialization support

This adds JSX/ReactElement support to the Prepack serializer so `ReactElement` "like" objects can correctly be converted back to JSX syntax. Example:

```jsx
'use strict';

const externalThing = __abstract('function', 'externalThing');

function Test() {
  return <div>{ externalThing() }</div>
}

global.test = Test;
```

Becomes:
```jsx
'use strict';

var _$0 = this;

var _0 = function () {
  return <div>{_1()}</div>;
};

var _1 = externalThing;
_$0.test = _0;
```

I've also added a JSXElement -> ReactElement evaluator.
Closes https://github.com/facebook/prepack/pull/1051

Differential Revision: D6053275

Pulled By: trueadm

fbshipit-source-id: 7c31545751ceedba55cdd4581bc6de51a98b412a
2017-10-13 12:18:35 -07:00
Herman Venter
b0e977136c Emit code for exceptions that make it to the top level.
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
2017-10-12 23:41:33 -07:00
Herman Venter
1cbdfa2022 Make "caller" a restricted property in strict mode.
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
2017-10-04 22:09:09 -07:00
Eric Wright
f68335998a Added --omitInvariants option to prevent invariants from being included in generated code.
Summary:
Fixes #992.
Closes https://github.com/facebook/prepack/pull/1038

Differential Revision: D5959825

Pulled By: Eric-Wright

fbshipit-source-id: 4eb3f5cd24ed2a6f4ba26be321042e3a864de498
2017-10-02 23:07:58 -07:00
Herman Venter
336236d85b Create tasks for TODOs
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
2017-09-30 16:25:32 -07:00
Chris Blappert
cd3821ab7e Serialize independent functions
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
2017-09-25 16:53:45 -07:00
Joseph Zhou
8a63ed58b9 Check undefined in addPriorityEffect and add max stack depth
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
2017-09-12 12:58:14 -07:00
Nikolai Tillmann
6ca6df1e3a Slight improvement to factorifyObject
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
2017-08-25 12:53:39 -07:00
Herman Venter
be0bed968c Handle syntax errors
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
2017-08-23 18:09:12 -07:00
Nikolai Tillmann
af73d3f6dc Changing default of --singlePass (and renaming option)
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
2017-08-17 21:41:51 -07:00
Herman Venter
3fabe89bf3 Add --debugNames flag to test-runner
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
2017-08-15 19:40:15 -07:00
Christopher Blappert
be70144220 Add option to not emit invariants for model functions
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
2017-08-15 15:28:26 -07:00
yinghuitan
208c7ab07f Allow Prepack CLI to prepack multiple source files
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
2017-08-14 22:41:24 -07:00
Sangboak Lee
1bbba378d2 Clean up options and fix test code
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
2017-08-11 14:55:20 -07:00
Herman Venter
ab85a0b734 Tweak test runner to see how many test actually run
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
2017-08-08 16:16:55 -07:00
Herman Venter
219961b247 Fixes for prepacking new internal test
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
2017-08-07 20:11:15 -07:00
Herman Venter
50ce236f5e Catch fatal errors in visitName.
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
2017-08-04 11:20:16 -07:00
Chris Blappert
195034443e Does deduplication of pure builtin calls in generator
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
2017-08-03 14:10:49 -07:00
Herman Venter
ddefa60949 Specify additional functions using expressions.
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
2017-08-01 15:33:04 -07:00
Herman Venter
12555b9817 Detect read-write conflicts
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
2017-07-31 13:28:20 -07:00
Jeffrey Tan
5b1f55d5f1 Refactor FunctionValue
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
2017-07-31 10:55:23 -07:00
Herman Venter
d37e01846f Specify additional initialization functions to prepack
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
2017-07-27 18:38:18 -07:00
Nikolai Tillmann
426dac2ee3 Make delaying of initializations optional
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
2017-07-26 17:47:17 -07:00
Kishore B. Rao
f862ddd0b8 Updated test262 runner to have parameters
Summary: Closes https://github.com/facebook/prepack/pull/840

Differential Revision: D5503362

Pulled By: Kishore-B-Rao

fbshipit-source-id: ec2a80dfbde9cca17818603632c0bd2413acfe3e
2017-07-26 17:15:16 -07:00
Kishore B. Rao
57952f4656 Fixed bug in test-runner
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
2017-07-25 17:02:45 -07:00
Herman Venter
f8bf43f673 Update yarn.lock
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
2017-07-25 14:27:51 -07:00