# HG changeset patch # User Christian Humer # Date 1413215080 -7200 # Node ID 87ea195b66ff714b068e19af3da0837408c23e8b # Parent e9815091957701d341a79f96a3d0996f17fcf453 Truffle: Make BranchProfile constructor private and introduce a factory Method BranchProfile.create(). diff -r e98150919577 -r 87ea195b66ff CHANGELOG.md --- a/CHANGELOG.md Mon Oct 13 17:44:15 2014 +0200 +++ b/CHANGELOG.md Mon Oct 13 17:44:40 2014 +0200 @@ -7,6 +7,7 @@ ### Truffle * Relaxed declared type restriction on child fields to allow for interface types in addition to Node subclasses. +* The BranchProfile constructor is now private. Use BranchProfile#create() instead. * ... ## Version 0.5 diff -r e98150919577 -r 87ea195b66ff graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/BranchProfileTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/BranchProfileTest.java Mon Oct 13 17:44:15 2014 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/BranchProfileTest.java Mon Oct 13 17:44:40 2014 +0200 @@ -32,14 +32,14 @@ @Test public void testEnter() { - BranchProfile profile = new BranchProfile(); + BranchProfile profile = BranchProfile.create(); profile.enter(); profile.enter(); } @Test public void testToString() { - BranchProfile profile = new BranchProfile(); + BranchProfile profile = BranchProfile.create(); assertTrue(profile.toString().contains(profile.getClass().getSimpleName())); assertTrue(profile.toString().contains("not-visited")); assertTrue(profile.toString().contains(Integer.toHexString(profile.hashCode()))); diff -r e98150919577 -r 87ea195b66ff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java Mon Oct 13 17:44:15 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java Mon Oct 13 17:44:40 2014 +0200 @@ -40,6 +40,9 @@ @CompilationFinal private boolean visited; + private BranchProfile() { + } + public void enter() { if (!visited) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -51,6 +54,10 @@ return visited; } + public static BranchProfile create() { + return new BranchProfile(); + } + @Override public String toString() { return String.format("%s(%s)@%x", getClass().getSimpleName(), visited ? "visited" : "not-visited", hashCode()); diff -r e98150919577 -r 87ea195b66ff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java Mon Oct 13 17:44:15 2014 +0200 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java Mon Oct 13 17:44:40 2014 +0200 @@ -47,8 +47,8 @@ * {@link SLReturnNode explicit return statement}. This allows the compiler to generate better * code. */ - private final BranchProfile exceptionTaken = new BranchProfile(); - private final BranchProfile nullTaken = new BranchProfile(); + private final BranchProfile exceptionTaken = BranchProfile.create(); + private final BranchProfile nullTaken = BranchProfile.create(); public SLFunctionBodyNode(SourceSection src, SLStatementNode bodyNode) { super(src); diff -r e98150919577 -r 87ea195b66ff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLRepeatingNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLRepeatingNode.java Mon Oct 13 17:44:15 2014 +0200 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLRepeatingNode.java Mon Oct 13 17:44:40 2014 +0200 @@ -46,8 +46,8 @@ * statement was used in this loop. This allows the compiler to generate better code for loops * without a {@code continue}. */ - private final BranchProfile continueTaken = new BranchProfile(); - private final BranchProfile breakTaken = new BranchProfile(); + private final BranchProfile continueTaken = BranchProfile.create(); + private final BranchProfile breakTaken = BranchProfile.create(); public SLRepeatingNode(SourceSection src, SLExpressionNode conditionNode, SLStatementNode bodyNode) { super(src); diff -r e98150919577 -r 87ea195b66ff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java Mon Oct 13 17:44:15 2014 +0200 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java Mon Oct 13 17:44:40 2014 +0200 @@ -45,7 +45,7 @@ * Profiling information, collected by the interpreter, capturing whether the function was * called with fewer actual arguments than formal arguments. */ - private final BranchProfile outOfBoundsTaken = new BranchProfile(); + private final BranchProfile outOfBoundsTaken = BranchProfile.create(); public SLReadArgumentNode(SourceSection src, int index) { super(src);