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

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

Issue 2668233002: Remove code supporting incremental compilation in dart2js (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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 _buildStaticNonFinalFields(librariesMap), 225 _buildStaticNonFinalFields(librariesMap),
226 _buildStaticLazilyInitializedFields(librariesMap), 226 _buildStaticLazilyInitializedFields(librariesMap),
227 _buildConstants(librariesMap)); 227 _buildConstants(librariesMap));
228 _outputs[librariesMap.outputUnit] = result; 228 _outputs[librariesMap.outputUnit] = result;
229 return result; 229 return result;
230 } 230 }
231 231
232 js.Statement _buildInvokeMain() { 232 js.Statement _buildInvokeMain() {
233 if (_compiler.isMockCompilation) return js.js.comment("Mock compilation"); 233 if (_compiler.isMockCompilation) return js.js.comment("Mock compilation");
234 234
235 MainCallStubGenerator generator = new MainCallStubGenerator( 235 MainCallStubGenerator generator =
236 backend, backend.emitter, 236 new MainCallStubGenerator(backend, backend.emitter);
237 hasIncrementalSupport: _compiler.options.hasIncrementalSupport);
238 return generator.generateInvokeMain(_compiler.mainFunction); 237 return generator.generateInvokeMain(_compiler.mainFunction);
239 } 238 }
240 239
241 DeferredFragment _buildDeferredFragment(LibrariesMap librariesMap) { 240 DeferredFragment _buildDeferredFragment(LibrariesMap librariesMap) {
242 DeferredFragment result = new DeferredFragment( 241 DeferredFragment result = new DeferredFragment(
243 librariesMap.outputUnit, 242 librariesMap.outputUnit,
244 backend.deferredPartFileName(librariesMap.name, addExtension: false), 243 backend.deferredPartFileName(librariesMap.name, addExtension: false),
245 librariesMap.name, 244 librariesMap.name,
246 _buildLibraries(librariesMap), 245 _buildLibraries(librariesMap),
247 _buildStaticNonFinalFields(librariesMap), 246 _buildStaticNonFinalFields(librariesMap),
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 !cls.isNative || !_unneededNativeClasses.contains(cls)) 484 !cls.isNative || !_unneededNativeClasses.contains(cls))
486 .toList(growable: false); 485 .toList(growable: false);
487 486
488 bool visitStatics = true; 487 bool visitStatics = true;
489 List<Field> staticFieldsForReflection = _buildFields(library, visitStatics); 488 List<Field> staticFieldsForReflection = _buildFields(library, visitStatics);
490 489
491 return new Library( 490 return new Library(
492 library, uri, statics, classes, staticFieldsForReflection); 491 library, uri, statics, classes, staticFieldsForReflection);
493 } 492 }
494 493
495 /// HACK for Incremental Compilation.
496 ///
497 /// Returns a class that contains the fields of a class.
498 Class buildFieldsHackForIncrementalCompilation(ClassElement element) {
499 assert(_compiler.options.hasIncrementalSupport);
500
501 List<Field> instanceFields = _buildFields(element, false);
502 js.Name name = namer.className(element);
503
504 return new Class(
505 element, name, null, [], instanceFields, [], [], [], [], [], [], null,
506 isDirectlyInstantiated: true,
507 hasRtiField: backend.classNeedsRtiField(element),
508 onlyForRti: false,
509 isNative: backend.isNative(element));
510 }
511
512 Class _buildClass(ClassElement element) { 494 Class _buildClass(ClassElement element) {
513 bool onlyForRti = collector.classesOnlyNeededForRti.contains(element); 495 bool onlyForRti = collector.classesOnlyNeededForRti.contains(element);
514 bool hasRtiField = backend.classNeedsRtiField(element); 496 bool hasRtiField = backend.classNeedsRtiField(element);
515 if (backend.isJsInterop(element)) { 497 if (backend.isJsInterop(element)) {
516 // TODO(jacobr): check whether the class has any active static fields 498 // TODO(jacobr): check whether the class has any active static fields
517 // if it does not we can suppress it completely. 499 // if it does not we can suppress it completely.
518 onlyForRti = true; 500 onlyForRti = true;
519 } 501 }
520 502
521 List<Method> methods = []; 503 List<Method> methods = [];
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 } 648 }
667 _classes[element] = result; 649 _classes[element] = result;
668 return result; 650 return result;
669 } 651 }
670 652
671 bool _methodNeedsStubs(FunctionElement method) { 653 bool _methodNeedsStubs(FunctionElement method) {
672 return !method.functionSignature.optionalParameters.isEmpty; 654 return !method.functionSignature.optionalParameters.isEmpty;
673 } 655 }
674 656
675 bool _methodCanBeReflected(FunctionElement method) { 657 bool _methodCanBeReflected(FunctionElement method) {
676 return backend.isAccessibleByReflection(method) || 658 return backend.isAccessibleByReflection(method);
677 // During incremental compilation, we have to assume that reflection
678 // *might* get enabled.
679 _compiler.options.hasIncrementalSupport;
680 } 659 }
681 660
682 bool _methodCanBeApplied(FunctionElement method) { 661 bool _methodCanBeApplied(FunctionElement method) {
683 return backend.hasFunctionApplySupport && 662 return backend.hasFunctionApplySupport &&
684 closedWorld.getMightBePassedToApply(method); 663 closedWorld.getMightBePassedToApply(method);
685 } 664 }
686 665
687 // TODO(herhut): Refactor incremental compilation and remove method.
688 Method buildMethodHackForIncrementalCompilation(FunctionElement element) {
689 assert(_compiler.options.hasIncrementalSupport);
690 if (element.isInstanceMember) {
691 return _buildMethod(element);
692 } else {
693 return _buildStaticMethod(element);
694 }
695 }
696
697 /* Map | List */ _computeParameterDefaultValues(FunctionSignature signature) { 666 /* Map | List */ _computeParameterDefaultValues(FunctionSignature signature) {
698 var /* Map | List */ optionalParameterDefaultValues; 667 var /* Map | List */ optionalParameterDefaultValues;
699 if (signature.optionalParametersAreNamed) { 668 if (signature.optionalParametersAreNamed) {
700 optionalParameterDefaultValues = new Map<String, ConstantValue>(); 669 optionalParameterDefaultValues = new Map<String, ConstantValue>();
701 signature.forEachOptionalParameter((ParameterElement parameter) { 670 signature.forEachOptionalParameter((ParameterElement parameter) {
702 ConstantValue def = 671 ConstantValue def =
703 backend.constants.getConstantValue(parameter.constant); 672 backend.constants.getConstantValue(parameter.constant);
704 optionalParameterDefaultValues[parameter.name] = def; 673 optionalParameterDefaultValues[parameter.name] = def;
705 }); 674 });
706 } else { 675 } else {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 Constant constant = new Constant(name, holder, constantValue); 961 Constant constant = new Constant(name, holder, constantValue);
993 _constants[constantValue] = constant; 962 _constants[constantValue] = constant;
994 } 963 }
995 } 964 }
996 965
997 Holder _registerStaticStateHolder() { 966 Holder _registerStaticStateHolder() {
998 return _registry.registerHolder(namer.staticStateHolder, 967 return _registry.registerHolder(namer.staticStateHolder,
999 isStaticStateHolder: true); 968 isStaticStateHolder: true);
1000 } 969 }
1001 } 970 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698