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

View File

@ -18,6 +18,8 @@ import {
Lexer,
ChangeDetection,
DynamicChangeDetection,
JitChangeDetection,
PreGeneratedChangeDetection,
PipeRegistry,
defaultPipeRegistry
} from 'angular2/change_detection';
@ -66,6 +68,12 @@ var _rootInjector: Injector;
var _rootBindings = [bind(Reflector).toValue(reflector), TestabilityRegistry];
function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
var bestChangeDetection: Type = DynamicChangeDetection;
if (PreGeneratedChangeDetection.isSupported()) {
bestChangeDetection = PreGeneratedChangeDetection;
} else if (JitChangeDetection.isSupported()) {
bestChangeDetection = JitChangeDetection;
}
return [
bind(DOCUMENT_TOKEN)
.toValue(DOM.defaultDoc()),
@ -117,7 +125,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
CompilerCache,
TemplateResolver,
bind(PipeRegistry).toValue(defaultPipeRegistry),
bind(ChangeDetection).toClass(DynamicChangeDetection),
bind(ChangeDetection).toClass(bestChangeDetection),
TemplateLoader,
DirectiveResolver,
Parser,