Examples of MethAddr


Examples of org.jruby.compiler.ir.operands.MethAddr

           IRMethod  mi = m.getInstanceMethod(methodToInline);
           for (BasicBlock b: c.getNodes()) {
               for (Instr i: b.getInstrs()) {
                   if (i instanceof CallInstr) {
                       CallInstr call = (CallInstr)i;
                       MethAddr addr = call.getMethodAddr();
                       if (methodToInline.equals(((MethAddr)addr).getName())) {
                           System.out.println("Will be inlining method " + methodToInline + " at callsite: " + call);
                           c.inlineMethod(mi, b, call);
                           // Just inline once per scope -- this is a test after all!
                           // Because, the surrounding iterators will break with a concurrent modification exception if we proceed!
View Full Code Here

Examples of org.jruby.compiler.ir.operands.MethAddr

        // to preserve expected code execution order
        Operand       receiver     = build(receiverNode, s);
        List<Operand> args         = setupCallArgs(callArgsNode, s);
        Operand       block        = setupCallClosure(callNode.getIterNode(), s);
        Variable      callResult   = s.getNewTemporaryVariable();
        Instr      callInstr    = new CallInstr(callResult, new MethAddr(callNode.getName()), receiver, args.toArray(new Operand[args.size()]), block);
        s.addInstr(callInstr);
        return callResult;
    }
View Full Code Here

Examples of org.jruby.compiler.ir.operands.MethAddr

        } else if (iVisited instanceof Colon2MethodNode) {
            Colon2MethodNode c2mNode = (Colon2MethodNode)iVisited;
            List<Operand> args       = setupCallArgs(null, s);
            Operand       block      = setupCallClosure(null, s);
            Variable      callResult = s.getNewTemporaryVariable();
            Instr      callInstr  = new CallInstr(callResult, new MethAddr(c2mNode.getName()),
                    null, args.toArray(new Operand[args.size()]), block);
            s.addInstr(callInstr);
            return callResult;
        }
        else { throw new NotCompilableException("Not compilable: " + iVisited); }
View Full Code Here

Examples of org.jruby.compiler.ir.operands.MethAddr

            case SELFNODE:
                return new StringLiteral("self");
            case VCALLNODE:
            {
                Variable tmp = s.getNewTemporaryVariable();
                s.addInstr(new JRubyImplCallInstr(tmp, new MethAddr("getMetaClass"), getSelf(s), NO_ARGS));

                Variable tmpVar = s.getNewTemporaryVariable();
                StringLiteral mName = new StringLiteral(((VCallNode) node).getName());
                s.addInstr(new JRubyImplCallInstr(tmpVar, new MethAddr("isMethodBound"), tmp, new Operand[]{mName, BooleanLiteral.FALSE}));
                buildDefinitionCheck(s, tmpVar, "method");
                return tmpVar;
            }
            case CONSTNODE:
            {
                Variable tmpVar = s.getNewTemporaryVariable();
                StringLiteral mName = new StringLiteral(((ConstNode) node).getName());
                s.addInstr(new JRubyImplCallInstr(tmpVar, new MethAddr("threadContext_getConstantDefined"), null, new Operand[]{mName}));
                buildDefinitionCheck(s, tmpVar, "constant");
                return tmpVar;
            }
            case GLOBALVARNODE:
            {
                Variable tmpVar = s.getNewTemporaryVariable();
                StringLiteral mName = new StringLiteral(((GlobalVarNode) node).getName());
                s.addInstr(new JRubyImplCallInstr(tmpVar, new MethAddr("runtime_isGlobalDefined"), null, new Operand[]{mName}));
                buildDefinitionCheck(s, tmpVar, "global-variable");
                return tmpVar;
            }
            case INSTVARNODE:
            {
                Variable tmpVar = s.getNewTemporaryVariable();
                StringLiteral mName = new StringLiteral(((GlobalVarNode) node).getName());
                s.addInstr(new JRubyImplCallInstr(tmpVar, new MethAddr("self_hasInstanceVariable"), getSelf(s), new Operand[]{mName}));
                buildDefinitionCheck(s, tmpVar, "instance-variable");
                return tmpVar;
            }
            case YIELDNODE:
        {
                Variable tmpVar = s.getNewTemporaryVariable();
                s.addInstr(new JRubyImplCallInstr(tmpVar, new MethAddr("block_isGiven"), null, NO_ARGS));
                buildDefinitionCheck(s, tmpVar, "yield");
                return tmpVar;
            }
            case FCALLNODE:
            {
                Variable tmpVar = s.getNewTemporaryVariable();
                s.addInstr(new JRubyImplCallInstr(tmpVar, new MethAddr("getMetaClass"), getSelf(s), NO_ARGS));
                Label undefLabel = s.getNewLabel();
                Label defLabel   = s.getNewLabel();
                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;
            }
            case COLON3NODE:
            case COLON2NODE:
            {
                final Colon3Node iVisited = (Colon3Node) node;
                final String name = iVisited.getName();

                // store previous exception for restoration if we rescue something
                Variable errInfo = s.getNewTemporaryVariable();
                s.addInstr(new JRubyImplCallInstr(errInfo, new MethAddr("threadContext_stashErrInfo"), null, NO_ARGS));

                CodeBlock protectedCode = new CodeBlock() {
                    public Object run(Object[] args) {
                        IRScope  m      = (IRScope)args[0];
                        Node     n      = (Node)args[1];
                        String   name   = (String)args[2];
                        Variable tmpVar = m.getNewTemporaryVariable();
                        Operand v;
                        if (n instanceof Colon2Node) {
                            v = build(((Colon2Node) n).getLeftNode(), m);
                        } else {
                            m.addInstr(new JRubyImplCallInstr(tmpVar, new MethAddr("runtime_getObject"), null, NO_ARGS));
                            v = tmpVar;
                        }
                        m.addInstr(new JRubyImplCallInstr(tmpVar, new MethAddr("getDefinedConstantOrBoundMethod"), null, new Operand[]{v, new StringLiteral(name)}));
                        return tmpVar;
                    }
                };

                // rescue block
                CodeBlock rescueBlock = new CodeBlock() {
                    public Object run(Object[] args) {
                        // Nothing to do -- ignore the exception, and restore stashed error info!
                        // SSS FIXME: Is this correct?  Or, do we compare against a specific exception type?
                        IRScope  m  = (IRScope)args[0];
                        m.addInstr(new JRubyImplCallInstr(null, new MethAddr("threadContext_restoreErrInfo"), null, new Operand[]{(Variable)args[1]}));
                        return Nil.NIL;
                    }
                };

                return protectCodeWithRescue(s, protectedCode, new Object[]{s, iVisited, name}, rescueBlock, new Object[] {s, errInfo});
View Full Code Here

Examples of org.jruby.compiler.ir.operands.MethAddr

    public Operand buildFCall(FCallNode fcallNode, IRScope s) {
        Node          callArgsNode = fcallNode.getArgsNode();
        List<Operand> args         = setupCallArgs(callArgsNode, s);
        Operand       block        = setupCallClosure(fcallNode.getIterNode(), s);
        Variable      callResult   = s.getNewTemporaryVariable();
        Instr         callInstr    = new CallInstr(callResult, new MethAddr(fcallNode.getName()), getSelf(s), args.toArray(new Operand[args.size()]), block);
        s.addInstr(callInstr);
        return callResult;
    }
View Full Code Here

Examples of org.jruby.compiler.ir.operands.MethAddr

        }
       
        // get attr
        Operand  v1 = build(opAsgnNode.getReceiverNode(), s);
        Variable      getResult   = s.getNewTemporaryVariable();
        Instr callInstr = new CallInstr(getResult, new MethAddr(opAsgnNode.getVariableName()), v1,
                NO_ARGS, null);
        s.addInstr(callInstr);

        // call operator
        Operand  v2 = build(opAsgnNode.getValueNode(), s);
        Variable      setValue   = s.getNewTemporaryVariable();
        callInstr = new CallInstr(setValue, new MethAddr(opAsgnNode.getOperatorName()), getResult,
                new Operand[]{v2}, null);
        s.addInstr(callInstr);

        // set attr
        Variable      setResult   = s.getNewTemporaryVariable();
        callInstr    = new CallInstr(setResult, new MethAddr(opAsgnNode.getVariableNameAsgn()),
                v1, new Operand[] {setValue}, null);
        s.addInstr(callInstr);

        return setResult;
    }
View Full Code Here

Examples of org.jruby.compiler.ir.operands.MethAddr

        Variable flag  = s.getNewTemporaryVariable();
        List<Operand> args = setupCallArgs(opElementAsgnNode.getArgsNode(), s);
        // SSS FIXME: Verify with Tom that I am not missing something here
        assert args.size() == 1;
        Operand  index = args.get(0);
        s.addInstr(new CallInstr(elt, new MethAddr("[]"), array, new Operand[] { index }, null));
        s.addInstr(new IsTrueInstr(flag, elt));
        s.addInstr(new BEQInstr(flag, BooleanLiteral.TRUE, l));
        Operand value = build(opElementAsgnNode.getValueNode(), s);
        s.addInstr(new CallInstr(elt, new MethAddr("[]="), array, new Operand[] { index, value }, null));
        s.addInstr(new CopyInstr(elt, value));
        s.addInstr(new LABEL_Instr(l));
        return elt;
    }
