Mercurial > hg > Members > anatofuz > slides
comparison slides/2018/06/05/zip.txt @ 47:32e35be2ce71
auto-Update generated slides by script
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 26 Jun 2018 22:41:26 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
46:8972d59ad904 | 47:32e35be2ce71 |
---|---|
1 2018-05-29---- | |
2 ❯ lldb -- /Users/anatofuz/workspace/cr/Basic/build_perl6/bin/moar nqp.moarvm examples/hello_world.nqp [13:52:54] | |
3 (lldb) target create "/Users/anatofuz/workspace/cr/Basic/build_perl6/bin/moar" | |
4 Current executable set to '/Users/anatofuz/workspace/cr/Basic/build_perl6/bin/moar' (x86_64). | |
5 (lldb) settings set -- target.run-args "nqp.moarvm" "examples/hello_world.nqp" | |
6 (lldb) b add_bb_facts | |
7 Breakpoint 1: where = libmoar.dylib`add_bb_facts + 32 at facts.c:362, address = 0x0000000000118540 | |
8 (lldb) c | |
9 error: invalid process | |
10 (lldb) run | |
11 Process 8479 launched: '/Users/anatofuz/workspace/cr/Basic/build_perl6/bin/moar' (x86_64) | |
12 Process 8479 stopped | |
13 * thread #2, stop reason = breakpoint 1.1 | |
14 frame #0: 0x00000001001bb540 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:362 | |
15 359 MVMint32 i, is_phi; | |
16 360 | |
17 361 /* Look for instructions that provide or propagate facts. */ | |
18 -> 362 MVMSpeshIns *ins = bb->first_ins; | |
19 363 while (ins) { | |
20 364 /* See if there's deopt and logged annotations. Sync cur_deopt_idx | |
21 365 * and, for logged+deopt-one, add logged facts and guards. */ | |
22 Target 0: (moar) stopped. | |
23 (lldb) bt | |
24 * thread #2, stop reason = breakpoint 1.1 | |
25 * frame #0: 0x00000001001bb540 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:362 | |
26 frame #1: 0x00000001001bb503 libmoar.dylib`MVM_spesh_facts_discover(tc=0x0000000100802e30, g=0x0000000100f4efe0, p=0x0000000100f514d0) at facts.c:659 | |
27 frame #2: 0x00000001001b4eb7 libmoar.dylib`MVM_spesh_candidate_add(tc=0x0000000100802e30, p=0x0000000100f514d0) at candidate.c:61 | |
28 frame #3: 0x00000001001cf991 libmoar.dylib`worker(tc=0x0000000100802e30, callsite=0x00000001006c9150, args=0x0000000000000000) at worker.c:16 | |
29 frame #4: 0x000000010014e8e2 libmoar.dylib`invoke_handler(tc=0x0000000100802e30, invokee=0x0000000102014840, callsite=0x00000001006c9150, args=0x0000000000000000) at MVMCFunction.c:9 | |
30 frame #5: 0x00000001000e8494 libmoar.dylib`thread_initial_invoke(tc=0x0000000100802e30, data=0x0000000100802050) at threads.c:59 | |
31 frame #6: 0x00000001000aefee libmoar.dylib`MVM_interp_run(tc=0x0000000100802e30, initial_invoke=(libmoar.dylib`thread_initial_invoke at threads.c:50), invoke_data=0x0000000100802050) at interp.c:93 | |
32 frame #7: 0x00000001000e7a35 libmoar.dylib`start_thread(data=0x0000000100802050) at threads.c:87 | |
33 frame #8: 0x00007fff7b9fe661 libsystem_pthread.dylib`_pthread_body + 340 | |
34 frame #9: 0x00007fff7b9fe50d libsystem_pthread.dylib`_pthread_start + 377 | |
35 frame #10: 0x00007fff7b9fdbf9 libsystem_pthread.dylib`thread_start + 13 | |
36 | |
37 (lldb) n | |
38 Process 8479 stopped | |
39 * thread #2, stop reason = step over | |
40 frame #0: 0x00000001001bb579 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:370 | |
41 367 MVMSpeshAnn *ann_deopt_one = NULL; | |
42 368 MVMSpeshAnn *ann_logged = NULL; | |
43 369 MVMint32 is_deopt_ins = 0; | |
44 -> 370 while (ann) { | |
45 371 switch (ann->type) { | |
46 372 case MVM_SPESH_ANN_DEOPT_ONE_INS: | |
47 373 ann_deopt_one = ann; | |
48 Target 0: (moar) stopped. | |
49 (lldb) | |
50 Process 8479 stopped | |
51 * thread #2, stop reason = step over | |
52 frame #0: 0x00000001001bb620 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:385 | |
53 382 } | |
54 383 ann = ann->next; | |
55 384 } | |
56 -> 385 if (ann_deopt_one && ann_logged) | |
57 386 log_facts(tc, g, bb, ins, p, ann_deopt_one, ann_logged); | |
58 387 | |
59 388 /* Look through operands for reads and writes. */ | |
60 Target 0: (moar) stopped. | |
61 (lldb) l | |
62 389 is_phi = ins->info->opcode == MVM_SSA_PHI; | |
63 390 for (i = 0; i < ins->info->num_operands; i++) { | |
64 391 /* Reads need usage tracking; if the read is after a deopt point | |
65 392 * relative to the write then give it an extra usage bump. */ | |
66 393 if ((is_phi && i > 0) | |
67 394 || (!is_phi && (ins->info->operands[i] & MVM_operand_rw_mask) == MVM_operand_read_reg)) { | |
68 395 MVMSpeshFacts *facts = &(g->facts[ins->operands[i].reg.orig][ins->operands[i].reg.i]); | |
69 (lldb) l | |
70 396 facts->usages += facts->deopt_idx == cur_deopt_idx ? 1 : 2; | |
71 397 } | |
72 398 | |
73 399 /* Writes need the current deopt index and the writing instruction | |
74 400 * to be specified. A write that's on a deopt instruction bumps | |
75 401 * the usage too. */ | |
76 402 if ((is_phi && i == 0) | |
77 (lldb) n | |
78 Process 8479 stopped | |
79 * thread #2, stop reason = step over | |
80 frame #0: 0x00000001001bb65b libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:389 | |
81 386 log_facts(tc, g, bb, ins, p, ann_deopt_one, ann_logged); | |
82 387 | |
83 388 /* Look through operands for reads and writes. */ | |
84 -> 389 is_phi = ins->info->opcode == MVM_SSA_PHI; | |
85 390 for (i = 0; i < ins->info->num_operands; i++) { | |
86 391 /* Reads need usage tracking; if the read is after a deopt point | |
87 392 * relative to the write then give it an extra usage bump. */ | |
88 Target 0: (moar) stopped. | |
89 (lldb) p MVM_SSA_PHI | |
90 error: use of undeclared identifier 'MVM_SSA_PHI' | |
91 (lldb) nexr | |
92 error: 'nexr' is not a valid command. | |
93 error: Unrecognized command 'nexr'. | |
94 (lldb) n | |
95 Process 8479 stopped | |
96 * thread #2, stop reason = step over | |
97 frame #0: 0x00000001001bb677 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:390 | |
98 387 | |
99 388 /* Look through operands for reads and writes. */ | |
100 389 is_phi = ins->info->opcode == MVM_SSA_PHI; | |
101 -> 390 for (i = 0; i < ins->info->num_operands; i++) { | |
102 391 /* Reads need usage tracking; if the read is after a deopt point | |
103 392 * relative to the write then give it an extra usage bump. */ | |
104 393 if ((is_phi && i > 0) | |
105 Target 0: (moar) stopped. | |
106 (lldb) p is_phi | |
107 (MVMint32) $14 = 0 | |
108 (lldb) p ins | |
109 (MVMSpeshIns *) $15 = 0x0000000102115e60 | |
110 (lldb) p *ins | |
111 (MVMSpeshIns) $16 = { | |
112 info = 0x00000001005757c0 | |
113 operands = 0x0000000000000000 | |
114 prev = 0x0000000000000000 | |
115 next = 0x0000000000000000 | |
116 annotations = 0x0000000000000000 | |
117 } | |
118 (lldb) p *ins->info | |
119 (MVMOpInfo) $17 = { | |
120 opcode = 0 | |
121 name = 0x00000001002def92 "no_op" | |
122 mark = { | |
123 [0] = ' ' | |
124 [1] = ' ' | |
125 } | |
126 num_operands = 0 | |
127 pure = '\0' | |
128 deopt_point = '\0' | |
129 logged = '\0' | |
130 no_inline = '\0' | |
131 jittivity = '\0' | |
132 uses_hll = '\0' | |
133 operands = ([0] = '\0', [1] = '\0', [2] = '\0', [3] = '\0', [4] = '\0', [5] = '\0', [6] = '\0', [7] = '\0') | |
134 } | |
135 | |
136 | |
137 * profilingの箇所を見ていく | |
138 | |
139 * perlスクリプトをperl6に移植する | |
140 * markdownのparserみたいなのを書き換えてみるなど | |
141 * タイトループを早くするのか,ここのハッシュを早くするのか,オブジェクトのオペレーションを早くするのか… | |
142 * 手近な場所をとにかく見ていきたい | |
143 | |
144 * native codeをやるのかvmをやるのか | |
145 | |
146 * bytecode interpureter, gc関連を書き直すという手もある | |
147 | |
148 * gcc vs clang | |
149 | |
150 * llvm側でtail coll呼び出す時はフラグを見ている | |
151 * code grarであるというフラグを渡している感じ | |
152 | |
153 * script言語--> 上手く並列化出来ない | |
154 | |
155 * targetとしてCbCのコードを吐く | |
156 * 継続コード(meta level) | |
157 * 継続コードを見て計算結果を見て変えていく | |
158 * MoarVMのJIT,nqpのコンパイラにcbcを生成する部分を入れる | |
159 * perlccみたいなものをいれる | |
160 * targetのアプリケーション...whileでstring matchをする部分を最適化する | |
161 | |
162 * 正規表現の箇所をターゲットとして書くのも手…!? | |
163 * fileをmmapを使うかどうかなど | |
164 * 並列のgrep | |
165 * 早くなるには早くなる | |
166 * cache prefetchの処理でも高速化出来る | |
167 | |
168 | |
169 ---------- | |
170 2018-06-05---- | |
171 MoarVMが実際にインタプリタとして走っているのはMVM_interp_runという関数らしい. | |
172 これはスレッド毎に用意されるらしい | |
173 | |
174 定義自体は `src/core/interp.c`に書かれている | |
175 | |
176 MVMInstancとかいう構造体に全ての情報が入っている | |
177 | |
178 MVM_cu_map_from_fileでスレッド情報とファイルから生成した結果をMVMCompUnit構造体として生成している | |
179 | |
180 DISPATCHでNEXT_OPを判断している,これはオペランドリストとswitch文が同じオーダーで書かれているので | |
181 最適化しやすいらしい | |
182 | |
183 MVM_interp_runの後DISPATCHというマクロでNEXT_OPというマクロに応じて処理を行っているが | |
184 これがMoarVMのバイトコードを一対一対応しているので5000行のcase文が生成されている | |
185 | |
186 | |
187 ---------- |