Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| index df84dd6eb988818874c81c3ecc24831df0cbe913..8c401edb012cfd86c603caca948481b35e5c0285 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart |
| @@ -31,52 +31,54 @@ class SsaBuilderTask extends CompilerTask { |
| HGraph build(CodegenWorkItem work) { |
| return measure(() { |
| Element element = work.element.implementation; |
| - HInstruction.idCounter = 0; |
| - ConstantSystem constantSystem = compiler.backend.constantSystem; |
| - SsaBuilder builder = new SsaBuilder(constantSystem, this, work); |
| - HGraph graph; |
| - ElementKind kind = element.kind; |
| - if (kind == ElementKind.GENERATIVE_CONSTRUCTOR) { |
| - graph = compileConstructor(builder, work); |
| - } else if (kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY || |
| - kind == ElementKind.FUNCTION || |
| - kind == ElementKind.GETTER || |
| - kind == ElementKind.SETTER) { |
| - graph = builder.buildMethod(element); |
| - } else if (kind == ElementKind.FIELD) { |
| - assert(!element.isInstanceMember()); |
| - graph = builder.buildLazyInitializer(element); |
| - } else { |
| - compiler.internalErrorOnElement(element, |
| - 'unexpected element kind $kind'); |
| - } |
| - assert(graph.isValid()); |
| - if (!identical(kind, ElementKind.FIELD)) { |
| - FunctionElement function = element; |
| - FunctionSignature signature = function.computeSignature(compiler); |
| - signature.forEachOptionalParameter((Element parameter) { |
| - // This ensures the default value will be computed. |
| - builder.compileVariable(parameter); |
| - }); |
| - } |
| + return compiler.withCurrentElement(element, () { |
|
ngeoffray
2013/08/24 11:16:26
Since the build method is the entry point of the b
Johnni Winther
2013/08/26 07:34:00
The current element was the declaration and not th
|
| + HInstruction.idCounter = 0; |
| + ConstantSystem constantSystem = compiler.backend.constantSystem; |
| + SsaBuilder builder = new SsaBuilder(constantSystem, this, work); |
| + HGraph graph; |
| + ElementKind kind = element.kind; |
| + if (kind == ElementKind.GENERATIVE_CONSTRUCTOR) { |
| + graph = compileConstructor(builder, work); |
| + } else if (kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY || |
| + kind == ElementKind.FUNCTION || |
| + kind == ElementKind.GETTER || |
| + kind == ElementKind.SETTER) { |
| + graph = builder.buildMethod(element); |
| + } else if (kind == ElementKind.FIELD) { |
| + assert(!element.isInstanceMember()); |
| + graph = builder.buildLazyInitializer(element); |
| + } else { |
| + compiler.internalErrorOnElement(element, |
| + 'unexpected element kind $kind'); |
| + } |
| + assert(graph.isValid()); |
| + if (!identical(kind, ElementKind.FIELD)) { |
| + FunctionElement function = element; |
| + FunctionSignature signature = function.computeSignature(compiler); |
| + signature.forEachOptionalParameter((Element parameter) { |
| + // This ensures the default value will be computed. |
| + builder.compileVariable(parameter); |
| + }); |
| + } |
| - if (compiler.tracer.enabled) { |
| - String name; |
| - if (element.isMember()) { |
| - String className = element.getEnclosingClass().name.slowToString(); |
| - String memberName = element.name.slowToString(); |
| - name = "$className.$memberName"; |
| - if (element.isGenerativeConstructorBody()) { |
| - name = "$name (body)"; |
| + if (compiler.tracer.enabled) { |
| + String name; |
| + if (element.isMember()) { |
| + String className = element.getEnclosingClass().name.slowToString(); |
| + String memberName = element.name.slowToString(); |
| + name = "$className.$memberName"; |
| + if (element.isGenerativeConstructorBody()) { |
| + name = "$name (body)"; |
| + } |
| + } else { |
| + name = "${element.name.slowToString()}"; |
| } |
| - } else { |
| - name = "${element.name.slowToString()}"; |
| + compiler.tracer.traceCompilation( |
| + name, work.compilationContext, compiler); |
| + compiler.tracer.traceGraph('builder', graph); |
| } |
| - compiler.tracer.traceCompilation( |
| - name, work.compilationContext, compiler); |
| - compiler.tracer.traceGraph('builder', graph); |
| - } |
| - return graph; |
| + return graph; |
| + }); |
| }); |
| } |
| @@ -2798,7 +2800,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| type = type.unalias(compiler); |
| if (type.kind == TypeKind.FUNCTION) { |
| if (backend.rti.isSimpleFunctionType(type)) { |
| - return new HIs(type, <HInstruction>[expression], HIs.RAW_CHECK); |
| + return new HIs.raw(type, expression ,invokeInterceptor(expression)); |
|
ngeoffray
2013/08/24 11:16:26
move space around last comma.
Johnni Winther
2013/08/26 07:34:00
Done.
|
| } |
| Element checkFunctionSubtype = backend.getCheckFunctionSubtype(); |
| @@ -2835,16 +2837,14 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| typeArguments]; |
| pushInvokeStatic(node, checkFunctionSubtype, inputs, HType.BOOLEAN); |
| HInstruction call = pop(); |
| - return new HIs(type, <HInstruction>[expression, call], |
| - HIs.COMPOUND_CHECK); |
| + return new HIs.compound(type, expression, call); |
| } else if (type.kind == TypeKind.TYPE_VARIABLE) { |
| HInstruction runtimeType = addTypeVariableReference(type); |
| Element helper = backend.getCheckSubtypeOfRuntimeType(); |
| List<HInstruction> inputs = <HInstruction>[expression, runtimeType]; |
| pushInvokeStatic(null, helper, inputs, HType.BOOLEAN); |
| HInstruction call = pop(); |
| - return new HIs(type, <HInstruction>[expression, call], |
| - HIs.VARIABLE_CHECK); |
| + return new HIs.variable(type, expression, call); |
| } else if (RuntimeTypes.hasTypeArguments(type)) { |
| ClassElement element = type.element; |
| Element helper = backend.getCheckSubtype(); |
| @@ -2863,10 +2863,21 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| asFieldName]; |
| pushInvokeStatic(node, helper, inputs, HType.BOOLEAN); |
| HInstruction call = pop(); |
| - return |
| - new HIs(type, <HInstruction>[expression, call], HIs.COMPOUND_CHECK); |
| + return new HIs.compound(type, expression, call); |
| } else { |
| - return new HIs(type, <HInstruction>[expression], HIs.RAW_CHECK); |
| + Element element = type.element; |
| + if (element == compiler.stringClass || |
|
ngeoffray
2013/08/24 11:16:26
Maybe add a "backend.hasDirectCheckFor(element)" i
Johnni Winther
2013/08/26 07:34:00
Done.
|
| + element == compiler.boolClass || |
| + element == compiler.numClass || |
| + element == compiler.intClass || |
| + element == compiler.doubleClass || |
| + element == backend.jsArrayClass || |
| + element == backend.jsMutableArrayClass || |
| + element == backend.jsExtendableArrayClass || |
| + element == backend.jsFixedArrayClass) { |
| + return new HIs.direct(type, expression); |
| + } |
| + return new HIs.raw(type, expression, invokeInterceptor(expression)); |
| } |
| } |
| @@ -4902,10 +4913,8 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| if (type == null) { |
| compiler.internalError('On with no type', node: catchBlock.type); |
| } |
| - // TODO(karlkose): support type arguments here. |
| - HInstruction condition = new HIs(type, |
| - <HInstruction>[unwrappedException], |
| - HIs.RAW_CHECK); |
| + HInstruction condition = |
| + buildIsNode(catchBlock.type, type, unwrappedException); |
| push(condition); |
| } else { |
| VariableDefinitions declaration = catchBlock.formals.nodes.head; |
| @@ -4922,9 +4931,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { |
| if (type == null) { |
| compiler.cancel('Catch with unresolved type', node: catchBlock); |
| } |
| - // TODO(karlkose): support type arguments here. |
| - condition = new HIs(type, <HInstruction>[unwrappedException], |
| - HIs.RAW_CHECK); |
| + condition = buildIsNode(declaration.type, type, unwrappedException); |
| push(condition); |
| } |
| } |