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

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

Issue 614993002: Rename Constant to ConstantValue and ConstExp to ConstantExpression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 2 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 part of ssa; 5 part of ssa;
6 6
7 abstract class HVisitor<R> { 7 abstract class HVisitor<R> {
8 R visitAdd(HAdd node); 8 R visitAdd(HAdd node);
9 R visitBitAnd(HBitAnd node); 9 R visitBitAnd(HBitAnd node);
10 R visitBitNot(HBitNot node); 10 R visitBitNot(HBitNot node);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 HBasicBlock exit; 131 HBasicBlock exit;
132 HThis thisInstruction; 132 HThis thisInstruction;
133 /// Receiver parameter, set for methods using interceptor calling convention. 133 /// Receiver parameter, set for methods using interceptor calling convention.
134 HParameterValue explicitReceiverParameter; 134 HParameterValue explicitReceiverParameter;
135 bool isRecursiveMethod = false; 135 bool isRecursiveMethod = false;
136 bool calledInLoop = false; 136 bool calledInLoop = false;
137 final List<HBasicBlock> blocks; 137 final List<HBasicBlock> blocks;
138 138
139 // We canonicalize all constants used within a graph so we do not 139 // We canonicalize all constants used within a graph so we do not
140 // have to worry about them for global value numbering. 140 // have to worry about them for global value numbering.
141 Map<Constant, HConstant> constants; 141 Map<ConstantValue, HConstant> constants;
142 142
143 HGraph() 143 HGraph()
144 : blocks = new List<HBasicBlock>(), 144 : blocks = new List<HBasicBlock>(),
145 constants = new Map<Constant, HConstant>() { 145 constants = new Map<ConstantValue, HConstant>() {
146 entry = addNewBlock(); 146 entry = addNewBlock();
147 // The exit block will be added later, so it has an id that is 147 // The exit block will be added later, so it has an id that is
148 // after all others in the system. 148 // after all others in the system.
149 exit = new HBasicBlock(); 149 exit = new HBasicBlock();
150 } 150 }
151 151
152 void addBlock(HBasicBlock block) { 152 void addBlock(HBasicBlock block) {
153 int id = blocks.length; 153 int id = blocks.length;
154 block.id = id; 154 block.id = id;
155 blocks.add(block); 155 blocks.add(block);
156 assert(identical(blocks[id], block)); 156 assert(identical(blocks[id], block));
157 } 157 }
158 158
159 HBasicBlock addNewBlock() { 159 HBasicBlock addNewBlock() {
160 HBasicBlock result = new HBasicBlock(); 160 HBasicBlock result = new HBasicBlock();
161 addBlock(result); 161 addBlock(result);
162 return result; 162 return result;
163 } 163 }
164 164
165 HBasicBlock addNewLoopHeaderBlock(JumpTarget target, 165 HBasicBlock addNewLoopHeaderBlock(JumpTarget target,
166 List<LabelDefinition> labels) { 166 List<LabelDefinition> labels) {
167 HBasicBlock result = addNewBlock(); 167 HBasicBlock result = addNewBlock();
168 result.loopInformation = 168 result.loopInformation =
169 new HLoopInformation(result, target, labels); 169 new HLoopInformation(result, target, labels);
170 return result; 170 return result;
171 } 171 }
172 172
173 HConstant addConstant(Constant constant, Compiler compiler) { 173 HConstant addConstant(ConstantValue constant, Compiler compiler) {
174 HConstant result = constants[constant]; 174 HConstant result = constants[constant];
175 if (result == null) { 175 if (result == null) {
176 TypeMask type = constant.computeMask(compiler); 176 TypeMask type = constant.computeMask(compiler);
177 result = new HConstant.internal(constant, type); 177 result = new HConstant.internal(constant, type);
178 entry.addAtExit(result); 178 entry.addAtExit(result);
179 constants[constant] = result; 179 constants[constant] = result;
180 } else if (result.block == null) { 180 } else if (result.block == null) {
181 // The constant was not used anymore. 181 // The constant was not used anymore.
182 entry.addAtExit(result); 182 entry.addAtExit(result);
183 } 183 }
184 return result; 184 return result;
185 } 185 }
186 186
187 HConstant addDeferredConstant(Constant constant, PrefixElement prefix, 187 HConstant addDeferredConstant(ConstantValue constant, PrefixElement prefix,
188 Compiler compiler) { 188 Compiler compiler) {
189 Constant wrapper = new DeferredConstant(constant, prefix); 189 ConstantValue wrapper = new DeferredConstantValue(constant, prefix);
190 compiler.deferredLoadTask.registerConstantDeferredUse(wrapper, prefix); 190 compiler.deferredLoadTask.registerConstantDeferredUse(wrapper, prefix);
191 return addConstant(wrapper, compiler); 191 return addConstant(wrapper, compiler);
192 } 192 }
193 193
194 HConstant addConstantInt(int i, Compiler compiler) { 194 HConstant addConstantInt(int i, Compiler compiler) {
195 return addConstant(compiler.backend.constantSystem.createInt(i), compiler); 195 return addConstant(compiler.backend.constantSystem.createInt(i), compiler);
196 } 196 }
197 197
198 HConstant addConstantDouble(double d, Compiler compiler) { 198 HConstant addConstantDouble(double d, Compiler compiler) {
199 return addConstant( 199 return addConstant(
(...skipping 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 static const int DO_WHILE_LOOP = 1; 2020 static const int DO_WHILE_LOOP = 1;
2021 2021
2022 final int kind; 2022 final int kind;
2023 HLoopBranch(HInstruction condition, [this.kind = CONDITION_FIRST_LOOP]) 2023 HLoopBranch(HInstruction condition, [this.kind = CONDITION_FIRST_LOOP])
2024 : super(<HInstruction>[condition]); 2024 : super(<HInstruction>[condition]);
2025 toString() => 'loop-branch'; 2025 toString() => 'loop-branch';
2026 accept(HVisitor visitor) => visitor.visitLoopBranch(this); 2026 accept(HVisitor visitor) => visitor.visitLoopBranch(this);
2027 } 2027 }
2028 2028
2029 class HConstant extends HInstruction { 2029 class HConstant extends HInstruction {
2030 final Constant constant; 2030 final ConstantValue constant;
2031 HConstant.internal(this.constant, TypeMask constantType) 2031 HConstant.internal(this.constant, TypeMask constantType)
2032 : super(<HInstruction>[], constantType); 2032 : super(<HInstruction>[], constantType);
2033 2033
2034 toString() => 'literal: $constant'; 2034 toString() => 'literal: $constant';
2035 accept(HVisitor visitor) => visitor.visitConstant(this); 2035 accept(HVisitor visitor) => visitor.visitConstant(this);
2036 2036
2037 bool isConstant() => true; 2037 bool isConstant() => true;
2038 bool isConstantBoolean() => constant.isBool; 2038 bool isConstantBoolean() => constant.isBool;
2039 bool isConstantNull() => constant.isNull; 2039 bool isConstantNull() => constant.isNull;
2040 bool isConstantNumber() => constant.isNum; 2040 bool isConstantNumber() => constant.isNum;
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 class HDynamicType extends HRuntimeType { 3078 class HDynamicType extends HRuntimeType {
3079 HDynamicType(DynamicType dartType, TypeMask instructionType) 3079 HDynamicType(DynamicType dartType, TypeMask instructionType)
3080 : super(const <HInstruction>[], dartType, instructionType); 3080 : super(const <HInstruction>[], dartType, instructionType);
3081 3081
3082 accept(HVisitor visitor) => visitor.visitDynamicType(this); 3082 accept(HVisitor visitor) => visitor.visitDynamicType(this);
3083 3083
3084 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; 3084 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE;
3085 3085
3086 bool typeEquals(HInstruction other) => other is HDynamicType; 3086 bool typeEquals(HInstruction other) => other is HDynamicType;
3087 } 3087 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698