Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart

Issue 2692303002: Split InterceptorData (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.js_emitter.program_builder; 5 library dart2js.js_emitter.program_builder;
6 6
7 import '../../closure.dart' show ClosureFieldElement; 7 import '../../closure.dart' show ClosureFieldElement;
8 import '../../common.dart'; 8 import '../../common.dart';
9 import '../../common/names.dart' show Names, Selectors; 9 import '../../common/names.dart' show Names, Selectors;
10 import '../../compiler.dart' show Compiler; 10 import '../../compiler.dart' show Compiler;
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 /// attribution. 798 /// attribution.
799 Method _buildStubMethod(js.Name name, js.Expression code, 799 Method _buildStubMethod(js.Name name, js.Expression code,
800 {MemberElement element}) { 800 {MemberElement element}) {
801 return new StubMethod(name, code, element: element); 801 return new StubMethod(name, code, element: element);
802 } 802 }
803 803
804 // The getInterceptor methods directly access the prototype of classes. 804 // The getInterceptor methods directly access the prototype of classes.
805 // We must evaluate these classes eagerly so that the prototype is 805 // We must evaluate these classes eagerly so that the prototype is
806 // accessible. 806 // accessible.
807 void _markEagerInterceptorClasses() { 807 void _markEagerInterceptorClasses() {
808 Map<js.Name, Set<ClassElement>> specializedGetInterceptors = 808 Iterable<js.Name> names =
809 backend.interceptorData.specializedGetInterceptors; 809 backend.oneShotInterceptorData.specializedGetInterceptorNames;
810 for (Set<ClassElement> classes in specializedGetInterceptors.values) { 810 for (js.Name name in names) {
811 for (ClassElement element in classes) { 811 for (ClassElement element in backend.oneShotInterceptorData
812 .getSpecializedGetInterceptorsFor(name)) {
812 Class cls = _classes[element]; 813 Class cls = _classes[element];
813 if (cls != null) cls.isEager = true; 814 if (cls != null) cls.isEager = true;
814 } 815 }
815 } 816 }
816 } 817 }
817 818
818 Iterable<StaticStubMethod> _generateGetInterceptorMethods() { 819 Iterable<StaticStubMethod> _generateGetInterceptorMethods() {
819 InterceptorStubGenerator stubGenerator = 820 InterceptorStubGenerator stubGenerator =
820 new InterceptorStubGenerator(_compiler, namer, backend, closedWorld); 821 new InterceptorStubGenerator(_compiler, namer, backend, closedWorld);
821 822
822 String holderName = 823 String holderName =
823 namer.globalObjectForLibrary(helpers.interceptorsLibrary); 824 namer.globalObjectForLibrary(helpers.interceptorsLibrary);
824 // TODO(floitsch): we shouldn't update the registry in the middle of 825 // TODO(floitsch): we shouldn't update the registry in the middle of
825 // generating the interceptor methods. 826 // generating the interceptor methods.
826 Holder holder = _registry.registerHolder(holderName); 827 Holder holder = _registry.registerHolder(holderName);
827 828
828 Map<js.Name, Set<ClassElement>> specializedGetInterceptors = 829 Iterable<js.Name> names =
829 backend.interceptorData.specializedGetInterceptors; 830 backend.oneShotInterceptorData.specializedGetInterceptorNames;
830 List<js.Name> names = specializedGetInterceptors.keys.toList()..sort();
831 return names.map((js.Name name) { 831 return names.map((js.Name name) {
832 Set<ClassElement> classes = specializedGetInterceptors[name]; 832 Set<ClassElement> classes =
833 backend.oneShotInterceptorData.getSpecializedGetInterceptorsFor(name);
833 js.Expression code = stubGenerator.generateGetInterceptorMethod(classes); 834 js.Expression code = stubGenerator.generateGetInterceptorMethod(classes);
834 return new StaticStubMethod(name, holder, code); 835 return new StaticStubMethod(name, holder, code);
835 }); 836 });
836 } 837 }
837 838
838 List<Field> _buildFields(Element holder, bool visitStatics) { 839 List<Field> _buildFields(Element holder, bool visitStatics) {
839 List<Field> fields = <Field>[]; 840 List<Field> fields = <Field>[];
840 new FieldVisitor(_compiler, namer, closedWorld) 841 new FieldVisitor(_compiler, namer, closedWorld)
841 .visitFields(holder, visitStatics, (FieldElement field, 842 .visitFields(holder, visitStatics, (FieldElement field,
842 js.Name name, 843 js.Name name,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 InterceptorStubGenerator stubGenerator = 887 InterceptorStubGenerator stubGenerator =
887 new InterceptorStubGenerator(_compiler, namer, backend, closedWorld); 888 new InterceptorStubGenerator(_compiler, namer, backend, closedWorld);
888 889
889 String holderName = 890 String holderName =
890 namer.globalObjectForLibrary(helpers.interceptorsLibrary); 891 namer.globalObjectForLibrary(helpers.interceptorsLibrary);
891 // TODO(floitsch): we shouldn't update the registry in the middle of 892 // TODO(floitsch): we shouldn't update the registry in the middle of
892 // generating the interceptor methods. 893 // generating the interceptor methods.
893 Holder holder = _registry.registerHolder(holderName); 894 Holder holder = _registry.registerHolder(holderName);
894 895
895 List<js.Name> names = 896 List<js.Name> names =
896 backend.interceptorData.oneShotInterceptors.keys.toList()..sort(); 897 backend.oneShotInterceptorData.oneShotInterceptorNames;
897 return names.map((js.Name name) { 898 return names.map((js.Name name) {
898 js.Expression code = stubGenerator.generateOneShotInterceptor(name); 899 js.Expression code = stubGenerator.generateOneShotInterceptor(name);
899 return new StaticStubMethod(name, holder, code); 900 return new StaticStubMethod(name, holder, code);
900 }); 901 });
901 } 902 }
902 903
903 StaticDartMethod _buildStaticMethod(MethodElement element) { 904 StaticDartMethod _buildStaticMethod(MethodElement element) {
904 js.Name name = namer.methodPropertyName(element); 905 js.Name name = namer.methodPropertyName(element);
905 String holder = namer.globalObjectFor(element); 906 String holder = namer.globalObjectFor(element);
906 js.Expression code = backend.generatedCode[element]; 907 js.Expression code = backend.generatedCode[element];
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 Constant constant = new Constant(name, holder, constantValue); 967 Constant constant = new Constant(name, holder, constantValue);
967 _constants[constantValue] = constant; 968 _constants[constantValue] = constant;
968 } 969 }
969 } 970 }
970 971
971 Holder _registerStaticStateHolder() { 972 Holder _registerStaticStateHolder() {
972 return _registry.registerHolder(namer.staticStateHolder, 973 return _registry.registerHolder(namer.staticStateHolder,
973 isStaticStateHolder: true); 974 isStaticStateHolder: true);
974 } 975 }
975 } 976 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder/collector.dart ('k') | pkg/compiler/lib/src/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698