Mercurial > hg > graal-jvmci-8
comparison 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 |
comparison
equal
deleted
inserted
replaced
13335:8531c47138dc | 13336:d4c6dd07be76 |
---|---|
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.sl.nodes; | 23 package com.oracle.truffle.sl.nodes; |
24 | 24 |
25 import com.oracle.truffle.api.*; | 25 import com.oracle.truffle.api.*; |
26 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; | |
27 import com.oracle.truffle.api.frame.*; | 26 import com.oracle.truffle.api.frame.*; |
27 import com.oracle.truffle.api.utilities.*; | |
28 import com.oracle.truffle.sl.runtime.*; | 28 import com.oracle.truffle.sl.runtime.*; |
29 | 29 |
30 public final class ReadFunctionNode extends TypedNode { | 30 public final class ReadFunctionNode extends TypedNode { |
31 | 31 |
32 private final SLFunctionRegistry registry; | 32 private final SLFunctionRegistry registry; |
33 private final String name; | 33 private final String name; |
34 | 34 private final BranchProfile invalidFunction = new BranchProfile(); |
35 @CompilationFinal private boolean seenInvalidFunction; | |
36 | 35 |
37 public ReadFunctionNode(SLFunctionRegistry registry, String name) { | 36 public ReadFunctionNode(SLFunctionRegistry registry, String name) { |
38 this.registry = registry; | 37 this.registry = registry; |
39 this.name = name; | 38 this.name = name; |
40 } | 39 } |
48 public CallTarget executeCallTarget(VirtualFrame frame) { | 47 public CallTarget executeCallTarget(VirtualFrame frame) { |
49 CallTarget target = registry.lookup(name); | 48 CallTarget target = registry.lookup(name); |
50 if (target != null) { | 49 if (target != null) { |
51 return target; | 50 return target; |
52 } | 51 } |
53 if (!seenInvalidFunction) { | 52 invalidFunction.enter(); |
54 CompilerDirectives.transferToInterpreter(); | 53 throw new RuntimeException("Function with name '" + name + "' not found."); |
55 seenInvalidFunction = true; | |
56 } | |
57 if (seenInvalidFunction) { | |
58 throw new RuntimeException("Function with name '" + name + "' not found."); | |
59 } | |
60 return null; | |
61 } | 54 } |
62 | 55 |
63 } | 56 } |