public Class compile(IRScope scope, ClassDefiningClassLoader jrubyClassLoader) { file = scope.getFile(); lastLine = -1; JVMVisitorMethodContext context = new JVMVisitorMethodContext(); return defineFromBytecode(scope, compileToBytecode(scope, context), jrubyClassLoader); }
public Class compile(IRScope scope, ClassDefiningClassLoader jrubyClassLoader) { file = scope.getFile(); lastLine = -1; JVMVisitorMethodContext context = new JVMVisitorMethodContext(); return defineFromBytecode(scope, compileToBytecode(scope, context), jrubyClassLoader); }
@SuppressWarnings("unchecked") protected void compile(JVMVisitorMethodContext context) { if (bytecode != null) return; // Time the compilation long start = System.nanoTime(); InterpreterContext ic = body.ensureInstrsReady(); int insnCount = ic.getInstructions().length; if (insnCount > Options.JIT_MAXSIZE.load()) { // methods with more than our limit of basic blocks are likely too large to JIT, so bail out throw new NotCompilableException("Could not compile " + body + "; instruction count " + insnCount + " exceeds threshold of " + Options.JIT_MAXSIZE.load()); } // This may not be ok since we'll end up running passes specific to JIT // CON FIXME: Really should clone scope before passes in any case bytecode = visitor.compileToBytecode(body.getIRScope(), context); compileTime = System.nanoTime() - start; }
@SuppressWarnings("unchecked") protected void compile(JVMVisitorMethodContext context) { if (bytecode != null) return; // Time the compilation long start = System.nanoTime(); InterpreterContext ic = body.ensureInstrsReady(); int insnCount = ic.getInstructions().length; if (insnCount > Options.JIT_MAXSIZE.load()) { // methods with more than our limit of basic blocks are likely too large to JIT, so bail out throw new NotCompilableException("Could not compile " + body + "; instruction count " + insnCount + " exceeds threshold of " + Options.JIT_MAXSIZE.load()); } // This may not be ok since we'll end up running passes specific to JIT // CON FIXME: Really should clone scope before passes in any case bytecode = visitor.compileToBytecode(body.getIRScope(), context); compileTime = System.nanoTime() - start; }
@SuppressWarnings("unchecked") protected void compile(JVMVisitorMethodContext context) { if (bytecode != null) return; // Time the compilation long start = System.nanoTime(); InterpreterContext ic = method.ensureInstrsReady(); int insnCount = ic.getInstructions().length; if (insnCount > Options.JIT_MAXSIZE.load()) { // methods with more than our limit of basic blocks are likely too large to JIT, so bail out throw new NotCompilableException("Could not compile " + method + "; instruction count " + insnCount + " exceeds threshold of " + Options.JIT_MAXSIZE.load()); } // This may not be ok since we'll end up running passes specific to JIT // CON FIXME: Really should clone scope before passes in any case bytecode = visitor.compileToBytecode(method.getIRScope(), context); // try { // java.io.FileOutputStream fos = new java.io.FileOutputStream(className + '#' + methodName + ".class"); // fos.write(bytecode); // fos.close(); // } catch (Exception e) { // e.printStackTrace(); // } compileTime = System.nanoTime() - start; }
@SuppressWarnings("unchecked") protected void compile(JVMVisitorMethodContext context) { if (bytecode != null) return; // Time the compilation long start = System.nanoTime(); InterpreterContext ic = method.ensureInstrsReady(); int insnCount = ic.getInstructions().length; if (insnCount > Options.JIT_MAXSIZE.load()) { // methods with more than our limit of basic blocks are likely too large to JIT, so bail out throw new NotCompilableException("Could not compile " + method + "; instruction count " + insnCount + " exceeds threshold of " + Options.JIT_MAXSIZE.load()); } // This may not be ok since we'll end up running passes specific to JIT // CON FIXME: Really should clone scope before passes in any case bytecode = visitor.compileToBytecode(method.getIRScope(), context); // try { // java.io.FileOutputStream fos = new java.io.FileOutputStream(className + '#' + methodName + ".class"); // fos.write(bytecode); // fos.close(); // } catch (Exception e) { // e.printStackTrace(); // } compileTime = System.nanoTime() - start; }
JVMVisitor visitor = new JVMVisitor(runtime); JVMVisitorMethodContext context = new JVMVisitorMethodContext(); bytecode = visitor.compileToBytecode(scope, context); Class compiled = visitor.defineFromBytecode(scope, bytecode, classLoader);
JVMVisitor visitor = new JVMVisitor(runtime); JVMVisitorMethodContext context = new JVMVisitorMethodContext(); bytecode = visitor.compileToBytecode(scope, context); Class compiled = visitor.defineFromBytecode(scope, bytecode, classLoader);
@JRubyMethod(module = true, name = "compile", required = 1, optional = 3) public static IRubyObject compile(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { // def compile(content = nil, filename = DEFAULT_FILENAME, extra_position_info = false, &block) final Ruby runtime = context.runtime; final RubyString content = args[0].convertToString(); args[0] = content; final RubyString filename = args.length > 1 ? args[1].convertToString() : RubyString.newEmptyString(runtime); IRScriptBody scope = compileIR(context, args, block); JVMVisitor visitor = new JVMVisitor(runtime); JVMVisitorMethodContext methodContext = new JVMVisitorMethodContext(); byte[] bytes = visitor.compileToBytecode(scope, methodContext); scope.getStaticScope().setModule( runtime.getTopSelf().getMetaClass() ); RubyClass CompiledScript = (RubyClass) runtime.getModule("JRuby").getConstantAt("CompiledScript"); // JRuby::CompiledScript#initialize(filename, class_name, content, bytes) return CompiledScript.newInstance(context, new IRubyObject[] { filename, scope.getName(), content, Java.getInstance(runtime, bytes) }, Block.NULL_BLOCK); }
@JRubyMethod(module = true, name = "compile", required = 1, optional = 3) public static IRubyObject compile(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { // def compile(content = nil, filename = DEFAULT_FILENAME, extra_position_info = false, &block) final Ruby runtime = context.runtime; final RubyString content = args[0].convertToString(); args[0] = content; final RubyString filename = args.length > 1 ? args[1].convertToString() : RubyString.newEmptyString(runtime); IRScriptBody scope = compileIR(context, args, block); JVMVisitor visitor = new JVMVisitor(runtime); JVMVisitorMethodContext methodContext = new JVMVisitorMethodContext(); byte[] bytes = visitor.compileToBytecode(scope, methodContext); scope.getStaticScope().setModule( runtime.getTopSelf().getMetaClass() ); RubyClass CompiledScript = (RubyClass) runtime.getModule("JRuby").getConstantAt("CompiledScript"); // JRuby::CompiledScript#initialize(filename, class_name, content, bytes) return CompiledScript.newInstance(context, new IRubyObject[] { filename, scope.getName(), content, Java.getInstance(runtime, bytes) }, Block.NULL_BLOCK); }