Commit Graph

27 Commits

Author SHA1 Message Date
Dominic Gannaway
9123227e45 Fixes Prettier issues on master
Summary:
Release notes: none

Fixes the current lint issues on master regarding Prettier.
Closes https://github.com/facebook/prepack/pull/1761

Differential Revision: D7686530

Pulled By: trueadm

fbshipit-source-id: 0885854c3cca409d47d4980735f56bd794f55606
2018-04-19 08:53:06 -07:00
Nikolai Tillmann
a6ed842b9a Tweaking Prepack's test-internal script.
Reviewed By: simonhj

Differential Revision: D7370098

fbshipit-source-id: d52dbae2a405580ac484718bcf456449d9aea74d
2018-03-22 19:09:39 -07:00
Nikolai Tillmann
5842db583e Fix environment record bindings in serializer
Summary:
Release notes: None

- Removed --additionalFunctions CLI argument as well as `// additional functions` comment from test runner, rewriting tests instead to use `__registerAdditionalFunctionToPrepack` everywhere.
- Turns out that too many modified bindings reach the serializer's visitor. As a short-term hack, introduced a global id counter for environment records to identify and filter out environment records created after global code. (Long term a `createdEnvironmentRecords` set just like `createdObjects` might be the proper solution.)
- There was some confusion around the global environment, as there's the `GlobalEnvironmentRecord`, but it in fact defers to its `.$DeclarativeRecord`, which ended up in a binding. This is now normalized.
- Separated out `resolveBinding` from `visitBinding`, to avoid the unnecessary (and error-prone) binding resolution step when possible
- Removed what looked like an unmotivated `residualBinding.modified = true;` statement.
Closes https://github.com/facebook/prepack/pull/1552

Differential Revision: D7249181

Pulled By: NTillmann

fbshipit-source-id: 4ec15c3eca7b45b7ea408f5407c4317a31319151
2018-03-12 17:46:40 -07:00
Dominic Gannaway
b389598bb5 Rename __registerAdditionalFunction -> __optimize
Summary:
Release notes: `__registerAdditionalFunction` is now `__optimize`

This PR renames `__registerAdditionalFunction` to `__optimize` and removes all tests that use the `// additional functions` logic in favor of declaratively using `__optimize`. Also the serializer option for `additionalFunctions` is removed too.
Closes https://github.com/facebook/prepack/pull/1561

Differential Revision: D7219751

Pulled By: trueadm

fbshipit-source-id: 7984496b3a68db3194fb3696839cb11fdd0b7843
2018-03-09 14:44:46 -08:00
Alex Dvornikov
8ed1ba6c1e Axe "prepareReact" functions from Bundle Entrypoints
Summary:
This diff completely removes
"prepareReact" function from our entrypoints

Reviewed By: alexeylang

Differential Revision: D6602427

fbshipit-source-id: 60fa3a7acc1fea2964bf4c65da5615da5348e993
2018-01-15 15:48:35 -08:00
Lukas Koebis
838d0cdc4a Add option to disable "acceleration" of require calls.
Summary:
Fixes #986
Closes https://github.com/facebook/prepack/pull/1283

Reviewed By: NTillmann

Differential Revision: D6638592

Pulled By: lukas1994

fbshipit-source-id: d964dc1f8611a9b95aa334e11506fc637705671f
2017-12-27 10:07:57 -08:00
Jhalley Badua De Castro
2f17f59751 Fix: Test output percentage should round down instead of up
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
2017-12-13 12:00:48 -08:00
Jhalley Badua De Castro
8c7b508162 Changed wrong use of console.log in the codebase to console.error
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
2017-12-12 16:34: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
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
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
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
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
Herman Venter
8b5f40bcad Downgrade errors to warnings if they occur inside a delayed module
Summary:
If a module get's delayed because of a prepack error, we would like to notify developers about it, but not expose this to them as errors, which would be presumed to break the build.
Closes https://github.com/facebook/prepack/pull/814

