Top Description Fields Constructors Methods
org.jruby.ir

public abstract Class IRScope

extends Object
implements ParseResult
Class Inheritance
All Implemented Interfaces
org.jruby.ParseResult
Known Direct Subclasses
org.jruby.ir.IRScriptBody, org.jruby.ir.IRClosure, org.jruby.ir.IRMethod, org.jruby.ir.IRModuleBody
Imports
org.jcodings.Encoding, org.jruby.ParseResult, .Ruby, .RubyInstanceConfig, .RubyModule, .RubySymbol, org.jruby.compiler.Compilable, org.jruby.ext.coverage.CoverageData, org.jruby.ir.instructions.*, org.jruby.ir.interpreter.FullInterpreterContext, .InterpreterContext, org.jruby.ir.operands.*, org.jruby.ir.passes.*, org.jruby.ir.persistence.IRWriter, .IRWriterEncoder, org.jruby.ir.representations.BasicBlock, org.jruby.ir.transformations.inlining.CFGInliner, .SimpleCloneInfo, org.jruby.ir.util.IGVDumper, org.jruby.parser.StaticScope, java.util.ArrayList, .Collection, .Collections, .EnumSet, .HashMap, .List, .Map, java.util.concurrent.atomic.AtomicInteger, java.util.function.Supplier, org.jruby.runtime.DynamicScope, .ThreadContext, org.jruby.util.ByteList, org.jruby.util.log.Logger, .LoggerFactory

