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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 23003031: Extract interceptor calls from raw is-checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix optimization of interceptors for HIs. Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
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..7c7ff1752060dbe4924fa351b428590e23ca7366 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, () {
+ 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));
}
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,12 @@ 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);
+ if (backend.hasDirectCheckFor(type)) {
+ return new HIs.direct(type, expression);
+ }
+ return new HIs.raw(type, expression, invokeInterceptor(expression));
}
}
@@ -4902,10 +4904,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 +4922,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);
}
}

Powered by Google App Engine
This is Rietveld 408576698