Thought I came up w/ talking w/ headius + kotlin dev
Have nonlocal return allowed only for blocks passed to fns that are either: macros, or take a specialized type that's generated from a yield
eg
class A
def foo
yield
ensure
puts "in ensure"
end
end
def bar
A.foo { return 1 }
end
and otherwise don't allow returns in blocks. That way it allows ppl to write libs that do NLR, but you have to do it conciously. Not sure if I like it that way, but it's a thought.
misuse JVM / things worked around
parsing: CRuby 12k LoC yacc JRuby: Jay parser 4k LoC
Parser problems: parser generates switch statment method that's big enough to need to be split into diff methods. Worked out by enveloping case bodies in tiny classes, several hundred o them.
JRuby uses byte arrays for backing its string impl because ruby & java string semantics radically different.
mixed mode vm running on a mixed mode vm has IR / JIT in JRuby land, but also AST interpreter. Just like JVM :p.
the JITed interpreter is faster than unJITed bytecode equivalent
##interpreter has had at least 4 diff versions
- original: visitor ast walking
- big giant switch statement
- experimental stackless IR
- current direct exec of AST
- exec state on artificial stack
##JRuby 9000
- newIR
- traditional IR compiler, can do trad compiler opto cuz IR not AST
- register based
- CFG, static analysis etc
##JVM tricks / problems manually splitting methods to get around 65k limit lack of class hierarchy analysis bites exceptions + everything being an expression tweaking JIT thingns make you sad unsafe 64bit strie camp byte arrays
##because JRuby strings != Java strings, ##ports ports ports Joni port of oniguruma
- bytecode engine, shallow callstack
- interruptable (java's isn't)
- reforked for nashorn to support char[]
JCodings
- char tables, transcoding tables etc
- faster than JDK for strings
###Fibers CRuby just performs stack swaps JRuby has to use java threads. keeps a pool for this to make creating them not super expensive
ObjectSpace in CRuby walks heap :(, JRuby has impl, but is off by default because it makes things slow.
JVMLS is good, but no women speaking. It is a small community, but really? Hmmm.