feat(code size): make assertionsEnabled() statically computable#4198
feat(code size): make assertionsEnabled() statically computable#4198yjbanov wants to merge 1 commit intoangular:masterfrom
Conversation
There was a problem hiding this comment.
No, because the value of the expression is true. assert only throws when the expression evals to false.
|
Got verbal LGTM from @vsavkin |
|
Merging PR #4198 on behalf of @yjbanov to branch presubmit-yjbanov-pr-4198. |
|
Merging PR #4198 on behalf of @yjbanov to branch presubmit-yjbanov-pr-4198. |
…rt2js Our existing implementation prevented dart2js from statically deducing the return value. This fix does not yet result in better tree-shaking due to the following dart2js bugs: dart-lang/sdk#24354 dart-lang/sdk#24355
a3516c3 to
96b0e03
Compare
|
Merging PR #4198 on behalf of @yjbanov to branch presubmit-yjbanov-pr-4198. |
|
You say "This PR alone does not fix the issue". bool checkedMode() {
var k = false;
assert((k = true));
return k;
}
main() {
if (checkedMode()) print('Hello');
if (checkedMode()) print('Bye');
}The difference is the bool vs var at the declaration of We should fix that: dart-lang/sdk#24365 |
|
@rakudrama we still need dart-lang/sdk#24354 though, no? |
|
@yjbanov Try it. Most likely you will see some benefit. dart-lang/sdk#24354 might take a long time to fix. |
|
@rakudrama I tried hard-coding |
|
@yjbanov I guess I misunderstood how these issues are connected. I understand now that you call checkedMode() once and pass the value everywhere. If you want to experiment, try passing null for disabled and true for enabled. Otherwise you could change from:
to:
You could also pass a singleton object with a checkedMode() method as above. We would inline that if we can prove the type of the singleton (we should be able to, again, if this fails, so will false/true). |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
See #3872. This PR alone does not fix the issue. We also need
dart2jsfixes (see below).Our existing implementation prevented dart2js from statically deducing the
return value. This fix does not yet result in better tree-shaking due to the
following dart2js bugs:
dart-lang/sdk#24354
dart-lang/sdk#24355