Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java @ 16992:5a1d764f6afc
Truffle: added support for Runtime#getCallTargets()
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 28 Aug 2014 15:35:29 +0200 |
parents | 534a87f866dc |
children | 7b45e33b7986 |
comparison
equal
deleted
inserted
replaced
16991:4a6d852dbb68 | 16992:5a1d764f6afc |
---|---|
39 */ | 39 */ |
40 public final class DefaultTruffleRuntime implements TruffleRuntime { | 40 public final class DefaultTruffleRuntime implements TruffleRuntime { |
41 | 41 |
42 private ThreadLocal<LinkedList<FrameInstance>> stackTraces = new ThreadLocal<>(); | 42 private ThreadLocal<LinkedList<FrameInstance>> stackTraces = new ThreadLocal<>(); |
43 private ThreadLocal<FrameInstance> currentFrames = new ThreadLocal<>(); | 43 private ThreadLocal<FrameInstance> currentFrames = new ThreadLocal<>(); |
44 private final Map<RootCallTarget, Void> callTargets = Collections.synchronizedMap(new WeakHashMap<RootCallTarget, Void>()); | |
44 | 45 |
45 public DefaultTruffleRuntime() { | 46 public DefaultTruffleRuntime() { |
46 if (Truffle.getRuntime() != null) { | 47 if (Truffle.getRuntime() != null) { |
47 throw new IllegalArgumentException("Cannot instantiate DefaultTruffleRuntime. Use Truffle.getRuntime() instead."); | 48 throw new IllegalArgumentException("Cannot instantiate DefaultTruffleRuntime. Use Truffle.getRuntime() instead."); |
48 } | 49 } |
53 return "Default Truffle Runtime"; | 54 return "Default Truffle Runtime"; |
54 } | 55 } |
55 | 56 |
56 @Override | 57 @Override |
57 public RootCallTarget createCallTarget(RootNode rootNode) { | 58 public RootCallTarget createCallTarget(RootNode rootNode) { |
58 return new DefaultCallTarget(rootNode, this); | 59 DefaultCallTarget target = new DefaultCallTarget(rootNode, this); |
60 callTargets.put(target, null); | |
61 return target; | |
59 } | 62 } |
60 | 63 |
61 public DirectCallNode createDirectCallNode(CallTarget target) { | 64 public DirectCallNode createDirectCallNode(CallTarget target) { |
62 return new DefaultDirectCallNode(target, this); | 65 return new DefaultDirectCallNode(target, this); |
63 } | 66 } |
130 public FrameInstance getCallerFrame() { | 133 public FrameInstance getCallerFrame() { |
131 return getThreadLocalStackTrace().peekFirst(); | 134 return getThreadLocalStackTrace().peekFirst(); |
132 } | 135 } |
133 | 136 |
134 @Override | 137 @Override |
138 public List<RootCallTarget> getCallTargets() { | |
139 return new ArrayList<>(callTargets.keySet()); | |
140 } | |
141 | |
142 @Override | |
135 public FrameInstance getCurrentFrame() { | 143 public FrameInstance getCurrentFrame() { |
136 return currentFrames.get(); | 144 return currentFrames.get(); |
137 } | 145 } |
138 | 146 |
139 public void notifyTransferToInterpreter() { | 147 public void notifyTransferToInterpreter() { |