Right now, this class abstracts the following execution scopes: Method, Closure, Module, Class, MetaClass Top-level Script, and Eval Script In the compiler-land, IR versions of these scopes encapsulate only as much information as is required to convert Ruby code into equivalent Java code. But, in the non-compiler land, there will be a corresponding java object for some of these scopes which encapsulates the runtime semantics and data needed for implementing them. In the case of Module, Class, MetaClass, and Method, they also happen to be instances of the corresponding Ruby classes -- so, in addition to providing code that help with this specific ruby implementation, they also have code that let them behave as ruby instances of their corresponding classes. Examples: - the runtime class object might have refs. to the runtime method objects. - the runtime method object might have a slot for a heap frame (for when it has closures that need access to the method's local variables), it might have version information, it might have references to other methods that were optimized with the current version number, etc. - the runtime closure object will have a slot for a heap frame (for when it has closures within) and might get reified as a method in the java land (but inaccessible in ruby land). So, passing closures in Java land might be equivalent to passing around the method handles. and so on ...

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private boolean
private boolean
public Compilable<T>
private int
protected FullInterpreterContext
fullInterpreterContext

-X-C full interpretation OR JIT depends on this

private static final AtomicInteger
private boolean
private boolean
private boolean
private boolean
private String
protected InterpreterContext
interpreterContext

Startup interpretation depends on this

private final List<IRScope>
private final IRScope
lexicalParent

Lexical parent scope

private final int
lineNumber

Starting line for this scope's definition

pack-priv Map<RubySymbol, LocalVariable>
public static final Logger
private final IRManager
private boolean
private ByteList
name

Name

private boolean
private List<IRClosure>
nestedClosures

List of (nested) closures in this scope

protected int
private int
nextLabelIndex

Keeps track of types of prefix indexes for variables and labels

private static final Collection<IRClosure>
protected FullInterpreterContext
optimizedInterpreterContext

Speculatively optimized code

private boolean
private boolean
private boolean
private final int
scopeId

Unique global scope id

private final StaticScope
staticScope

Parser static-scope that this IR scope corresponds to

private boolean
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
protected
IRScope(IRScope s, IRScope lexicalParent)

public
IRScope(IRManager manager, IRScope lexicalParent, ByteList name, int lineNumber, StaticScope staticScope)

public
IRScope(IRManager manager, IRScope lexicalParent, ByteList name, int lineNumber, StaticScope staticScope, int coverageMode)

Method Summary

Modifier and TypeMethod and Description
public boolean
protected synchronized void
public void
public static EnumSet<IRFlags>
public InterpreterContext
allocateInterpreterContext(List<Instr> instructions, int tempVariableCount, EnumSet<IRFlags> flags)

Make version specific to scope which needs it (e.g. Closure vs non-closure).

public InterpreterContext
allocateInterpreterContext(Supplier<List<Instr>> instructions, int tempVariableCount, EnumSet<IRFlags> flags)

Make version specific to scope which needs it (e.g. Closure vs non-closure).

public boolean
public Map<BasicBlock, Label>
public InterpreterContext
public boolean
public boolean
public boolean
public void
captureParentRefinements(ThreadContext context)

Duplicate the parent scope's refinements overlay to get a moment-in-time snapshot.

public void
cleanupAfterExecution()

We are done with execution of this scope and we can cleanup some amount of things in this scope which will no longer be used.

private Instr[]
public int
public String
protected void
public IGVDumper
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public boolean
protected LocalVariable
public Object
public ByteList
public Collection<IRClosure>
public int
public DynamicScope
public Encoding
public List<CompilerPass>
public FullInterpreterContext
public String
public String
getFileName()
Deprecated

public FullInterpreterContext
public String
public String
public InterpreterContext
public IRScope
getLexicalParent()

Returns the lexical scope that contains this scope definition

public synchronized List<IRScope>
public int
public int
getLineNumber()
Deprecated

public LocalVariable
getLocalVariable(RubySymbol name, int scopeDepth)

Find or create a local variable.

public Map<RubySymbol, LocalVariable>
getLocalVariables()

Get the local variables for this scope.

public IRManager
public RubySymbol
public IRMethod
public int
getNearestModuleReferencingScopeDepth()

Returns the nearest scope which we can extract a live module from.

public IRScope
public IRScope
public Label
public Label
public LocalVariable
getNewLocalVariable(RubySymbol name, int scopeDepth)

public int
public int
public FullInterpreterContext
public IRScope
getRootLexicalScope()

Returns the top level scope

public int
public abstract IRScopeType
public Variable
public StaticScope
public boolean
hasBeenBuilt()

For lazy scopes which IRBuild on demand we can ask this method whether it has been built yet...

public boolean
public boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public boolean
private FullInterpreterContext
public void
inlineMethod(IRMethod methodToInline, RubyModule metaclass, long callsiteId, int classToken, boolean cloneHost)

private FullInterpreterContext
inlineMethodCommon(IRMethod methodToInline, RubyModule implClass, long callsiteId, int classToken, boolean cloneHost)

public void
inlineMethodCompiled(IRMethod methodToInline, RubyModule implClass, long callsiteId, int classToken, boolean cloneHost)

public void
inlineMethodJIT(IRMethod methodToInline, RubyModule implClass, long callsiteId, int classToken, boolean cloneHost)

public boolean
public boolean
isModuleBody()

Does this scope represent a module body?

public boolean
public boolean
isNonSingletonClassBody()

Is this IRClassBody but not IRMetaClassBody?

public boolean
public boolean

Returns:

true if this scope is contained by parentScope.
isScopeContainedBy
(IRScope
we want to see if it contains this scope
parentScope
)

returns whether this scope is contained by the parentScope parameter.

public boolean
isScriptScope()

Is this an eval script or a regular file script?

public boolean
public boolean
public boolean
public LocalVariable
public boolean
public boolean
public boolean
public void
public void
public synchronized BasicBlock[]
prepareForCompilation()

Run any necessary passes to get the IR ready for compilation (AOT and/or JIT)

public synchronized FullInterpreterContext
prepareFullBuild()

This initializes a more complete(full) InterpreterContext which if used in mixed mode will be used by the JIT and if used in pure-interpreted mode it will be used by an interpreter engine.

public boolean
public boolean
public void
private void
public void
public void
public void
public void
public void
public void
setCoverageMode(int coverageMode)

public void
setFileName(String filename)

public void
public void
setHasFlipFlops(boolean hasFlipFlops)

public void
public void
public void
public void
public void
setNextLabelIndex(int index)

public void
public void
public void
private void
public void
public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public String
public String
public boolean
public boolean
public boolean
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait