X Tutup
Skip to content

feat(code size): make assertionsEnabled() statically computable#4198

Closed
yjbanov wants to merge 1 commit intoangular:masterfrom
yjbanov:optional-long-stack-traces
Closed

feat(code size): make assertionsEnabled() statically computable#4198
yjbanov wants to merge 1 commit intoangular:masterfrom
yjbanov:optional-long-stack-traces

Conversation

@yjbanov
Copy link
Copy Markdown
Contributor

@yjbanov yjbanov commented Sep 15, 2015

See #3872. This PR alone does not fix the issue. We also need dart2js fixes (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

@yjbanov yjbanov added comp: core area: performance Issues related to performance and removed cla: yes labels Sep 15, 2015
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this throw?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because the value of the expression is true. assert only throws when the expression evals to false.

@yjbanov
Copy link
Copy Markdown
Contributor Author

yjbanov commented Sep 15, 2015

Got verbal LGTM from @vsavkin

@mary-poppins
Copy link
Copy Markdown

Merging PR #4198 on behalf of @yjbanov to branch presubmit-yjbanov-pr-4198.

@yjbanov yjbanov added pr_state: LGTM action: merge The PR is ready for merge by the caretaker labels Sep 15, 2015
@mary-poppins mary-poppins removed action: merge The PR is ready for merge by the caretaker labels Sep 15, 2015
@mary-poppins
Copy link
Copy Markdown

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
@yjbanov yjbanov force-pushed the optional-long-stack-traces branch from a3516c3 to 96b0e03 Compare September 16, 2015 17:32
@yjbanov yjbanov added the action: merge The PR is ready for merge by the caretaker label Sep 16, 2015
@mary-poppins
Copy link
Copy Markdown

Merging PR #4198 on behalf of @yjbanov to branch presubmit-yjbanov-pr-4198.

@mary-poppins mary-poppins removed the action: merge The PR is ready for merge by the caretaker label Sep 16, 2015
@yjbanov yjbanov closed this in 241632a Sep 16, 2015
@rakudrama
Copy link
Copy Markdown
Contributor

You say "This PR alone does not fix the issue".
I just discovered that you can get this to work before I fix dart-lang/sdk#24355

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 k.
Actually having a type makes the code look 'bigger', just enough to make the code look too big to inline.

We should fix that: dart-lang/sdk#24365

@yjbanov
Copy link
Copy Markdown
Contributor Author

yjbanov commented Sep 17, 2015

@rakudrama we still need dart-lang/sdk#24354 though, no?

@rakudrama
Copy link
Copy Markdown
Contributor

@yjbanov Try it. Most likely you will see some benefit. dart-lang/sdk#24354 might take a long time to fix.

@yjbanov
Copy link
Copy Markdown
Contributor Author

yjbanov commented Sep 22, 2015

@rakudrama I tried hard-coding return false and while it does inline the value at call sites, it fails to propagate it, exactly as described in dart-lang/sdk#24354

@rakudrama
Copy link
Copy Markdown
Contributor

@yjbanov I guess I misunderstood how these issues are connected.

I understand now that you call checkedMode() once and pass the value everywhere.
Even if we do an excellent job of improving dart-lang/sdk#24354, that pattern will always be a bit fragile, if there is one step that we cannot get you lose the whole tree under that step.

If you want to experiment, try passing null for disabled and true for enabled.
We track null/non-null more accurately than any other fact.
If null/true does not work, then false/true will not work either.

Otherwise you could change from:

  • passing down one result from checkedMode() into a tree of code

to:

  • Calling checkedMode() at each place.

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

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: performance Issues related to performance cla: yes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

X Tutup