feat(dart/transform): Use the best available Change Detectors

Enable pregenerated (for Dart) and JIT (for Js) change detectors when
possible. Previously we would always use `DynamicChangeDetector`s, but
these cause megamorphic calls and are therefore much slower.

Closes #502
This commit is contained in:
Tim Blasi
2015-05-29 16:34:51 -07:00
parent 21dcfc89e9
commit 8e3bf3907a
24 changed files with 215 additions and 96 deletions
@@ -20,7 +20,7 @@ export function main() {
});
it("should return a proto change detector when one is available", () => {
var map = {'id': (registry) => proto};
var map = {'id': (registry, def) => proto};
var cd = new PreGeneratedChangeDetection(null, map);
expect(cd.createProtoChangeDetector(def)).toBe(proto)
@@ -37,7 +37,6 @@ import {
ON_PUSH,
DEFAULT,
WrappedValue,
JitProtoChangeDetector,
DynamicProtoChangeDetector,
ChangeDetectorDefinition,
Lexer,
@@ -45,6 +44,7 @@ import {
Locals,
ProtoChangeDetector
} from 'angular2/change_detection';
import {JitProtoChangeDetector} from 'angular2/src/change_detection/jit_proto_change_detector';
import {getDefinition} from './change_detector_config';
import {getFactoryById} from './generated/change_detector_classes';
@@ -22,8 +22,6 @@ void initReflector(reflector) {
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(changeDetection: 'CHECK_ONCE')
]
'annotations': const [const Component(changeDetection: 'CHECK_ONCE')]
});
}
@@ -22,8 +22,6 @@ void initReflector(reflector) {
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(events: ['onFoo', 'onBar'])
]
'annotations': const [const Component(events: ['onFoo', 'onBar'])]
});
}
@@ -20,6 +20,8 @@ void initReflector(reflector) {
const View(template: 'Salad')
]
});
_gen.preGeneratedProtoDetectors['MyComponent_comp_0'] =
_MyComponent_ChangeDetector0.newProtoChangeDetector;
}
class _MyComponent_ChangeDetector0 extends _gen.AbstractChangeDetector {
final dynamic _dispatcher;