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

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

Issue 2975433002: Assert that we don't mix K and J elements (Closed)
Patch Set: Updated cf. comments Created 3 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/codegen.dart' show CodegenRegistry; 9 import '../common/codegen.dart' show CodegenRegistry;
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 ClassEntity cls = _elementMap.getClass(constructedClass); 285 ClassEntity cls = _elementMap.getClass(constructedClass);
286 InterfaceType thisType = _elementMap.elementEnvironment.getThisType(cls); 286 InterfaceType thisType = _elementMap.elementEnvironment.getThisType(cls);
287 _worldBuilder.forEachInstanceField(cls, 287 _worldBuilder.forEachInstanceField(cls,
288 (ClassEntity enclosingClass, FieldEntity member) { 288 (ClassEntity enclosingClass, FieldEntity member) {
289 var value = fieldValues[member]; 289 var value = fieldValues[member];
290 assert(value != null, 'No value for field ${member}'); 290 assert(value != null, 'No value for field ${member}');
291 constructorArguments.add(value); 291 constructorArguments.add(value);
292 }); 292 });
293 293
294 // Create the runtime type information, if needed. 294 // Create the runtime type information, if needed.
295 bool hasRtiInput = backend.rtiNeed.classNeedsRtiField(cls); 295 bool hasRtiInput = closedWorld.rtiNeed.classNeedsRtiField(cls);
296 if (hasRtiInput) { 296 if (hasRtiInput) {
297 // Read the values of the type arguments and create a HTypeInfoExpression 297 // Read the values of the type arguments and create a HTypeInfoExpression
298 // to set on the newly create object. 298 // to set on the newly create object.
299 List<HInstruction> typeArguments = <HInstruction>[]; 299 List<HInstruction> typeArguments = <HInstruction>[];
300 for (ir.DartType typeParameter 300 for (ir.DartType typeParameter
301 in constructedClass.thisType.typeArguments) { 301 in constructedClass.thisType.typeArguments) {
302 HInstruction argument = localsHandler.readLocal(localsHandler 302 HInstruction argument = localsHandler.readLocal(localsHandler
303 .getTypeVariableAsLocal(_elementMap.getDartType(typeParameter))); 303 .getTypeVariableAsLocal(_elementMap.getDartType(typeParameter)));
304 typeArguments.add(argument); 304 typeArguments.add(argument);
305 } 305 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 // If there are locals that escape (i.e. mutated in closures), we pass the 350 // If there are locals that escape (i.e. mutated in closures), we pass the
351 // box to the constructor. 351 // box to the constructor.
352 ClosureScope scopeData = closureDataLookup 352 ClosureScope scopeData = closureDataLookup
353 .getClosureScope(constructorElement.resolvedAst.node); 353 .getClosureScope(constructorElement.resolvedAst.node);
354 if (scopeData.requiresContextBox) { 354 if (scopeData.requiresContextBox) {
355 bodyCallInputs.add(localsHandler.readLocal(scopeData.context)); 355 bodyCallInputs.add(localsHandler.readLocal(scopeData.context));
356 } 356 }
357 357
358 // Pass type arguments. 358 // Pass type arguments.
359 ir.Class currentClass = body.enclosingClass; 359 ir.Class currentClass = body.enclosingClass;
360 if (backend.rtiNeed.classNeedsRti(_elementMap.getClass(currentClass))) { 360 if (closedWorld.rtiNeed
361 .classNeedsRti(_elementMap.getClass(currentClass))) {
361 for (ir.DartType typeParameter in currentClass.thisType.typeArguments) { 362 for (ir.DartType typeParameter in currentClass.thisType.typeArguments) {
362 HInstruction argument = localsHandler.readLocal(localsHandler 363 HInstruction argument = localsHandler.readLocal(localsHandler
363 .getTypeVariableAsLocal(_elementMap.getDartType(typeParameter) 364 .getTypeVariableAsLocal(_elementMap.getDartType(typeParameter)
364 as ResolutionTypeVariableType)); 365 as ResolutionTypeVariableType));
365 bodyCallInputs.add(argument); 366 bodyCallInputs.add(argument);
366 } 367 }
367 } 368 }
368 369
369 _invokeConstructorBody(body, bodyCallInputs); 370 _invokeConstructorBody(body, bodyCallInputs);
370 } 371 }
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 generateUnsupportedError( 2381 generateUnsupportedError(
2381 invocation, 2382 invocation,
2382 '${function.enclosingClass.name}.${function.name} ' 2383 '${function.enclosingClass.name}.${function.name} '
2383 'can only be used as a const constructor'); 2384 'can only be used as a const constructor');
2384 } 2385 }
2385 return; 2386 return;
2386 } 2387 }
2387 2388
2388 // Factory constructors take type parameters; other static methods ignore 2389 // Factory constructors take type parameters; other static methods ignore
2389 // them. 2390 // them.
2390 if (backend.rtiNeed.classNeedsRti(function.enclosingClass)) { 2391 if (closedWorld.rtiNeed.classNeedsRti(function.enclosingClass)) {
2391 _addTypeArguments(arguments, invocation.arguments); 2392 _addTypeArguments(arguments, invocation.arguments);
2392 } 2393 }
2393 } 2394 }
2394 2395
2395 _pushStaticInvocation(function, arguments, typeMask); 2396 _pushStaticInvocation(function, arguments, typeMask);
2396 } 2397 }
2397 2398
2398 void handleInvokeStaticForeign( 2399 void handleInvokeStaticForeign(
2399 ir.StaticInvocation invocation, ir.Procedure target) { 2400 ir.StaticInvocation invocation, ir.Procedure target) {
2400 String name = target.name.name; 2401 String name = target.name.name;
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 ConstantValue constant = _elementMap.getConstantValue(invocation); 3059 ConstantValue constant = _elementMap.getConstantValue(invocation);
3059 stack.add(graph.addConstant(constant, closedWorld)); 3060 stack.add(graph.addConstant(constant, closedWorld));
3060 return; 3061 return;
3061 } 3062 }
3062 3063
3063 // TODO(sra): For JS-interop targets, process arguments differently. 3064 // TODO(sra): For JS-interop targets, process arguments differently.
3064 List<HInstruction> arguments = 3065 List<HInstruction> arguments =
3065 _visitArgumentsForStaticTarget(target.function, invocation.arguments); 3066 _visitArgumentsForStaticTarget(target.function, invocation.arguments);
3066 ConstructorEntity constructor = _elementMap.getConstructor(target); 3067 ConstructorEntity constructor = _elementMap.getConstructor(target);
3067 ClassEntity cls = constructor.enclosingClass; 3068 ClassEntity cls = constructor.enclosingClass;
3068 if (backend.rtiNeed.classNeedsRti(cls)) { 3069 if (closedWorld.rtiNeed.classNeedsRti(cls)) {
3069 _addTypeArguments(arguments, invocation.arguments); 3070 _addTypeArguments(arguments, invocation.arguments);
3070 } 3071 }
3071 TypeMask typeMask = new TypeMask.nonNullExact(cls, closedWorld); 3072 TypeMask typeMask = new TypeMask.nonNullExact(cls, closedWorld);
3072 InterfaceType type = _elementMap.createInterfaceType( 3073 InterfaceType type = _elementMap.createInterfaceType(
3073 target.enclosingClass, invocation.arguments.types); 3074 target.enclosingClass, invocation.arguments.types);
3074 addImplicitInstantiation(type); 3075 addImplicitInstantiation(type);
3075 _pushStaticInvocation(constructor, arguments, typeMask); 3076 _pushStaticInvocation(constructor, arguments, typeMask);
3076 removeImplicitInstantiation(type); 3077 removeImplicitInstantiation(type);
3077 } 3078 }
3078 3079
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
3506 enterBlock.setBlockFlow( 3507 enterBlock.setBlockFlow(
3507 new HTryBlockInformation( 3508 new HTryBlockInformation(
3508 kernelBuilder.wrapStatementGraph(bodyGraph), 3509 kernelBuilder.wrapStatementGraph(bodyGraph),
3509 exception, 3510 exception,
3510 kernelBuilder.wrapStatementGraph(catchGraph), 3511 kernelBuilder.wrapStatementGraph(catchGraph),
3511 kernelBuilder.wrapStatementGraph(finallyGraph)), 3512 kernelBuilder.wrapStatementGraph(finallyGraph)),
3512 exitBlock); 3513 exitBlock);
3513 kernelBuilder.inTryStatement = previouslyInTryStatement; 3514 kernelBuilder.inTryStatement = previouslyInTryStatement;
3514 } 3515 }
3515 } 3516 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution_strategy.dart ('k') | pkg/compiler/lib/src/ssa/graph_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698