refactor(core): add a checkIndex to the compiler view nodes

Each node now has two index: nodeIndex and checkIndex.

nodeIndex is the index in both the view definition and the view data.
checkIndex is the index in in the update function (update directives and update
renderer).

While nodeIndex and checkIndex have the same value for now, having both of them
will allow changing the structure of view definition after compilation (ie for
runtime translations).
This commit is contained in:
Victor Berchet
2017-09-22 14:29:16 -07:00
committed by Alex Rickabaugh
parent caa51950e8
commit 0833b59aab
27 changed files with 666 additions and 781 deletions

View File

@ -6,7 +6,7 @@ more functionality from codegen into runtime to reduce generated code size.
As we introduce more runtime code, we need to be very careful to not
regress in performance, compared to the pure codegen solution.
## Initial resuls: size of Deep Tree Benchmark
## Initial results: size of Deep Tree Benchmark
File size for Tree benchmark template,
view class of the component + the 2 embedded view classes (without imports nor host view factory):

View File

@ -26,8 +26,8 @@ let viewFlags = ViewFlags.None;
function TreeComponent_Host(): ViewDefinition {
return viewDef(viewFlags, [
elementDef(NodeFlags.None, null, null, 1, 'tree', null, null, null, null, TreeComponent_0),
directiveDef(NodeFlags.Component, null, 0, TreeComponent, []),
elementDef(0, NodeFlags.None, null, null, 1, 'tree', null, null, null, null, TreeComponent_0),
directiveDef(1, NodeFlags.Component, null, 0, TreeComponent, []),
]);
}
@ -35,8 +35,9 @@ function TreeComponent_1() {
return viewDef(
viewFlags,
[
elementDef(NodeFlags.None, null, null, 1, 'tree', null, null, null, null, TreeComponent_0),
directiveDef(NodeFlags.Component, null, 0, TreeComponent, [], {data: [0, 'data']}),
elementDef(
0, NodeFlags.None, null, null, 1, 'tree', null, null, null, null, TreeComponent_0),
directiveDef(1, NodeFlags.Component, null, 0, TreeComponent, [], {data: [0, 'data']}),
],
(check, view) => {
const cmp = view.component;
@ -48,8 +49,9 @@ function TreeComponent_2() {
return viewDef(
viewFlags,
[
elementDef(NodeFlags.None, null, null, 1, 'tree', null, null, null, null, TreeComponent_0),
directiveDef(NodeFlags.Component, null, 0, TreeComponent, [], {data: [0, 'data']}),
elementDef(
0, NodeFlags.None, null, null, 1, 'tree', null, null, null, null, TreeComponent_0),
directiveDef(1, NodeFlags.Component, null, 0, TreeComponent, [], {data: [0, 'data']}),
],
(check, view) => {
const cmp = view.component;
@ -62,15 +64,15 @@ function TreeComponent_0(): ViewDefinition {
viewFlags,
[
elementDef(
NodeFlags.None, null, null, 1, 'span', null,
0, NodeFlags.None, null, null, 1, 'span', null,
[[BindingFlags.TypeElementStyle, 'backgroundColor', null]]),
textDef(null, [' ', ' ']),
textDef(1, null, [' ', ' ']),
anchorDef(NodeFlags.EmbeddedViews, null, null, 1, null, TreeComponent_1),
directiveDef(
NodeFlags.None, null, 0, NgIf, [ViewContainerRef, TemplateRef], {ngIf: [0, 'ngIf']}),
3, NodeFlags.None, null, 0, NgIf, [ViewContainerRef, TemplateRef], {ngIf: [0, 'ngIf']}),
anchorDef(NodeFlags.EmbeddedViews, null, null, 1, null, TreeComponent_2),
directiveDef(
NodeFlags.None, null, 0, NgIf, [ViewContainerRef, TemplateRef], {ngIf: [0, 'ngIf']}),
5, NodeFlags.None, null, 0, NgIf, [ViewContainerRef, TemplateRef], {ngIf: [0, 'ngIf']}),
],
(check, view) => {
const cmp = view.component;