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

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

Issue 1584543002: dart2js cps: Support inlining constructors with type arguments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update status files and unit tests Created 4 years, 11 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 code_generator; 5 library code_generator;
6 6
7 import 'glue.dart'; 7 import 'glue.dart';
8 8
9 import '../../closure.dart' show 9 import '../../closure.dart' show
10 ClosureClassElement; 10 ClosureClassElement;
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 accumulator.add(new js.Try(tryBlock, catchPart, null)); 807 accumulator.add(new js.Try(tryBlock, catchPart, null));
808 } 808 }
809 809
810 @override 810 @override
811 js.Expression visitCreateBox(tree_ir.CreateBox node) { 811 js.Expression visitCreateBox(tree_ir.CreateBox node) {
812 return new js.ObjectInitializer(const <js.Property>[]); 812 return new js.ObjectInitializer(const <js.Property>[]);
813 } 813 }
814 814
815 @override 815 @override
816 js.Expression visitCreateInstance(tree_ir.CreateInstance node) { 816 js.Expression visitCreateInstance(tree_ir.CreateInstance node) {
817 ClassElement classElement = node.classElement; 817 ClassElement classElement = node.dartType.element;
818 // TODO(asgerf): To allow inlining of InvokeConstructor, CreateInstance must 818 registry.registerInstantiation(node.dartType);
819 // carry a DartType so we can register the instantiated type
820 // with its type arguments. Otherwise dataflow analysis is
821 // needed to reconstruct the instantiated type.
822 registry.registerInstantiation(classElement.rawType);
823 if (classElement is ClosureClassElement) { 819 if (classElement is ClosureClassElement) {
824 registry.registerInstantiatedClosure(classElement.methodElement); 820 registry.registerInstantiatedClosure(classElement.methodElement);
825 } 821 }
826 js.Expression instance = new js.New( 822 js.Expression instance = new js.New(
827 glue.constructorAccess(classElement), 823 glue.constructorAccess(classElement),
828 visitExpressionList(node.arguments)) 824 visitExpressionList(node.arguments))
829 .withSourceInformation(node.sourceInformation); 825 .withSourceInformation(node.sourceInformation);
830 826
831 List<tree_ir.Expression> typeInformation = node.typeInformation; 827 List<tree_ir.Expression> typeInformation = node.typeInformation;
832 assert(typeInformation.isEmpty || 828 assert(typeInformation.isEmpty ||
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 void registerDefaultParameterValues(ExecutableElement element) { 1221 void registerDefaultParameterValues(ExecutableElement element) {
1226 if (element is! FunctionElement) return; 1222 if (element is! FunctionElement) return;
1227 FunctionElement function = element; 1223 FunctionElement function = element;
1228 if (function.isStatic) return; // Defaults are inlined at call sites. 1224 if (function.isStatic) return; // Defaults are inlined at call sites.
1229 function.functionSignature.forEachOptionalParameter((param) { 1225 function.functionSignature.forEachOptionalParameter((param) {
1230 ConstantValue constant = glue.getDefaultParameterValue(param); 1226 ConstantValue constant = glue.getDefaultParameterValue(param);
1231 registry.registerCompileTimeConstant(constant); 1227 registry.registerCompileTimeConstant(constant);
1232 }); 1228 });
1233 } 1229 }
1234 } 1230 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/scalar_replacement.dart ('k') | pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698