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

Unified Diff: tool/input_sdk/private/ddc_runtime/classes.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/src/compiler/code_generator.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/ddc_runtime/classes.dart
diff --git a/tool/input_sdk/private/ddc_runtime/classes.dart b/tool/input_sdk/private/ddc_runtime/classes.dart
index 637a2302ff1b01a491f038a6b79fb87e2f59dafe..0998ca2608fb90e220d72a64d03b96428926199b 100644
--- a/tool/input_sdk/private/ddc_runtime/classes.dart
+++ b/tool/input_sdk/private/ddc_runtime/classes.dart
@@ -420,19 +420,23 @@ canonicalMember(obj, name) => JS('', '''(() => {
})()''');
/// Sets the type of `obj` to be `type`
-setType(obj, type) => JS('', '''(() => {
- $obj.__proto__ = $type.prototype;
- // TODO(vsm): This should be set in registerExtension, but that is only
- // invoked on the generic type (e.g., JSArray<dynamic>, not JSArray<int>).
- $obj.__proto__[$_extensionType] = $type;
- return $obj;
-})()''');
+setType(obj, type) {
+ JS('', '#.__proto__ = #.prototype', obj, type);
+ return obj;
+}
/// Sets the element type of a list literal.
list(obj, elementType) =>
JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))');
-setBaseClass(derived, base) => JS('', '''(() => {
- // Link the extension to the type it's extending as a base class.
- $derived.prototype.__proto__ = $base.prototype;
-})()''');
+/// Link the extension to the type it's extending as a base class.
+setBaseClass(derived, base) {
+ JS('', '#.prototype.__proto__ = #.prototype', derived, base);
+}
+
+/// Like [setBaseClass] but for generic extension types, e.g. `JSArray<E>`
+setExtensionBaseClass(derived, base) {
+ // Mark the generic type as an extension type.
+ JS('', '#.prototype[#] = #', derived, _extensionType, derived);
+ setBaseClass(derived, base);
+}
« no previous file with comments | « lib/src/compiler/code_generator.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698