Slide 1

Slide 1 text

RUBY EM TODOS OS LUGARES E DISPOSITIVOS @carlosbrando e @luisbebop

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Por que VMs?

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

7

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

03 de Novembro de 2012 RubyConf Brazil mRuby JavaScript Picol

Slide 13

Slide 13 text

Por que tinyvm? 03 de Novembro de 2012 RubyConf Brazil https://github.com/GenTiradentes/tinyvm.git

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

03 de Novembro de 2012 640K ought to be enough for anybody. “ ” Bill Gates, 1981 RubyConf Brazil whatever

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Ruby => Assembly 03 de Novembro de 2012 RubyConf Brazil

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Tipos complexos Strings Float Arrays Hashs

Slide 20

Slide 20 text

ARRAY DE VARIÁVEIS 0 1 2 10 HASHTABLE 0x75EC78 0x80BACD 0x75EC78 *STRING 0x80BACD *HASH (void *) (void *)

Slide 21

Slide 21 text

Treetop YARV Melbourne (Rubinius) Sexp Processor Parse tree

Slide 22

Slide 22 text

YARV YARV Koichi Sasada

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Vamos começar com algo bem simples

Slide 26

Slide 26 text

Vamos começar com algo bem simples

Slide 27

Slide 27 text

puts "Hello RubyConf" STACK HEAP RUBY

Slide 28

Slide 28 text

== disasm: @>========== 0000 putnil ( 1) 0001 putstring "Hello RubyConf" 0003 send :puts, 1, nil, 8, 0009 leave STACK HEAP YARV

Slide 29

Slide 29 text

.LC0: .string "Hello RubyConf" start: push .LC0 pop eax prn eax jmp leave leave: STACK HEAP ASSEMBLY

Slide 30

Slide 30 text

.LC0: .string "Hello RubyConf" start: push .LC0 pop eax prn eax jmp leave leave: STACK HEAP ASSEMBLY

Slide 31

Slide 31 text

STACK .LC0: .string "Hello RubyConf" start: push .LC0 pop eax prn eax jmp leave leave: HEAP ASSEMBLY "Hello RubyConf"

Slide 32

Slide 32 text

.LC0: .string "Hello RubyConf" start: push .LC0 pop eax prn eax jmp leave leave: HEAP ASSEMBLY STACK eax = "Hello RubyConf"

Slide 33

Slide 33 text

.LC0: .string "Hello RubyConf" start: push .LC0 pop eax prn eax jmp leave leave: HEAP ASSEMBLY STACK eax = "Hello RubyConf"

Slide 34

Slide 34 text

.LC0: .string "Hello RubyConf" start: push .LC0 pop eax prn eax pop ebp jmp leave leave: HEAP ASSEMBLY STACK eax = "Hello RubyConf" > Hello RubyConf

Slide 35

Slide 35 text

.LC0: .string "Hello RubyConf" start: push .LC0 pop eax prn eax jmp leave leave: HEAP ASSEMBLY STACK eax = "Hello RubyConf"

Slide 36

Slide 36 text

.LC0: .string "Hello RubyConf" start: push .LC0 pop eax prn eax jmp leave leave: HEAP ASSEMBLY eax = "Hello RubyConf" STACK

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Vamos complicar um pouco

Slide 39

Slide 39 text

def say_hello(name) puts "Hello, " + name end say_hello("Brando e Luis") STACK HEAP RUBY

Slide 40

Slide 40 text

STACK HEAP == disasm: @>========== 0000 putspecialobject 1 ( 1) 0002 putspecialobject 2 0004 putobject :say_hello 0006 putiseq say_hello 0008 send :"core#define_method", 3, nil, 0, 0014 pop 0015 putnil ( 5) 0016 putstring "Brando e Luis" 0018 send :say_hello, 1, nil, 8, 0024 leave == disasm: >=========== local table (size: 2, argc: 1 [opts: 0, rest: -1, post: 0, block: -1] s1) [ 2] name 0000 putnil ( 2) 0001 putstring "Hello, " 0003 getlocal name 0005 opt_plus 0007 send :puts, 1, nil, 8, 0013 leave YARV

Slide 41

Slide 41 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret start: push .LC0 call say_hello jmp leave leave: STACK HEAP ASSEMBLY

Slide 42

Slide 42 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " start: push .LC0 call say_hello jmp leave leave: STACK HEAP ASSEMBLY

Slide 43

Slide 43 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " start: push .LC0 call say_hello jmp leave leave: STACK HEAP ASSEMBLY

Slide 44

Slide 44 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " start: push .LC0 call say_hello jmp leave leave: STACK HEAP ASSEMBLY "Brando e Luis"

Slide 45

Slide 45 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " start: push .LC0 call say_hello jmp leave leave: STACK HEAP ASSEMBLY "Brando e Luis" 0xFF

Slide 46

Slide 46 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY "Brando e Luis" 0xFF

Slide 47

Slide 47 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY "Brando e Luis" r10 = 0xFF

Slide 48

Slide 48 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis"

Slide 49

Slide 49 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, "

Slide 50

Slide 50 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, " ebx = "Brando e Luis"

Slide 51

Slide 51 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY edi = "Hello, Brando e Luis" r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, " ebx = "Brando e Luis"

Slide 52

Slide 52 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, Brando e Luis" ebx = "Brando e Luis" edi = "Hello, Brando e Luis"

Slide 53

Slide 53 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, Brando e Luis" ebx = "Brando e Luis" edi = "Hello, Brando e Luis"

Slide 54

Slide 54 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, Brando e Luis" ebx = "Brando e Luis" edi = "Hello, Brando e Luis" edi = "Hello, Brando e Luis" > Hello, Brando e Luis

Slide 55

Slide 55 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, Brando e Luis" ebx = "Brando e Luis" 0xFF edi = "Hello, Brando e Luis"

Slide 56

Slide 56 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " say_hello: pop r10 pop [20002] mov eax, .LC1 mov ebx, [20002] strcat eax, ebx mov eax, edi prn eax push r10 ret STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, Brando e Luis" ebx = "Brando e Luis" 0xFF edi = "Hello, Brando e Luis"

Slide 57

Slide 57 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " start: push .LC0 call say_hello jmp leave leave: STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, Brando e Luis" ebx = "Brando e Luis" edi = "Hello, Brando e Luis"

Slide 58

Slide 58 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " start: push .LC0 call say_hello jmp leave leave: STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, Brando e Luis" ebx = "Brando e Luis" edi = "Hello, Brando e Luis"

Slide 59

Slide 59 text

.LC0: .string "Brando e Luis" .LC1: .string "Hello, " start: push .LC0 call say_hello jmp leave leave: STACK HEAP ASSEMBLY r10 = 0xFF [20002] = "Brando e Luis" eax = "Hello, Brando e Luis" ebx = "Brando e Luis" edi = "Hello, Brando e Luis"

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

HARDCORE!!!

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Perguntas?

Slide 64

Slide 64 text

@carlosbrando @luisbebop Obrigado!