-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🏗 Refactor transform-log-asserts #24028
Conversation
The only big change here is now we'll try to statically analyze assertions. - If we're asserting a type and we know that the argument is not of that type, we rewrite to a throw expression - Else if we're assertiong truthiness and the argument is falsey, we rewrite to a throw expression This is to better support stubbed out methods, eg, layers: ```js class Resources { layersStuff() { devAssert(this.layersEnabled_); // lots of code that can be DCE'd when layers is statically disabled } } ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this PR locally after removing AmpPass.java
, and am still seeing the number of instances of assert
in v0.js
increase from 20 to 80. Happy to chat offline to make sure we're on the same page.
2e45987
to
cbde1a9
Compare
That's due to amphtml/build-system/build.conf.js Lines 138 to 140 in c5d6e5a
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Removing if (isSinglePass)
and deleting AmpPass.java
brings down the number of asserts from 80 to 30. (You said the additional 10 are intentional.)
This PR LGTM based on the testing I did . Will allow @erwinmombay and @choumx review the transform code.
* 'master' of github.com:ampproject/amphtml: (32 commits) ✨ Make tweet id a bindable attribute (ampproject#23953) 🏗 Update Local AMP extension to allow custom base URLs (ampproject#24029) 🏗 Improve serving from non-localhost host (ampproject#24066) Preventing half pixels. (ampproject#24050) Update callout-vendors.js (ampproject#23218) 🏗 Fixes to `check-package-manager.js` (ampproject#24060) Rename AMP_MODE to __AMP_MODE. (ampproject#24052) Story media performance metrics. (ampproject#23962) Updating Story amp-sidebar width documentation. (ampproject#23894) Fixes race condition in amp-video-iframe (ampproject#24033) Rename ampExtendedElements to __AMP_EXTENDED_ELEMENTS (ampproject#24056) 🏗🚮 Enable property inlining (ampproject#24053) ✨amp-ads: Added optional params for Directadvert network (ampproject#23724) <amp-experiment> style mutation fix and improvment (ampproject#23669) 🐛 Allow http protocol for noscript > img fallbacks for parity with amp-img (ampproject#21686) 🏗 Refactor transform-log-asserts (ampproject#24028) Automatically preconnect to source origins on page loads. (ampproject#24045) Support visibility API in the ampdoc (ampproject#23799) Amphtml visual tests should use relative path against root (ampproject#24042) FIX: check all fields' dirtiness on AMP form init (ampproject#23978) ...
The only big change here is now we'll try to statically analyze assertions.
This is to better support stubbed out methods, eg, layers:
Fixes #23960.