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

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

Issue 10807069: Split TypeGuard and BailoutTarget. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 visitBailoutTarget(HBailoutTarget node);
7 R visitBitAnd(HBitAnd node); 8 R visitBitAnd(HBitAnd node);
8 R visitBitNot(HBitNot node); 9 R visitBitNot(HBitNot node);
9 R visitBitOr(HBitOr node); 10 R visitBitOr(HBitOr node);
10 R visitBitXor(HBitXor node); 11 R visitBitXor(HBitXor node);
11 R visitBoolify(HBoolify node); 12 R visitBoolify(HBoolify node);
12 R visitBoundsCheck(HBoundsCheck node); 13 R visitBoundsCheck(HBoundsCheck node);
13 R visitBreak(HBreak node); 14 R visitBreak(HBreak node);
14 R visitConstant(HConstant node); 15 R visitConstant(HConstant node);
15 R visitContinue(HContinue node); 16 R visitContinue(HContinue node);
16 R visitDivide(HDivide node); 17 R visitDivide(HDivide node);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 visitInvokeBinary(HInvokeBinary node) => visitInvokeStatic(node); 250 visitInvokeBinary(HInvokeBinary node) => visitInvokeStatic(node);
250 visitInvokeDynamic(HInvokeDynamic node) => visitInvoke(node); 251 visitInvokeDynamic(HInvokeDynamic node) => visitInvoke(node);
251 visitInvokeDynamicField(HInvokeDynamicField node) => visitInvokeDynamic(node); 252 visitInvokeDynamicField(HInvokeDynamicField node) => visitInvokeDynamic(node);
252 visitInvokeUnary(HInvokeUnary node) => visitInvokeStatic(node); 253 visitInvokeUnary(HInvokeUnary node) => visitInvokeStatic(node);
253 visitConditionalBranch(HConditionalBranch node) => visitControlFlow(node); 254 visitConditionalBranch(HConditionalBranch node) => visitControlFlow(node);
254 visitControlFlow(HControlFlow node) => visitInstruction(node); 255 visitControlFlow(HControlFlow node) => visitInstruction(node);
255 visitFieldAccess(HFieldAccess node) => visitInstruction(node); 256 visitFieldAccess(HFieldAccess node) => visitInstruction(node);
256 visitRelational(HRelational node) => visitInvokeBinary(node); 257 visitRelational(HRelational node) => visitInvokeBinary(node);
257 258
258 visitAdd(HAdd node) => visitBinaryArithmetic(node); 259 visitAdd(HAdd node) => visitBinaryArithmetic(node);
260 visitBailoutTarget(HBailoutTarget node) => visitInstruction(node);
259 visitBitAnd(HBitAnd node) => visitBinaryBitOp(node); 261 visitBitAnd(HBitAnd node) => visitBinaryBitOp(node);
260 visitBitNot(HBitNot node) => visitInvokeUnary(node); 262 visitBitNot(HBitNot node) => visitInvokeUnary(node);
261 visitBitOr(HBitOr node) => visitBinaryBitOp(node); 263 visitBitOr(HBitOr node) => visitBinaryBitOp(node);
262 visitBitXor(HBitXor node) => visitBinaryBitOp(node); 264 visitBitXor(HBitXor node) => visitBinaryBitOp(node);
263 visitBoolify(HBoolify node) => visitInstruction(node); 265 visitBoolify(HBoolify node) => visitInstruction(node);
264 visitBoundsCheck(HBoundsCheck node) => visitCheck(node); 266 visitBoundsCheck(HBoundsCheck node) => visitCheck(node);
265 visitBreak(HBreak node) => visitJump(node); 267 visitBreak(HBreak node) => visitJump(node);
266 visitContinue(HContinue node) => visitJump(node); 268 visitContinue(HContinue node) => visitJump(node);
267 visitCheck(HCheck node) => visitInstruction(node); 269 visitCheck(HCheck node) => visitInstruction(node);
268 visitConstant(HConstant node) => visitInstruction(node); 270 visitConstant(HConstant node) => visitInstruction(node);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 static final int STATUS_NEW = 0; 434 static final int STATUS_NEW = 0;
433 static final int STATUS_OPEN = 1; 435 static final int STATUS_OPEN = 1;
434 static final int STATUS_CLOSED = 2; 436 static final int STATUS_CLOSED = 2;
435 int status = STATUS_NEW; 437 int status = STATUS_NEW;
436 438
437 HInstructionList phis; 439 HInstructionList phis;
438 440
439 HLoopInformation loopInformation = null; 441 HLoopInformation loopInformation = null;
440 HBlockFlow blockFlow = null; 442 HBlockFlow blockFlow = null;
441 HBasicBlock parentLoopHeader = null; 443 HBasicBlock parentLoopHeader = null;
442 List<HTypeGuard> guards; 444 List<HBailoutTarget> bailoutTargets;
443 445
444 final List<HBasicBlock> predecessors; 446 final List<HBasicBlock> predecessors;
445 List<HBasicBlock> successors; 447 List<HBasicBlock> successors;
446 448
447 HBasicBlock dominator = null; 449 HBasicBlock dominator = null;
448 final List<HBasicBlock> dominatedBlocks; 450 final List<HBasicBlock> dominatedBlocks;
449 451
450 HBasicBlock() : this.withId(null); 452 HBasicBlock() : this.withId(null);
451 HBasicBlock.withId(this.id) 453 HBasicBlock.withId(this.id)
452 : phis = new HInstructionList(), 454 : phis = new HInstructionList(),
453 predecessors = <HBasicBlock>[], 455 predecessors = <HBasicBlock>[],
454 successors = const <HBasicBlock>[], 456 successors = const <HBasicBlock>[],
455 dominatedBlocks = <HBasicBlock>[], 457 dominatedBlocks = <HBasicBlock>[],
456 guards = <HTypeGuard>[]; 458 bailoutTargets = <HBailoutTarget>[];
457 459
458 int hashCode() => id; 460 int hashCode() => id;
459 461
460 bool isNew() => status == STATUS_NEW; 462 bool isNew() => status == STATUS_NEW;
461 bool isOpen() => status == STATUS_OPEN; 463 bool isOpen() => status == STATUS_OPEN;
462 bool isClosed() => status == STATUS_CLOSED; 464 bool isClosed() => status == STATUS_CLOSED;
463 465
464 bool isLoopHeader() { 466 bool isLoopHeader() {
465 return loopInformation !== null; 467 return loopInformation !== null;
466 } 468 }
467 469
468 void setBlockFlow(HBlockInformation blockInfo, HBasicBlock continuation) { 470 void setBlockFlow(HBlockInformation blockInfo, HBasicBlock continuation) {
469 blockFlow = new HBlockFlow(blockInfo, continuation); 471 blockFlow = new HBlockFlow(blockInfo, continuation);
470 } 472 }
471 473
472 bool isLabeledBlock() => 474 bool isLabeledBlock() =>
473 blockFlow !== null && 475 blockFlow !== null &&
474 blockFlow.body is HLabeledBlockInformation; 476 blockFlow.body is HLabeledBlockInformation;
475 477
476 HBasicBlock get enclosingLoopHeader() { 478 HBasicBlock get enclosingLoopHeader() {
477 if (isLoopHeader()) return this; 479 if (isLoopHeader()) return this;
478 return parentLoopHeader; 480 return parentLoopHeader;
479 } 481 }
480 482
481 bool hasGuards() => !guards.isEmpty(); 483 bool hasBailoutTargets() => !bailoutTargets.isEmpty();
482 484
483 void open() { 485 void open() {
484 assert(isNew()); 486 assert(isNew());
485 status = STATUS_OPEN; 487 status = STATUS_OPEN;
486 } 488 }
487 489
488 void close(HControlFlow end) { 490 void close(HControlFlow end) {
489 assert(isOpen()); 491 assert(isOpen());
490 addAfter(last, end); 492 addAfter(last, end);
491 status = STATUS_CLOSED; 493 status = STATUS_CLOSED;
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 abstract class HCheck extends HInstruction { 1032 abstract class HCheck extends HInstruction {
1031 HCheck(inputs) : super(inputs); 1033 HCheck(inputs) : super(inputs);
1032 HInstruction get checkedInput() => inputs[0]; 1034 HInstruction get checkedInput() => inputs[0];
1033 bool get isStatement() => true; 1035 bool get isStatement() => true;
1034 void prepareGvn() { 1036 void prepareGvn() {
1035 assert(!hasSideEffects()); 1037 assert(!hasSideEffects());
1036 setUseGvn(); 1038 setUseGvn();
1037 } 1039 }
1038 } 1040 }
1039 1041
1042 class HBailoutTarget extends HInstruction {
1043 final int state;
1044 bool isEnabled = false;
1045 HBailoutTarget(this.state) : super(<HInstruction>[]);
1046 void prepareGvn() {
1047 assert(!hasSideEffects());
1048 setUseGvn();
1049 }
1050
1051 bool isControlFlow() => true;
1052 bool get isStatement() => isEnabled;
1053
1054 accept(HVisitor visitor) => visitor.visitBailoutTarget(this);
1055 int typeCode() => 29;
1056 bool typeEquals(other) => other is HBailoutTarget;
1057 bool dataEquals(HBailoutTarget other) => other.state == state;
1058 }
1059
1040 class HTypeGuard extends HCheck { 1060 class HTypeGuard extends HCheck {
1041 final int state;
1042 final HType guardedType; 1061 final HType guardedType;
1043 bool isEnabled = false; 1062 bool isEnabled = false;
1044 int checkedInputIndex = 0;
1045 1063
1046 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); 1064 HTypeGuard(this.guardedType, HInstruction guarded, HInstruction bailoutTarget)
1065 : super(<HInstruction>[guarded, bailoutTarget]);
1047 1066
1048 HInstruction get guarded() => inputs[checkedInputIndex]; 1067 HInstruction get guarded() => inputs[0];
1049 HInstruction get checkedInput() => guarded; 1068 HInstruction get checkedInput() => guarded;
1069 HBailoutTarget get bailoutTarget() => inputs[1];
1070 int get state() => bailoutTarget.state;
1050 1071
1051 HType computeTypeFromInputTypes() { 1072 HType computeTypeFromInputTypes() {
1052 return isEnabled ? guardedType : guarded.propagatedType; 1073 return isEnabled ? guardedType : guarded.propagatedType;
1053 } 1074 }
1054 1075
1055 HType get guaranteedType() => isEnabled ? guardedType : HType.UNKNOWN; 1076 HType get guaranteedType() => isEnabled ? guardedType : HType.UNKNOWN;
1056 1077
1057 bool isControlFlow() => true; 1078 bool isControlFlow() => true;
1058 1079
1059 bool get isStatement() => isEnabled; 1080 bool get isStatement() => isEnabled;
1060 1081
1061 accept(HVisitor visitor) => visitor.visitTypeGuard(this); 1082 accept(HVisitor visitor) => visitor.visitTypeGuard(this);
1062 int typeCode() => 1; 1083 int typeCode() => 1;
1063 bool typeEquals(other) => other is HTypeGuard; 1084 bool typeEquals(other) => other is HTypeGuard;
1064 bool dataEquals(HTypeGuard other) { 1085 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType;
1065 return guarded == other.guarded && guardedType == other.guardedType;
1066 }
1067 } 1086 }
1068 1087
1069 class HBoundsCheck extends HCheck { 1088 class HBoundsCheck extends HCheck {
1070 static final int ALWAYS_FALSE = 0; 1089 static final int ALWAYS_FALSE = 0;
1071 static final int FULL_CHECK = 1; 1090 static final int FULL_CHECK = 1;
1072 static final int ALWAYS_ABOVE_ZERO = 2; 1091 static final int ALWAYS_ABOVE_ZERO = 2;
1073 static final int ALWAYS_TRUE = 3; 1092 static final int ALWAYS_TRUE = 3;
1074 /** 1093 /**
1075 * Details which tests have been done statically during compilation. 1094 * Details which tests have been done statically during compilation.
1076 * Default is that all checks must be performed dynamically. 1095 * Default is that all checks must be performed dynamically.
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 HBasicBlock get start() => expression.start; 2683 HBasicBlock get start() => expression.start;
2665 HBasicBlock get end() { 2684 HBasicBlock get end() {
2666 // We don't create a switch block if there are no cases. 2685 // We don't create a switch block if there are no cases.
2667 assert(!statements.isEmpty()); 2686 assert(!statements.isEmpty());
2668 return statements.last().end; 2687 return statements.last().end;
2669 } 2688 }
2670 2689
2671 bool accept(HStatementInformationVisitor visitor) => 2690 bool accept(HStatementInformationVisitor visitor) =>
2672 visitor.visitSwitchInfo(this); 2691 visitor.visitSwitchInfo(this);
2673 } 2692 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/codegen.dart ('k') | lib/compiler/implementation/ssa/tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698