public ArgsNode getArgsNode() { return realMethod.getArgsNode(); }
public ArgsNode getArgsNode() { return realMethod.getArgsNode(); }
public JITClassGenerator(String className, String methodName, String key, Ruby ruby, DefaultMethod method, JITCounts counts) { this.packageName = JITCompiler.RUBY_JIT_PREFIX; if (RubyInstanceConfig.JAVA_VERSION == Opcodes.V1_7 || Options.COMPILE_INVOKEDYNAMIC.load() == true) { // Some versions of Java 7 seems to have a bug that leaks definitions across cousin classloaders // so we force the class name to be unique to this runtime. // Also, invokedynamic forces us to make jitted code unique to each runtime, since the call sites cache // at class level rather than at our runtime level. This makes it impossible to share jitted code // across runtimes. digestString = key + Math.abs(ruby.hashCode()); } else { digestString = key; } this.className = packageName + "/" + className.replace('.', '/') + CLASS_METHOD_DELIMITER + JavaNameMangler.mangleMethodName(methodName) + "_" + digestString; this.name = this.className.replaceAll("/", "."); this.bodyNode = method.getBodyNode(); this.argsNode = method.getArgsNode(); this.methodName = methodName; filename = calculateFilename(argsNode, bodyNode); staticScope = method.getStaticScope(); asmCompiler = new StandardASMCompiler(this.className, filename); this.ruby = ruby; this.counts = counts; }
public JITClassGenerator(String className, String methodName, String key, Ruby ruby, DefaultMethod method, JITCounts counts) { this.packageName = JITCompiler.RUBY_JIT_PREFIX; if (RubyInstanceConfig.JAVA_VERSION == Opcodes.V1_7 || Options.COMPILE_INVOKEDYNAMIC.load() == true) { // Some versions of Java 7 seems to have a bug that leaks definitions across cousin classloaders // so we force the class name to be unique to this runtime. // Also, invokedynamic forces us to make jitted code unique to each runtime, since the call sites cache // at class level rather than at our runtime level. This makes it impossible to share jitted code // across runtimes. digestString = getHashForString(key) + Math.abs(ruby.hashCode()); } else { digestString = getHashForString(key); } this.className = packageName + "/" + className.replace('.', '/') + CLASS_METHOD_DELIMITER + JavaNameMangler.mangleMethodName(methodName) + "_" + digestString; this.name = this.className.replaceAll("/", "."); this.bodyNode = method.getBodyNode(); this.argsNode = method.getArgsNode(); this.methodName = methodName; filename = calculateFilename(argsNode, bodyNode); staticScope = method.getStaticScope(); asmCompiler = new StandardASMCompiler(this.className, filename); this.ruby = ruby; this.counts = counts; }
/** * Visit methods contained in the specified class using the given visitor. * * @param visitor the visitor to use * @param mod the module/class whose methods to visit */ private static void visitMethods(NodeVisitor visitor, RubyModule mod) { for (DynamicMethod method : mod.getNonIncludedClass().getMethods().values()) { DynamicMethod realMethod = method.getRealMethod(); List<Node> args, body; if (method instanceof DefaultMethod) { DefaultMethod defaultMethod = ((DefaultMethod) realMethod); args = defaultMethod.getArgsNode().childNodes(); body = defaultMethod.getBodyNode().childNodes(); } else if (method instanceof InterpretedMethod) { InterpretedMethod interpretedMethod = ((InterpretedMethod) realMethod); args = interpretedMethod.getArgsNode().childNodes(); body = interpretedMethod.getBodyNode().childNodes(); } else { return; } for (int i = 0; i < args.size(); i++) args.get(i).accept(visitor); for (int i = 0; i < body.size(); i++) body.get(i).accept(visitor); } }
String key = SexpMaker.create(methodName, method.getArgsNode(), method.getBodyNode()); JITClassGenerator generator = new JITClassGenerator(className, methodName, key, runtime, method, counts);
String key = SexpMaker.sha1(methodName, method.getArgsNode(), method.getBodyNode()); JITClassGenerator generator = new JITClassGenerator(className, methodName, key, runtime, method, counts);
/** * Visit methods contained in the specified class using the given visitor. * * @param visitor the visitor to use * @param mod the module/class whose methods to visit */ private static void visitMethods(NodeVisitor visitor, RubyModule mod) { for (DynamicMethod method : mod.getNonIncludedClass().getMethods().values()) { DynamicMethod realMethod = method.getRealMethod(); if (method instanceof DefaultMethod) { for (Node node : ((DefaultMethod) realMethod).getArgsNode().childNodes()) { node.accept(visitor); } for (Node node : ((DefaultMethod) realMethod).getBodyNode().childNodes()) { node.accept(visitor); } } else if (method instanceof InterpretedMethod) { for (Node node : ((InterpretedMethod) realMethod).getArgsNode().childNodes()) { node.accept(visitor); } for (Node node : ((InterpretedMethod) realMethod).getBodyNode().childNodes()) { node.accept(visitor); } } } }