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

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

Issue 1195573003: dart2js cps: Refactor and optimize string concatenations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove renegade linebreak Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library dart2js.ir_nodes; 4 library dart2js.ir_nodes;
5 5
6 import '../constants/expressions.dart'; 6 import '../constants/expressions.dart';
7 import '../constants/values.dart' as values show ConstantValue; 7 import '../constants/values.dart' as values show ConstantValue;
8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/source_information.dart' show SourceInformation; 10 import '../io/source_information.dart' show SourceInformation;
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 this.type, 417 this.type,
418 List<Primitive> typeArguments, 418 List<Primitive> typeArguments,
419 Continuation cont) 419 Continuation cont)
420 : this.value = new Reference<Primitive>(value), 420 : this.value = new Reference<Primitive>(value),
421 this.typeArguments = _referenceList(typeArguments), 421 this.typeArguments = _referenceList(typeArguments),
422 this.continuation = new Reference<Continuation>(cont); 422 this.continuation = new Reference<Continuation>(cont);
423 423
424 accept(Visitor visitor) => visitor.visitTypeCast(this); 424 accept(Visitor visitor) => visitor.visitTypeCast(this);
425 } 425 }
426 426
427 /// Invoke [toString] on each argument and concatenate the results.
428 class ConcatenateStrings extends Expression {
429 final List<Reference<Primitive>> arguments;
430 final Reference<Continuation> continuation;
431
432 ConcatenateStrings(List<Primitive> args, Continuation cont)
433 : arguments = _referenceList(args),
434 continuation = new Reference<Continuation>(cont);
435
436 accept(Visitor visitor) => visitor.visitConcatenateStrings(this);
437 }
438
439 /// Apply a built-in operator. 427 /// Apply a built-in operator.
440 /// 428 ///
441 /// It must be known that the arguments have the proper types. 429 /// It must be known that the arguments have the proper types.
442 class ApplyBuiltinOperator extends Primitive { 430 class ApplyBuiltinOperator extends Primitive {
443 BuiltinOperator operator; 431 BuiltinOperator operator;
444 List<Reference<Primitive>> arguments; 432 List<Reference<Primitive>> arguments;
445 433
446 ApplyBuiltinOperator(this.operator, List<Primitive> arguments) 434 ApplyBuiltinOperator(this.operator, List<Primitive> arguments)
447 : this.arguments = _referenceList(arguments); 435 : this.arguments = _referenceList(arguments);
448 436
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 final Selector selector; 708 final Selector selector;
721 final List<Reference<Primitive>> arguments; 709 final List<Reference<Primitive>> arguments;
722 710
723 CreateInvocationMirror(this.selector, List<Primitive> arguments) 711 CreateInvocationMirror(this.selector, List<Primitive> arguments)
724 : this.arguments = _referenceList(arguments); 712 : this.arguments = _referenceList(arguments);
725 713
726 accept(Visitor visitor) => visitor.visitCreateInvocationMirror(this); 714 accept(Visitor visitor) => visitor.visitCreateInvocationMirror(this);
727 } 715 }
728 716
729 class Constant extends Primitive { 717 class Constant extends Primitive {
730 final ConstantExpression expression; 718 values.ConstantValue value;
karlklose 2015/06/19 08:33:45 Is this field mutated now or can we keep it final?
asgerf 2015/06/19 11:04:34 We can keep it final.
731 final values.ConstantValue value;
732 719
733 Constant(this.expression, this.value); 720 Constant(this.value);
734 721
735 accept(Visitor visitor) => visitor.visitConstant(this); 722 accept(Visitor visitor) => visitor.visitConstant(this);
736 } 723 }
737 724
738 class LiteralList extends Primitive { 725 class LiteralList extends Primitive {
739 /// The List type being created; this is not the type argument. 726 /// The List type being created; this is not the type argument.
740 final InterfaceType type; 727 final InterfaceType type;
741 final List<Reference<Primitive>> values; 728 final List<Reference<Primitive>> values;
742 729
743 LiteralList(this.type, List<Primitive> values) 730 LiteralList(this.type, List<Primitive> values)
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 // Expressions. 904 // Expressions.
918 T visitLetPrim(LetPrim node); 905 T visitLetPrim(LetPrim node);
919 T visitLetCont(LetCont node); 906 T visitLetCont(LetCont node);
920 T visitLetHandler(LetHandler node); 907 T visitLetHandler(LetHandler node);
921 T visitLetMutable(LetMutable node); 908 T visitLetMutable(LetMutable node);
922 T visitInvokeContinuation(InvokeContinuation node); 909 T visitInvokeContinuation(InvokeContinuation node);
923 T visitInvokeStatic(InvokeStatic node); 910 T visitInvokeStatic(InvokeStatic node);
924 T visitInvokeMethod(InvokeMethod node); 911 T visitInvokeMethod(InvokeMethod node);
925 T visitInvokeMethodDirectly(InvokeMethodDirectly node); 912 T visitInvokeMethodDirectly(InvokeMethodDirectly node);
926 T visitInvokeConstructor(InvokeConstructor node); 913 T visitInvokeConstructor(InvokeConstructor node);
927 T visitConcatenateStrings(ConcatenateStrings node);
928 T visitThrow(Throw node); 914 T visitThrow(Throw node);
929 T visitRethrow(Rethrow node); 915 T visitRethrow(Rethrow node);
930 T visitBranch(Branch node); 916 T visitBranch(Branch node);
931 T visitTypeCast(TypeCast node); 917 T visitTypeCast(TypeCast node);
932 T visitSetMutableVariable(SetMutableVariable node); 918 T visitSetMutableVariable(SetMutableVariable node);
933 T visitSetStatic(SetStatic node); 919 T visitSetStatic(SetStatic node);
934 T visitGetLazyStatic(GetLazyStatic node); 920 T visitGetLazyStatic(GetLazyStatic node);
935 T visitSetField(SetField node); 921 T visitSetField(SetField node);
936 T visitUnreachable(Unreachable node); 922 T visitUnreachable(Unreachable node);
937 923
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 node.arguments.forEach(processReference); 1027 node.arguments.forEach(processReference);
1042 } 1028 }
1043 1029
1044 processInvokeConstructor(InvokeConstructor node) {} 1030 processInvokeConstructor(InvokeConstructor node) {}
1045 visitInvokeConstructor(InvokeConstructor node) { 1031 visitInvokeConstructor(InvokeConstructor node) {
1046 processInvokeConstructor(node); 1032 processInvokeConstructor(node);
1047 processReference(node.continuation); 1033 processReference(node.continuation);
1048 node.arguments.forEach(processReference); 1034 node.arguments.forEach(processReference);
1049 } 1035 }
1050 1036
1051 processConcatenateStrings(ConcatenateStrings node) {}
1052 visitConcatenateStrings(ConcatenateStrings node) {
1053 processConcatenateStrings(node);
1054 processReference(node.continuation);
1055 node.arguments.forEach(processReference);
1056 }
1057
1058 processThrow(Throw node) {} 1037 processThrow(Throw node) {}
1059 visitThrow(Throw node) { 1038 visitThrow(Throw node) {
1060 processThrow(node); 1039 processThrow(node);
1061 processReference(node.value); 1040 processReference(node.value);
1062 } 1041 }
1063 1042
1064 processRethrow(Rethrow node) {} 1043 processRethrow(Rethrow node) {}
1065 visitRethrow(Rethrow node) { 1044 visitRethrow(Rethrow node) {
1066 processRethrow(node); 1045 processRethrow(node);
1067 } 1046 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 const RemovalVisitor(); 1235 const RemovalVisitor();
1257 1236
1258 processReference(Reference reference) { 1237 processReference(Reference reference) {
1259 reference.unlink(); 1238 reference.unlink();
1260 } 1239 }
1261 1240
1262 static void remove(Node node) { 1241 static void remove(Node node) {
1263 (const RemovalVisitor()).visit(node); 1242 (const RemovalVisitor()).visit(node);
1264 } 1243 }
1265 } 1244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698