Last active
April 10, 2018 08:12
-
-
Save rednaxelafx/df1f708f507a6934c685eebb7ba213c1 to your computer and use it in GitHub Desktop.
JRuby 9.1.6.0 example of massign (paralle assignment) optimized
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jit.dumping=true | |
jit.logging=true | |
jit.logging.verbose=true | |
jit.threshold=500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(a, b, c) | |
a, b, c = c, a, b | |
a | |
end | |
(501+20000).times { foo(1, 2, 3) } | |
__END__ | |
foo is optimized by JRuby and HotSpot Server Compiler into equivalent of: | |
def foo(a, b, c) | |
c | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ~/sdk/jruby-9.1.6.0/bin/jirb | |
2017-01-09T13:27:23.030-08:00: Ruby: compiled: ~/sdk/jruby-9.1.6.0/bin/jirb | |
irb(main):001:0> def foo(a, b, c) | |
irb(main):002:1> a, b, c = c, a, b | |
irb(main):003:1> a | |
irb(main):004:1> end | |
=> nil | |
irb(main):005:0> (501+20000).times { foo(1, 2, 3) } | |
// class version 51.0 (51) | |
// access flags 0x21 | |
public class rubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006 extends org/jruby/ast/executable/AbstractScript { | |
// compiled from: (irb) | |
// debug info: /private/tmp/test_jruby/(irb) | |
// access flags 0x100A | |
private static setPosition(Lorg/jruby/runtime/ThreadContext;I)V | |
ALOAD 0 | |
LDC "(irb)" | |
ILOAD 1 | |
INVOKEVIRTUAL org/jruby/runtime/ThreadContext.setFileAndLine (Ljava/lang/String;I)V | |
RETURN | |
MAXSTACK = 3 | |
MAXLOCALS = 2 | |
// access flags 0x1 | |
public <init>()V | |
ALOAD 0 | |
INVOKESPECIAL org/jruby/ast/executable/AbstractScript.<init> ()V | |
ALOAD 0 | |
LDC "(irb)" | |
PUTFIELD rubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006.filename : Ljava/lang/String; | |
ALOAD 0 | |
NEW org/jruby/ast/executable/RuntimeCache | |
DUP | |
INVOKESPECIAL org/jruby/ast/executable/RuntimeCache.<init> ()V | |
PUTFIELD org/jruby/ast/executable/AbstractScript.runtimeCache : Lorg/jruby/ast/executable/RuntimeCache; | |
ALOAD 0 | |
LDC "\uffff\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" | |
INVOKEVIRTUAL org/jruby/ast/executable/AbstractScript.initFromDescriptor (Ljava/lang/String;)V | |
RETURN | |
MAXSTACK = 3 | |
MAXLOCALS = 1 | |
// access flags 0x9 | |
public static __file__(Lrubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject; | |
@Lorg/jruby/anno/JRubyMethod;(name="__file__", frame=true, required=3, optional=0, rest=false) | |
L0 | |
ALOAD 3 | |
ASTORE 11 | |
ALOAD 4 | |
ASTORE 12 | |
ALOAD 5 | |
ASTORE 13 | |
L1 | |
LINENUMBER 2 L1 | |
ALOAD 13 | |
ALOAD 11 | |
ALOAD 12 | |
DUP_X2 | |
POP | |
SWAP | |
ASTORE 11 | |
ASTORE 12 | |
ASTORE 13 | |
L2 | |
LINENUMBER 3 L2 | |
ALOAD 11 | |
ARETURN | |
LOCALVARIABLE a Lorg/jruby/runtime/builtin/IRubyObject; L0 L0 11 | |
LOCALVARIABLE b Lorg/jruby/runtime/builtin/IRubyObject; L0 L0 12 | |
LOCALVARIABLE c Lorg/jruby/runtime/builtin/IRubyObject; L0 L0 13 | |
MAXSTACK = 4 | |
MAXLOCALS = 14 | |
// access flags 0x1 | |
public __file__(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;[Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject; | |
ALOAD 0 | |
ALOAD 1 | |
ALOAD 2 | |
ALOAD 3 | |
ALOAD 4 | |
INVOKESTATIC rubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006.__file__ (Lrubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;[Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject; | |
ARETURN | |
MAXSTACK = 5 | |
MAXLOCALS = 5 | |
// access flags 0x1 | |
public __file__(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject; | |
ALOAD 0 | |
ALOAD 1 | |
ALOAD 2 | |
ALOAD 3 | |
ALOAD 4 | |
ALOAD 5 | |
ALOAD 6 | |
INVOKESTATIC rubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006.__file__ (Lrubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject; | |
ARETURN | |
MAXSTACK = 7 | |
MAXLOCALS = 7 | |
// access flags 0x1009 | |
public static __file__(Lrubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;[Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject; | |
ALOAD 1 | |
ALOAD 3 | |
ICONST_3 | |
INVOKESTATIC org/jruby/runtime/Helpers.checkArgumentCount (Lorg/jruby/runtime/ThreadContext;[Lorg/jruby/runtime/builtin/IRubyObject;I)V | |
ALOAD 0 | |
ALOAD 1 | |
ALOAD 2 | |
ALOAD 3 | |
LDC 0 | |
AALOAD | |
ALOAD 3 | |
LDC 1 | |
AALOAD | |
ALOAD 3 | |
LDC 2 | |
AALOAD | |
ALOAD 4 | |
INVOKESTATIC rubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006.__file__ (Lrubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject; | |
ARETURN | |
MAXSTACK = 7 | |
MAXLOCALS = 5 | |
} | |
2017-01-09T13:27:26.311-08:00: JITCompiler: done jitting:Object.Object.foo at (irb):1 | |
=> 20501 | |
irb(main):006:0> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static __file__(Lrubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd231043998006;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject; | |
@Lorg/jruby/anno/JRubyMethod;(name="__file__", frame=true, required=3, optional=0, rest=false) | |
L0 | |
ALOAD 3 | |
ASTORE 11 | |
ALOAD 4 | |
ASTORE 12 | |
ALOAD 5 | |
ASTORE 13 | |
L1 | |
LINENUMBER 2 L1 | |
ALOAD 13 | |
ALOAD 11 | |
ALOAD 12 | |
DUP_X2 | |
POP | |
SWAP | |
ASTORE 11 | |
ASTORE 12 | |
ASTORE 13 | |
L2 | |
LINENUMBER 3 L2 | |
ALOAD 11 | |
ARETURN | |
LOCALVARIABLE a Lorg/jruby/runtime/builtin/IRubyObject; L0 L0 11 | |
LOCALVARIABLE b Lorg/jruby/runtime/builtin/IRubyObject; L0 L0 12 | |
LOCALVARIABLE c Lorg/jruby/runtime/builtin/IRubyObject; L0 L0 13 | |
MAXSTACK = 4 | |
MAXLOCALS = 14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ JAVA_OPTS="-XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly" ~/sdk/jruby-9.1.6.0/bin/jirb | |
... | |
Decoding compiled method 0x000000010772e990: | |
Code: | |
[Entry Point] | |
[Constants] | |
# {method} '__file__' '(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject;' in 'rubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd23594590671' | |
# this: rsi:rsi = 'rubyjit/Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd23594590671' | |
# parm0: rdx:rdx = 'org/jruby/runtime/ThreadContext' | |
# parm1: rcx:rcx = 'org/jruby/runtime/builtin/IRubyObject' | |
# parm2: r8:r8 = 'org/jruby/runtime/builtin/IRubyObject' | |
# parm3: r9:r9 = 'org/jruby/runtime/builtin/IRubyObject' | |
# parm4: rdi:rdi = 'org/jruby/runtime/builtin/IRubyObject' | |
# parm5: [sp+0x20] = 'org/jruby/runtime/Block' (sp of caller) | |
0x000000010772eac0: mov 0x8(%rsi),%r10d | |
0x000000010772eac4: shl $0x3,%r10 | |
0x000000010772eac8: cmp %r10,%rax | |
0x000000010772eacb: jne 0x000000010768d960 ; {runtime_call} | |
0x000000010772ead1: data32 xchg %ax,%ax | |
0x000000010772ead4: nopl 0x0(%rax,%rax,1) | |
0x000000010772eadc: data32 data32 xchg %ax,%ax | |
[Verified Entry Point] | |
0x000000010772eae0: sub $0x18,%rsp | |
0x000000010772eae7: mov %rbp,0x10(%rsp) ;*synchronization entry | |
; - rubyjit.Object$$foo_4bf0e5f1cc4a54c5f4e2f8727e91176c740fdd23594590671::__file__@-1 | |
0x000000010772eaec: mov %rdi,%rax | |
0x000000010772eaef: add $0x10,%rsp | |
0x000000010772eaf3: pop %rbp | |
0x000000010772eaf4: test %eax,-0x158eafa(%rip) # 0x00000001061a0000 | |
; {poll_return} | |
0x000000010772eafa: retq | |
0x000000010772eafb: hlt | |
0x000000010772eafc: hlt | |
0x000000010772eafd: hlt | |
0x000000010772eafe: hlt | |
0x000000010772eaff: hlt | |
[Exception Handler] | |
[Stub Code] | |
0x000000010772eb00: jmpq 0x00000001076b98e0 ; {no_reloc} | |
[Deopt Handler Code] | |
0x000000010772eb05: callq 0x000000010772eb0a | |
0x000000010772eb0a: subq $0x5,(%rsp) | |
0x000000010772eb0f: jmpq 0x000000010768eb00 ; {runtime_call} | |
0x000000010772eb14: hlt | |
0x000000010772eb15: hlt | |
0x000000010772eb16: hlt | |
0x000000010772eb17: hlt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment