mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-09-11 14:46:37 +03:00
Summary: Release Notes: None This PR makes it so we no longer report conflicts for child optimized functions reading from values that their parents have written. Couple of things for discussion: - This creates somewhat confusing behavior because the child functions will take the concrete value after the parent functions' effects have been applied: ```javascript (function () { let obj = {p: 42}; function f() { obj.p += 3; function g() { return obj.p; } // Will optimize to `return 47;` obj.p += 1; __optimize(g); obj.p += 1; return g; } __optimize(f); global.f = f; })(); ``` - This PR creates the Parent/Child relationship based off `AdditionalFunctionEffects.parentAdditionalFunction` which goes off of syntactic nesting of functions instead of nesting of `__optimize` calls as in the issue. I believe basing the nesting off of `__optimize` calls could lead to somewhat unintuitive results (especially considering we store `parentAdditionalFunction` in `AdditionalFunctionEffects` to be the syntactic parent). I am not sure if it is needed by Instant Render NTillmann? If it is, we may want to consider changing `AdditionalFunctionEffects.parentAdditionalFunction` to be based off of `__optimize` call nesting as well for consistency. As an example a slight modification on the example above: ```javascript (function () { let obj = {p: 42}; function g() { return obj.p; } function f() { obj.p += 3; __optimize(g); obj.p += 1; return [g, obj]; } __optimize(f); global.f = f; })(); ``` With this PR, we report an error. Based off of `__optimize` nesting, we would optimize `g` to `return 46;`. I would expect to see `return 42;` `return 45;` or `return obj.p;` in this case. - To resolve the above issues, in the future, we could make any values modified by parent optimized functions into abstract values during evaluation for child optimized functions to force their accesses to be recorded in generators . Resolves #2351 Pull Request resolved: https://github.com/facebook/prepack/pull/2542 Differential Revision: D9803741 Pulled By: cblappert fbshipit-source-id: baca233c8de81633332b25f0776ed1a9d6c95a60 |
||
---|---|---|
.. | ||
error-handler | ||
react | ||
serializer | ||
source-maps | ||
std-in | ||
test262@e9a5a7f918 |