Chromium Code Reviews| Index: pkg/compiler/lib/src/ssa/codegen.dart |
| diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart |
| index e9614853658473233443fdc8f25397576fa15e8c..e8b26a819635494d9a4028a1022500ad83184278 100644 |
| --- a/pkg/compiler/lib/src/ssa/codegen.dart |
| +++ b/pkg/compiler/lib/src/ssa/codegen.dart |
| @@ -2855,6 +2855,79 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| } |
| } |
| + void visitTypeInfoReadRaw(HTypeInfoReadRaw node) { |
| + use(node.inputs[0]); |
| + js.Expression receiver = pop(); |
| + push(js.js(r'#.$builtinTypeInfo', receiver)); |
|
Siggi Cherem (dart-lang)
2016/08/19 18:21:46
I thought $builtinTypeInfo was replaced by $ti, is
sra1
2016/08/19 18:47:43
Yes, the renaming is part of the other CL
|
| + } |
| + |
| + void visitTypeInfoReadVariable(HTypeInfoReadVariable node) { |
| + TypeVariableElement element = node.variable.element; |
| + ClassElement context = element.enclosingClass; |
| + |
| + int index = element.index; |
| + use(node.inputs[0]); |
| + js.Expression receiver = pop(); |
| + |
| + if (needsSubstitutionForTypeVariableAccess(context)) { |
| + js.Expression typeName = |
| + js.quoteName(backend.namer.runtimeTypeName(context)); |
| + Element helperElement = helpers.getRuntimeTypeArgument; |
| + registry.registerStaticUse( |
| + new StaticUse.staticInvoke(helperElement, CallStructure.THREE_ARGS)); |
|
Siggi Cherem (dart-lang)
2016/08/19 18:21:46
I'm surprised we never registered this before (eve
sra1
2016/08/19 18:47:43
No bug. It was registered via being lowered to a H
|
| + js.Expression helper = |
| + backend.emitter.staticFunctionAccess(helperElement); |
| + push(js.js( |
| + r'#(#, #, #)', [helper, receiver, typeName, js.js.number(index)])); |
| + } else { |
| + Element helperElement = helpers.getTypeArgumentByIndex; |
| + registry.registerStaticUse( |
| + new StaticUse.staticInvoke(helperElement, CallStructure.TWO_ARGS)); |
| + js.Expression helper = |
| + backend.emitter.staticFunctionAccess(helperElement); |
| + push(js.js(r'#(#, #)', [helper, receiver, js.js.number(index)])); |
| + } |
| + } |
| + |
| + void visitTypeInfoExpression(HTypeInfoExpression node) { |
| + List<js.Expression> arguments = <js.Expression>[]; |
| + for (HInstruction input in node.inputs) { |
| + use(input); |
| + arguments.add(pop()); |
| + } |
| + |
| + switch (node.kind) { |
| + case TypeInfoExpressionKind.COMPLETE: |
| + int index = 0; |
| + js.Expression result = backend.rtiEncoder.getTypeRepresentation( |
| + node.dartType, |
| + (TypeVariableType variable) => arguments[index++]); |
| + if (index != node.inputs.length) { |
| + print('$node $index ${node.inputs}'); |
|
Siggi Cherem (dart-lang)
2016/08/19 18:21:46
delete debug code?
sra1
2016/08/19 18:47:43
Done. That was from debugging https://codereview.c
|
| + } |
| + assert(index == node.inputs.length); |
| + push(result); |
| + return; |
| + |
| + case TypeInfoExpressionKind.INSTANCE: |
| + // We expect only flat types for the INSTANCE representation. |
| + assert( |
| + node.dartType == (node.dartType.element as ClassElement).thisType); |
| + registry.registerInstantiatedClass(coreClasses.listClass); |
| + push(new js.ArrayInitializer(arguments) |
| + .withSourceInformation(node.sourceInformation)); |
| + } |
| + } |
| + |
| + bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { |
| + ClassWorld classWorld = compiler.world; |
| + if (classWorld.isUsedAsMixin(cls)) return true; |
| + |
| + return compiler.world.anyStrictSubclassOf(cls, (ClassElement subclass) { |
| + return !backend.rti.isTrivialSubstitution(subclass, cls); |
| + }); |
| + } |
| + |
| void visitReadTypeVariable(HReadTypeVariable node) { |
| TypeVariableElement element = node.dartType.element; |
| Element helperElement = helpers.convertRtiToRuntimeType; |