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
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
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 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:
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:
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:
- 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:
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:
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
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
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
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
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
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
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
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.
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.
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.