# HG changeset patch # User Christian Humer # Date 1383127680 -3600 # Node ID 50aca0c0dff409b573d829dd909a0aae70e33bf5 # Parent 02f844c76626ff78564f4db5404839a41047ac80# Parent 321229a79f7aa2c8d7e7e39bdd40287664947829 Merge. diff -r 321229a79f7a -r 50aca0c0dff4 graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathTest.java --- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathTest.java Wed Oct 30 10:05:59 2013 +0100 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathTest.java Wed Oct 30 11:08:00 2013 +0100 @@ -28,6 +28,7 @@ import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.dsl.test.SlowPathTestFactory.SlowPathOnGeneric0Factory; import com.oracle.truffle.api.dsl.test.SlowPathTestFactory.SlowPathOnGeneric1Factory; +import com.oracle.truffle.api.dsl.test.SlowPathTestFactory.SlowPathOnGeneric2Factory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.nodes.*; @@ -69,4 +70,27 @@ } + @Test + public void testSlowPathOnGeneric2() throws NoSuchMethodException, SecurityException { + Node node = SlowPathOnGeneric2Factory.create(null); + Assert.assertNull(node.getClass().getSuperclass().getDeclaredMethod("executeGeneric0", VirtualFrame.class, Object.class).getAnnotation(SlowPath.class)); + } + + @NodeChild + abstract static class SlowPathOnGeneric2 extends ValueNode { + + @Specialization(order = 0) + @SuppressWarnings("unused") + Object doObject0(int value0) { + throw new AssertionError(); + } + + @Specialization(order = 1) + @SuppressWarnings("unused") + Object doObject1(VirtualFrame frame, String value0) { + throw new AssertionError(); + } + + } + } diff -r 321229a79f7a -r 50aca0c0dff4 graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java Wed Oct 30 10:05:59 2013 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java Wed Oct 30 11:08:00 2013 +0100 @@ -1280,9 +1280,6 @@ CodeTree init = createAdoptChild(builder, varType, CodeTreeBuilder.singleString(copyAccess)); builder.startStatement().string("this.").string(varName).string(" = ").tree(init).end(); } - if (getModel().getNode().isPolymorphic()) { - builder.statement("this.next0 = adoptChild(copy.next0)"); - } return method; } @@ -1377,10 +1374,10 @@ TypeMirror genericReturnType = node.getGenericSpecialization().getReturnType().getType(); CodeExecutableElement method = new CodeExecutableElement(modifiers(PROTECTED), genericReturnType, EXECUTE_GENERIC_NAME); - if (!node.getGenericSpecialization().hasFrame(getContext())) { + if (!node.needsFrame(getContext())) { method.getAnnotationMirrors().add(new CodeAnnotationMirror(getContext().getTruffleTypes().getSlowPath())); } - addInternalValueParameters(method, node.getGenericSpecialization(), node.needsFrame(), false); + addInternalValueParameters(method, node.getGenericSpecialization(), node.needsFrame(getContext()), false); final CodeTreeBuilder builder = method.createBuilder(); builder.tree(createExecuteTree(builder, node.getGenericSpecialization(), group, false, new CodeBlock() { @@ -1803,7 +1800,7 @@ } if (current.isGeneric()) { builder.startReturn().tree(replace).string(".").startCall(EXECUTE_GENERIC_NAME); - addInternalValueParameterNames(builder, source, current, null, current.getNode().needsFrame(), true, null); + addInternalValueParameterNames(builder, source, current, null, current.getNode().needsFrame(getContext()), true, null); builder.end().end(); } else if (current.getMethod() == null) { if (replaceCall != null) { @@ -2702,11 +2699,12 @@ CodeTreeBuilder builder = superConstructor.createBuilder(); builder.tree(body); + if (node.isPolymorphic()) { + if (specialization.isSpecialized() || specialization.isPolymorphic()) { + builder.statement("this.next0 = adoptChild(copy.next0)"); + } + } if (superConstructor != null) { - if (getModel().isGeneric() && node.isPolymorphic()) { - builder.statement("this.next0 = null"); - } - for (ActualParameter param : getImplicitTypeParamters(getModel())) { clazz.add(new CodeVariableElement(modifiers(PRIVATE, FINAL), getContext().getType(Class.class), implicitTypeName(param))); superConstructor.getParameters().add(new CodeVariableElement(getContext().getType(Class.class), implicitTypeName(param))); @@ -2968,7 +2966,7 @@ emitEncounteredSynthetic(builder, specialization); } else if (specialization.isGeneric()) { returnBuilder.startCall("super", EXECUTE_GENERIC_NAME); - addInternalValueParameterNames(returnBuilder, specialization, specialization, null, node.needsFrame(), true, null); + addInternalValueParameterNames(returnBuilder, specialization, specialization, null, node.needsFrame(getContext()), true, null); returnBuilder.end(); } else { returnBuilder.tree(createTemplateMethodCall(returnBuilder, null, specialization, specialization, null)); diff -r 321229a79f7a -r 50aca0c0dff4 graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java Wed Oct 30 10:05:59 2013 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java Wed Oct 30 11:08:00 2013 +0100 @@ -78,12 +78,12 @@ this.assumptions = splitSource.assumptions; } - public boolean needsFrame() { + public boolean needsFrame(ProcessorContext context) { for (SpecializationData specialization : specializations) { if (!specialization.isReachable()) { continue; } - if (specialization.findParameter("frameValue") != null) { + if (specialization.hasFrame(context)) { return true; } } diff -r 321229a79f7a -r 50aca0c0dff4 graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java Wed Oct 30 10:05:59 2013 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java Wed Oct 30 11:08:00 2013 +0100 @@ -663,7 +663,7 @@ // calculate reachability SpecializationData prev = null; - int specializationCount = 0; + int polymorphicCombinations = 0; boolean reachable = true; for (SpecializationData specialization : specializations) { if (specialization.isUninitialized()) { @@ -680,14 +680,23 @@ reachable = false; } if (!specialization.isGeneric()) { - specializationCount++; + int combinations = 1; + for (ActualParameter parameter : specialization.getParameters()) { + if (!parameter.getSpecification().isSignature()) { + continue; + } + TypeData type = parameter.getTypeSystemType(); + combinations *= node.getTypeSystem().lookupSourceTypes(type).size(); + } + polymorphicCombinations += combinations; } + prev = specialization; } // initialize polymorphic depth if (node.getPolymorphicDepth() < 0) { - node.setPolymorphicDepth(specializationCount - 1); + node.setPolymorphicDepth(polymorphicCombinations - 1); } // reduce polymorphicness if generic is not reachable