Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.codegen.test/src/com/oracle/truffle/api/codegen/test/GuardsTest.java @ 9345:0a8bf24d660a
Implemented improvements to the generated source code.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 26 Apr 2013 22:43:23 +0200 |
parents | 8e3a1635cc9e |
children | 86d981cd8e22 |
comparison
equal
deleted
inserted
replaced
9306:2e12f1719a42 | 9345:0a8bf24d660a |
---|---|
43 TestRootNode<InvocationGuard> root = createRoot(InvocationGuardFactory.getInstance()); | 43 TestRootNode<InvocationGuard> root = createRoot(InvocationGuardFactory.getInstance()); |
44 | 44 |
45 assertEquals(Integer.MAX_VALUE, executeWith(root, Integer.MAX_VALUE - 1, 1)); | 45 assertEquals(Integer.MAX_VALUE, executeWith(root, Integer.MAX_VALUE - 1, 1)); |
46 assertEquals(1, InvocationGuard.specializedInvocations); | 46 assertEquals(1, InvocationGuard.specializedInvocations); |
47 assertEquals(0, InvocationGuard.genericInvocations); | 47 assertEquals(0, InvocationGuard.genericInvocations); |
48 assertEquals(1, InvocationGuard.guardInvocations); | |
48 | 49 |
49 assertEquals(42, executeWith(root, Integer.MAX_VALUE, 1)); | 50 assertEquals(42, executeWith(root, Integer.MAX_VALUE, 1)); |
50 assertEquals(1, InvocationGuard.specializedInvocations); | 51 assertEquals(1, InvocationGuard.specializedInvocations); |
51 assertEquals(1, InvocationGuard.genericInvocations); | 52 assertEquals(1, InvocationGuard.genericInvocations); |
53 assertEquals(2, InvocationGuard.guardInvocations); | |
52 } | 54 } |
53 | 55 |
54 @NodeChildren({@NodeChild("value0"), @NodeChild("value1")}) | 56 @NodeChildren({@NodeChild("value0"), @NodeChild("value1")}) |
55 public abstract static class InvocationGuard extends ValueNode { | 57 public abstract static class InvocationGuard extends ValueNode { |
56 | 58 |
59 static int guardInvocations = 0; | |
57 static int specializedInvocations = 0; | 60 static int specializedInvocations = 0; |
58 static int genericInvocations = 0; | 61 static int genericInvocations = 0; |
59 | 62 |
60 boolean guard(int value0, int value1) { | 63 boolean guard(int value0, int value1) { |
64 guardInvocations++; | |
61 return value0 != Integer.MAX_VALUE; | 65 return value0 != Integer.MAX_VALUE; |
62 } | 66 } |
63 | 67 |
64 @Specialization(guards = "guard") | 68 @Specialization(guards = "guard") |
65 int doSpecialized(int value0, int value1) { | 69 int doSpecialized(int value0, int value1) { |