diff truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/profiles/ByteValueProfileTest.java @ 22527:114a6a77b440

Colorifying ByteValueProfile sample code
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 30 Dec 2015 15:33:13 +0100
parents a63bda98cfdb
children 4ba1aa33fda4
line wrap: on
line diff
--- 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
 }