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

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

Issue 2934783002: Handle named mixin application in emitter (Closed)
Patch Set: Fixes Created 3 years, 6 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 'dart:io'; 7 import 'dart:io';
8 import 'dart:convert' show JSON; 8 import 'dart:convert' show JSON;
9 9
10 import '../../closure.dart' show ClosureTask, ClosureFieldElement; 10 import '../../closure.dart' show ClosureTask, ClosureFieldElement;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 import '../../native/enqueue.dart' show NativeCodegenEnqueuer; 51 import '../../native/enqueue.dart' show NativeCodegenEnqueuer;
52 import '../../options.dart'; 52 import '../../options.dart';
53 import '../../universe/selector.dart' show Selector; 53 import '../../universe/selector.dart' show Selector;
54 import '../../universe/world_builder.dart' 54 import '../../universe/world_builder.dart'
55 show CodegenWorldBuilder, SelectorConstraints; 55 show CodegenWorldBuilder, SelectorConstraints;
56 import '../../world.dart' show ClosedWorld; 56 import '../../world.dart' show ClosedWorld;
57 import '../js_emitter.dart' 57 import '../js_emitter.dart'
58 show 58 show
59 ClassStubGenerator, 59 ClassStubGenerator,
60 CodeEmitterTask, 60 CodeEmitterTask,
61 computeMixinClass,
62 Emitter, 61 Emitter,
63 InterceptorStubGenerator, 62 InterceptorStubGenerator,
64 MainCallStubGenerator, 63 MainCallStubGenerator,
65 ParameterStubGenerator, 64 ParameterStubGenerator,
66 RuntimeTypeGenerator, 65 RuntimeTypeGenerator,
67 TypeTestProperties; 66 TypeTestProperties;
68 import '../model.dart'; 67 import '../model.dart';
69 import '../sorter.dart'; 68 import '../sorter.dart';
70 69
71 part 'collector.dart'; 70 part 'collector.dart';
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (superclass != null) { 226 if (superclass != null) {
228 c.setSuperclass(_classes[superclass]); 227 c.setSuperclass(_classes[superclass]);
229 assert( 228 assert(
230 c.superclass != null, 229 c.superclass != null,
231 failedAt( 230 failedAt(
232 cls, 231 cls,
233 "No Class for has been created for superclass " 232 "No Class for has been created for superclass "
234 "${superclass} of $c.")); 233 "${superclass} of $c."));
235 } 234 }
236 if (c is MixinApplication) { 235 if (c is MixinApplication) {
237 c.setMixinClass(_classes[computeMixinClass(cls)]); 236 ClassEntity effectiveMixinClass =
238 assert(c.mixinClass != null); 237 _elementEnvironment.getEffectiveMixinClass(cls);
238 c.setMixinClass(_classes[effectiveMixinClass]);
239 assert(
240 c.mixinClass != null,
241 failedAt(cls,
242 "No class for effective mixin ${effectiveMixinClass} on $cls.")) ;
Emily Fortuna 2017/06/13 17:22:50 nit: >80 char here
239 } 243 }
240 }); 244 });
241 245
242 List<Class> nativeClasses = collector.nativeClassesAndSubclasses 246 List<Class> nativeClasses = collector.nativeClassesAndSubclasses
243 .map((ClassEntity classElement) => _classes[classElement]) 247 .map((ClassEntity classElement) => _classes[classElement])
244 .toList(); 248 .toList();
245 249
246 Set<ClassEntity> interceptorClassesNeededByConstants = 250 Set<ClassEntity> interceptorClassesNeededByConstants =
247 collector.computeInterceptorsReferencedFromConstants(); 251 collector.computeInterceptorsReferencedFromConstants();
248 Set<ClassEntity> classesModifiedByEmitRTISupport = 252 Set<ClassEntity> classesModifiedByEmitRTISupport =
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 324 }
321 325
322 String data = new File(allocatedClassesPath).readAsStringSync(); 326 String data = new File(allocatedClassesPath).readAsStringSync();
323 Set<String> allocatedClassesKeys = JSON.decode(data).keys.toSet(); 327 Set<String> allocatedClassesKeys = JSON.decode(data).keys.toSet();
324 Set<ClassElement> allocatedClasses = new Set<ClassElement>(); 328 Set<ClassElement> allocatedClasses = new Set<ClassElement>();
325 329
326 // Collects all super and mixin classes of a class. 330 // Collects all super and mixin classes of a class.
327 void collect(ClassElement element) { 331 void collect(ClassElement element) {
328 allocatedClasses.add(element); 332 allocatedClasses.add(element);
329 if (element.isMixinApplication) { 333 if (element.isMixinApplication) {
330 collect(computeMixinClass(element)); 334 collect(_elementEnvironment.getEffectiveMixinClass(element));
331 } 335 }
332 if (element.superclass != null) { 336 if (element.superclass != null) {
333 collect(element.superclass); 337 collect(element.superclass);
334 } 338 }
335 } 339 }
336 340
337 // For every known class, see if it was allocated in the profile. If yes, 341 // For every known class, see if it was allocated in the profile. If yes,
338 // collect its dependencies (supers and mixins) and mark them as 342 // collect its dependencies (supers and mixins) and mark them as
339 // not-soft-deferrable. 343 // not-soft-deferrable.
340 collector.outputClassLists.forEach((_, List<ClassElement> elements) { 344 collector.outputClassLists.forEach((_, List<ClassElement> elements) {
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 740
737 if (isClosureBaseClass) { 741 if (isClosureBaseClass) {
738 // We add a special getter to allow for tearing off a closure from itself. 742 // We add a special getter to allow for tearing off a closure from itself.
739 js.Name name = _namer.getterForMember(Names.call); 743 js.Name name = _namer.getterForMember(Names.call);
740 js.Fun function = js.js('function() { return this; }'); 744 js.Fun function = js.js('function() { return this; }');
741 callStubs.add(_buildStubMethod(name, function)); 745 callStubs.add(_buildStubMethod(name, function));
742 } 746 }
743 747
744 // MixinApplications run through the members of their mixin. Here, we are 748 // MixinApplications run through the members of their mixin. Here, we are
745 // only interested in direct members. 749 // only interested in direct members.
746 if (!onlyForRti && !_elementEnvironment.isUnnamedMixinApplication(cls)) { 750 if (!onlyForRti && !_elementEnvironment.isMixinApplication(cls)) {
747 _elementEnvironment.forEachClassMember(cls, visitMember); 751 _elementEnvironment.forEachClassMember(cls, visitMember);
748 if (cls is ClassElement) { 752 if (cls is ClassElement) {
749 // TODO(johnniwinther): Support constructor bodies for entities. 753 // TODO(johnniwinther): Support constructor bodies for entities.
750 cls.forEachConstructorBody((ConstructorBodyElement constructorBody) => 754 cls.forEachConstructorBody((ConstructorBodyElement constructorBody) =>
751 visitMember(cls, constructorBody)); 755 visitMember(cls, constructorBody));
752 } 756 }
753 } 757 }
754 bool isInterceptedClass = _interceptorData.isInterceptedClass(cls); 758 bool isInterceptedClass = _interceptorData.isInterceptedClass(cls);
755 List<Field> instanceFields = onlyForRti 759 List<Field> instanceFields = onlyForRti
756 ? const <Field>[] 760 ? const <Field>[]
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 799
796 js.Name name = _namer.className(cls); 800 js.Name name = _namer.className(cls);
797 String holderName = _namer.globalObjectForClass(cls); 801 String holderName = _namer.globalObjectForClass(cls);
798 // TODO(floitsch): we shouldn't update the registry in the middle of 802 // TODO(floitsch): we shouldn't update the registry in the middle of
799 // building a class. 803 // building a class.
800 Holder holder = _registry.registerHolder(holderName); 804 Holder holder = _registry.registerHolder(holderName);
801 bool isInstantiated = !_nativeData.isJsInteropClass(cls) && 805 bool isInstantiated = !_nativeData.isJsInteropClass(cls) &&
802 _worldBuilder.directlyInstantiatedClasses.contains(cls); 806 _worldBuilder.directlyInstantiatedClasses.contains(cls);
803 807
804 Class result; 808 Class result;
805 if (_elementEnvironment.isUnnamedMixinApplication(cls) && !onlyForRti) { 809 if (_elementEnvironment.isMixinApplication(cls) && !onlyForRti) {
806 assert(!_nativeData.isNativeClass(cls)); 810 assert(!_nativeData.isNativeClass(cls));
807 assert(methods.isEmpty); 811 assert(methods.isEmpty);
808 assert(!isClosureBaseClass); 812 assert(!isClosureBaseClass);
809 813
810 result = new MixinApplication( 814 result = new MixinApplication(
811 cls, 815 cls,
812 name, 816 name,
813 holder, 817 holder,
814 instanceFields, 818 instanceFields,
815 staticFieldsForReflection, 819 staticFieldsForReflection,
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 Constant constant = new Constant(name, holder, constantValue); 1184 Constant constant = new Constant(name, holder, constantValue);
1181 _constants[constantValue] = constant; 1185 _constants[constantValue] = constant;
1182 } 1186 }
1183 } 1187 }
1184 1188
1185 Holder _registerStaticStateHolder() { 1189 Holder _registerStaticStateHolder() {
1186 return _registry.registerHolder(_namer.staticStateHolder, 1190 return _registry.registerHolder(_namer.staticStateHolder,
1187 isStaticStateHolder: true); 1191 isStaticStateHolder: true);
1188 } 1192 }
1189 } 1193 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder/field_visitor.dart ('k') | pkg/compiler/lib/src/kernel/element_map_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698