Examples of IRMethod


Examples of org.jruby.compiler.ir.IRMethod

        // parent.
        if (root.getStaticScope().getModule() == null) { // If an eval this may already be setup.
            root.getStaticScope().setModule(runtime.getObject());
        }

        IRMethod rootMethod = root.getRootClass().getRootMethod();
        RubyModule metaclass = self.getMetaClass();

        InterpretedIRMethod method = new InterpretedIRMethod(rootMethod, metaclass);

        IRubyObject rv =  method.call(runtime.getCurrentContext(), self, metaclass, "", new IRubyObject[]{});
View Full Code Here

Examples of org.jruby.compiler.ir.IRMethod

        if (c != null) {
            System.out.println("\nGraph:\n" + c.getGraph().toString());
            System.out.println("\nInstructions:\n" + c.toStringInstrs());
        } else if (s instanceof IRMethod) {
            IRMethod m = (IRMethod)s;
            System.out.println("\n  instrs:\n" + m.toStringInstrs());
            System.out.println("\n  live variables:\n" + m.toStringVariables());
        }
    }
View Full Code Here

Examples of org.jruby.compiler.ir.IRMethod

    public void run(IRScope s) {
        if (s instanceof IRMethod) {
           CFG       c  = ((IRMethod)s).getCFG();
           IRModule m  = s.getNearestModule();
           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();
View Full Code Here

Examples of org.jruby.compiler.ir.IRMethod

    }

    public void run(IRScope s) {
        if (!(s instanceof IRMethod)) return;

        IRMethod m = (IRMethod) s;
        //        if (m.requiresBinding()) {
        CFG c = m.getCFG();
        BindingStorePlacementProblem fsp = new BindingStorePlacementProblem();
        fsp.setup(c);
        fsp.compute_MOP_Solution();
        fsp.addStoreAndBindingAllocInstructions();
View Full Code Here

Examples of org.jruby.compiler.ir.IRMethod

                            r = v;
                    }

                    // Check if we can optimize this call based on the receiving method and receiver type
                    // Use the simplified receiver!
                    IRMethod rm = call.getTargetMethodWithReceiver(r);
                    if (rm != null) {
                        IRModule rc = rm.getDefiningIRModule();
                        if (rc != null) { // TODO: I am fairly sure I am wallpapering
                            if (rc.isCoreClass("Fixnum")) {
                                Operand[] args = call.getOperands();
                                if (args[2].isConstant()) {
                                    addMethodGuard(rm, deoptLabel, versionMap, instrs);
                                    val = ((Fixnum) r).computeValue(rm.getName(), (Constant) args[2]);
                                }
                            } else if (rc.isCoreClass("Float")) {
                                Operand[] args = call.getOperands();
                                if (args[2].isConstant()) {
                                    addMethodGuard(rm, deoptLabel, versionMap, instrs);
                                    val = ((Float) r).computeValue(rm.getName(), (Constant) args[2]);
                                }
                            } else if (rc.isCoreClass("Array")) {
                                Operand[] args = call.getOperands();
                                if (args[2] instanceof Fixnum && (rm.getName() == "[]")) {
                                    addMethodGuard(rm, deoptLabel, versionMap, instrs);
                                    val = ((Array) r).fetchCompileTimeArrayElement(((Fixnum) args[2]).value.intValue(), false);
                                }
                            }
                        }
View Full Code Here

Examples of org.jruby.compiler.ir.IRMethod

    // Can this call lead to ruby code getting modified? 
    // If we don't know what method we are calling, we assume it can (pessimistic, but safe!)
    // If we do know the target method, we ask the method itself whether it modifies ruby code
    public boolean canModifyCode() {
        IRMethod method = getTargetMethod();

        return method == null ? true : method.modifiesCode();
    }
View Full Code Here

Examples of org.jruby.compiler.ir.IRMethod

        return !n.equals("each") && !n.equals("inject") && !n.equals("+") && !n.equals("*") && !n.equals("+=") && !n.equals("*=");
        }
         **/

        Operand r = getReceiver();
        IRMethod rm = getTargetMethodWithReceiver(r);

        // If we don't know the method we are dispatching to, or if we know that the method can capture the callers frame,
        // we are in deep doo-doo.  We will need to store all variables in the call frame.
        //
        // SSS FIXME:
        // This is a "static" check and at some point during the execution, the caller's code could change and capture the binding at that point!
        // We need to set a compilation flag that records this dependency on the caller, so that this method can be recompiled whenever
        // the caller changes.
        return ((rm == null) || rm.canCaptureCallersBinding());
    }
View Full Code Here

Examples of org.jruby.compiler.ir.IRMethod

               if (count == null) {
                  count = new Integer(1);
               } else {
                  count = new Integer(count + 1);
                  if ((count > 50) && (m instanceof InterpretedIRMethod) && (_profile.size() == 1)) {
                     IRMethod inlineableMethod = ((InterpretedIRMethod)m).method;
                     _profile.remove(m); // remove it because the interpreter might ignore this hint
                     throw new org.jruby.interpreter.InlineMethodHint(inlineableMethod);
                  }
               }
               _profile.put(m, count);
View Full Code Here

Examples of org.jruby.compiler.ir.IRMethod

        }
        method().invokeVirtual(Type.getType(Object.class), Method.getMethod("Object " + call.getMethodAddr() + " ()"));
    }

    public void emitDEF_INST_METH(DefineInstanceMethodInstr instr) {
        IRMethod irMethod = instr.method;
        GeneratorAdapter adapter = new GeneratorAdapter(ACC_PUBLIC, Method.getMethod("void " + irMethod.getName() + " ()"), null, null, cls());
        adapter.loadThis();
        adapter.loadArgs();
        adapter.invokeStatic(Type.getType(Object.class), Method.getMethod("Object __ruby__" + irMethod.getName() + " (Object)"));
        adapter.returnValue();
        adapter.endMethod();
    }
View Full Code Here

Examples of org.jruby.compiler.ir.IRMethod

        adapter.returnValue();
        adapter.endMethod();
    }

    public void emitDEF_CLS_METH(DefineClassMethodInstr instr) {
        IRMethod irMethod = instr.method;
        GeneratorAdapter adapter = new GeneratorAdapter(ACC_PUBLIC | ACC_STATIC, Method.getMethod("void " + irMethod.getName() + " ()"), null, null, cls());
        adapter.returnValue();
        adapter.endMethod();
    }
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.