| OLD | NEW |
| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 collect(_elementEnvironment.getEffectiveMixinClass(element)); | 336 collect(_elementEnvironment.getEffectiveMixinClass(element)); |
| 337 } | 337 } |
| 338 if (element.superclass != null) { | 338 if (element.superclass != null) { |
| 339 collect(element.superclass); | 339 collect(element.superclass); |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 // For every known class, see if it was allocated in the profile. If yes, | 343 // For every known class, see if it was allocated in the profile. If yes, |
| 344 // collect its dependencies (supers and mixins) and mark them as | 344 // collect its dependencies (supers and mixins) and mark them as |
| 345 // not-soft-deferrable. | 345 // not-soft-deferrable. |
| 346 collector.outputClassLists.forEach((_, List<ClassElement> elements) { | 346 collector.outputClassLists.forEach((_, List<ClassEntity> elements) { |
| 347 for (ClassElement element in elements) { | 347 for (ClassElement element in elements) { |
| 348 // TODO(29574): share the encoding of the element with the code | 348 // TODO(29574): share the encoding of the element with the code |
| 349 // that emits the profile-run. | 349 // that emits the profile-run. |
| 350 var key = "${element.library.canonicalUri}:${element.name}"; | 350 var key = "${element.library.canonicalUri}:${element.name}"; |
| 351 if (allocatedClassesKeys.contains(key) || | 351 if (allocatedClassesKeys.contains(key) || |
| 352 _nativeData.isJsInteropClass(element) || | 352 _nativeData.isJsInteropClass(element) || |
| 353 blackList.contains(element.library.canonicalUri.toString())) { | 353 blackList.contains(element.library.canonicalUri.toString())) { |
| 354 collect(element); | 354 collect(element); |
| 355 } | 355 } |
| 356 } | 356 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 // a method in the case where there exist multiple JavaScript classes | 518 // a method in the case where there exist multiple JavaScript classes |
| 519 // that conflict on whether the member is a getter or a method. | 519 // that conflict on whether the member is a getter or a method. |
| 520 var interceptorClass = _classes[_commonElements.jsJavaScriptObjectClass]; | 520 var interceptorClass = _classes[_commonElements.jsJavaScriptObjectClass]; |
| 521 var stubNames = new Set<String>(); | 521 var stubNames = new Set<String>(); |
| 522 librariesMap | 522 librariesMap |
| 523 .forEach((LibraryEntity library, List<ClassEntity> classElements, _) { | 523 .forEach((LibraryEntity library, List<ClassEntity> classElements, _) { |
| 524 for (ClassEntity cls in classElements) { | 524 for (ClassEntity cls in classElements) { |
| 525 if (_nativeData.isJsInteropClass(cls)) { | 525 if (_nativeData.isJsInteropClass(cls)) { |
| 526 // TODO(johnniwinther): Handle class entities. | 526 // TODO(johnniwinther): Handle class entities. |
| 527 ClassElement e = cls; | 527 ClassElement e = cls; |
| 528 e.declaration.forEachMember((_, MemberElement member) { | 528 e.declaration.forEachMember((_, _member) { |
| 529 MemberElement member = _member; |
| 529 var jsName = _nativeData.computeUnescapedJSInteropName(member.name); | 530 var jsName = _nativeData.computeUnescapedJSInteropName(member.name); |
| 530 if (!member.isInstanceMember) return; | 531 if (!member.isInstanceMember) return; |
| 531 if (member.isGetter || member.isField || member.isFunction) { | 532 if (member.isGetter || member.isField || member.isFunction) { |
| 532 var selectors = | 533 var selectors = |
| 533 _worldBuilder.getterInvocationsByName(member.name); | 534 _worldBuilder.getterInvocationsByName(member.name); |
| 534 if (selectors != null && !selectors.isEmpty) { | 535 if (selectors != null && !selectors.isEmpty) { |
| 535 for (var selector in selectors.keys) { | 536 for (var selector in selectors.keys) { |
| 536 var stubName = _namer.invocationName(selector); | 537 var stubName = _namer.invocationName(selector); |
| 537 if (stubNames.add(stubName.key)) { | 538 if (stubNames.add(stubName.key)) { |
| 538 interceptorClass.callStubs.add(_buildStubMethod(stubName, | 539 interceptorClass.callStubs.add(_buildStubMethod(stubName, |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 | 861 |
| 861 bool _methodCanBeApplied(FunctionEntity method) { | 862 bool _methodCanBeApplied(FunctionEntity method) { |
| 862 return _backendUsage.isFunctionApplyUsed && | 863 return _backendUsage.isFunctionApplyUsed && |
| 863 _closedWorld.getMightBePassedToApply(method); | 864 _closedWorld.getMightBePassedToApply(method); |
| 864 } | 865 } |
| 865 | 866 |
| 866 /* Map | List */ _computeParameterDefaultValues(FunctionSignature signature) { | 867 /* Map | List */ _computeParameterDefaultValues(FunctionSignature signature) { |
| 867 var /* Map | List */ optionalParameterDefaultValues; | 868 var /* Map | List */ optionalParameterDefaultValues; |
| 868 if (signature.optionalParametersAreNamed) { | 869 if (signature.optionalParametersAreNamed) { |
| 869 optionalParameterDefaultValues = new Map<String, ConstantValue>(); | 870 optionalParameterDefaultValues = new Map<String, ConstantValue>(); |
| 870 signature.forEachOptionalParameter((ParameterElement parameter) { | 871 signature.forEachOptionalParameter((_parameter) { |
| 872 ParameterElement parameter = _parameter; |
| 871 ConstantValue def = | 873 ConstantValue def = |
| 872 _constantHandler.getConstantValue(parameter.constant); | 874 _constantHandler.getConstantValue(parameter.constant); |
| 873 optionalParameterDefaultValues[parameter.name] = def; | 875 optionalParameterDefaultValues[parameter.name] = def; |
| 874 }); | 876 }); |
| 875 } else { | 877 } else { |
| 876 optionalParameterDefaultValues = <ConstantValue>[]; | 878 optionalParameterDefaultValues = <ConstantValue>[]; |
| 877 signature.forEachOptionalParameter((ParameterElement parameter) { | 879 signature.forEachOptionalParameter((_parameter) { |
| 880 ParameterElement parameter = _parameter; |
| 878 ConstantValue def = | 881 ConstantValue def = |
| 879 _constantHandler.getConstantValue(parameter.constant); | 882 _constantHandler.getConstantValue(parameter.constant); |
| 880 optionalParameterDefaultValues.add(def); | 883 optionalParameterDefaultValues.add(def); |
| 881 }); | 884 }); |
| 882 } | 885 } |
| 883 return optionalParameterDefaultValues; | 886 return optionalParameterDefaultValues; |
| 884 } | 887 } |
| 885 | 888 |
| 886 DartMethod _buildMethod(FunctionEntity element) { | 889 DartMethod _buildMethod(FunctionEntity element) { |
| 887 assert(!(element is MethodElement && !element.isDeclaration)); | 890 assert(!(element is MethodElement && !element.isDeclaration)); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 Constant constant = new Constant(name, holder, constantValue); | 1189 Constant constant = new Constant(name, holder, constantValue); |
| 1187 _constants[constantValue] = constant; | 1190 _constants[constantValue] = constant; |
| 1188 } | 1191 } |
| 1189 } | 1192 } |
| 1190 | 1193 |
| 1191 Holder _registerStaticStateHolder() { | 1194 Holder _registerStaticStateHolder() { |
| 1192 return _registry.registerHolder(_namer.staticStateHolder, | 1195 return _registry.registerHolder(_namer.staticStateHolder, |
| 1193 isStaticStateHolder: true); | 1196 isStaticStateHolder: true); |
| 1194 } | 1197 } |
| 1195 } | 1198 } |
| OLD | NEW |