Present Online
Send the link below via email or IM to invite your audience
Start the presentation
- Invited audience will follow you as you navigate and present
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can view together your prezi
- Learn more about this feature in the manual
Download prezi for:
Present offline on a PC or Mac.
- Embedded YouTube videos need an active Internet connection to play.
- Portable prezis are not editable.
Edit and present offline with Prezi Desktop
- To open PEZ file, please download Prezi Desktop
Do you really want to delete this prezi?
Neither you, nor the coeditors you shared it with will be able to recover it again.
Make your likes visible on Facebook?
Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.
JRuby Hacking Guide
No description
by Hiroshi Nakamura
on 21 February 2011
Tweet
Prezi Transcript
JRuby
Hacking
Guide JRuby VM Scanner/Parser Java Integration Ruby Core objects org.jruby.java.*
org.jruby.javasupport.*
lib/ruby/site_ruby/shared/builtin/javasupport.rb
for accessing Java resources from Ruby Method | defined at runtime
CallSite | method invoker for each invocation
DynamicScope and Variables
Frame % jruby -S ast foo.rb
% ruby19 --dump=parsetree foo.rb Scanner
Ported CRuby's scanner
Parser
based on 'jay' parser generator
generates AST 3 interfaces
RedBridge | original
BSF
JSR223 org.jruby.Main.java (entry point)
org.jruby.Ruby.java (VM implementation)
org.jruby.RubyInstanceConfig.java
JRuby VM instance and runtime settings org.jruby.Ruby*.java
implements Ruby Core objects org.jruby.ast.*
represents Abstract Syntax Tree org.jruby.compiler.*
implements JRuby Compiler org.jruby.lexer.*
org.jruby.parser.*
implements Ruby scanner and parser org.jruby.internal.*
org.jruby.runtime.*
handles VM's runtime information org.jruby.embed.*
implements embedding interfaces for Java require 'java'
allow to access Java resource
'include_package'
include Java package to the namespace
'include_class'
include Java Class to the namespace org.jruby.ant.*
implements Ant task which runs Rake task
lib/ruby/site_ruby/shared/ant/ant.rb
Rake task which runs Ant task
Runnable as an Ant taks
Let Rake task run with JRuby VM by Hiroshi Nakamura
nahi@ruby-lang.org
@nahi org.jruby.Ruby*.java
org.jruby.ext.*
implements Extension objects
in Java
digest, zlib, mathn, socket, etc. Syntax
Analysis Garbage Collection generates one AST per one *.rb file Context Thread org.jruby.RubyThread.java
org.jruby.runtime.ThreadContext.java
org.jruby.internal.runtime.ThreadService.java
handles JRuby VM runtime information Fixnum and Float org.jruby.util.io.ChannelStream.java
implements FILE(stdio) org.jruby.util.io.ChannelDescriptor.java
implements fd and wraps;
Channel (NIO)
FileDescriptor (NIO)
fileno (virtual)
mode Generated from AST
basis of new JRuby Interpreter and JRuby JIT Compiler
will make IR level optimization easier
will make JRuby JIT Compiler efficient
org.jruby.compiler.ir.*
IR Builder and Compiler
org.jruby.interpreter.*
New JRuby Evaluator AST Compiler JRUBY_HOME/src Not really.
finalizer
fd
PermGen org.jruby.Ruby*.java
org.jruby.ext.*
org.jruby.lexer.*
org.jruby.parser.*
org.jruby.ast.*
org.jruby.Main.java
org.jruby.Ruby.java
org.jruby.internal.*
org.jruby.runtime.*
org.jruby.compiler.*
org.jruby.compiler.ir.*
org.jruby.interpreter.*
org.jruby.java.*
org.jruby.javasupport.*
org.jruby.embed.*
org.jruby.ant.* JRuby in 2002-12-11 Object Evaluator Compiler Integration Future Extension objects Ruby Object
is a
Java Object GC? there's nothing special
Let JVM work! Boxing
Fixnum cache IO Ruby Object is a Java Object
Defined Java class:
RubyBasicObject, RubyObject,
RubyModule, RubyString, RubyFixnum, etc.
For example... AST AOT and JIT Compiler Settings Interpreters & Compilers dynamic Java bytecode generation Nihongo-JRuby by Hirotsugu Asari
http://jruby-ja.blogspot.com/
JRuby Wiki | Design: Internals
http://kenai.com/projects/jruby/pages/Internals
Distilling JRuby by R.J. Lorimer
http://www.realjenius.com/category/article/distilling-jruby/
Dynamic Optimization by Charles
http://blog.headius.com/2010/05/kicking-jruby-performance-up-notch.html
InfoQ Article about IR
http://www.infoq.com/news/2009/11/jruby-ir
JRuby Compile Settings by NaHi
http://bit.ly/JRubyCompileSettings
JRuby Source Code Reading Guide
http://bit.ly/JRubySrcReadingGuide And the Future You saw "Keynote - JRuby: Pony Show", right? Further Reading JRuby Interpreter JRuby Interpreter Scanner&Parser JRuby Interpreter JRuby JIT Compiler
AST Compiler AOT Compiler
(jrubyc) JVM native machine code JVM JIT Compiler Embedding JRuby in Java Rake/Ant integration Scanner&Parser compatibility
meta-programming feature
Core objects compatibility
Ext objects compatibility
UNIX layer compatibility
Performance JRuby in 2010-08-28 Scanner&Parser compatibility
meta-programming feature
Core objects compatibility
Ext objects compatibility
UNIX layer compatibility
Performance OK
OK
OK
OK + jffi, c-ext
OK
OK for Server
Startup-time matters http://bit.ly/JRubyHackingGuide String ByteList as buffer
Encoding
ByteList operation ...except UTF-8 org.jruby.RubyFixnum.java
org.jruby.RubyFloat.java org.jruby.RubyString.java
org.jruby.RubyEncoding.java Excellent
NO
Poor
NO
NO
Poor
See the full transcript




