diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadFunctionNode.java @ 13336:d4c6dd07be76

SL: added exemplary uses of new profiling utility BranchProfile to SL.
author Christian Humer <christian.humer@gmail.com>
date Sun, 15 Dec 2013 22:20:12 +0100
parents 71991b7a0f14
children
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadFunctionNode.java	Sun Dec 15 22:19:19 2013 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadFunctionNode.java	Sun Dec 15 22:20:12 2013 +0100
@@ -23,16 +23,15 @@
 package com.oracle.truffle.sl.nodes;
 
 import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
 import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.utilities.*;
 import com.oracle.truffle.sl.runtime.*;
 
 public final class ReadFunctionNode extends TypedNode {
 
     private final SLFunctionRegistry registry;
     private final String name;
-
-    @CompilationFinal private boolean seenInvalidFunction;
+    private final BranchProfile invalidFunction = new BranchProfile();
 
     public ReadFunctionNode(SLFunctionRegistry registry, String name) {
         this.registry = registry;
@@ -50,14 +49,8 @@
         if (target != null) {
             return target;
         }
-        if (!seenInvalidFunction) {
-            CompilerDirectives.transferToInterpreter();
-            seenInvalidFunction = true;
-        }
-        if (seenInvalidFunction) {
-            throw new RuntimeException("Function with name '" + name + "' not found.");
-        }
-        return null;
+        invalidFunction.enter();
+        throw new RuntimeException("Function with name '" + name + "' not found.");
     }
 
 }