Mercurial > hg > truffle
changeset 17421:87ea195b66ff
Truffle: Make BranchProfile constructor private and introduce a factory Method BranchProfile.create().
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 13 Oct 2014 17:44:40 +0200 |
parents | e98150919577 |
children | 89f801a9b4d4 |
files | CHANGELOG.md graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/BranchProfileTest.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLRepeatingNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java |
diffstat | 6 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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())));
--- 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());
--- 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);
--- 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);
--- 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);