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

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

Issue 1839243003: Serialize ResolutionImpact instead of WorldImpact. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 EventSink, 8 EventSink,
9 Future; 9 Future;
10 10
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 const <DiagnosticMessage>[], 1950 const <DiagnosticMessage>[],
1951 api.Diagnostic.HINT); 1951 api.Diagnostic.HINT);
1952 }); 1952 });
1953 } 1953 }
1954 } 1954 }
1955 } 1955 }
1956 1956
1957 // TODO(johnniwinther): Move [ResolverTask] here. 1957 // TODO(johnniwinther): Move [ResolverTask] here.
1958 class _CompilerResolution implements Resolution { 1958 class _CompilerResolution implements Resolution {
1959 final Compiler compiler; 1959 final Compiler compiler;
1960 final Map<Element, ResolutionImpact> _resolutionImpactCache =
1961 <Element, ResolutionImpact>{};
1960 final Map<Element, WorldImpact> _worldImpactCache = <Element, WorldImpact>{}; 1962 final Map<Element, WorldImpact> _worldImpactCache = <Element, WorldImpact>{};
1961 1963
1962 _CompilerResolution(this.compiler); 1964 _CompilerResolution(this.compiler);
1963 1965
1964 @override 1966 @override
1965 DiagnosticReporter get reporter => compiler.reporter; 1967 DiagnosticReporter get reporter => compiler.reporter;
1966 1968
1967 @override 1969 @override
1968 Parsing get parsing => compiler.parsing; 1970 Parsing get parsing => compiler.parsing;
1969 1971
(...skipping 24 matching lines...) Expand all
1994 FunctionSignature resolveSignature(FunctionElement function) { 1996 FunctionSignature resolveSignature(FunctionElement function) {
1995 return compiler.resolver.resolveSignature(function); 1997 return compiler.resolver.resolveSignature(function);
1996 } 1998 }
1997 1999
1998 @override 2000 @override
1999 DartType resolveTypeAnnotation(Element element, TypeAnnotation node) { 2001 DartType resolveTypeAnnotation(Element element, TypeAnnotation node) {
2000 return compiler.resolver.resolveTypeAnnotation(element, node); 2002 return compiler.resolver.resolveTypeAnnotation(element, node);
2001 } 2003 }
2002 2004
2003 @override 2005 @override
2006 ResolutionImpact getResolutionImpact(Element element) {
2007 ResolutionImpact resolutionImpact = _resolutionImpactCache[element];
2008 assert(invariant(element, resolutionImpact != null,
2009 message: "ResolutionImpact not available for $element."));
2010 return resolutionImpact;
2011 }
2012
2013 @override
2004 WorldImpact getWorldImpact(Element element) { 2014 WorldImpact getWorldImpact(Element element) {
2005 WorldImpact worldImpact = _worldImpactCache[element]; 2015 WorldImpact worldImpact = _worldImpactCache[element];
2006 assert(invariant(element, worldImpact != null, 2016 assert(invariant(element, worldImpact != null,
2007 message: "WorldImpact not computed for $element.")); 2017 message: "WorldImpact not computed for $element."));
2008 return worldImpact; 2018 return worldImpact;
2009 } 2019 }
2010 2020
2011 @override 2021 @override
2012 WorldImpact computeWorldImpact(Element element) { 2022 WorldImpact computeWorldImpact(Element element) {
2013 return _worldImpactCache.putIfAbsent(element, () { 2023 return _worldImpactCache.putIfAbsent(element, () {
2014 assert(compiler.parser != null); 2024 assert(compiler.parser != null);
2015 Node tree = compiler.parser.parse(element); 2025 Node tree = compiler.parser.parse(element);
2016 assert(invariant(element, !element.isSynthesized || tree == null)); 2026 assert(invariant(element, !element.isSynthesized || tree == null));
2017 ResolutionImpact resolutionImpact = 2027 ResolutionImpact resolutionImpact =
2018 compiler.resolver.resolve(element); 2028 compiler.resolver.resolve(element);
2029 if (compiler.serialization.supportSerialization) {
2030 // [ResolutionImpact] is currently only used by serialization. The
2031 // enqueuer uses the [WorldImpact] which is always cached.
2032 // TODO(johnniwinther): Align these use cases better; maybe only
2033 // cache [ResolutionImpact] and let the enqueuer transform it into
2034 // a [WorldImpact].
2035 _resolutionImpactCache[element] = resolutionImpact;
2036 }
2019 if (tree != null && !compiler.options.analyzeSignaturesOnly) { 2037 if (tree != null && !compiler.options.analyzeSignaturesOnly) {
2020 // TODO(het): don't do this if suppressWarnings is on, currently we have 2038 // TODO(het): don't do this if suppressWarnings is on, currently we have
2021 // to do it because the typechecker also sets types 2039 // to do it because the typechecker also sets types
2022 // Only analyze nodes with a corresponding [TreeElements]. 2040 // Only analyze nodes with a corresponding [TreeElements].
2023 compiler.checker.check(element); 2041 compiler.checker.check(element);
2024 } 2042 }
2025 WorldImpact worldImpact = 2043 WorldImpact worldImpact =
2026 compiler.backend.impactTransformer.transformResolutionImpact( 2044 compiler.backend.impactTransformer.transformResolutionImpact(
2027 resolutionImpact); 2045 resolutionImpact);
2028 return worldImpact; 2046 return worldImpact;
2029 }); 2047 });
2030 } 2048 }
2031 2049
2032 @override 2050 @override
2033 void uncacheWorldImpact(Element element) { 2051 void uncacheWorldImpact(Element element) {
2034 if (compiler.serialization.isDeserialized(element)) return; 2052 if (compiler.serialization.isDeserialized(element)) return;
2035 assert(invariant(element, _worldImpactCache[element] != null, 2053 assert(invariant(element, _worldImpactCache[element] != null,
2036 message: "WorldImpact not computed for $element.")); 2054 message: "WorldImpact not computed for $element."));
2037 _worldImpactCache[element] = const WorldImpact(); 2055 _worldImpactCache[element] = const WorldImpact();
2056 _resolutionImpactCache.remove(element);
2038 } 2057 }
2039 2058
2040 @override 2059 @override
2041 void emptyCache() { 2060 void emptyCache() {
2042 for (Element element in _worldImpactCache.keys) { 2061 for (Element element in _worldImpactCache.keys) {
2043 _worldImpactCache[element] = const WorldImpact(); 2062 _worldImpactCache[element] = const WorldImpact();
2044 } 2063 }
2064 _resolutionImpactCache.clear();
2045 } 2065 }
2046 2066
2047 @override 2067 @override
2048 bool hasBeenResolved(Element element) { 2068 bool hasBeenResolved(Element element) {
2049 return _worldImpactCache.containsKey(element); 2069 return _worldImpactCache.containsKey(element);
2050 } 2070 }
2051 2071
2052 @override 2072 @override
2053 ResolutionWorkItem createWorkItem( 2073 ResolutionWorkItem createWorkItem(
2054 Element element, ItemCompilationContext compilationContext) { 2074 Element element, ItemCompilationContext compilationContext) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 _ElementScanner(this.scanner); 2157 _ElementScanner(this.scanner);
2138 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); 2158 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library);
2139 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); 2159 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit);
2140 } 2160 }
2141 2161
2142 class _EmptyEnvironment implements Environment { 2162 class _EmptyEnvironment implements Environment {
2143 const _EmptyEnvironment(); 2163 const _EmptyEnvironment();
2144 2164
2145 String valueOf(String key) => null; 2165 String valueOf(String key) => null;
2146 } 2166 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/common/resolution.dart ('k') | pkg/compiler/lib/src/serialization/impact_serialization.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698