Skip to content

Commit

Permalink
Document copy_captured_locals in the source code
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/599
  • Loading branch information
eregon committed Feb 6, 2019
2 parents 54ccb2e + 0eca6d7 commit 024f27d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/org/truffleruby/extra/TruffleGraalNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,16 @@ public DynamicObject splitProc(DynamicObject rubyProc) {
}
}

// Like Smalltalk's fixTemps but not mutating the Proc
/**
* This method creates a new Proc with a copy of the captured variables' values, which is
* correct if these variables are not changed in the parent scope later on. It works by
* replacing {@link ReadDeclarationVariableNode} with the captured variables' values. This
* avoids constantly reading from the declaration frame (which always escapes in a
* define_method) and folds many checks on these captured variables since their values become
* compilation constants.
* <p>
* Similar to Smalltalk's fixTemps, but not mutating the Proc.
*/
@CoreMethod(names = "copy_captured_locals", onSingleton = true, required = 1)
public abstract static class CopyCapturedLocalsNode extends CoreMethodArrayArgumentsNode {

Expand Down

0 comments on commit 024f27d

Please sign in to comment.