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 ...
| constant | type | note |
|---|---|---|
| LOG | Logger |
| field | type | note |
|---|---|---|
| compilable | Compilable |
<init>(org.jruby.ir.IRManager manager, org.jruby.ir.IRScope lexicalParent, org.jruby.util.ByteList name, int lineNumber, org.jruby.parser.StaticScope staticScope)<init>(org.jruby.ir.IRManager manager, org.jruby.ir.IRScope lexicalParent, org.jruby.util.ByteList name, int lineNumber, org.jruby.parser.StaticScope staticScope, int coverageMode)accessesParentsLocalVariables()allocateInterpreterContext(List<org.jruby.ir.instructions.Instr> instructions, int tempVariableCount, EnumSet<org.jruby.ir.IRFlags> flags)Make version specific to scope which needs it (e.g. Closure vs non-closure).
allocateInterpreterContext(java.util.function.Supplier<List<org.jruby.ir.instructions.Instr>> instructions, int tempVariableCount, EnumSet<org.jruby.ir.IRFlags> flags)Make version specific to scope which needs it (e.g. Closure vs non-closure).
anyUsesEval()getAST() · also: get_astbuildJVMExceptionTable(org.jruby.ir.interpreter.FullInterpreterContext fic)canCaptureCallersBinding()canReceiveBreaks()canReceiveNonlocalReturns()captureParentRefinements(org.jruby.runtime.ThreadContext context)Duplicate the parent scope's refinements overlay to get a moment-in-time snapshot.
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. Sub-classes will be the deciders of what is no longer needed. An example, to illustrate the complexity of cleanup: A class with no nested closures can remove any ICs created and can remove some other infomrational data structures like allocated variables unless closures do exist and then the ICs must stay for when closures JIT.
correctVariableDepthForForLoopsForEncoding(int depth)getCoverageMode() · also: get_coverage_modesetCoverageMode(int coverageMode) · also: set_coverage_modedebugOutput()getEncoding() · also: get_encodingequals(Object other)executesOnce()getExecutionContext() · also: get_execution_contextgetFile() · also: get_filegetFileName() · also: get_file_namesetFileName(String filename) · also: set_file_namegetFullInterpreterContext() · also: get_full_interpreter_contextgetFullyQualifiedName() · also: get_fully_qualified_namegetLocalVariable(org.jruby.RubySymbol name, int scopeDepth)Find or create a local variable. By default, scopes are assumed to only check current depth. Blocks/Closures override this because they have special nesting rules.
getNewLocalVariable(org.jruby.RubySymbol name, int scopeDepth)hasBeenBuilt() · also: has_been_builtFor lazy scopes which IRBuild on demand we can ask this method whether it has been built yet...
hasBreakInstructions() · also: has_break_instructionssetHasFlipFlops(boolean hasFlipFlops) · also: set_has_flip_flopshasFlipFlops() · also: has_flip_flopshasLoops() · also: has_loopshasNonLocalReturns() · also: has_non_local_returnshashCode()getId() · also: get_idinlineMethod(org.jruby.ir.IRMethod methodToInline, org.jruby.RubyModule metaclass, long callsiteId, int classToken, boolean cloneHost)inlineMethodCompiled(org.jruby.ir.IRMethod methodToInline, org.jruby.RubyModule implClass, long callsiteId, int classToken, boolean cloneHost)inlineMethodJIT(org.jruby.ir.IRMethod methodToInline, org.jruby.RubyModule implClass, long callsiteId, int classToken, boolean cloneHost)inliningAllowed()getInterpreterContext() · also: get_interpreter_contextisNestedInClosure(org.jruby.ir.IRClosure closure)isScopeContainedBy(org.jruby.ir.IRScope parentScope)returns whether this scope is contained by the parentScope parameter. For simplicity a scope is considered to contain itself.
| name | type | description |
|---|---|---|
| parent_scope | org.jruby.ir.IRScope | we want to see if it contains this scope |
Returns: true if this scope is contained by parentScope.
Returns the lexical scope that contains this scope definition
getLine() · also: get_linegetLineNumber() · also: get_line_numbergetLocalVariables() · also: get_local_variablesGet the local variables for this scope. This should only be used by persistence layer.
lookupExistingLVar(org.jruby.RubySymbol name)maybeUsingRefinements()isModuleBody() · also: is_module_bodyDoes this scope represent a module body?
getNearestModuleReferencingScopeDepth() · also: get_nearest_module_referencing_scope_depthReturns the nearest scope which we can extract a live module from. If this returns null (like for evals), then it means it cannot be statically determined.
getNearestNonClosurelikeScope() · also: get_nearest_non_closurelike_scopegetNearestTopLocalVariableScope() · also: get_nearest_top_local_variable_scopeneedsCodeCoverage()getNextClosureId() · also: get_next_closure_idgetNextLabelIndex() · also: get_next_label_indexsetNextLabelIndex(int index) · also: set_next_label_indexisNonSingletonClassBody() · also: is_non_singleton_class_bodyIs this IRClassBody but not IRMetaClassBody?
getOptimizedInterpreterContext() · also: get_optimized_interpreter_contextparentMaybeUsingRefinements()persistScopeFlags(org.jruby.ir.persistence.IRWriterEncoder file)persistScopeHeader(org.jruby.ir.persistence.IRWriterEncoder file)Run any necessary passes to get the IR ready for compilation (AOT and/or JIT)
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.
receivesClosureArg()receivesKeywordArgs()Returns the top level scope
isRuby2Keywords() · also: is_ruby2_keywordsgetScopeId() · also: get_scope_idisScriptScope() · also: is_script_scopeIs this an eval script or a regular file script?
setAccessesParentsLocalVariables()setCanCaptureCallersBinding()setCanReceiveBreaks()setCanReceiveNonlocalReturns()setHasBreakInstructions()setHasLoops()setHasNonLocalReturns()setIsMaybeUsingRefinements()setNeedsCodeCoverage()setReceivesClosureArg()setReceivesKeywordArgs()setRuby2Keywords()setUsesEval()setUsesSuper()setUsesZSuper()toString()toStringCompileForm()toStringInstrs()isTopLocalVariableScope() · also: is_top_local_variable_scopeusesEval()usesSuper()usesZSuper()isWhereFlipFlopStateVariableIs() · also: is_where_flip_flop_state_variable_isisWithinEND() · also: is_within_endisWithinMethod() · also: is_within_method