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

Side by Side Diff: lib/compiler/implementation/ssa/nodes.dart

Issue 10539106: Simplify generated code for trivial bailout methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/ssa/codegen.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 interface HVisitor<R> { 5 interface HVisitor<R> {
6 R visitAdd(HAdd node); 6 R visitAdd(HAdd node);
7 R visitBitAnd(HBitAnd node); 7 R visitBitAnd(HBitAnd node);
8 R visitBitNot(HBitNot node); 8 R visitBitNot(HBitNot node);
9 R visitBitOr(HBitOr node); 9 R visitBitOr(HBitOr node);
10 R visitBitXor(HBitXor node); 10 R visitBitXor(HBitXor node);
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 abstract class HCheck extends HInstruction { 978 abstract class HCheck extends HInstruction {
979 HCheck(inputs) : super(inputs); 979 HCheck(inputs) : super(inputs);
980 HInstruction get checkedInput() => inputs[0]; 980 HInstruction get checkedInput() => inputs[0];
981 bool isStatement() => true; 981 bool isStatement() => true;
982 } 982 }
983 983
984 class HTypeGuard extends HCheck { 984 class HTypeGuard extends HCheck {
985 final int state; 985 final int state;
986 final HType guardedType; 986 final HType guardedType;
987 bool isOn = false; 987 bool isOn = false;
988 int checkedInputIndex = 0;
989
988 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); 990 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env);
989 991
990 void prepareGvn() { 992 void prepareGvn() {
991 assert(!hasSideEffects()); 993 assert(!hasSideEffects());
992 setUseGvn(); 994 setUseGvn();
993 } 995 }
994 996
995 HInstruction get guarded() => inputs.last(); 997 HInstruction get guarded() => inputs[checkedInputIndex];
996 HInstruction get checkedInput() => guarded; 998 HInstruction get checkedInput() => guarded;
997 999
998 HType computeTypeFromInputTypes() { 1000 HType computeTypeFromInputTypes() {
999 return isOn ? guardedType : guarded.propagatedType; 1001 return isOn ? guardedType : guarded.propagatedType;
1000 } 1002 }
1001 1003
1002 HType get guaranteedType() => isOn ? guardedType : HType.UNKNOWN; 1004 HType get guaranteedType() => isOn ? guardedType : HType.UNKNOWN;
1003 1005
1004 bool isControlFlow() => true; 1006 bool isControlFlow() => true;
1005 1007
1006 accept(HVisitor visitor) => visitor.visitTypeGuard(this); 1008 accept(HVisitor visitor) => visitor.visitTypeGuard(this);
1007 int typeCode() => 1; 1009 int typeCode() => 1;
1008 bool typeEquals(other) => other is HTypeGuard; 1010 bool typeEquals(other) => other is HTypeGuard;
1009 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType; 1011 bool dataEquals(HTypeGuard other) {
1012 return guarded == other.guarded && guardedType == other.guardedType;
1013 }
1010 } 1014 }
1011 1015
1012 class HBoundsCheck extends HCheck { 1016 class HBoundsCheck extends HCheck {
1013 static final int ALWAYS_FALSE = 0; 1017 static final int ALWAYS_FALSE = 0;
1014 static final int FULL_CHECK = 1; 1018 static final int FULL_CHECK = 1;
1015 static final int ALWAYS_ABOVE_ZERO = 2; 1019 static final int ALWAYS_ABOVE_ZERO = 2;
1016 static final int ALWAYS_TRUE = 3; 1020 static final int ALWAYS_TRUE = 3;
1017 /** 1021 /**
1018 * Details which tests have been done statically during compilation. 1022 * Details which tests have been done statically during compilation.
1019 * Default is that all checks must be performed dynamically. 1023 * Default is that all checks must be performed dynamically.
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 this.labels); 2488 this.labels);
2485 2489
2486 HBasicBlock get start() { 2490 HBasicBlock get start() {
2487 if (initializer !== null) return initializer.start; 2491 if (initializer !== null) return initializer.start;
2488 if (kind == DO_WHILE_LOOP) { 2492 if (kind == DO_WHILE_LOOP) {
2489 return body.start; 2493 return body.start;
2490 } 2494 }
2491 return condition.start; 2495 return condition.start;
2492 } 2496 }
2493 2497
2498 HBasicBlock get loopHeader() {
2499 return kind == DO_WHILE_LOOP ? body.start : condition.start;
2500 }
2501
2494 HBasicBlock get end() { 2502 HBasicBlock get end() {
2495 if (updates !== null) return updates.end; 2503 if (updates !== null) return updates.end;
2496 if (kind == DO_WHILE_LOOP) { 2504 if (kind == DO_WHILE_LOOP) {
2497 return condition.end; 2505 return condition.end;
2498 } 2506 }
2499 return body.end; 2507 return body.end;
2500 } 2508 }
2501 2509
2502 static int loopType(Node node) { 2510 static int loopType(Node node) {
2503 return node.accept(const LoopTypeVisitor()); 2511 return node.accept(const LoopTypeVisitor());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2581 HBasicBlock get start() => expression.start; 2589 HBasicBlock get start() => expression.start;
2582 HBasicBlock get end() { 2590 HBasicBlock get end() {
2583 // We don't create a switch block if there are no cases. 2591 // We don't create a switch block if there are no cases.
2584 assert(!statements.isEmpty()); 2592 assert(!statements.isEmpty());
2585 return statements.last().end; 2593 return statements.last().end;
2586 } 2594 }
2587 2595
2588 bool accept(HStatementInformationVisitor visitor) => 2596 bool accept(HStatementInformationVisitor visitor) =>
2589 visitor.visitSwitchInfo(this); 2597 visitor.visitSwitchInfo(this);
2590 } 2598 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/codegen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698