View Full Code Here

Examples of org.jruby.compiler.ir.operands.MethAddr

        Variable flag  = s.getNewTemporaryVariable();
        List<Operand> args = setupCallArgs(opElementAsgnNode.getArgsNode(), s);
        // SSS FIXME: Verify with Tom that I am not missing something here
        assert args.size() == 1;
        Operand  index = args.get(0);
        s.addInstr(new CallInstr(elt, new MethAddr("[]"), array, new Operand[] { index }, null));
        s.addInstr(new IsTrueInstr(flag, elt));
        s.addInstr(new BEQInstr(flag, BooleanLiteral.FALSE, l));
        Operand value = build(opElementAsgnNode.getValueNode(), s);
        s.addInstr(new CallInstr(elt, new MethAddr("[]="), array, new Operand[] { index, value }, null));
        s.addInstr(new CopyInstr(elt, value));
        s.addInstr(new LABEL_Instr(l));
        return elt;
    }
View Full Code Here

Examples of org.jruby.compiler.ir.operands.MethAddr

        List<Operand> args = setupCallArgs(opElementAsgnNode.getArgsNode(), s);
        // SSS FIXME: Verify with Tom that I am not missing something here
        assert args.size() == 1;
        Operand  index = args.get(0);
        Variable elt   = s.getNewTemporaryVariable();
        s.addInstr(new CallInstr(elt, new MethAddr("[]"), array, new Operand[] { index }, null));         // elt = a[index]
        Operand value = build(opElementAsgnNode.getValueNode(), s);                                       // Load 'value'
        String  operation = opElementAsgnNode.getOperatorName();
        s.addInstr(new CallInstr(elt, new MethAddr(operation), elt, new Operand[] { value }, null));      // elt = elt.OPERATION(value)
        // SSS: do not load the call result into 'elt' to eliminate the RAW dependency on the call
        // We already know what the result is going be .. we are just storing it back into the array
        Variable tmp = s.getNewTemporaryVariable();
        s.addInstr(new CallInstr(tmp, new MethAddr("[]="), array, new Operand[] { index, elt }, null));   // a[index] = elt
        return elt;
    }
View Full Code Here

Examples of org.jruby.compiler.ir.operands.MethAddr

    }

    public Operand buildVCall(VCallNode node, IRScope s) {
        List<Operand> args       = new ArrayList<Operand>(); args.add(getSelf(s));
        Variable      callResult = s.getNewTemporaryVariable();
        Instr         callInstr  = new CallInstr(callResult, new MethAddr(node.getName()), getSelf(s), NO_ARGS, null);
        s.addInstr(callInstr);
        return callResult;
    }
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.