| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 import 'graph_builder.dart'; | 35 import 'graph_builder.dart'; |
| 36 import 'jump_handler.dart'; | 36 import 'jump_handler.dart'; |
| 37 import 'kernel_ast_adapter.dart'; | 37 import 'kernel_ast_adapter.dart'; |
| 38 import 'kernel_string_builder.dart'; | 38 import 'kernel_string_builder.dart'; |
| 39 import 'locals_handler.dart'; | 39 import 'locals_handler.dart'; |
| 40 import 'loop_handler.dart'; | 40 import 'loop_handler.dart'; |
| 41 import 'nodes.dart'; | 41 import 'nodes.dart'; |
| 42 import 'ssa_branch_builder.dart'; | 42 import 'ssa_branch_builder.dart'; |
| 43 import 'switch_continue_analysis.dart'; | 43 import 'switch_continue_analysis.dart'; |
| 44 import 'type_builder.dart'; | 44 import 'type_builder.dart'; |
| 45 import 'types.dart' show TypeMaskFactory; | |
| 46 | 45 |
| 47 class KernelSsaBuilder extends ir.Visitor with GraphBuilder { | 46 class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
| 48 final ir.Node target; | 47 final ir.Node target; |
| 49 final bool _targetIsConstructorBody; | 48 final bool _targetIsConstructorBody; |
| 50 final MemberEntity targetElement; | 49 final MemberEntity targetElement; |
| 51 | 50 |
| 52 /// The root node of [targetElement]. This is used as the key into the | 51 /// The root node of [targetElement]. This is used as the key into the |
| 53 /// [startFunction] of the locals handler. | 52 /// [startFunction] of the locals handler. |
| 54 // TODO(johnniwinther,efortuna): Avoid the need for AST nodes in the locals | 53 // TODO(johnniwinther,efortuna): Avoid the need for AST nodes in the locals |
| 55 // handler. | 54 // handler. |
| 56 final Node functionNode; | 55 final Node functionNode; |
| 57 final ClosedWorld closedWorld; | 56 final ClosedWorld closedWorld; |
| 58 final CodegenRegistry registry; | 57 final CodegenRegistry registry; |
| 59 final ClosureClassMaps closureToClassMapper; | 58 final ClosureClassMaps closureToClassMapper; |
| 60 | 59 |
| 61 /// Helper accessor for all kernel function-like targets (Procedure, | 60 /// Helper accessor for all kernel function-like targets (Procedure, |
| 62 /// FunctionExpression, FunctionDeclaration) of the inner FunctionNode itself. | 61 /// FunctionExpression, FunctionDeclaration) of the inner FunctionNode itself. |
| 63 /// If the current target is not a function-like target, _targetFunction will | 62 /// If the current target is not a function-like target, _targetFunction will |
| 64 /// be null. | 63 /// be null. |
| 65 ir.FunctionNode _targetFunction; | 64 ir.FunctionNode _targetFunction; |
| 66 | 65 |
| 67 /// A stack of [ResolutionDartType]s that have been seen during inlining of | 66 /// A stack of [ResolutionDartType]s that have been seen during inlining of |
| 68 /// factory constructors. These types are preserved in [HInvokeStatic]s and | 67 /// factory constructors. These types are preserved in [HInvokeStatic]s and |
| 69 /// [HCreate]s inside the inline code and registered during code generation | 68 /// [HCreate]s inside the inline code and registered during code generation |
| 70 /// for these nodes. | 69 /// for these nodes. |
| 71 // TODO(karlklose): consider removing this and keeping the (substituted) types | 70 // TODO(karlklose): consider removing this and keeping the (substituted) types |
| 72 // of the type variables in an environment (like the [LocalsHandler]). | 71 // of the type variables in an environment (like the [LocalsHandler]). |
| 73 final List<ResolutionDartType> currentImplicitInstantiations = | 72 final List<InterfaceType> currentImplicitInstantiations = <InterfaceType>[]; |
| 74 <ResolutionDartType>[]; | |
| 75 | 73 |
| 76 HInstruction rethrowableException; | 74 HInstruction rethrowableException; |
| 77 | 75 |
| 78 final Compiler compiler; | 76 final Compiler compiler; |
| 79 | 77 |
| 80 @override | 78 @override |
| 81 JavaScriptBackend get backend => compiler.backend; | 79 JavaScriptBackend get backend => compiler.backend; |
| 82 | 80 |
| 83 @override | 81 @override |
| 84 TreeElements get elements => astAdapter.elements; | 82 TreeElements get elements => astAdapter.elements; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 HInstruction result = new HBoolify(value, commonMasks.boolType); | 188 HInstruction result = new HBoolify(value, commonMasks.boolType); |
| 191 add(result); | 189 add(result); |
| 192 return result; | 190 return result; |
| 193 } | 191 } |
| 194 | 192 |
| 195 /// Extend current method parameters with parameters for the class type | 193 /// Extend current method parameters with parameters for the class type |
| 196 /// parameters. If the class has type parameters but does not need them, bind | 194 /// parameters. If the class has type parameters but does not need them, bind |
| 197 /// to `dynamic` (represented as `null`) so the bindings are available for | 195 /// to `dynamic` (represented as `null`) so the bindings are available for |
| 198 /// building types up the inheritance chain of generative constructors. | 196 /// building types up the inheritance chain of generative constructors. |
| 199 void _addClassTypeVariablesIfNeeded(ir.Member constructor) { | 197 void _addClassTypeVariablesIfNeeded(ir.Member constructor) { |
| 200 var enclosing = constructor.enclosingClass; | 198 ir.Class enclosing = constructor.enclosingClass; |
| 199 ClassEntity cls = _elementMap.getClass(enclosing); |
| 201 bool needParameters; | 200 bool needParameters; |
| 202 enclosing.typeParameters.forEach((ir.TypeParameter typeParameter) { | 201 enclosing.typeParameters.forEach((ir.TypeParameter typeParameter) { |
| 203 var typeParamElement = astAdapter.getElement(typeParameter); | 202 TypeVariableType typeVariableType = |
| 203 _elementMap.getDartType(new ir.TypeParameterType(typeParameter)); |
| 204 HInstruction param; | 204 HInstruction param; |
| 205 needParameters ??= rtiNeed.classNeedsRti(_elementMap.getClass(enclosing)); | 205 needParameters ??= rtiNeed.classNeedsRti(cls); |
| 206 if (needParameters) { | 206 if (needParameters) { |
| 207 param = addParameter(typeParamElement, commonMasks.nonNullType); | 207 param = addParameter(typeVariableType.element, commonMasks.nonNullType); |
| 208 } else { | 208 } else { |
| 209 // Unused, so bind to `dynamic`. | 209 // Unused, so bind to `dynamic`. |
| 210 param = graph.addConstantNull(closedWorld); | 210 param = graph.addConstantNull(closedWorld); |
| 211 } | 211 } |
| 212 // This is a little bit wacky (and n^2) until we make the localsHandler | |
| 213 // take Kernel DartTypes instead of just the AST DartTypes. | |
| 214 ClassElement cls = _elementMap.getClass(enclosing); | |
| 215 ResolutionTypeVariableType typeVariableType = cls.typeVariables | |
| 216 .firstWhere( | |
| 217 (ResolutionTypeVariableType i) => i.name == typeParameter.name); | |
| 218 localsHandler.directLocals[ | 212 localsHandler.directLocals[ |
| 219 localsHandler.getTypeVariableAsLocal(typeVariableType)] = param; | 213 localsHandler.getTypeVariableAsLocal(typeVariableType)] = param; |
| 220 }); | 214 }); |
| 221 } | 215 } |
| 222 | 216 |
| 217 /// Comparator for the canonical order or named arguments. |
| 218 int namedOrdering(ir.VariableDeclaration a, ir.VariableDeclaration b) { |
| 219 return a.name.compareTo(b.name); |
| 220 } |
| 221 |
| 223 /// Builds a generative constructor. | 222 /// Builds a generative constructor. |
| 224 /// | 223 /// |
| 225 /// Generative constructors are built in stages, in effect inlining the | 224 /// Generative constructors are built in stages, in effect inlining the |
| 226 /// initializers and constructor bodies up the inheritance chain. | 225 /// initializers and constructor bodies up the inheritance chain. |
| 227 /// | 226 /// |
| 228 /// 1. Extend method parameters with parameters the class's type parameters. | 227 /// 1. Extend method parameters with parameters the class's type parameters. |
| 229 /// | 228 /// |
| 230 /// 2. Add type checks for value parameters (might need result of (1)). | 229 /// 2. Add type checks for value parameters (might need result of (1)). |
| 231 /// | 230 /// |
| 232 /// 3. Walk inheritance chain to build bindings for type parameters of | 231 /// 3. Walk inheritance chain to build bindings for type parameters of |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 List<HInstruction> bodyCallInputs = <HInstruction>[]; | 317 List<HInstruction> bodyCallInputs = <HInstruction>[]; |
| 319 bodyCallInputs.add(newObject); | 318 bodyCallInputs.add(newObject); |
| 320 | 319 |
| 321 // Pass uncaptured arguments first, captured arguments in a box, then type | 320 // Pass uncaptured arguments first, captured arguments in a box, then type |
| 322 // arguments. | 321 // arguments. |
| 323 | 322 |
| 324 ConstructorElement constructorElement = _elementMap.getConstructor(body); | 323 ConstructorElement constructorElement = _elementMap.getConstructor(body); |
| 325 ClosureClassMap parameterClosureData = | 324 ClosureClassMap parameterClosureData = |
| 326 closureToClassMapper.getMemberMap(constructorElement); | 325 closureToClassMapper.getMemberMap(constructorElement); |
| 327 | 326 |
| 328 var functionSignature = astAdapter.getFunctionSignature(body.function); | 327 void handleParameter(ir.VariableDeclaration node) { |
| 329 // Provide the parameters to the generative constructor body. | 328 Local parameter = _localsMap.getLocal(node); |
| 330 functionSignature.orderedForEachParameter((ParameterElement parameter) { | |
| 331 // If [parameter] is boxed, it will be a field in the box passed as the | 329 // If [parameter] is boxed, it will be a field in the box passed as the |
| 332 // last parameter. So no need to directly pass it. | 330 // last parameter. So no need to directly pass it. |
| 333 if (!localsHandler.isBoxed(parameter)) { | 331 if (!localsHandler.isBoxed(parameter)) { |
| 334 bodyCallInputs.add(localsHandler.readLocal(parameter)); | 332 bodyCallInputs.add(localsHandler.readLocal(parameter)); |
| 335 } | 333 } |
| 336 }); | 334 } |
| 335 |
| 336 // Provide the parameters to the generative constructor body. |
| 337 body.function.positionalParameters.forEach(handleParameter); |
| 338 body.function.namedParameters.toList() |
| 339 ..sort(namedOrdering) |
| 340 ..forEach(handleParameter); |
| 337 | 341 |
| 338 // If there are locals that escape (i.e. mutated in closures), we pass the | 342 // If there are locals that escape (i.e. mutated in closures), we pass the |
| 339 // box to the constructor. | 343 // box to the constructor. |
| 340 ClosureScope scopeData = parameterClosureData | 344 ClosureScope scopeData = parameterClosureData |
| 341 .capturingScopes[constructorElement.resolvedAst.node]; | 345 .capturingScopes[constructorElement.resolvedAst.node]; |
| 342 if (scopeData != null) { | 346 if (scopeData != null) { |
| 343 bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement)); | 347 bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement)); |
| 344 } | 348 } |
| 345 | 349 |
| 346 // Pass type arguments. | 350 // Pass type arguments. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 assert( | 458 assert( |
| 455 _elementMap.getClass(constructor.enclosingClass) == | 459 _elementMap.getClass(constructor.enclosingClass) == |
| 456 _elementMap.commonElements.objectClass, | 460 _elementMap.commonElements.objectClass, |
| 457 'All constructors should have super- or redirecting- initializers,' | 461 'All constructors should have super- or redirecting- initializers,' |
| 458 ' except Object()'); | 462 ' except Object()'); |
| 459 } | 463 } |
| 460 } | 464 } |
| 461 | 465 |
| 462 List<HInstruction> _normalizeAndBuildArguments( | 466 List<HInstruction> _normalizeAndBuildArguments( |
| 463 ir.FunctionNode function, ir.Arguments arguments) { | 467 ir.FunctionNode function, ir.Arguments arguments) { |
| 464 var signature = astAdapter.getFunctionSignature(function); | |
| 465 var builtArguments = <HInstruction>[]; | 468 var builtArguments = <HInstruction>[]; |
| 466 var positionalIndex = 0; | 469 var positionalIndex = 0; |
| 467 signature.forEachRequiredParameter((_) { | 470 function.positionalParameters.forEach((ir.VariableDeclaration node) { |
| 468 arguments.positional[positionalIndex++].accept(this); | 471 if (positionalIndex < arguments.positional.length) { |
| 469 builtArguments.add(pop()); | 472 arguments.positional[positionalIndex++].accept(this); |
| 473 builtArguments.add(pop()); |
| 474 } else { |
| 475 ConstantValue constantValue = |
| 476 _elementMap.getConstantValue(node.initializer, implicitNull: true); |
| 477 assert( |
| 478 constantValue != null, |
| 479 failedAt(_elementMap.getMethod(function.parent), |
| 480 'No constant computed for $node')); |
| 481 builtArguments.add(graph.addConstant(constantValue, closedWorld)); |
| 482 } |
| 470 }); | 483 }); |
| 471 if (!signature.optionalParametersAreNamed) { | 484 function.namedParameters.toList() |
| 472 signature.forEachOptionalParameter((ParameterElement element) { | 485 ..sort(namedOrdering) |
| 473 if (positionalIndex < arguments.positional.length) { | 486 ..forEach((ir.VariableDeclaration node) { |
| 474 arguments.positional[positionalIndex++].accept(this); | 487 var correspondingNamed = arguments.named |
| 475 builtArguments.add(pop()); | 488 .firstWhere((named) => named.name == node.name, orElse: () => null); |
| 476 } else { | |
| 477 var constantValue = constants.getConstantValue(element.constant); | |
| 478 assert(constantValue != null, | |
| 479 failedAt(element, 'No constant computed for $element')); | |
| 480 builtArguments.add(graph.addConstant(constantValue, closedWorld)); | |
| 481 } | |
| 482 }); | |
| 483 } else { | |
| 484 signature.orderedOptionalParameters.forEach((ParameterElement element) { | |
| 485 var correspondingNamed = arguments.named.firstWhere( | |
| 486 (named) => named.name == element.name, | |
| 487 orElse: () => null); | |
| 488 if (correspondingNamed != null) { | 489 if (correspondingNamed != null) { |
| 489 correspondingNamed.value.accept(this); | 490 correspondingNamed.value.accept(this); |
| 490 builtArguments.add(pop()); | 491 builtArguments.add(pop()); |
| 491 } else { | 492 } else { |
| 492 var constantValue = constants.getConstantValue(element.constant); | 493 ConstantValue constantValue = _elementMap |
| 493 assert(constantValue != null, | 494 .getConstantValue(node.initializer, implicitNull: true); |
| 494 failedAt(element, 'No constant computed for $element')); | 495 assert( |
| 496 constantValue != null, |
| 497 failedAt(_elementMap.getMethod(function.parent), |
| 498 'No constant computed for $node')); |
| 495 builtArguments.add(graph.addConstant(constantValue, closedWorld)); | 499 builtArguments.add(graph.addConstant(constantValue, closedWorld)); |
| 496 } | 500 } |
| 497 }); | 501 }); |
| 498 } | |
| 499 | 502 |
| 500 return builtArguments; | 503 return builtArguments; |
| 501 } | 504 } |
| 502 | 505 |
| 503 /// Creates localsHandler bindings for type parameters of a Supertype. | 506 /// Creates localsHandler bindings for type parameters of a Supertype. |
| 504 void _bindSupertypeTypeParameters(ir.Supertype supertype) { | 507 void _bindSupertypeTypeParameters(ir.Supertype supertype) { |
| 505 ir.Class cls = supertype.classNode; | 508 ir.Class cls = supertype.classNode; |
| 506 var parameters = cls.typeParameters; | 509 var parameters = cls.typeParameters; |
| 507 var arguments = supertype.typeArguments; | 510 var arguments = supertype.typeArguments; |
| 508 assert(arguments.length == parameters.length); | 511 assert(arguments.length == parameters.length); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 initializer, target, arguments, constructorChain, fieldValues, caller); | 572 initializer, target, arguments, constructorChain, fieldValues, caller); |
| 570 } | 573 } |
| 571 | 574 |
| 572 void _inlineSuperOrRedirectCommon( | 575 void _inlineSuperOrRedirectCommon( |
| 573 ir.Initializer initializer, | 576 ir.Initializer initializer, |
| 574 ir.Constructor constructor, | 577 ir.Constructor constructor, |
| 575 List<HInstruction> arguments, | 578 List<HInstruction> arguments, |
| 576 List<ir.Constructor> constructorChain, | 579 List<ir.Constructor> constructorChain, |
| 577 Map<FieldEntity, HInstruction> fieldValues, | 580 Map<FieldEntity, HInstruction> fieldValues, |
| 578 ir.Constructor caller) { | 581 ir.Constructor caller) { |
| 579 var signature = astAdapter.getFunctionSignature(constructor.function); | |
| 580 var index = 0; | 582 var index = 0; |
| 581 signature.orderedForEachParameter((ParameterElement parameter) { | 583 void handleParameter(ir.VariableDeclaration node) { |
| 584 Local parameter = _localsMap.getLocal(node); |
| 582 HInstruction argument = arguments[index++]; | 585 HInstruction argument = arguments[index++]; |
| 583 // Because we are inlining the initializer, we must update | 586 // Because we are inlining the initializer, we must update |
| 584 // what was given as parameter. This will be used in case | 587 // what was given as parameter. This will be used in case |
| 585 // there is a parameter check expression in the initializer. | 588 // there is a parameter check expression in the initializer. |
| 586 parameters[parameter] = argument; | 589 parameters[parameter] = argument; |
| 587 localsHandler.updateLocal(parameter, argument); | 590 localsHandler.updateLocal(parameter, argument); |
| 588 }); | 591 } |
| 592 |
| 593 constructor.function.positionalParameters.forEach(handleParameter); |
| 594 constructor.function.namedParameters.toList() |
| 595 ..sort(namedOrdering) |
| 596 ..forEach(handleParameter); |
| 589 | 597 |
| 590 // Set the locals handler state as if we were inlining the constructor. | 598 // Set the locals handler state as if we were inlining the constructor. |
| 591 ConstructorElement astElement = _elementMap.getConstructor(constructor); | 599 ConstructorElement astElement = _elementMap.getConstructor(constructor); |
| 592 ResolvedAst resolvedAst = astElement.resolvedAst; | 600 ResolvedAst resolvedAst = astElement.resolvedAst; |
| 593 ClosureClassMap oldClosureData = localsHandler.closureData; | 601 ClosureClassMap oldClosureData = localsHandler.closureData; |
| 594 ClosureClassMap newClosureData = | 602 ClosureClassMap newClosureData = |
| 595 closureToClassMapper.getMemberMap(astElement); | 603 closureToClassMapper.getMemberMap(astElement); |
| 596 localsHandler.closureData = newClosureData; | 604 localsHandler.closureData = newClosureData; |
| 597 if (resolvedAst.kind == ResolvedAstKind.PARSED) { | 605 if (resolvedAst.kind == ResolvedAstKind.PARSED) { |
| 598 localsHandler.enterScope(resolvedAst.node, | 606 localsHandler.enterScope(resolvedAst.node, |
| (...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 | 1943 |
| 1936 // If runtime type information is needed and the map literal has no type | 1944 // If runtime type information is needed and the map literal has no type |
| 1937 // parameters, 'constructor' is a static function that forwards the call to | 1945 // parameters, 'constructor' is a static function that forwards the call to |
| 1938 // the factory constructor without type parameters. | 1946 // the factory constructor without type parameters. |
| 1939 assert(constructor.isFunction || | 1947 assert(constructor.isFunction || |
| 1940 (constructor is ConstructorEntity && constructor.isFactoryConstructor)); | 1948 (constructor is ConstructorEntity && constructor.isFactoryConstructor)); |
| 1941 | 1949 |
| 1942 // The instruction type will always be a subtype of the mapLiteralClass, but | 1950 // The instruction type will always be a subtype of the mapLiteralClass, but |
| 1943 // type inference might discover a more specific type, or find nothing (in | 1951 // type inference might discover a more specific type, or find nothing (in |
| 1944 // dart2js unit tests). | 1952 // dart2js unit tests). |
| 1953 |
| 1945 TypeMask mapType = new TypeMask.nonNullSubtype( | 1954 TypeMask mapType = new TypeMask.nonNullSubtype( |
| 1946 _commonElements.mapLiteralClass, closedWorld); | 1955 _commonElements.mapLiteralClass, closedWorld); |
| 1947 TypeMask returnTypeMask = TypeMaskFactory.inferredReturnTypeForElement( | 1956 TypeMask returnTypeMask = _typeInferenceMap.getReturnTypeOf(constructor); |
| 1948 constructor, globalInferenceResults); | |
| 1949 TypeMask instructionType = | 1957 TypeMask instructionType = |
| 1950 mapType.intersection(returnTypeMask, closedWorld); | 1958 mapType.intersection(returnTypeMask, closedWorld); |
| 1951 | 1959 |
| 1952 addImplicitInstantiation(type); | 1960 addImplicitInstantiation(type); |
| 1953 _pushStaticInvocation(constructor, inputs, instructionType); | 1961 _pushStaticInvocation(constructor, inputs, instructionType); |
| 1954 removeImplicitInstantiation(type); | 1962 removeImplicitInstantiation(type); |
| 1955 } | 1963 } |
| 1956 | 1964 |
| 1957 @override | 1965 @override |
| 1958 void visitMapEntry(ir.MapEntry mapEntry) { | 1966 void visitMapEntry(ir.MapEntry mapEntry) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 | 2237 |
| 2230 void _addTypeArguments(List<HInstruction> values, ir.Arguments arguments) { | 2238 void _addTypeArguments(List<HInstruction> values, ir.Arguments arguments) { |
| 2231 // need to translate type to | 2239 // need to translate type to |
| 2232 for (ir.DartType type in arguments.types) { | 2240 for (ir.DartType type in arguments.types) { |
| 2233 values.add(typeBuilder.analyzeTypeArgument( | 2241 values.add(typeBuilder.analyzeTypeArgument( |
| 2234 _elementMap.getDartType(type), sourceElement)); | 2242 _elementMap.getDartType(type), sourceElement)); |
| 2235 } | 2243 } |
| 2236 } | 2244 } |
| 2237 | 2245 |
| 2238 HInstruction _defaultValueForParameter(ir.VariableDeclaration parameter) { | 2246 HInstruction _defaultValueForParameter(ir.VariableDeclaration parameter) { |
| 2239 ir.Expression initializer = parameter.initializer; | 2247 ConstantValue constant = |
| 2240 if (initializer == null) return graph.addConstantNull(closedWorld); | 2248 _elementMap.getConstantValue(parameter.initializer, implicitNull: true); |
| 2241 // TODO(sra): Evaluate constant in ir.Node domain. | 2249 assert(constant != null, failedAt(CURRENT_ELEMENT_SPANNABLE)); |
| 2242 ConstantValue constant = _elementMap.getConstantValue(initializer); | |
| 2243 if (constant == null) return graph.addConstantNull(closedWorld); | |
| 2244 return graph.addConstant(constant, closedWorld); | 2250 return graph.addConstant(constant, closedWorld); |
| 2245 } | 2251 } |
| 2246 | 2252 |
| 2247 @override | 2253 @override |
| 2248 void visitStaticInvocation(ir.StaticInvocation invocation) { | 2254 void visitStaticInvocation(ir.StaticInvocation invocation) { |
| 2249 ir.Procedure target = invocation.target; | 2255 ir.Procedure target = invocation.target; |
| 2250 if (_elementMap.isForeignLibrary(target.enclosingLibrary)) { | 2256 if (_elementMap.isForeignLibrary(target.enclosingLibrary)) { |
| 2251 handleInvokeStaticForeign(invocation, target); | 2257 handleInvokeStaticForeign(invocation, target); |
| 2252 return; | 2258 return; |
| 2253 } | 2259 } |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2731 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); | 2737 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); |
| 2732 push(new HStringConcat(inputs[0], inputs[1], commonMasks.stringType)); | 2738 push(new HStringConcat(inputs[0], inputs[1], commonMasks.stringType)); |
| 2733 } | 2739 } |
| 2734 | 2740 |
| 2735 void _pushStaticInvocation( | 2741 void _pushStaticInvocation( |
| 2736 MemberEntity target, List<HInstruction> arguments, TypeMask typeMask) { | 2742 MemberEntity target, List<HInstruction> arguments, TypeMask typeMask) { |
| 2737 HInvokeStatic instruction = new HInvokeStatic(target, arguments, typeMask, | 2743 HInvokeStatic instruction = new HInvokeStatic(target, arguments, typeMask, |
| 2738 targetCanThrow: !closedWorld.getCannotThrow(target)); | 2744 targetCanThrow: !closedWorld.getCannotThrow(target)); |
| 2739 if (currentImplicitInstantiations.isNotEmpty) { | 2745 if (currentImplicitInstantiations.isNotEmpty) { |
| 2740 instruction.instantiatedTypes = | 2746 instruction.instantiatedTypes = |
| 2741 new List<ResolutionInterfaceType>.from(currentImplicitInstantiations); | 2747 new List<InterfaceType>.from(currentImplicitInstantiations); |
| 2742 } | 2748 } |
| 2743 instruction.sideEffects = closedWorld.getSideEffectsOfElement(target); | 2749 instruction.sideEffects = closedWorld.getSideEffectsOfElement(target); |
| 2744 | 2750 |
| 2745 push(instruction); | 2751 push(instruction); |
| 2746 } | 2752 } |
| 2747 | 2753 |
| 2748 void _pushDynamicInvocation( | 2754 void _pushDynamicInvocation( |
| 2749 ir.Node node, TypeMask mask, List<HInstruction> arguments, | 2755 ir.Node node, TypeMask mask, List<HInstruction> arguments, |
| 2750 {Selector selector}) { | 2756 {Selector selector}) { |
| 2751 HInstruction receiver = arguments.first; | 2757 HInstruction receiver = arguments.first; |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3419 enterBlock.setBlockFlow( | 3425 enterBlock.setBlockFlow( |
| 3420 new HTryBlockInformation( | 3426 new HTryBlockInformation( |
| 3421 kernelBuilder.wrapStatementGraph(bodyGraph), | 3427 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3422 exception, | 3428 exception, |
| 3423 kernelBuilder.wrapStatementGraph(catchGraph), | 3429 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3424 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3430 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3425 exitBlock); | 3431 exitBlock); |
| 3426 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3432 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3427 } | 3433 } |
| 3428 } | 3434 } |
| OLD | NEW |