Skip to content
Permalink
Browse files

perf(ivy): replace select instruction with advance (#32516)

Replaces the `select` instruction with a new one called `advance`. Instead of the jumping to a specific index, the new instruction goes forward X amount of elements. The advantage of doing this is that it should generate code the compresses better.

PR Close #32516
  • Loading branch information...
crisbeto authored and matsko committed Sep 6, 2019
1 parent 2230dfa commit 664e0015d4de720216c52b13b808f9ba41b7da38
Showing with 280 additions and 304 deletions.
  1. +3 −3 modules/benchmarks/src/tree/render3_function/index.ts
  2. +17 −17 packages/compiler-cli/test/compliance/r3_compiler_compliance_spec.ts
  3. +26 −26 packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts
  4. +11 −43 packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts
  5. +24 −24 packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts
  6. +10 −10 packages/compiler-cli/test/compliance/r3_view_compiler_template_spec.ts
  7. +1 −1 packages/compiler/design/architecture.md
  8. +1 −0 packages/compiler/src/render3/r3_identifiers.ts
  9. +49 −34 packages/compiler/src/render3/view/template.ts
  10. +1 −0 packages/core/src/core_render3_private_export.ts
  11. +1 −2 packages/core/src/render3/VIEW_DATA.md
  12. +0 −1 packages/core/src/render3/features/providers_feature.ts
  13. +2 −0 packages/core/src/render3/index.ts
  14. +28 −18 packages/core/src/render3/instructions/{select.ts → advance.ts}
  15. +1 −1 packages/core/src/render3/instructions/all.ts
  16. +4 −4 packages/core/src/render3/instructions/shared.ts
  17. +1 −0 packages/core/src/render3/jit/environment.ts
  18. +1 −1 packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json
  19. +1 −1 packages/core/test/bundling/hello_world/bundle.golden_symbols.json
  20. +4 −4 packages/core/test/bundling/injection/bundle.golden_symbols.json
  21. +4 −4 packages/core/test/bundling/todo/bundle.golden_symbols.json
  22. +2 −7 packages/core/test/render3/change_detection_spec.ts
  23. +5 −13 packages/core/test/render3/component_spec.ts
  24. +1 −0 packages/core/test/render3/control_flow_spec.ts
  25. +4 −9 packages/core/test/render3/integration_spec.ts
  26. +1 −2 packages/core/test/render3/lifecycle_spec.ts
  27. +12 −12 packages/core/test/render3/perf/interpolation/index.ts
  28. +11 −11 packages/core/test/render3/perf/map_based_style_and_class_bindings/index.ts
  29. +12 −12 packages/core/test/render3/perf/property_binding/index.ts
  30. +11 −11 packages/core/test/render3/perf/style_and_class_bindings/index.ts
  31. +22 −22 packages/core/test/render3/perf/style_binding/index.ts
  32. +2 −5 packages/core/test/render3/pipe_spec.ts
  33. +4 −6 packages/core/test/render3/providers_spec.ts
  34. +3 −0 tools/public_api_guard/core/core.d.ts
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

importRenderFlags, ɵrenderComponent as renderComponent, ɵɵcontainer, ɵɵcontainerRefreshEnd, ɵɵcontainerRefreshStart, ɵɵdefineComponent, ɵɵelementEnd, ɵɵelementStart, ɵɵembeddedViewEnd, ɵɵembeddedViewStart, ɵɵselect, ɵɵstyleProp, ɵɵstyling, ɵɵstylingApply, ɵɵtext, ɵɵtextInterpolate1} from '@angular/core';
importRenderFlags, ɵrenderComponent as renderComponent, ɵɵadvance, ɵɵcontainer, ɵɵcontainerRefreshEnd, ɵɵcontainerRefreshStart, ɵɵdefineComponent, ɵɵelementEnd, ɵɵelementStart, ɵɵembeddedViewEnd, ɵɵembeddedViewStart, ɵɵstyleProp, ɵɵstyling, ɵɵstylingApply, ɵɵtext, ɵɵtextInterpolate1} from '@angular/core';

