Commit Graph

26 Commits

Author SHA1 Message Date
Chris Blappert
0ef3c43563 Change initializeMoreModules to modulesToInitialize allowing you to s… (#2576)
Summary:
…pecify modules

Release Notes: None

Sometimes it'll be useful to allow the user to specify which specific modules you want to speculatively execute. This allows that by turning `--initializeMoreModules` into `--modulesToInitialize <ALL | comma separated list of modules>`

Updated tests as well.
Pull Request resolved: https://github.com/facebook/prepack/pull/2576

Differential Revision: D10092554

Pulled By: cblappert

fbshipit-source-id: bf601e14c2be59c865ae9513c914f39325521945
2018-09-27 15:10:17 -07:00
Herman Venter
7157849a44 Do full joins (#2402)
Summary:
Release note: Rewrote the joining logic to always do a full join at every join point

Closes #2151 #2222 #2279

I've spent a lot of time in the last few months trying to sort out problems that arise from effects being applied too many or too few times. Fixing these feel a bit like playing wack a mole and in the end no fix goes unpunished.

Stepping back a bit from the fray, it seems to me that the root cause of all this pain is the fact that joins of different kinds of completions get delayed.

Before we had path conditions and the simplifier this seemed like a rather good thing since exceptional paths did not contribute values to the normal paths and we thus had fewer abstract values to deal with and fewer places where Prepack would grind to a halt.

In the current state of things, however, it seems perfectly possible to join in all branches at every join point. I've had to decrease some limits, in particular the number of times we go around a loop with conditional exits. I've also had to make the test runner impose a limit on how many times the simplifier can invoke Path.implies.

Nevertheless, the tests seem to pass and hopefully this will also fix quite a lot of bugs that have been unresolved for many months already.
Pull Request resolved: https://github.com/facebook/prepack/pull/2402

Differential Revision: D9236263

Pulled By: hermanventer

fbshipit-source-id: 92a25b591591297afeba536429226c5a0291f451
2018-08-11 20:53:43 -07:00
Sapan Bhatia
db45feabfe Support InstantRender empty built-in (#2364)
Summary:
Resolves #2186. Embeds the value `__empty` in array and object literals for properties that are conditionally set, instead of handling such values via assignments and deletes. Raises an exception if there is a cycle in object or array creation (InstantRender does not support these).
Pull Request resolved: https://github.com/facebook/prepack/pull/2364

Differential Revision: D9169335

Pulled By: sb98052

fbshipit-source-id: f83d85677b30f10f3c548349e93ce792fc6c1ca0
2018-08-03 17:24:26 -07:00
Andres Suarez
f20de93335 Prettier 1.13.4 fixes
Reviewed By: trueadm

Differential Revision: D8301297

fbshipit-source-id: f2fb9562680aa0c1de717f8f162ae8cb611c27f4
2018-06-06 12:49:59 -07:00
Nikolai Tillmann
032f71403f Removing --abstractEffectsInAdditionalFunctions option
Summary:
Release notes: Removing --abstractEffectsInAdditionalFunctions option

It is now the new default, as nothing seems to depend on the old behavior.
Closes https://github.com/facebook/prepack/pull/1623

Differential Revision: D7342083

Pulled By: NTillmann

fbshipit-source-id: c02d13bddd0ff3d8a113a6a5a83c1bf35c96ba4d
2018-03-20 15:04:24 -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
Herman Venter
5932b4e08c Fix _getTarget to deal with abstract values that are referenced from more than one additional function
Summary:
Release note: none

Abstract values from the global scope are not registered as additional roots, so the usual common ancestor logic fails in this case.

Also fix a bug in test-error-handler.js that allowed this regression to go undetected.
Closes https://github.com/facebook/prepack/pull/1511

Differential Revision: D7128652

Pulled By: hermanventer

fbshipit-source-id: 4317d50810dfdf0ce3b97e17a0c169e056389ca5
2018-03-01 14:42:04 -08:00
Herman Venter
2fdcf9a778 Compile time error for Set constructor argument if using JSC
Summary:
Release note: fixes issue #1340

When the target platform is JSC, issue a compile time diagnostic if an argument is provided to the set constructor. Then proceed as if there were no argument, which is what JSC does at runtime.
Closes https://github.com/facebook/prepack/pull/1386

Differential Revision: D6863721

Pulled By: hermanventer

fbshipit-source-id: 9ee3af5e8028ea1657e0b39d31393036c66f744a
2018-01-31 14:40:02 -08:00
Sebastian Markbage
112e775e52 Error if an abstract function that might throw is called within a try
Summary:
This is a follow up to #1142. If we call an unknown function it might throw which will take a different control flow. #1264 is the follow up to do this properly but since we don't have a use case right now, we can just issue a recoverable error if this happens.
Closes https://github.com/facebook/prepack/pull/1284

Differential Revision: D6669732

Pulled By: sebmarkbage

fbshipit-source-id: 32ff40d4afba589ce60193b01034dfb8bc764378
2018-01-05 15:56:33 -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
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
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
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
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
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
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
d182dcda70 Allow more than one input file for Prepack
Summary:
We usually need at least two files: 1) the environmental model and 2) the bundle to be Prepacked.
In general, there is no good reason to not allow as many files as the caller wants.

To make this not be a breaking chance, I've added a new API for this: prepackSources.

Further complications result from working around a bug in Babel and not increasing the module cycle length for Flow.
Closes https://github.com/facebook/prepack/pull/776

Differential Revision: D5366190

Pulled By: hermanventer

fbshipit-source-id: 74595b1b60e8e8a6d24cb974b5be10210d745266
2017-07-03 15:08:01 -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
Herman Venter
a8f7394547 Errors for instanceof operator
Summary:
Now give error messages for instanceof operators when the right operand is too abstract.
Closes https://github.com/facebook/prepack/pull/735

Differential Revision: D5281708

Pulled By: hermanventer

fbshipit-source-id: 78b848a46860ccbf67554fb25d235740df3ac06b
2017-06-19 19:52:02 -07:00
Herman Venter
25134c4ad6 Error for in with abstract
Summary:
Give a more detailed error when the in operation is not safe to do at Prepack time.
Closes https://github.com/facebook/prepack/pull/733

Differential Revision: D5281195

Pulled By: hermanventer

fbshipit-source-id: ea92b418cf6a836b2934ecca64ac1b3f3a0898d8
2017-06-19 18:38:44 -07:00
Herman Venter
8fd2bede97 First bit of support for error recovery (#725) 2017-06-13 14:09:18 -07:00
Herman Venter
f49ce47482 Make error handler test less verbose (#716) 2017-06-12 10:12:10 -07:00
Guy Hershenbaum
7d7f07b436 Enable compiler-diagnostics reporting for errors (#698)
Added interface for reporting compilation/evaluation errors with relevant metadata
The new interface is used in a single location as a proof-of-concept

* Cleaning up the interface for handling recoverable errors

* more general recoverable error

* Addressed review comments

* Addressed review comments + added basic tests

* Address review comments #2

* Addressed CR comment about errorHandler in Options

* Fixing typo in import

* Address more review comments

* Fix linter errors

* Fix more linter errors

* Adjust test runners to run the new test
2017-06-06 15:53:39 -07:00