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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1148343004: Remove ConstantExpression.value (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Update comments. Created 5 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
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 class SsaFunctionCompiler implements FunctionCompiler { 7 class SsaFunctionCompiler implements FunctionCompiler {
8 SsaCodeGeneratorTask generator; 8 SsaCodeGeneratorTask generator;
9 SsaBuilderTask builder; 9 SsaBuilderTask builder;
10 SsaOptimizerTask optimizer; 10 SsaOptimizerTask optimizer;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } else { 134 } else {
135 compiler.internalError(element, 'Unexpected element kind $kind.'); 135 compiler.internalError(element, 'Unexpected element kind $kind.');
136 } 136 }
137 assert(graph.isValid()); 137 assert(graph.isValid());
138 if (!identical(kind, ElementKind.FIELD)) { 138 if (!identical(kind, ElementKind.FIELD)) {
139 FunctionElement function = element; 139 FunctionElement function = element;
140 FunctionSignature signature = function.functionSignature; 140 FunctionSignature signature = function.functionSignature;
141 signature.forEachOptionalParameter((ParameterElement parameter) { 141 signature.forEachOptionalParameter((ParameterElement parameter) {
142 // This ensures the default value will be computed. 142 // This ensures the default value will be computed.
143 ConstantValue constant = 143 ConstantValue constant =
144 backend.constants.getConstantForVariable(parameter).value; 144 backend.constants.getConstantValueForVariable(parameter);
145 CodegenRegistry registry = work.registry; 145 CodegenRegistry registry = work.registry;
146 registry.registerCompileTimeConstant(constant); 146 registry.registerCompileTimeConstant(constant);
147 }); 147 });
148 } 148 }
149 if (compiler.tracer.isEnabled) { 149 if (compiler.tracer.isEnabled) {
150 String name; 150 String name;
151 if (element.isClassMember) { 151 if (element.isClassMember) {
152 String className = element.enclosingClass.name; 152 String className = element.enclosingClass.name;
153 String memberName = element.name; 153 String memberName = element.name;
154 name = "$className.$memberName"; 154 name = "$className.$memberName";
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 sourceInformationBuilder.forContext(element.implementation); 1498 sourceInformationBuilder.forContext(element.implementation);
1499 sourceElementStack.add(element.declaration); 1499 sourceElementStack.add(element.declaration);
1500 var result = f(); 1500 var result = f();
1501 sourceInformationBuilder = oldSourceInformationBuilder; 1501 sourceInformationBuilder = oldSourceInformationBuilder;
1502 sourceElementStack.removeLast(); 1502 sourceElementStack.removeLast();
1503 return result; 1503 return result;
1504 }); 1504 });
1505 } 1505 }
1506 1506
1507 HInstruction handleConstantForOptionalParameter(Element parameter) { 1507 HInstruction handleConstantForOptionalParameter(Element parameter) {
1508 ConstantExpression constant = 1508 ConstantValue constantValue =
1509 backend.constants.getConstantForVariable(parameter); 1509 backend.constants.getConstantValueForVariable(parameter);
1510 assert(invariant(parameter, constant != null, 1510 assert(invariant(parameter, constantValue != null,
1511 message: 'No constant computed for $parameter')); 1511 message: 'No constant computed for $parameter'));
1512 return graph.addConstant(constant.value, compiler); 1512 return graph.addConstant(constantValue, compiler);
1513 } 1513 }
1514 1514
1515 Element get currentNonClosureClass { 1515 Element get currentNonClosureClass {
1516 ClassElement cls = sourceElement.enclosingClass; 1516 ClassElement cls = sourceElement.enclosingClass;
1517 if (cls != null && cls.isClosure) { 1517 if (cls != null && cls.isClosure) {
1518 var closureClass = cls; 1518 var closureClass = cls;
1519 return closureClass.methodElement.enclosingClass; 1519 return closureClass.methodElement.enclosingClass;
1520 } else { 1520 } else {
1521 return cls; 1521 return cls;
1522 } 1522 }
(...skipping 15 matching lines...) Expand all
1538 final List<DartType> currentInlinedInstantiations = <DartType>[]; 1538 final List<DartType> currentInlinedInstantiations = <DartType>[];
1539 1539
1540 final List<AstInliningState> inliningStack = <AstInliningState>[]; 1540 final List<AstInliningState> inliningStack = <AstInliningState>[];
1541 1541
1542 Local returnLocal; 1542 Local returnLocal;
1543 DartType returnType; 1543 DartType returnType;
1544 1544
1545 bool inTryStatement = false; 1545 bool inTryStatement = false;
1546 1546
1547 ConstantValue getConstantForNode(ast.Node node) { 1547 ConstantValue getConstantForNode(ast.Node node) {
1548 ConstantExpression constant = 1548 ConstantValue constantValue =
1549 backend.constants.getConstantForNode(node, elements); 1549 backend.constants.getConstantValueForNode(node, elements);
1550 assert(invariant(node, constant != null, 1550 assert(invariant(node, constantValue != null,
1551 message: 'No constant computed for $node')); 1551 message: 'No constant computed for $node'));
1552 return constant.value; 1552 return constantValue;
1553 } 1553 }
1554 1554
1555 HInstruction addConstant(ast.Node node) { 1555 HInstruction addConstant(ast.Node node) {
1556 return graph.addConstant(getConstantForNode(node), compiler); 1556 return graph.addConstant(getConstantForNode(node), compiler);
1557 } 1557 }
1558 1558
1559 TypeMask cachedTypeOfThis; 1559 TypeMask cachedTypeOfThis;
1560 1560
1561 TypeMask getTypeOfThis() { 1561 TypeMask getTypeOfThis() {
1562 TypeMask result = cachedTypeOfThis; 1562 TypeMask result = cachedTypeOfThis;
(...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after
3303 // error. 3303 // error.
3304 stack.add(graph.addConstantNull(compiler)); 3304 stack.add(graph.addConstantNull(compiler));
3305 } 3305 }
3306 } 3306 }
3307 3307
3308 /// Read a static or top level [field] of constant value. 3308 /// Read a static or top level [field] of constant value.
3309 void generateStaticConstGet( 3309 void generateStaticConstGet(
3310 ast.Send node, 3310 ast.Send node,
3311 FieldElement field, 3311 FieldElement field,
3312 ConstantExpression constant) { 3312 ConstantExpression constant) {
3313 ConstantValue value = constant.value; 3313 ConstantValue value = backend.constants.getConstantValue(constant);
3314 HConstant instruction; 3314 HConstant instruction;
3315 // Constants that are referred via a deferred prefix should be referred 3315 // Constants that are referred via a deferred prefix should be referred
3316 // by reference. 3316 // by reference.
3317 PrefixElement prefix = compiler.deferredLoadTask 3317 PrefixElement prefix = compiler.deferredLoadTask
3318 .deferredPrefixElement(node, elements); 3318 .deferredPrefixElement(node, elements);
3319 if (prefix != null) { 3319 if (prefix != null) {
3320 instruction = graph.addDeferredConstant(value, prefix, compiler); 3320 instruction = graph.addDeferredConstant(value, prefix, compiler);
3321 } else { 3321 } else {
3322 instruction = graph.addConstant(value, compiler); 3322 instruction = graph.addConstant(value, compiler);
3323 } 3323 }
(...skipping 4528 matching lines...) Expand 10 before | Expand all | Expand 10 after
7852 if (unaliased is TypedefType) throw 'unable to unalias $type'; 7852 if (unaliased is TypedefType) throw 'unable to unalias $type';
7853 unaliased.accept(this, builder); 7853 unaliased.accept(this, builder);
7854 } 7854 }
7855 7855
7856 void visitDynamicType(DynamicType type, SsaBuilder builder) { 7856 void visitDynamicType(DynamicType type, SsaBuilder builder) {
7857 JavaScriptBackend backend = builder.compiler.backend; 7857 JavaScriptBackend backend = builder.compiler.backend;
7858 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 7858 ClassElement cls = backend.findHelper('DynamicRuntimeType');
7859 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 7859 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
7860 } 7860 }
7861 } 7861 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution_common.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698