import {bindAction, profile} from '../../util';
import {createDom, destroyDom, detectChanges} from '../render3/tree';
@@ -48,10 +48,10 @@ export function TreeTpl(rf: ɵRenderFlags, ctx: TreeNode) {
ɵɵelementEnd();
}
if (rf & ɵRenderFlags.Update) {
ɵɵselect(1);
ɵɵadvance(1);
ɵɵstyleProp('background-color', ctx.depth % 2 ? '' : 'grey');
ɵɵstylingApply();
ɵɵselect(2);
ɵɵadvance(1);
ɵɵtextInterpolate1(' ', ctx.value, ' ');
ɵɵcontainerRefreshStart(3);
{
@@ -774,7 +774,7 @@ describe('compiler compliance', () => {
if (rf & 2) {
const $myComp$ = $r3$.ɵɵnextContext();
const $foo$ = $r3$.ɵɵreference(1);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate2("", $myComp$.salutation, " ", $foo$, "");
}
}
@@ -1275,7 +1275,7 @@ describe('compiler compliance', () => {
}
if (rf & 2) {
$r3$.ɵɵproperty("ngIf", ctx.visible);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵproperty("ngIf", ctx.visible);
}
}
@@ -2032,7 +2032,7 @@ describe('compiler compliance', () => {
}
if (rf & 2) {
$r3$.ɵɵtextInterpolate($r3$.ɵɵpipeBind2(1, 3, $r3$.ɵɵpipeBind2(2, 6, ctx.name, ctx.size), ctx.size));
$r3$.ɵɵselect(4);
$r3$.ɵɵadvance(4);
$r3$.ɵɵtextInterpolate2("", $r3$.ɵɵpipeBindV(5, 9, $r3$.ɵɵpureFunction1(18, $c0$, ctx.name)), " ", ctx.name ? 1 : $r3$.ɵɵpipeBind1(6, 16, 2), "");
}
},
@@ -2216,7 +2216,7 @@ describe('compiler compliance', () => {
}
if (rf & 2) {
const $user$ = $r3$.ɵɵreference(1);
$r3$.ɵɵselect(2);
$r3$.ɵɵadvance(2);
$r3$.ɵɵtextInterpolate1("Hello ", $user$.value, "!");
}
},
@@ -2279,7 +2279,7 @@ describe('compiler compliance', () => {
$r3$.ɵɵnextContext();
const $foo$ = $r3$.ɵɵreference(1);
const $baz$ = $r3$.ɵɵreference(5);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate3("", $foo$, "-", $bar$, "-", $baz$, "");
}
}
@@ -2295,7 +2295,7 @@ describe('compiler compliance', () => {
const $bar$ = $r3$.ɵɵreference(4);
$r3$.ɵɵnextContext();
const $foo$ = $r3$.ɵɵreference(1);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate2(" ", $foo$, "-", $bar$, " ");
}
}
@@ -2314,7 +2314,7 @@ describe('compiler compliance', () => {
}
if (rf & 2) {
const $foo$ = $r3$.ɵɵreference(1);
$r3$.ɵɵselect(2);
$r3$.ɵɵadvance(2);
$r3$.ɵɵtextInterpolate1(" ", $foo$, " ");
}
},
@@ -2365,7 +2365,7 @@ describe('compiler compliance', () => {
if (rf & 2) {
const $item$ = $i0$.ɵɵnextContext().$implicit;
const $foo$ = $i0$.ɵɵreference(2);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$i0$.ɵɵtextInterpolate2(" ", $foo$, " - ", $item$, " ");
}
}
@@ -2379,7 +2379,7 @@ describe('compiler compliance', () => {
}
if (rf & 2) {
const $app$ = $i0$.ɵɵnextContext();
$r3$.ɵɵselect(3);
$r3$.ɵɵadvance(3);
$i0$.ɵɵproperty("ngIf", $app$.showing);
}
}
@@ -2469,7 +2469,7 @@ describe('compiler compliance', () => {
}
if (rf & 2) {
$r3$.ɵɵproperty("name", ctx.name1);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵproperty("name", ctx.name2);
}
},
@@ -2602,7 +2602,7 @@ describe('compiler compliance', () => {
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵproperty("forOf", ctx.items);
}
},
@@ -2670,7 +2670,7 @@ describe('compiler compliance', () => {
}
if (rf & 2) {
const $item$ = ctx.$implicit;
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate($item$.name);
}
}
@@ -2687,7 +2687,7 @@ describe('compiler compliance', () => {
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵproperty("forOf", ctx.items);
}
},
@@ -2753,7 +2753,7 @@ describe('compiler compliance', () => {
if (rf & 2) {
const $info$ = ctx.$implicit;
const $item$ = $r3$.ɵɵnextContext().$implicit;
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵtextInterpolate2(" ", $item$.name, ": ", $info$.description, " ");
}
}
@@ -2771,9 +2771,9 @@ describe('compiler compliance', () => {
}
if (rf & 2) {
const $item$ = ctx.$implicit;
$r3$.ɵɵselect(2);
$r3$.ɵɵadvance(2);
$r3$.ɵɵtextInterpolate(IDENT.name);
$r3$.ɵɵselect(4);
$r3$.ɵɵadvance(2);
$r3$.ɵɵproperty("forOf", IDENT.infos);
}
}
@@ -2791,7 +2791,7 @@ describe('compiler compliance', () => {
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵproperty("forOf", ctx.items);
}
},
@@ -44,7 +44,7 @@ describe('compiler compliance: bindings', () => {
$i0$.ɵɵelementEnd();
}
if (rf & 2) {
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$i0$.ɵɵtextInterpolate1("Hello ", $ctx$.name, "");
}
}`;
@@ -360,9 +360,9 @@ describe('compiler compliance: bindings', () => {
if (rf & 2) {
$r3$.ɵɵproperty("title", ctx.myTitle)("id", ctx.buttonId)("tabindex", 1);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵproperty("id", 1)("title", "hello")("someProp", 1 + 2);
$r3$.ɵɵselect(2);
$r3$.ɵɵadvance(1);
$r3$.ɵɵproperty("prop", "one")("otherProp", 2);
}
}
@@ -397,7 +397,7 @@ describe('compiler compliance: bindings', () => {
if (rf & 2) {
$r3$.ɵɵproperty("title", ctx.myTitle)("id", ctx.buttonId)("tabindex", 1);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵproperty("id", 1)("title", "hello")("someProp", 1 + 2);
}
}
@@ -566,9 +566,9 @@ describe('compiler compliance: bindings', () => {
if (rf & 2) {
$r3$.ɵɵattribute("title", ctx.myTitle)("id", ctx.buttonId)("tabindex", 1);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵattribute("id", 1)("title", "hello")("some-attr", 1 + 2);
$r3$.ɵɵselect(2);
$r3$.ɵɵadvance(1);
$r3$.ɵɵattribute("some-attr", "one")("some-other-attr", 2);
}
}
@@ -603,7 +603,7 @@ describe('compiler compliance: bindings', () => {
if (rf & 2) {
$r3$.ɵɵattribute("title", ctx.myTitle)("id", ctx.buttonId)("tabindex", 1);
$r3$.ɵɵselect(1);
$r3$.ɵɵadvance(1);
$r3$.ɵɵattribute("id", 1)("title", "hello")("some-attr", 1 + 2);
}
}
@@ -1173,23 +1173,23 @@ describe('compiler compliance: bindings', () => {
if (rf & 2) {
i0.ɵɵpropertyInterpolateV("title", ["a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i", ctx.nine, "j"]);
i0.ɵɵselect(1);
i0.ɵɵadvance(1);
i0.ɵɵpropertyInterpolate8("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i");
i0.ɵɵselect(2);
i0.ɵɵadvance(1);
i0.ɵɵpropertyInterpolate7("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h");
i0.ɵɵselect(3);
i0.ɵɵadvance(1);
i0.ɵɵpropertyInterpolate6("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g");
i0.ɵɵselect(4);
i0.ɵɵadvance(1);
i0.ɵɵpropertyInterpolate5("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f");
i0.ɵɵselect(5);
i0.ɵɵadvance(1);
i0.ɵɵpropertyInterpolate4("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e");
i0.ɵɵselect(6);
i0.ɵɵadvance(1);
i0.ɵɵpropertyInterpolate3("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d");
i0.ɵɵselect(7);
i0.ɵɵadvance(1);
i0.ɵɵpropertyInterpolate2("title", "a", ctx.one, "b", ctx.two, "c");
i0.ɵɵselect(8);
i0.ɵɵadvance(1);
i0.ɵɵpropertyInterpolate1("title", "a", ctx.one, "b");
i0.ɵɵselect(9);
i0.ɵɵadvance(1);
i0.ɵɵpropertyInterpolate("title", ctx.one);
}
@@ -1217,23 +1217,23 @@ describe('compiler compliance: bindings', () => {
if (rf & 2) {
i0.ɵɵattributeInterpolateV("title", ["a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i", ctx.nine, "j"]);
i0.ɵɵselect(1);
i0.ɵɵadvance(1);
i0.ɵɵattributeInterpolate8("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i");
i0.ɵɵselect(2);
i0.ɵɵadvance(1);
i0.ɵɵattributeInterpolate7("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h");
i0.ɵɵselect(3);
i0.ɵɵadvance(1);
i0.ɵɵattributeInterpolate6("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g");
i0.ɵɵselect(4);
i0.ɵɵadvance(1);
i0.ɵɵattributeInterpolate5("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f");
i0.ɵɵselect(5);
i0.ɵɵadvance(1);
i0.ɵɵattributeInterpolate4("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e");
i0.ɵɵselect(6);
i0.ɵɵadvance(1);
i0.ɵɵattributeInterpolate3("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d");
i0.ɵɵselect(7);
i0.ɵɵadvance(1);
i0.ɵɵattributeInterpolate2("title", "a", ctx.one, "b", ctx.two, "c");
i0.ɵɵselect(8);
i0.ɵɵadvance(1);
i0.ɵɵattributeInterpolate1("title", "a", ctx.one, "b");
i0.ɵɵselect(9);
i0.ɵɵadvance(1);
i0.ɵɵattribute("title", ctx.one);
}
@@ -1267,7 +1267,7 @@ describe('compiler compliance: bindings', () => {
}
if (rf & 2) {
const $_r0$ = $i0$.ɵɵreference(1);
$r3$.ɵɵselect(4);
$r3$.ɵɵadvance(4);
$i0$.ɵɵtextInterpolate1(" ", $_r0$.id, " ");
}
}

0 comments on commit 664e001

Please sign in to comment.
You can’t perform that action at this time.