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

Unified Diff: lib/src/compiler/code_generator.dart

Issue 1999273002: fix performance of setType (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/private/ddc_runtime/classes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/compiler/code_generator.dart
diff --git a/lib/src/compiler/code_generator.dart b/lib/src/compiler/code_generator.dart
index 478327afa187534277ced67e0120cd1f6b68d971..9179a4018e3adcda87a3c8222dc349ea2a11da09 100644
--- a/lib/src/compiler/code_generator.dart
+++ b/lib/src/compiler/code_generator.dart
@@ -697,7 +697,8 @@ class CodeGenerator extends GeneralizingAstVisitor
_defineClass(classElem, className, classExpr, body);
// Emit things that come after the ES6 `class ... { ... }`.
- _setBaseClass(classElem, className, body);
+ var jsPeerName = _getJSPeerName(classElem);
+ _setBaseClass(classElem, className, jsPeerName, body);
_defineNamedConstructors(ctors, body, className);
_emitVirtualFieldSymbols(virtualFieldSymbols, body);
_emitClassSignature(methods, classElem, ctors, extensions, className, body);
@@ -712,7 +713,7 @@ class CodeGenerator extends GeneralizingAstVisitor
body = <JS.Statement>[classDef];
_emitStaticFields(staticFields, staticFieldOverrides, classElem, body);
- _registerExtensionType(classElem, body);
+ _registerExtensionType(classElem, jsPeerName, body);
return _statement(body);
}
@@ -1141,30 +1142,24 @@ class CodeGenerator extends GeneralizingAstVisitor
return jsPeerName;
}
- void _registerExtensionType(ClassElement classElem, List<JS.Statement> body) {
- var jsPeerName = _getJSPeerName(classElem);
+ void _registerExtensionType(
+ ClassElement classElem, String jsPeerName, List<JS.Statement> body) {
if (jsPeerName != null) {
- // TODO(jmesserly): this copies the dynamic members.
- // Probably fine for objects coming from JS, but not if we actually
- // want to support construction of instances with generic types other
- // than dynamic. See issue #154 for Array and List<E> related bug.
body.add(js.statement('dart.registerExtension(dart.global.#, #);',
[_propertyName(jsPeerName), _emitTopLevelName(classElem)]));
}
}
void _setBaseClass(ClassElement classElem, JS.Expression className,
- List<JS.Statement> body) {
- String jsPeerName = _getJSPeerName(classElem);
- JS.Expression newBaseClass;
+ String jsPeerName, List<JS.Statement> body) {
if (jsPeerName != null && classElem.typeParameters.isNotEmpty) {
// TODO(jmesserly): we should really just extend Array in the first place.
- newBaseClass = js.call('dart.global.#', [jsPeerName]);
+ var newBaseClass = js.call('dart.global.#', [jsPeerName]);
+ body.add(js.statement(
+ 'dart.setExtensionBaseClass(#, #);', [className, newBaseClass]));
} else if (_hasDeferredSupertype.contains(classElem)) {
- newBaseClass = _emitType(classElem.type.superclass,
+ var newBaseClass = _emitType(classElem.type.superclass,
subClass: classElem, className: className);
- }
- if (newBaseClass != null) {
body.add(
js.statement('dart.setBaseClass(#, #);', [className, newBaseClass]));
}
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/private/ddc_runtime/classes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698