Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jruby.ir.instructions;
 
This instruction will be generated whenever speculative optimizations are performed based on assuming that an object's metaclass is C (as determined by the version number of C -- where the version number changes every time C's class structure changes).
public class ModuleVersionGuardInstr extends Instr {
    
The token value that has been assumed
    private final int expectedVersion;

    
The module whose version we are testing
    private final RubyModule module;

    
The object whose metaclass token has to be verifie
    private Operand candidateObj;

    
Where to jump if the version assumption fails?
    private Label failurePathLabel;
    public ModuleVersionGuardInstr(RubyModule moduleint expectedVersionOperand candidateObjLabel failurePathLabel) {
        super(.);
        this. = module;
        this. = expectedVersion;
        this. = candidateObj;
        this. = failurePathLabel;
    }
    public Label getFailurePathLabel() {
        return ;
    }
    @Override
    public Operand[] getOperands() {
        return new Operand[] {  };
    }
    @Override
    public void simplifyOperands(Map<OperandOperandvalueMapboolean force) {
         = .getSimplifiedOperand(valueMapforce);
    }
    @Override
    public String toString() {
        return super.toString() + "(" +  + ", " +  + "[" + .getName() + "], " +  + ")";
    }
    @Override
    public Instr cloneForInlinedScope(InlinerInfo ii) {
    }
    @Override
    public Instr cloneForBlockCloning(InlinerInfo ii) {
    }
    public boolean versionMatches(ThreadContext contextDynamicScope currDynScopeIRubyObject selfObject[] temp) {
        IRubyObject receiver = (IRubyObject.retrieve(contextselfcurrDynScopetemp);
        // if (module.getGeneration() != expectedVersion) ... replace this instr with a direct jump
        //
        // SSS FIXME: This is not always correct.  Implementation class is not always receiver.getMetaClass()
        // as we know from how we add instance-methods.  We add it to rubyClass value on the stack.  So, how
        // do we handle this sticky situation?
        return (receiver.getMetaClass().getGeneration() == );
    }
    @Override
    public void visit(IRVisitor visitor) {
        visitor.ModuleVersionGuardInstr(this);
    }
New to GrepCode? Check out our FAQ X