Mercurial > hg > truffle
changeset 22527:114a6a77b440
Colorifying ByteValueProfile sample code
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 30 Dec 2015 15:33:13 +0100 |
parents | a5e58793bbca |
children | d725323deb6c |
files | truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ByteValueProfile.java truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ByteValueProfileTest.java |
diffstat | 2 files changed, 13 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ByteValueProfile.java Wed Dec 30 11:06:33 2015 +0100 +++ b/truffle/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ByteValueProfile.java Wed Dec 30 15:33:13 2015 +0100 @@ -37,22 +37,7 @@ * </p> * * <p> - * <b> Usage example: </b> - * - * <pre> - * class SampleNode extends Node { - * - * final ByteValueProfile profile = ByteValueProfile.createIdentityProfile(); - * - * byte execute(byte input) { - * byte profiledValue = profile.profile(input); - * // compiler may know now more about profiledValue - * return profiledValue; - * } - * } - * </pre> - * <p> - * + * <b> Usage example: </b> {@codesnippet ByteValueProfileSample} * * {@inheritDoc} *
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ByteValueProfileTest.java Wed Dec 30 11:06:33 2015 +0100 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ByteValueProfileTest.java Wed Dec 30 15:33:13 2015 +0100 @@ -22,6 +22,7 @@ */ package com.oracle.truffle.api.profiles; +import com.oracle.truffle.api.nodes.Node; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -113,4 +114,15 @@ p.toString(); // test that it is not crashing } + // BEGIN: ByteValueProfileSample + class SampleNode extends Node { + final ByteValueProfile profile = ByteValueProfile.createIdentityProfile(); + + byte execute(byte input) { + byte profiledValue = profile.profile(input); + // compiler may know now more about profiledValue + return profiledValue; + } + } + // END: ByteValueProfileSample }