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

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

Issue 1240263002: dart2js cps: Streamline expressions and primitives. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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/values.dart' as values show ConstantValue; 6 import '../constants/values.dart' as values show ConstantValue;
7 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 7 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../io/source_information.dart' show SourceInformation; 9 import '../io/source_information.dart' show SourceInformation;
10 import '../types/types.dart' show TypeMask; 10 import '../types/types.dart' show TypeMask;
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 bool get isSafeForElimination => true; 572 bool get isSafeForElimination => true;
573 bool get isSafeForReordering => false; 573 bool get isSafeForReordering => false;
574 } 574 }
575 575
576 /// Assign a [MutableVariable]. 576 /// Assign a [MutableVariable].
577 /// 577 ///
578 /// [MutableVariable]s can be seen as ref cells that are not first-class 578 /// [MutableVariable]s can be seen as ref cells that are not first-class
579 /// values. This can be seen as a dereferencing assignment: 579 /// values. This can be seen as a dereferencing assignment:
580 /// 580 ///
581 /// { [variable] := [value]; [body] } 581 /// { [variable] := [value]; [body] }
582 class SetMutableVariable extends InteriorExpression { 582 class SetMutableVariable extends Primitive {
583 final Reference<MutableVariable> variable; 583 final Reference<MutableVariable> variable;
584 final Reference<Primitive> value; 584 final Reference<Primitive> value;
585 Expression body;
586 585
587 SetMutableVariable(MutableVariable variable, Primitive value) 586 SetMutableVariable(MutableVariable variable, Primitive value)
588 : this.variable = new Reference<MutableVariable>(variable), 587 : this.variable = new Reference<MutableVariable>(variable),
589 this.value = new Reference<Primitive>(value); 588 this.value = new Reference<Primitive>(value);
590 589
591 accept(Visitor visitor) => visitor.visitSetMutableVariable(this); 590 accept(Visitor visitor) => visitor.visitSetMutableVariable(this);
592 591
593 Expression plug(Expression expr) { 592 bool get isSafeForElimination => false;
594 assert(body == null); 593 bool get isSafeForReordering => false;
595 return body = expr;
596 }
597 } 594 }
598 595
599 /// Invoke a continuation in tail position. 596 /// Invoke a continuation in tail position.
600 class InvokeContinuation extends TailExpression { 597 class InvokeContinuation extends TailExpression {
601 Reference<Continuation> continuation; 598 Reference<Continuation> continuation;
602 List<Reference<Primitive>> arguments; 599 List<Reference<Primitive>> arguments;
603 SourceInformation sourceInformation; 600 SourceInformation sourceInformation;
604 601
605 // An invocation of a continuation is recursive if it occurs in the body of 602 // An invocation of a continuation is recursive if it occurs in the body of
606 // the continuation itself. 603 // the continuation itself.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 final Reference<Continuation> falseContinuation; 652 final Reference<Continuation> falseContinuation;
656 653
657 Branch(this.condition, Continuation trueCont, Continuation falseCont) 654 Branch(this.condition, Continuation trueCont, Continuation falseCont)
658 : trueContinuation = new Reference<Continuation>(trueCont), 655 : trueContinuation = new Reference<Continuation>(trueCont),
659 falseContinuation = new Reference<Continuation>(falseCont); 656 falseContinuation = new Reference<Continuation>(falseCont);
660 657
661 accept(Visitor visitor) => visitor.visitBranch(this); 658 accept(Visitor visitor) => visitor.visitBranch(this);
662 } 659 }
663 660
664 /// Directly assigns to a field on a given object. 661 /// Directly assigns to a field on a given object.
665 class SetField extends InteriorExpression { 662 class SetField extends Primitive {
666 final Reference<Primitive> object; 663 final Reference<Primitive> object;
667 FieldElement field; 664 FieldElement field;
668 final Reference<Primitive> value; 665 final Reference<Primitive> value;
669 Expression body;
670 666
671 SetField(Primitive object, this.field, Primitive value) 667 SetField(Primitive object, this.field, Primitive value)
672 : this.object = new Reference<Primitive>(object), 668 : this.object = new Reference<Primitive>(object),
673 this.value = new Reference<Primitive>(value); 669 this.value = new Reference<Primitive>(value);
674 670
675 Expression plug(Expression expr) {
676 assert(body == null);
677 return body = expr;
678 }
679
680 accept(Visitor visitor) => visitor.visitSetField(this); 671 accept(Visitor visitor) => visitor.visitSetField(this);
672
673 bool get isSafeForElimination => false;
674 bool get isSafeForReordering => false;
681 } 675 }
682 676
683 /// Directly reads from a field on a given object. 677 /// Directly reads from a field on a given object.
684 /// 678 ///
685 /// The [object] must either be `null` or an object that has [field]. 679 /// The [object] must either be `null` or an object that has [field].
686 class GetField extends Primitive { 680 class GetField extends Primitive {
687 final Reference<Primitive> object; 681 final Reference<Primitive> object;
688 FieldElement field; 682 FieldElement field;
689 683
690 /// True if the object is known not to be null. 684 /// True if the object is known not to be null.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 765
772 bool get isSafeForElimination { 766 bool get isSafeForElimination {
773 return true; 767 return true;
774 } 768 }
775 bool get isSafeForReordering { 769 bool get isSafeForReordering {
776 return element is FunctionElement || element.isFinal; 770 return element is FunctionElement || element.isFinal;
777 } 771 }
778 } 772 }
779 773
780 /// Sets the value of a static field. 774 /// Sets the value of a static field.
781 class SetStatic extends InteriorExpression { 775 class SetStatic extends Primitive {
782 final FieldElement element; 776 final FieldElement element;
783 final Reference<Primitive> value; 777 final Reference<Primitive> value;
784 Expression body;
785 final SourceInformation sourceInformation; 778 final SourceInformation sourceInformation;
786 779
787 SetStatic(this.element, Primitive value, [this.sourceInformation]) 780 SetStatic(this.element, Primitive value, [this.sourceInformation])
788 : this.value = new Reference<Primitive>(value); 781 : this.value = new Reference<Primitive>(value);
789 782
790 Expression plug(Expression expr) { 783 accept(Visitor visitor) => visitor.visitSetStatic(this);
791 assert(body == null);
792 return body = expr;
793 }
794 784
795 accept(Visitor visitor) => visitor.visitSetStatic(this); 785 bool get isSafeForElimination => false;
786 bool get isSafeForReordering => false;
796 } 787 }
797 788
798 /// Reads the value of a lazily initialized static field. 789 /// Reads the value of a lazily initialized static field.
799 /// 790 ///
800 /// If the field has not yet been initialized, its initializer is evaluated 791 /// If the field has not yet been initialized, its initializer is evaluated
801 /// and assigned to the field. 792 /// and assigned to the field.
802 /// 793 ///
803 /// [continuation] is then invoked with the value of the field as argument. 794 /// [continuation] is then invoked with the value of the field as argument.
804 class GetLazyStatic extends CallExpression { 795 class GetLazyStatic extends CallExpression {
805 final FieldElement element; 796 final FieldElement element;
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 processTypeTest(node); 1272 processTypeTest(node);
1282 processReference(node.value); 1273 processReference(node.value);
1283 node.typeArguments.forEach(processReference); 1274 node.typeArguments.forEach(processReference);
1284 } 1275 }
1285 1276
1286 processSetMutableVariable(SetMutableVariable node) {} 1277 processSetMutableVariable(SetMutableVariable node) {}
1287 visitSetMutableVariable(SetMutableVariable node) { 1278 visitSetMutableVariable(SetMutableVariable node) {
1288 processSetMutableVariable(node); 1279 processSetMutableVariable(node);
1289 processReference(node.variable); 1280 processReference(node.variable);
1290 processReference(node.value); 1281 processReference(node.value);
1291 visit(node.body);
1292 } 1282 }
1293 1283
1294 processGetLazyStatic(GetLazyStatic node) {} 1284 processGetLazyStatic(GetLazyStatic node) {}
1295 visitGetLazyStatic(GetLazyStatic node) { 1285 visitGetLazyStatic(GetLazyStatic node) {
1296 processGetLazyStatic(node); 1286 processGetLazyStatic(node);
1297 processReference(node.continuation); 1287 processReference(node.continuation);
1298 } 1288 }
1299 1289
1300 processLiteralList(LiteralList node) {} 1290 processLiteralList(LiteralList node) {}
1301 visitLiteralList(LiteralList node) { 1291 visitLiteralList(LiteralList node) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 processCreateInstance(node); 1353 processCreateInstance(node);
1364 node.arguments.forEach(processReference); 1354 node.arguments.forEach(processReference);
1365 node.typeInformation.forEach(processReference); 1355 node.typeInformation.forEach(processReference);
1366 } 1356 }
1367 1357
1368 processSetField(SetField node) {} 1358 processSetField(SetField node) {}
1369 visitSetField(SetField node) { 1359 visitSetField(SetField node) {
1370 processSetField(node); 1360 processSetField(node);
1371 processReference(node.object); 1361 processReference(node.object);
1372 processReference(node.value); 1362 processReference(node.value);
1373 visit(node.body);
1374 } 1363 }
1375 1364
1376 processGetField(GetField node) {} 1365 processGetField(GetField node) {}
1377 visitGetField(GetField node) { 1366 visitGetField(GetField node) {
1378 processGetField(node); 1367 processGetField(node);
1379 processReference(node.object); 1368 processReference(node.object);
1380 } 1369 }
1381 1370
1382 processGetStatic(GetStatic node) {} 1371 processGetStatic(GetStatic node) {}
1383 visitGetStatic(GetStatic node) { 1372 visitGetStatic(GetStatic node) {
1384 processGetStatic(node); 1373 processGetStatic(node);
1385 } 1374 }
1386 1375
1387 processSetStatic(SetStatic node) {} 1376 processSetStatic(SetStatic node) {}
1388 visitSetStatic(SetStatic node) { 1377 visitSetStatic(SetStatic node) {
1389 processSetStatic(node); 1378 processSetStatic(node);
1390 processReference(node.value); 1379 processReference(node.value);
1391 visit(node.body);
1392 } 1380 }
1393 1381
1394 processCreateBox(CreateBox node) {} 1382 processCreateBox(CreateBox node) {}
1395 visitCreateBox(CreateBox node) { 1383 visitCreateBox(CreateBox node) {
1396 processCreateBox(node); 1384 processCreateBox(node);
1397 } 1385 }
1398 1386
1399 processReifyRuntimeType(ReifyRuntimeType node) {} 1387 processReifyRuntimeType(ReifyRuntimeType node) {}
1400 visitReifyRuntimeType(ReifyRuntimeType node) { 1388 visitReifyRuntimeType(ReifyRuntimeType node) {
1401 processReifyRuntimeType(node); 1389 processReifyRuntimeType(node);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 const RemovalVisitor(); 1461 const RemovalVisitor();
1474 1462
1475 processReference(Reference reference) { 1463 processReference(Reference reference) {
1476 reference.unlink(); 1464 reference.unlink();
1477 } 1465 }
1478 1466
1479 static void remove(Node node) { 1467 static void remove(Node node) {
1480 (const RemovalVisitor()).visit(node); 1468 (const RemovalVisitor()).visit(node);
1481 } 1469 }
1482 } 1470 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698