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

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

Issue 1525603002: Associate compile-time errors with elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@_temporary_fletch_patches
Patch Set: Created 5 years 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 final SsaCodeGeneratorTask generator; 8 final SsaCodeGeneratorTask generator;
9 final SsaBuilderTask builder; 9 final SsaBuilderTask builder;
10 final SsaOptimizerTask optimizer; 10 final SsaOptimizerTask optimizer;
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 backend.registerStaticUse(element, compiler.enqueuer.codegen); 1341 backend.registerStaticUse(element, compiler.enqueuer.codegen);
1342 1342
1343 if (backend.isJsInterop(element) && !element.isFactoryConstructor) { 1343 if (backend.isJsInterop(element) && !element.isFactoryConstructor) {
1344 // We only inline factory JavaScript interop constructors. 1344 // We only inline factory JavaScript interop constructors.
1345 return false; 1345 return false;
1346 } 1346 }
1347 1347
1348 // Ensure that [element] is an implementation element. 1348 // Ensure that [element] is an implementation element.
1349 element = element.implementation; 1349 element = element.implementation;
1350 1350
1351 if (compiler.elementHasCompileTimeError(element)) return false; 1351 if (compiler.generateCodeWithCompileTimeErrors &&
1352 compiler.elementHasCompileTimeError(element)) return false;
Johnni Winther 2015/12/14 11:31:20 Add brace around `return false;` now that the stat
sigurdm 2015/12/14 12:07:43 Done.
1352 1353
1353 FunctionElement function = element; 1354 FunctionElement function = element;
1354 bool insideLoop = loopNesting > 0 || graph.calledInLoop; 1355 bool insideLoop = loopNesting > 0 || graph.calledInLoop;
1355 1356
1356 // Bail out early if the inlining decision is in the cache and we can't 1357 // Bail out early if the inlining decision is in the cache and we can't
1357 // inline (no need to check the hard constraints). 1358 // inline (no need to check the hard constraints).
1358 bool cachedCanBeInlined = 1359 bool cachedCanBeInlined =
1359 backend.inlineCache.canInline(function, insideLoop: insideLoop); 1360 backend.inlineCache.canInline(function, insideLoop: insideLoop);
1360 if (cachedCanBeInlined == false) return false; 1361 if (cachedCanBeInlined == false) return false;
1361 1362
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 * Run through the fields of [cls] and add their potential 2123 * Run through the fields of [cls] and add their potential
2123 * initializers. 2124 * initializers.
2124 * 2125 *
2125 * Invariant: [classElement] must be an implementation element. 2126 * Invariant: [classElement] must be an implementation element.
2126 */ 2127 */
2127 void buildFieldInitializers(ClassElement classElement, 2128 void buildFieldInitializers(ClassElement classElement,
2128 Map<Element, HInstruction> fieldValues) { 2129 Map<Element, HInstruction> fieldValues) {
2129 assert(invariant(classElement, classElement.isImplementation)); 2130 assert(invariant(classElement, classElement.isImplementation));
2130 classElement.forEachInstanceField( 2131 classElement.forEachInstanceField(
2131 (ClassElement enclosingClass, VariableElement member) { 2132 (ClassElement enclosingClass, VariableElement member) {
2132 if (compiler.elementHasCompileTimeError(member)) return; 2133 if (compiler.generateCodeWithCompileTimeErrors &&
2134 compiler.elementHasCompileTimeError(member)) return;
Johnni Winther 2015/12/14 11:31:20 Ditto.
sigurdm 2015/12/14 12:07:43 Done.
2133 reporter.withCurrentElement(member, () { 2135 reporter.withCurrentElement(member, () {
2134 TreeElements definitions = member.treeElements; 2136 TreeElements definitions = member.treeElements;
2135 ast.Node node = member.node; 2137 ast.Node node = member.node;
2136 ast.Expression initializer = member.initializer; 2138 ast.Expression initializer = member.initializer;
2137 if (initializer == null) { 2139 if (initializer == null) {
2138 // Unassigned fields of native classes are not initialized to 2140 // Unassigned fields of native classes are not initialized to
2139 // prevent overwriting pre-initialized native properties. 2141 // prevent overwriting pre-initialized native properties.
2140 if (!backend.isNativeOrExtendsNative(classElement)) { 2142 if (!backend.isNativeOrExtendsNative(classElement)) {
2141 fieldValues[member] = graph.addConstantNull(compiler); 2143 fieldValues[member] = graph.addConstantNull(compiler);
2142 } 2144 }
(...skipping 2979 matching lines...) Expand 10 before | Expand all | Expand 10 after
5122 node); 5124 node);
5123 } 5125 }
5124 target = target.immediateRedirectionTarget; 5126 target = target.immediateRedirectionTarget;
5125 } 5127 }
5126 } 5128 }
5127 InterfaceType type = elements.getType(node); 5129 InterfaceType type = elements.getType(node);
5128 InterfaceType expectedType = 5130 InterfaceType expectedType =
5129 constructorDeclaration.computeEffectiveTargetType(type); 5131 constructorDeclaration.computeEffectiveTargetType(type);
5130 expectedType = localsHandler.substInContext(expectedType); 5132 expectedType = localsHandler.substInContext(expectedType);
5131 5133
5132 if (compiler.elementHasCompileTimeError(constructor)) { 5134 if (compiler.generateCodeWithCompileTimeErrors &&
5135 compiler.elementHasCompileTimeError(constructor)) {
5133 // TODO(ahe): Do something like [generateWrongArgumentCountError]. 5136 // TODO(ahe): Do something like [generateWrongArgumentCountError].
5134 stack.add(graph.addConstantNull(compiler)); 5137 stack.add(graph.addConstantNull(compiler));
5135 return; 5138 return;
5136 } 5139 }
5137 if (checkTypeVariableBounds(node, type)) return; 5140 if (checkTypeVariableBounds(node, type)) return;
5138 5141
5139 var inputs = <HInstruction>[]; 5142 var inputs = <HInstruction>[];
5140 if (constructor.isGenerativeConstructor && 5143 if (constructor.isGenerativeConstructor &&
5141 backend.isNativeOrExtendsNative(constructor.enclosingClass) && 5144 backend.isNativeOrExtendsNative(constructor.enclosingClass) &&
5142 !backend.isJsInterop(constructor)) { 5145 !backend.isJsInterop(constructor)) {
(...skipping 4018 matching lines...) Expand 10 before | Expand all | Expand 10 after
9161 if (unaliased is TypedefType) throw 'unable to unalias $type'; 9164 if (unaliased is TypedefType) throw 'unable to unalias $type';
9162 unaliased.accept(this, builder); 9165 unaliased.accept(this, builder);
9163 } 9166 }
9164 9167
9165 void visitDynamicType(DynamicType type, SsaBuilder builder) { 9168 void visitDynamicType(DynamicType type, SsaBuilder builder) {
9166 JavaScriptBackend backend = builder.compiler.backend; 9169 JavaScriptBackend backend = builder.compiler.backend;
9167 ClassElement cls = backend.helpers.DynamicRuntimeType; 9170 ClassElement cls = backend.helpers.DynamicRuntimeType;
9168 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 9171 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
9169 } 9172 }
9170 } 9173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698