Differential Revision: D5434272

Pulled By: cblappert

fbshipit-source-id: 6be27a30706c70b43a925603e62f1750ec395b3f
2017-07-17 10:13:13 -07:00
Herman Venter
f0808ebc36 Rename CompilerDiagnostics to CompilerDiagnostic
Summary:
An instance of this class is a single diagnostic message, so the plural just seems wrong.
Closes https://github.com/facebook/prepack/pull/811

Differential Revision: D5420522

Pulled By: hermanventer

fbshipit-source-id: c848911a27d2c445ba98ee04988f5c4afe261dc1
2017-07-13 16:53:40 -07:00
Herman Venter
2145351b38 Test separate model file and fix source maps for comments
Summary:
Adapt the test-internal script to combine separate files containing a model, a source bundle and a source map.

Also extend fixup_filenames to explicitly traverse comments because the default traverser does not do so.
Closes https://github.com/facebook/prepack/pull/789

Differential Revision: D5386836

Pulled By: hermanventer

fbshipit-source-id: da0499cd027ecf94dcde612d0ce831ea1fd4a98b
2017-07-07 23:42:17 -07:00
Nikolai Tillmann
4824b47038 Ran Prettier over codebase.
Summary: Closes https://github.com/facebook/prepack/pull/778

Differential Revision: D5367120

Pulled By: NTillmann

fbshipit-source-id: 4c8810efee816d699157e59ea9ba0c8d57950015
2017-07-03 16:29:47 -07:00
Herman Venter
934ee3619a Hook up error handling code for all prepack clients
Summary:
Except for the web site.

Also reorganized the API a bit and deprecated some calls.
Closes https://github.com/facebook/prepack/pull/763

Differential Revision: D5351215

Pulled By: hermanventer

fbshipit-source-id: c5da7f81138f7b0cb97d28da25c5e3fe8836ccb9
2017-07-03 12:08:04 -07:00
Kishore B. Rao
a6cb03b5e6 Updated Sandcastle Tests
Summary: Sandcastle Tests now prepack a checked in version of instagram on every single diff. Of note is that to run the test-internal locally you need to put the instagram bundles in a directory called facebook/test as this is the cleanest way to run these tests internally. The buck targets are updated and still exist but are not entirely necessary right now. If people outside of prepack want to build it and use it, however, they could link up with the buck target.

Reviewed By: cblappert

Differential Revision: D5335451

fbshipit-source-id: 102cb228e0b422b399605132de96b881cd4233e7
2017-06-30 00:55:26 -07:00
Herman Venter
3462753ef8 Error messages for call expressions
Summary:
Check for calls to abstract values that are not known to be functions. Also check for calls to eval with abstract arguments.

See also: #705
Closes https://github.com/facebook/prepack/pull/742

Differential Revision: D5296150

Pulled By: hermanventer

fbshipit-source-id: 071543dc6690297a08ad03eb1b0cb2c3c6a9a2dd
2017-06-21 14:38:23 -07:00
Herman Venter
6cb22dd91e Early termination for fatal errors
Summary:
If an error is reported to the host application and it returns a value that indicates that the error is fatal, the evaluator now throws a FatalError exception rather than causing an IntrospectionError.

This terminates things quickly and cleanly but uncovered a bug in the way effect tracking is cleaned up in the face of exceptions that are not throw completions. To fix this, the code that pops an evaluation context off the stack now checks if there are any dangling effects in the context and, if there are, it folds them into the effects of the outer context.

The effects then propagate to the most closely nested evaluateForEffects call, where they are
rolled back from the global state and incorporated into the effects returned from the call.

When they propagate all the way to a test runner, as happens when there is an IntrospectionError in global code, the state is never rolled back and thus the error can be logged in the state that applied when it was created.

