-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNOTES
609 lines (429 loc) · 19 KB
/
NOTES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
# Rely on llvm-config.
set(CONFIG_OUTPUT)
# find_program(LLVM_CONFIG "llvm-config")
set(LLVM_CONFIG "/Users/spinlock/src/llvm/llvm/build/bin/llvm-config")
https://stackoverflow.com/questions/34479428/lldb-in-android-studio-select-frame-does-not-work
https://stackoverflow.com/questions/16136258/how-can-i-automate-this-sequence-of-lldb-commands
https://www.unknowncheats.me/forum/general-programming-and-reversing/109735-mac-osx-memory-editing.html
./configure --with-debug-level=slowdebug --with-jobs=8 --with-jvm-variants=server --disable-warnings-as-errors
CONF=macosx-x86_64-normal-server-slowdebug make images
wget -c https://ftp.heanet.ie/mirrors/gnu/binutils/binutils-2.26.tar.gz
tar xvf binutils-2.26.tar.gz
make BINUTILS=binutils-2.26 ARCH=amd64
cp build/macosx-amd64/hsdis-amd64.dylib ~/src/jdk9/build/macosx-x86_64-normal-server-release/images/jdk-bundle/jdk-9.jdk/Contents/Home/jre/lib/server/
sudo cp build/macosx-amd64/hsdis-amd64.dylib /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre/lib/server/
http://www.graphviz.org/Documentation/dotguide.pdf
http://www.cc.gatech.edu/~harrold/6340/cs6340_fall2009/Readings/lengauer91jul.pdf
https://www.cs.rice.edu/~keith/EMBED/dom.pdf
https://github.com/skylot/jadx haaayyy~~~
http://blog.golovin.in/how-to-start-using-webassembly-today/
https://news.ycombinator.com/item?id=9457133
https://github.com/bedatadriven/renjin/tree/master/tools/gcc-bridge
https://github.com/neelance/ffi_gen
https://github.com/vmt/udis86
should prob just use javax.lang.model now
https://blogs.oracle.com/darcy/entry/unsigned_api
MEH:
- subswitch generator
TODO:
- NodePath, just child index, ... NodePath.deduce / NodePath.find, "0,4,2,1,1" ...
- PrivateModules?
- fucking default i32 return 0? ugh
- fixup void returns (breaks too?)
- Mangle local names
- *** Boolean optimization. Get rid of these fucking (expr ? 0 : 1) != 0
- Boolean primitive type? yeah probably
- Cleanup / de-yen-ify ops
- Track down x = y = x shit
- Fucking stupid statementizer RESULT IS NOT ALWAYS TEMP
- only init locals if necessary
DONESORTA:
- Yes, dedicated Switch Node, analysis + transform passes to identify, BreakTable still supported for sadistic frontends
- https://github.com/WebAssembly/binaryen/pull/617/files hi
test/wasm-install/wasm-install/bin/clang -I wasm-install/wasm-install/sysroot/include -emit-llvm --target=wasm32 -Oz -c test/wasm-install/wasm-install/bin/emscripten/tests/sqlite/sqlite3.c -o test/wasm-install/wasm-install/bin/emscripten/tests/sqlite/sqlite3.bc -DSQLITE_DISABLE_LFS -DLONGDOUBLE_TYPE=double -DSQLITE_THREADSAFE=0
test/wasm-install/wasm-install/bin/llc -asm-verbose=false test/wasm-install/wasm-install/bin/emscripten/tests/sqlite/sqlite3.bc -o test/wasm-install/wasm-install/bin/emscripten/tests/sqlite/sqlite3.s
bin/s2wasm test/wasm-install/wasm-install/bin/emscripten/tests/sqlite/sqlite3.s > test/wasm-install/wasm-install/bin/emscripten/tests/sqlite/sqlite3.wast
PassFactory ?
Key.get(Pass.class, "PassName")
context.seed(PassClass.class, FooPass.class)
injector.getInstance(Pass.class) ?
destruction / clobbering?
based on provision requirements?
@FunctionalInterface
public interface PassOutput<T>
void set(T value)
@FunctionalInterface
public interface Pass
void run()
public abstract class PassModule<T, P extends Pass<T>> extends PrivateModule
public abstract Class<? extends P> getPassClass()
Hmm ... scopes:
- Module
- ModulePass
- Function
- FunctionPass
- FunctionContext?
- 'Mutable'?
- FunctionAnalysis?
- Session scope equivs?
Dependencies:
- Commandline / config
- Global, per module, per function
- Analyses
- Global, per module, per function
- Persistent, clobbered
- Passes
Products:
- Analyses
- Statistics
- Transformed units
** Planner **
enum PassKind { MODULE, FUNCTION, JMETHOD, JCOMPILATIONUNIT }
- JTree?
- FunctionThings just nested in a single giant ModuleThing
Pass
Analyzer extends Pass
Transformer extends Pass
AnalyzerFactory::createAnalyzer
Analyzer::analyze Node T -> Analysis
TransformerFactory::createTransform
Transformer::transform T -> T
/*
Set<JImportSpec> getImports();
List<JDeclaration> getPreConstructorDeclarations();
List<JArg> getConstructorArgs();
List<JStatement> getConstructorStatements();
List<JDeclaration> getPostConstructorDeclarations();
^^ just helper'd existing passes
- add imports
- add declarations
- modify ctor
- add args
- add statements
*/
Set<Name> getReservedNames();
- Just a module-level analysis everything happens to depend on?
- kinda punkass ghetto if they dont depend on Module
- User vs System?
Set<Name> getSystemNames()
Function<Name, Name> mangleSystemName
Function<Name, Name> mangleUserName
Module processModule(Module module);
Function processFunction(Module module, Function function);
JMethod processJMethod(Module module, Function function, JMethod jmethod);
JCompilationUnit processJCompilationUnit(Module module, JCompilationUnit jcompilationUnit);
interface Pass<T> { T process(T t); } // j.u.f.UnaryOperator :3
interface Compiler<T, R> { R compile(T t); }
Pass<Module>
Compiler<Module, JCompilationUnit>
Pass<Function>
Compiler<Function, JMethod>
Pass<JMethod>
Pass<JCompilationUnit>
priorities / positions: floats?
Module -> JCompilationUnit
Function -> JMethod
Contexts? yugh.
Components? yugh.
StatementizerComponent
StatementizerTransform
ControlFlowAnalysis
ValueTypeAnalysis
abstract Context<T>
T subject
Map<Class<?>, Object> objects;
Pass<T>
Context<T> apply(Context<T> context)
<T> T get(Class<> extends T> cls);
Context<Function> functionContext = ...;
Module module = ((Context<Function>) functionContext).get(Module.class);
Context<Function> functionContext = ...;
Context<Module> moduleContext = functionContext.get(new ContextKey<Context<Module>>() {});
AnalysisPass
TransformationPass
boolean wtf0 = aTrue() & aFalse();
boolean wtf1 = aTrue() && aFalse();
18: aload_0
19: invokevirtual #6 // Method aTrue:()Z
22: aload_0
23: invokevirtual #7 // Method aFalse:()Z
26: iand
27: istore_2
28: aload_0
29: invokevirtual #6 // Method aTrue:()Z
32: ifeq 46
35: aload_0
36: invokevirtual #7 // Method aFalse:()Z
39: ifeq 46
42: iconst_1
43: goto 47
46: iconst_0
47: istore_3
https://github.com/Celtoys/clReflect sup
--memory-init-file
https://sites.google.com/site/markusicu/unicode/base16k
https://gist.github.com/commi/1583588
https://en.wikipedia.org/wiki/Dominator_(graph_theory)
https://en.wikibooks.org/wiki/ROSE_Compiler_Framework/outliner
https://stackoverflow.com/questions/4206679/can-anyone-give-a-good-example-of-using-org-apache-maven-cli-mavencli-programatt
dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-wagon</artifactId>
<version>0.9.0.M2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
MavenCli cli = new MavenCli();
cli.doMain(new String[]{"clean", "compile"}, "project_dir", System.out, System.out);
__cos:
$2 = 1.0 - ($3 = ($4 = $0 * $0) * 0.5);
return ($2 + (((1.0 - $2) - $3) + (($4 * (($4 * (($4 * (($4 * 2.480158728947673E-5) + -0.001388888888887411)) + 0.0416666666666666)) + ((($3 = $4 * $4) * $3) * (($4 * (($4 * -1.1359647557788195E-11) + 2.087572321298175E-9)) + -2.7557314351390663E-7)))) - ($0 * $1))));
https://webassembly.github.io/demo/AngryBots/Release/AngryBots.js
https://github.com/WebAssembly/ilwasm
--
- prob gonna win up with a lucene/ei-style attribute map and that's okay
- SourceLocation
- DeclaredType
https://github.com/wrmsr/lljvm/tree/master/java/src/lljvm = MIT
https://github.com/WebAssembly/design/issues/104
- https://github.com/juj/emscripten-fastcomp/tree/pthreads sup
- https://github.com/WebAssembly/design/issues/300
https://github.com/WebAssembly/design/issues/625
https://github.com/WebAssembly/spec/issues/227 ->
https://github.com/WebAssembly/spec/pull/234
https://github.com/WebAssembly/spec/issues/179
TODO:
- compile-time .class optimizer? ehhhh?
- doppio-doped pypyjs-style wasm tracing+jitting jvm?
- https://github.com/pypyjs/pypyjs/issues/145
- https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#platform-independent-just-in-time-compilation
https://github.com/headius/invokebinder
// TODO: should probably @Inject or contextualize NameGenerator at some point
// - @Inject FunctionScope?
tempvalues dominate
uh, fuck:
(block block1
(block block2
(break block1 10)))
-> BlockNamer pass? require all blocks to have names? then BlockUnnamer?
BreakConverter? make ifs?
TODO return value analysis
TODO class Switchifier .... :|
https://github.com/WebAssembly/binaryen/blob/master/test/llvm_autogenerated/switch.wast\#L23
- not wast->wast, but not j as it's more general. more an analysis pass that outputs its own tree
- naw just a Map<SwitchExpression, SwitchAnalysis>
- after temper, requires value-less internal breaks
- can still do weird shit like break-ins via lbl:do{...}while(false); blocks as normal, maybe a switchifying threshold
TODO chopper
- hello jruby
https://github.com/jruby/jruby/wiki/PerformanceTuning
jruby.compile.mode=JIT|FORCE|OFF
Set compilation mode. JIT is default; FORCE compiles all, OFF disables.
jruby.compile.fastest=true|false
(EXPERIMENTAL) Turn on all experimental compiler optimizations.
jruby.compile.frameless=true|false
(EXPERIMENTAL) Turn on frameless compilation where possible.
jruby.compile.positionless=true|false
(EXPERIMENTAL) Turn on compilation that avoids updating Ruby position info.
Default is false
jruby.compile.threadless=true|false
(EXPERIMENTAL) Turn on compilation without polling for "unsafe" thread events.
Default is false.
jruby.compile.fastops=true|false
(EXPERIMENTAL) Turn on fast operators for Fixnum. Default is false.
jruby.compile.fastcase=true|false
(EXPERIMENTAL) Turn on fast case/when for all-Fixnum whens. Default is false.
jruby.compile.chainsize=<line count>
Set the number of lines at which compiled bodies are "chained". Default is 500.
jruby.compile.lazyHandles=true|false
Generate method bindings (handles) for compiled methods lazily. Default is false.
jruby.compile.peephole=true|false
Enable or disable peephole optimizations. Default is true (on).
https://github.com/graalvm/sulong
pseudo-ops
- comment!
- acquire
- release
!! JCommentedStatement, JCommentedExpression ( /* */ ) -> src file / linum
lol java->wasm->java->throw = hilariously undefined, wrap
https://github.com/WebAssembly/design/blob/7d1532a40d107fe82fd1ae4724024ca6e66fbe37/AstSemantics.md#floating-point-operators
!! There is no observable difference between quiet and signalling NaN.
https://szegedi.github.io/dynalink/
https://github.com/szegedi/dynalink/wiki/User-Guide-0.7#performing-dynamic-operations-on-objects-from-java
- all funcs are interfaced types types ala clj
- naw only ones in funcptr map cuz dayum
jdk.nashorn.internal.runtime.linker.Bootstrap
TempScopePolicy ? tiered for java, flat for bytecode?
- fuck it flat
** stealing com.sun.tools.javac.tree.JCTree hierarchy
http://debasishg.blogspot.com/2006/03/non-java-languages-on-jvm.html
https://blog.balboa.io/emscripten.html
Integer.rotateRight
https://github.com/kripken/emscripten/blob/07b87426f898d6e9c677db291d9088c839197291/site/source/docs/porting/simd.rst
https://hacks.mozilla.org/2014/10/introducing-simd-js/
https://blog.mozilla.org/javascript/2015/03/10/state-of-simd-js-performance-in-firefox/
http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/b800986664f4 ... ehehe
https://developers.opengamma.com/articles/DGEMV.pdf
https://blogs.msdn.microsoft.com/dotnet/2014/04/07/the-jit-finally-proposed-jit-and-simd-are-getting-married/
https://msdn.microsoft.com/en-us/library/dn879696(v=vs.110).aspx
https://github.com/dotnet/coreclr/blob/775003a4c72f0acc37eab84628fcef541533ba4e/src/jit/simd.cpp
https://github.com/kripken/emscripten/blob/master/src/library_syscall.js
https://github.com/kripken/emscripten/blob/master/src/library_signals.js
https://github.com/kripken/emscripten/blob/master/src/library_pthread.js
https://github.com/jnr/jnr-posix/blob/master/src/main/java/jnr/posix/LibC.java ayyy
- https://github.com/jnr/jnr-posix/issues/73
- https://github.com/jnr/jnr-posix/blob/master/LICENSE.txt fuk
- https://github.com/jnr/jffi/commit/36b973f46c44efb728bc1db350ec5fd35347553e ...
rt.jar:com.sun.tools.javap sup
nio DMB's
https://github.com/OpenHFT/Chronicle-Core
https://github.com/OpenHFT/Chronicle-Bytes
https://github.com/OpenHFT/Chronicle-Values ??
- https://github.com/OpenHFT/Chronicle-Values/commit/25dc90353db57962360972f74981853aabbd1339 dammit
interface Typed { Type getType(); }
interface Valued extends Typed { Expression getValue(); default Type getType() { return getValue().getType(); } }
interface Named { Name getName(); }
mem: array vs unsafe
code: bytecode vs src
just use fukn guice
https://github.com/WebAssembly/polyfill-prototype-2/blob/master/opcodes.ts
llvm webassembly FRONTend...
graal vec intrinsics
lol rebrand nativity?
c++. / c libclang powered binding gen
hit jni / wava’d libs transparently
gen java callgates to extern c’s
structs? gen jni, jnr, native
ptrs are just longs
optional mem bounds checks
and graal
and panama
we have asm.js equiv, on TCO and shit just do what it does
Map<Long, Function>
… LongObjectHashMap…
Oo optimize cc push prims natively
initial mem image bin file in jar memcpy’d unsafe OR java .init src
inline mem hits OR go through static helpers
graal tail call opt
panama mostly about c/c++ interop, complementary but not really overlapping webasm be
javah
omfg func ptrs via indy omfg
- bahahah i can bring runtime virtual inlining to c++ via fuckin hotspot
LOOOL compile linux src network drivers for mmapped nic comm
X-ray stuff
- + rewind stuff
postgresql v MySQL = BSD vs gpl
Postgresql req fork shm and signals
Ghetto fork via base ptr reg
Preemptive memcpy, class emitted with priv final inst|stat base field in diff class loader, jit warm =~ cow
todo ensure final class from object instanceof == 1 instr -- lolvalhalla
can't fully mirror presto plan machinery
- children are not sources
- children are occasionally _optional_
** depless wava-runtime prj/jar
- embed directly into result jar
walkers:
- Optional<Expression> vs List<Expression>
- flatten blocks vs remove nops
implicit breaks for blocks
Implicit names for blocks?
label name mangler? FML lol
can vars and labels clash
labeler + breaker
purifier - returns
temper - “pure lifter”?
include full source code as comment
!! attach to Expressions, Rewriters preserve
https://github.com/WebAssembly/spec/issues/258
https://github.com/WebAssembly/design/issues/602
https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
llvm, clang ofc
sqlite, mysql, postgres
- + native drivers
hotspot lol
cpython
- https://github.com/replit/empythoned
fukkin linux drivers
- https://github.com/scylladb/dpdk/tree/master/examples
- dpdk.org
webkit :|
crypto, compression
zmq
udis86
llvm.js
j2me.js
zee.js
gmp.js
lzma.js
ammo.js
sql.js
-- signals and shit, at the end of the day it's just another platform / port
java yield(), resurrect kilim
ninject style concepts / structural types for guice
from to
llvm
js
jvm
webasm
https://github.com/raphw/byte-buddy ?
https://github.com/kframework/mpfr-java
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/file/tip/src/share/vm/oops/instanceKlass.hpp#l46
https://github.com/WebAssembly/design/blob/master/AstSemantics.md#floating-point-operators
http://en.cppreference.com/w/cpp/numeric/math/nan
http://nodyn.io/
https://github.com/v8/v8/tree/master/src/wasm
- steal its fuzzer
http://mreinhold.org/blog/jigsaw-module-system
https://github.com/kripken/llvm.js
http://blog.rchapman.org/post/36801038863/linux-system-call-table-for-x86-64
optimize:
5611 (block $label$89
5612 (br_if $label$89
5613 (i32.eqz
5614 (set_local $27
5615 (i32.load
5616 (i32.add
5617 (set_local $26
5618 (i32.add
5619 (i32.load
5620 (get_local $11)
5621 )
5622 (i32.mul
5623 (i32.load
5624 (i32.add
5625 (get_local $11)
5626 (i32.const 4)
5627 )
5628 )
5629 (i32.const 56)
5630 )
5631 )
5632 )
5633 (i32.const 8)
5634 )
5635 )
5636 )
5637 )
5638 )
5639 (call $sqlite3StrAccumAppend
5640 (get_local $0)
5641 (get_local $27)
5642 (i32.const -1)
5643 )
5644 (call $sqlite3StrAccumAppend
5645 (get_local $0)
5646 (i32.const 2656)
5647 (i32.const 1)
5648 )
5649 )
lol.