Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java @ 13836:64c77f0577bb
More documentation and improvements of Simple Language
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 30 Jan 2014 17:53:27 -0800 |
parents | b16ec83edc73 |
children | afd6fa5e8229 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java Thu Jan 30 17:52:24 2014 -0800 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java Thu Jan 30 17:53:27 2014 -0800 @@ -22,15 +22,31 @@ */ package com.oracle.truffle.sl.nodes.local; +import com.oracle.truffle.api.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.sl.nodes.*; +import com.oracle.truffle.sl.parser.*; import com.oracle.truffle.sl.runtime.*; +/** + * Reads a function argument. Arguments are passed in as a {@link SLArguments} object, which + * encapsulates an {@link SLArguments#getFromFrame Object[] array}. Language-defined subclasses of + * {@link Arguments} are the standard Truffle way to pass values between function. + * <p> + * Arguments are not type-specialized. To ensure that repeated accesses within a method are + * specialized and can, e.g., accessed without unboxing, all arguments are loaded into local + * variables {@link SLNodeFactory#addFormalParameter in the method prologue}. + */ public class SLReadArgumentNode extends SLExpressionNode { + /** The argument number, i.e., the index into the array of arguments. */ private final int index; + /** + * Profiling information, collected by the interpreter, capturing whether the function was + * called with fewer actual arguments than formal arguments. + */ private final BranchProfile outOfBoundsTaken = new BranchProfile(); public SLReadArgumentNode(int index) { @@ -43,7 +59,9 @@ if (index < args.length) { return args[index]; } else { + /* In the interpreter, record profiling information that the branch was used. */ outOfBoundsTaken.enter(); + /* Use the default null value. */ return SLNull.SINGLETON; } }