DEPRECATED API
The InitializationError constructor in prepack-standalone.js is going to go away in a future release. Please use FatalError instead. For now, InitializationError.prototype is on the prototype chain of FatalError.prototype, so instances of FatalError will still be instances of InitializationError, so this should not be a breaking change in the next release.
Closes https://github.com/facebook/prepack/pull/740

Differential Revision: D5286107

Pulled By: hermanventer

fbshipit-source-id: 05c7f9197acaa0ba922d136f122968b2f41a4b82
2017-06-20 20:23:35 -07:00
Herman Venter
e96ef88e59 Introduce new partial evaluator mode (#671)
* Introduce new partial evaluator mode

* Make options argument optional again

* Rename isPartialEvaluator to useAbstractInterpretation
2017-05-23 11:08:46 -07:00
Abhishek Soni
2237aef446 Remove ambiguity as discussed in #612 2017-05-10 11:38:44 -07:00
Sebastian Markbåge
eb8268a7e0 Use public APIs in tests (#563)
This gives us some better end-to-end coverage and makes it easier move
internals around.

This surfaced a few bugs/issues in the API.

I left the thing that detects introspection errors but this surfaced that
we don't have a way to pass custom error loggers through the public API.
I didn't want to expose the whole Realm and Value types externally. But
it might be worth having a string based way to get logs.
2017-05-04 15:16:31 -07:00
Sebastian Markbåge
8f9e912deb Refactor global intrinsics initialization (#477)
We used initialize all possible environments in a single intrinsics entry
point. That doesn't quite scale to many and complex environments. So the
goal of this refactor is to invert the initialization of globals.

Now a Realm is created with only the standard ECMA262 intrinsics. This is
also important because we should be able to create new realms from within
user code to model things like iframes, node.js contextify and the new
standard Realm API that is used to create new realms. All of these
basically starts out with a standard realm that can then be expanded.

Then the actual initialization of the global happens outside of the
serializer so that the serializer dependency isn't coupled to any
particular set of environments.

To do this I created a "global.js" file for each environment inside of
intrinsics.

It's interesting to note that "console" and timers isn't part of the
standard realm.

Another interesting one is that "global" isn't actually part of the DOM
environment yet. It might be if this proposal gets through:
https://github.com/tc39/proposal-global

However, since so many tests depend on global, including in test262,
I model it as already part of ECMA262 globals.

I also had move the initialization of the realm out of the serializer API
so that it is possible to initialize the realm with arbitrary intrinsics
before that happens.

However, when I did that I had to move the attaching of of the generator
into the serializer because otherwise mutations to intrinsics during
initialization gets tracked as something to serialize.

This might help avoid the cycle problem that construct_realm was meant to
fix so that we can just go back to using a simple constructor for Realm.
2017-04-27 18:11:37 -07:00
Sebastian Markbåge
db10fc86f1 Extract scripts from npm package (#463)
This moves things around in a more common idiomatic folder structure / naming convention. This extracts the scripts that are only used to test the library from the source of the library itself.

/src/scripts -> /scripts

This is no longer part of the build process. Therefore we use babel-node to run the files as needed. The exception is test-runner that is just ran in plain node so that it works with the coverage reports.

The lib folder now includes only and all the library files required to use the package and no longer test runners.

Because of that I moved all the dependencies that were related only to our test scripts and website build to devDependencies. That way we minimize the required dependencies to use Prepack downstream as an npm package.

Then I configured the package.json to only list lib/ and bin/ folders as part of the package. This lets `npm publish` ignore all other files so that people installing the package don't need to include all our testing code.

I added files to bin/ and package.json which is a convention to make this package installable and usable as a command-line tool.

Renamed run_util -> prepack-cli and repl -> repl-cli to separate these from library variants.

The coverage reports now get created in the root instead of lib folder so that they don't get included in the build.

I bumped the version number to one minor above what is already on npm since we can't publish earlier than that.
2017-04-26 12:26:18 -07:00