Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadArgumentNode.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.frame.*; | 25 import com.oracle.truffle.api.frame.*; |
26 import com.oracle.truffle.api.utilities.*; | |
26 import com.oracle.truffle.sl.runtime.*; | 27 import com.oracle.truffle.sl.runtime.*; |
27 | 28 |
28 public class ReadArgumentNode extends TypedNode { | 29 public class ReadArgumentNode extends TypedNode { |
29 | 30 |
30 private final int index; | 31 private final int index; |
32 | |
33 private final BranchProfile outOfBounds = new BranchProfile(); | |
34 private final BranchProfile inBounds = new BranchProfile(); | |
31 | 35 |
32 public ReadArgumentNode(int index) { | 36 public ReadArgumentNode(int index) { |
33 this.index = index; | 37 this.index = index; |
34 } | 38 } |
35 | 39 |
36 @Override | 40 @Override |
37 public Object executeGeneric(VirtualFrame frame) { | 41 public Object executeGeneric(VirtualFrame frame) { |
38 Object[] args = SLArguments.get(frame).arguments; | 42 Object[] args = SLArguments.get(frame).arguments; |
39 if (index < args.length) { | 43 if (index < args.length) { |
44 inBounds.enter(); | |
40 return args[index]; | 45 return args[index]; |
41 } else { | 46 } else { |
47 outOfBounds.enter(); | |
42 return SLNull.INSTANCE; | 48 return SLNull.INSTANCE; |
43 } | 49 } |
44 } | 50 } |
45 | 51 |
46 } | 52 } |