Skip to content
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(core): Replace ExpandoInstructions with HostBindingOpCodes #39301

Closed
wants to merge 3 commits into from

Conversation

mhevery
Copy link
Contributor

@mhevery mhevery commented Oct 16, 2020

Review last change only.
This PR builds on #39233 and #39003

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

LGTM, just left a few minor comments, thanks @mhevery 👍

packages/core/src/render3/component.ts Outdated Show resolved Hide resolved
@@ -409,11 +409,17 @@ export interface TNode {

/**
* Stores starting index of the directives.
*
* The first directive is always component.
Copy link
Contributor

Choose a reason for hiding this comment

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

That's an important comment, thanks for adding it! 👍

Can we expand it a bit by adding a reference to the corresponding function/logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you suggest what you would like to see here.

packages/core/src/render3/interfaces/view.ts Outdated Show resolved Hide resolved
packages/core/src/render3/component.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions/shared.ts Outdated Show resolved Hide resolved
packages/core/src/render3/node_manipulation_i18n.ts Outdated Show resolved Hide resolved
packages/core/src/render3/node_manipulation_i18n.ts Outdated Show resolved Hide resolved
@mhevery mhevery force-pushed the i18n_cleanup_6 branch 2 times, most recently from eefd762 to edc7b59 Compare October 17, 2020 21:02
@mhevery
Copy link
Contributor Author

mhevery commented Oct 17, 2020

presubmit

Comment on lines 471 to 485
* for (let i = 0; i < hostBindingOpCodes.length; i++) {
* const opCode = hostBindingOpCodes[i] as number;
* if (opCode < 0) {
* // Negative numbers are element indexes.
* setSelectedIndex(~opCode);
* } else {
* // Positive numbers are NumberTuple which store bindingRootIndex and directiveIndex.
* const directiveIdx = opCode;
* const bindingRootIndx = hostBindingOpCodes[++i] as number;
* const hostBindingFn = hostBindingOpCodes[++i] as HostBindingsFunction<any>;
* setBindingRootForHostBindings(bindingRootIndx, directiveIdx);
* const context = lView[directiveIdx];
* hostBindingFn(RenderFlags.Update, context);
* }
* }
Copy link
Member

Choose a reason for hiding this comment

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

NIT - you can dedent these lines, since the if statement above does not create a block.

Copy link
Member

Choose a reason for hiding this comment

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

By the way, this pseudo code indicates that the items after the elementIdx can be 0 or more, rather than the 1 or more mentioned further up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dedented.

I see your point about 1 or more vs 0 or more. But in practice it would be 1 or more, even thought you are right the code supports it. I don't want to suggest that there would ever be situation followed by 0 functions. That would be just wasteful. Any suggestion on how to make that more clear?

packages/core/src/render3/instructions/shared.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions/shared.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions/shared.ts Outdated Show resolved Hide resolved
integration/README.md Outdated Show resolved Hide resolved
packages/core/src/render3/node_manipulation.ts Outdated Show resolved Hide resolved
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Reviewed-for: size-tracking

@pullapprove pullapprove bot requested a review from atscott October 18, 2020 19:44
@petebacondarwin petebacondarwin added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Oct 18, 2020
@mhevery mhevery force-pushed the i18n_cleanup_6 branch 2 times, most recently from d51b241 to 41d1b35 Compare October 19, 2020 15:28
@mhevery mhevery added target: minor This PR is targeted for the next minor release and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Oct 19, 2020
Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

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

LGTM with just a few minor comments. This technique to optionally pull in part of the core is interesting (but admittedly it makes my head hurt a bit).

Thanks for tracking down most of the size regression and documenting the debugging steps.

Reviewed-for: global-approvers, size-tracking

packages/core/src/render3/i18n/i18n_tree_shaking.ts Outdated Show resolved Hide resolved
packages/core/src/render3/i18n/i18n_util.ts Outdated Show resolved Hide resolved
integration/README.md Outdated Show resolved Hide resolved
integration/README.md Outdated Show resolved Hide resolved
@mhevery mhevery added the target: rc This PR is targeted for the next release-candidate label Oct 19, 2020
@IgorMinar IgorMinar removed the target: minor This PR is targeted for the next minor release label Oct 19, 2020
@AndrewKushnir AndrewKushnir added area: core Issues related to the framework runtime refactoring Issue that involves refactoring or code-cleanup labels Oct 21, 2020
@ngbot ngbot bot modified the milestone: needsTriage Oct 21, 2020
@mhevery
Copy link
Contributor Author

mhevery commented Oct 21, 2020

presubmit

@mhevery
Copy link
Contributor Author

mhevery commented Oct 21, 2020

presubmit

@mhevery
Copy link
Contributor Author

mhevery commented Oct 22, 2020

presubmit

The `ExpandoInstructions` was unnecessarily convoluted way to solve the
problem of calling the `HostBindingFunction`s on components and
directives. The code was complicated and hard to fallow.

The replacement is a simplified way to achieve the same thing, which
is also more efficient in space and speed.
@mhevery
Copy link
Contributor Author

mhevery commented Oct 22, 2020

presubmit

`TNode.insertBeforeIndex` is only populated when i18n is present. This
change puts all code which reads `insertBeforeIndex` behind a
dynamically loaded functions which are set only when i18n code executes.
@alxhub alxhub added the action: merge The PR is ready for merge by the caretaker label Oct 22, 2020
@alxhub alxhub closed this in 68d4de6 Oct 22, 2020
alxhub pushed a commit that referenced this pull request Oct 22, 2020
`TNode.insertBeforeIndex` is only populated when i18n is present. This
change puts all code which reads `insertBeforeIndex` behind a
dynamically loaded functions which are set only when i18n code executes.

PR Close #39301
alxhub pushed a commit that referenced this pull request Oct 22, 2020
…s` (#39301)

The `ExpandoInstructions` was unnecessarily convoluted way to solve the
problem of calling the `HostBindingFunction`s on components and
directives. The code was complicated and hard to fallow.

The replacement is a simplified way to achieve the same thing, which
is also more efficient in space and speed.

PR Close #39301
alxhub pushed a commit that referenced this pull request Oct 22, 2020
`TNode.insertBeforeIndex` is only populated when i18n is present. This
change puts all code which reads `insertBeforeIndex` behind a
dynamically loaded functions which are set only when i18n code executes.

PR Close #39301
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this pull request Oct 25, 2020
This commit removes a workaround to calculate the `expandoStartIndex` value. That workaround was needed
because the `expandoStartIndex` was updated previously, so it pointed at the wrong location. The PR angular#39301
(angular#39301) fixed that problem and the workaround is no longer needed.
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this pull request Oct 26, 2020
This commit removes a workaround to calculate the `expandoStartIndex` value. That workaround was needed
because the `expandoStartIndex` was updated previously, so it pointed at the wrong location. The problem
was fixed in PR angular#39301 and the workaround is no longer needed.
alxhub pushed a commit that referenced this pull request Oct 27, 2020
This commit removes a workaround to calculate the `expandoStartIndex` value. That workaround was needed
because the `expandoStartIndex` was updated previously, so it pointed at the wrong location. The problem
was fixed in PR #39301 and the workaround is no longer needed.

PR Close #39416
alxhub pushed a commit that referenced this pull request Oct 27, 2020
This commit removes a workaround to calculate the `expandoStartIndex` value. That workaround was needed
because the `expandoStartIndex` was updated previously, so it pointed at the wrong location. The problem
was fixed in PR #39301 and the workaround is no longer needed.

PR Close #39416
@angular-automatic-lock-bot
Copy link

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 Nov 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes refactoring Issue that involves refactoring or code-cleanup target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants