Examples of JumpInstr


Examples of org.jruby.compiler.ir.instructions.JumpInstr

            // add body to map for emitting later
            bodies.put(bodyLabel, whenNode.getBodyNode());
        }

        // Jump to else or the end in case nothing matches!
        m.addInstr(new JumpInstr(hasElse ? elseLabel : endLabel));

        // build "else" if it exists
        if (hasElse) {
            caseInstr.setElse(elseLabel);
            bodies.put(elseLabel, caseNode.getElseNode());
        }

        // now emit bodies
        for (Map.Entry<Label, Node> entry : bodies.entrySet()) {
            m.addInstr(new LABEL_Instr(entry.getKey()));
            Operand bodyValue = build(entry.getValue(), m);
            // bodyValue can be null if the body ends with a return!
            if (bodyValue != null) {
               // Local optimization of break results (followed by a copy & jump) to short-circuit the jump right away
               // rather than wait to do it during an optimization pass when a dead jump needs to be removed.
               Label tgt = endLabel;
               if (bodyValue instanceof BreakResult) {
                   BreakResult br = (BreakResult)bodyValue;
                   bodyValue = br._result;
                   tgt = br._jumpTarget;
               }
               m.addInstr(new CopyInstr(result, bodyValue));
               m.addInstr(new JumpInstr(tgt));
            }
        }

        // close it out
        m.addInstr(new LABEL_Instr(endLabel));
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.JumpInstr

        // SSS FIXME: How do we get this to catch all exceptions, not just Ruby exceptions?
        Label dummyRescueBlockLabel = m.getNewLabel();
        rescueLabels.add(dummyRescueBlockLabel);
        m.addInstr(new LABEL_Instr(dummyRescueBlockLabel));
        m.addInstr(new SET_RETADDR_Instr(ebi.returnAddr, ebi.end));
        m.addInstr(new JumpInstr(ebi.start));

        // End
        m.addInstr(new LABEL_Instr(rEndLabel));

        // SSS FIXME: Is this correct?  Shoudln't we be copying v1 & v2 into an variable and returning that instead?
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.JumpInstr

        // Protected region code
        m.addInstr(new LABEL_Instr(rBeginLabel));
        m.addInstr(new ExceptionRegionStartMarkerInstr(rBeginLabel, rEndLabel, rescueLabels));
        Object v1 = protectedCode.run(protectedCodeArgs); // YIELD: Run the protected code block
        m.addInstr(new CopyInstr(rv, (Operand)v1));
        m.addInstr(new JumpInstr(rEndLabel));
        m.addInstr(new ExceptionRegionEndMarkerInstr());

        // Rescue code
        Label rbLabel = m.getNewLabel();
        rescueLabels.add(rbLabel);
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.JumpInstr

            } else {
                Operand def = buildGetDefinition(node, m);
                m.addInstr(new BEQInstr(def, Nil.NIL, failLabel));
            }
            m.addInstr(new CopyInstr(rv, new StringLiteral(type)));
            m.addInstr(new JumpInstr(doneLabel));
            m.addInstr(new LABEL_Instr(failLabel));
            m.addInstr(new CopyInstr(rv, Nil.NIL));
            m.addInstr(new LABEL_Instr(doneLabel));
            return rv;
        }
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.JumpInstr

    private void buildDefinitionCheck(IRScope s, Variable tmpVar, String definedReturnValue) {
        Label undefLabel = s.getNewLabel();
        Label defLabel   = s.getNewLabel();
        s.addInstr(new BEQInstr(tmpVar, BooleanLiteral.FALSE, undefLabel));
        s.addInstr(new CopyInstr(tmpVar, new StringLiteral(definedReturnValue)));
        s.addInstr(new JumpInstr(defLabel));
        s.addInstr(new LABEL_Instr(undefLabel));
        s.addInstr(new CopyInstr(tmpVar, Nil.NIL));
        s.addInstr(new LABEL_Instr(defLabel));
    }
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.JumpInstr

                StringLiteral mName = new StringLiteral(((FCallNode)node).getName());
                Instr callInstr  = new JRubyImplCallInstr(tmpVar, new MethAddr("isMethodBound"), tmpVar, new Operand[]{mName, BooleanLiteral.FALSE});
                s.addInstr(callInstr);
                s.addInstr(new BEQInstr(tmpVar, BooleanLiteral.FALSE, undefLabel));
                s.addInstr(new CopyInstr(tmpVar, buildGetArgumentDefinition(((FCallNode) node).getArgsNode(), s, "method")));
                s.addInstr(new JumpInstr(defLabel));
                s.addInstr(new LABEL_Instr(undefLabel));
                s.addInstr(new CopyInstr(tmpVar, Nil.NIL));
                s.addInstr(new LABEL_Instr(defLabel));
                return tmpVar;
            }
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.JumpInstr

        rescueLabels.add(dummyRescueBlockLabel);
        Variable exc = m.getNewTemporaryVariable();
        m.addInstr(new LABEL_Instr(dummyRescueBlockLabel));
        m.addInstr(new RECV_EXCEPTION_Instr(exc));
        m.addInstr(new SET_RETADDR_Instr(ebi.returnAddr, rethrowExcLabel));
        m.addInstr(new JumpInstr(ebi.start));
        m.addInstr(new LABEL_Instr(rethrowExcLabel));
        m.addInstr(new THROW_EXCEPTION_Instr(exc));

        // End label for the exception region
        m.addInstr(new LABEL_Instr(rEndLabel));
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.JumpInstr

                    BreakResult br = (BreakResult)thenResult;
                    thenResult = br._result;
                    tgt = br._jumpTarget;
                }
                s.addInstr(new CopyInstr(result, thenResult));
                s.addInstr(new JumpInstr(tgt));
            }
            else {
                thenUnil = true;
            }
        }
        else {
            thenNull = true;
            s.addInstr(new CopyInstr(result, Nil.NIL));
            s.addInstr(new JumpInstr(doneLabel));
        }

        // Build the else part of the if-statement
        s.addInstr(new LABEL_Instr(falseLabel));
        if (ifNode.getElseBody() != null) {
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.JumpInstr

        Operand rv = (nextNode.getValueNode() == null) ? Nil.NIL : build(nextNode.getValueNode(), s);
        // SSS FIXME: 1. Is the ordering correct? (poll before next)
        s.addInstr(new ThreadPollInstr());
        // If a closure, the next is simply a return from the closure!
        // If a regular loop, the next is simply a jump to the end of the iteration
        s.addInstr((s instanceof IRClosure) ? new ClosureReturnInstr(rv) : new JumpInstr(s.getCurrentLoop().iterEndLabel));
        return rv;
    }
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.JumpInstr

**/

    public Operand buildRedo(Node node, IRExecutionScope s) {
        // For closures, a redo is a jump to the beginning of the closure
        // For non-closures, a redo is a jump to the beginning of the loop
        s.addInstr(new JumpInstr((s instanceof IRClosure) ? ((IRClosure)s).startLabel : s.getCurrentLoop().iterStartLabel));
        return Nil.NIL;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.