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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart

Issue 340023003: Various caches for incremental compilation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Only allocate caches when hasIncrementalCompilation is true. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: dart/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart b/dart/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
index 900823debae97ed865376b6903a98f92076cd5c0..1e77f3f9c9f7298182286362801bbfdbb6a39e79 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
@@ -6,7 +6,9 @@ part of js_backend;
class NativeEmitter {
- CodeEmitterTask emitter;
+ final Map<Element, ClassBuilder> cachedBuilders;
+
+ final CodeEmitterTask emitter;
CodeBuffer nativeBuffer;
// Native classes found in the application.
@@ -26,11 +28,13 @@ class NativeEmitter {
// it finds any native class that needs noSuchMethod handling.
bool handleNoSuchMethod = false;
- NativeEmitter(this.emitter)
- : subtypes = new Map<ClassElement, List<ClassElement>>(),
+ NativeEmitter(CodeEmitterTask emitter)
+ : this.emitter = emitter,
+ subtypes = new Map<ClassElement, List<ClassElement>>(),
directSubtypes = new Map<ClassElement, List<ClassElement>>(),
nativeMethods = new Set<FunctionElement>(),
- nativeBuffer = new CodeBuffer();
+ nativeBuffer = new CodeBuffer(),
+ cachedBuilders = emitter.compiler.cacheStrategy.newMap();
Compiler get compiler => emitter.compiler;
JavaScriptBackend get backend => compiler.backend;
@@ -279,6 +283,16 @@ class NativeEmitter {
}
ClassBuilder generateNativeClass(ClassElement classElement) {
+ ClassBuilder builder;
+ if (compiler.hasIncrementalSupport) {
+ builder = cachedBuilders[classElement];
+ if (builder != null) return builder;
+ builder = new ClassBuilder(backend.namer);
+ cachedBuilders[classElement] = builder;
+ } else {
+ builder = new ClassBuilder(backend.namer);
+ }
+
// TODO(sra): Issue #13731- this is commented out as part of custom element
// constructor work.
//assert(!classElement.hasBackendMembers);
@@ -294,7 +308,6 @@ class NativeEmitter {
String superName = backend.namer.getNameOfClass(superclass);
- ClassBuilder builder = new ClassBuilder(backend.namer);
emitter.classEmitter.emitClassConstructor(classElement, builder);
bool hasFields = emitter.classEmitter.emitFields(
classElement, builder, superName, classIsNative: true);

Powered by Google App Engine
This is Rietveld 408576698