| OLD | NEW |
| 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 import '../closure.dart'; | 5 import '../closure.dart'; |
| 6 import '../common.dart'; | 6 import '../common.dart'; |
| 7 import '../common/backend_api.dart' show BackendClasses; | 7 import '../common/backend_api.dart' show BackendClasses; |
| 8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
| 9 import '../constants/constant_system.dart'; | 9 import '../constants/constant_system.dart'; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return result; | 200 return result; |
| 201 } | 201 } |
| 202 | 202 |
| 203 HBasicBlock addNewLoopHeaderBlock( | 203 HBasicBlock addNewLoopHeaderBlock( |
| 204 JumpTarget target, List<LabelDefinition> labels) { | 204 JumpTarget target, List<LabelDefinition> labels) { |
| 205 HBasicBlock result = addNewBlock(); | 205 HBasicBlock result = addNewBlock(); |
| 206 result.loopInformation = new HLoopInformation(result, target, labels); | 206 result.loopInformation = new HLoopInformation(result, target, labels); |
| 207 return result; | 207 return result; |
| 208 } | 208 } |
| 209 | 209 |
| 210 HConstant addConstant(ConstantValue constant, Compiler compiler, | 210 HConstant addConstant(ConstantValue constant, ClosedWorld closedWorld, |
| 211 {SourceInformation sourceInformation}) { | 211 {SourceInformation sourceInformation}) { |
| 212 HConstant result = constants[constant]; | 212 HConstant result = constants[constant]; |
| 213 // TODO(johnniwinther): Support source information per constant reference. | 213 // TODO(johnniwinther): Support source information per constant reference. |
| 214 if (result == null) { | 214 if (result == null) { |
| 215 if (!constant.isConstant) { | 215 if (!constant.isConstant) { |
| 216 // We use `null` as the value for invalid constant expressions. | 216 // We use `null` as the value for invalid constant expressions. |
| 217 constant = const NullConstantValue(); | 217 constant = const NullConstantValue(); |
| 218 } | 218 } |
| 219 TypeMask type = | 219 TypeMask type = computeTypeMask(closedWorld, constant); |
| 220 computeTypeMask(compiler.closedWorld, compiler.backend, constant); | |
| 221 result = new HConstant.internal(constant, type) | 220 result = new HConstant.internal(constant, type) |
| 222 ..sourceInformation = sourceInformation; | 221 ..sourceInformation = sourceInformation; |
| 223 entry.addAtExit(result); | 222 entry.addAtExit(result); |
| 224 constants[constant] = result; | 223 constants[constant] = result; |
| 225 } else if (result.block == null) { | 224 } else if (result.block == null) { |
| 226 // The constant was not used anymore. | 225 // The constant was not used anymore. |
| 227 entry.addAtExit(result); | 226 entry.addAtExit(result); |
| 228 } | 227 } |
| 229 return result; | 228 return result; |
| 230 } | 229 } |
| 231 | 230 |
| 232 HConstant addDeferredConstant(ConstantValue constant, Entity prefix, | 231 HConstant addDeferredConstant( |
| 233 SourceInformation sourceInformation, Compiler compiler) { | 232 ConstantValue constant, |
| 233 Entity prefix, |
| 234 SourceInformation sourceInformation, |
| 235 Compiler compiler, |
| 236 ClosedWorld closedWorld) { |
| 234 // TODO(sigurdm,johnniwinther): These deferred constants should be created | 237 // TODO(sigurdm,johnniwinther): These deferred constants should be created |
| 235 // by the constant evaluator. | 238 // by the constant evaluator. |
| 236 ConstantValue wrapper = new DeferredConstantValue(constant, prefix); | 239 ConstantValue wrapper = new DeferredConstantValue(constant, prefix); |
| 237 compiler.deferredLoadTask.registerConstantDeferredUse(wrapper, prefix); | 240 compiler.deferredLoadTask.registerConstantDeferredUse(wrapper, prefix); |
| 238 return addConstant(wrapper, compiler, sourceInformation: sourceInformation); | 241 return addConstant(wrapper, closedWorld, |
| 242 sourceInformation: sourceInformation); |
| 239 } | 243 } |
| 240 | 244 |
| 241 HConstant addConstantInt(int i, Compiler compiler) { | 245 HConstant addConstantInt(int i, ClosedWorld closedWorld) { |
| 242 return addConstant(compiler.backend.constantSystem.createInt(i), compiler); | 246 return addConstant(closedWorld.constantSystem.createInt(i), closedWorld); |
| 243 } | 247 } |
| 244 | 248 |
| 245 HConstant addConstantDouble(double d, Compiler compiler) { | 249 HConstant addConstantDouble(double d, ClosedWorld closedWorld) { |
| 246 return addConstant( | 250 return addConstant(closedWorld.constantSystem.createDouble(d), closedWorld); |
| 247 compiler.backend.constantSystem.createDouble(d), compiler); | |
| 248 } | 251 } |
| 249 | 252 |
| 250 HConstant addConstantString(ast.DartString str, Compiler compiler) { | 253 HConstant addConstantString(ast.DartString str, ClosedWorld closedWorld) { |
| 251 return addConstant( | 254 return addConstant( |
| 252 compiler.backend.constantSystem.createString(str), compiler); | 255 closedWorld.constantSystem.createString(str), closedWorld); |
| 253 } | 256 } |
| 254 | 257 |
| 255 HConstant addConstantStringFromName(js.Name name, Compiler compiler) { | 258 HConstant addConstantStringFromName(js.Name name, ClosedWorld closedWorld) { |
| 256 return addConstant( | 259 return addConstant( |
| 257 new SyntheticConstantValue( | 260 new SyntheticConstantValue( |
| 258 SyntheticConstantKind.NAME, js.quoteName(name)), | 261 SyntheticConstantKind.NAME, js.quoteName(name)), |
| 259 compiler); | 262 closedWorld); |
| 260 } | 263 } |
| 261 | 264 |
| 262 HConstant addConstantBool(bool value, Compiler compiler) { | 265 HConstant addConstantBool(bool value, ClosedWorld closedWorld) { |
| 263 return addConstant( | 266 return addConstant( |
| 264 compiler.backend.constantSystem.createBool(value), compiler); | 267 closedWorld.constantSystem.createBool(value), closedWorld); |
| 265 } | 268 } |
| 266 | 269 |
| 267 HConstant addConstantNull(Compiler compiler) { | 270 HConstant addConstantNull(ClosedWorld closedWorld) { |
| 268 return addConstant(compiler.backend.constantSystem.createNull(), compiler); | 271 return addConstant(closedWorld.constantSystem.createNull(), closedWorld); |
| 269 } | 272 } |
| 270 | 273 |
| 271 void finalize() { | 274 void finalize() { |
| 272 addBlock(exit); | 275 addBlock(exit); |
| 273 exit.open(); | 276 exit.open(); |
| 274 exit.close(new HExit()); | 277 exit.close(new HExit()); |
| 275 assignDominators(); | 278 assignDominators(); |
| 276 } | 279 } |
| 277 | 280 |
| 278 void assignDominators() { | 281 void assignDominators() { |
| (...skipping 3169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3448 class HDynamicType extends HRuntimeType { | 3451 class HDynamicType extends HRuntimeType { |
| 3449 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3452 HDynamicType(DynamicType dartType, TypeMask instructionType) |
| 3450 : super(const <HInstruction>[], dartType, instructionType); | 3453 : super(const <HInstruction>[], dartType, instructionType); |
| 3451 | 3454 |
| 3452 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3455 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
| 3453 | 3456 |
| 3454 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3457 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
| 3455 | 3458 |
| 3456 bool typeEquals(HInstruction other) => other is HDynamicType; | 3459 bool typeEquals(HInstruction other) => other is HDynamicType; |
| 3457 } | 3460 } |
| OLD | NEW |