Skip to content

Instantly share code, notes, and snippets.

@samth
Created December 15, 2018 17:49
Show Gist options
  • Save samth/4d17d6ea50d0cc75d2c3a4676521280a to your computer and use it in GitHub Desktop.
Save samth/4d17d6ea50d0cc75d2c3a4676521280a to your computer and use it in GitHub Desktop.
#lang pycket
(define N 1000000)
(let countdown1 ([n N]) (if (< n 0) 1 (countdown1 (- n 1))))
#;#;#;
(require racket/linklet)
(define l
(compile-linklet
`(linklet
()
()
(display ((letrec-values (((countdown2)
(lambda (n) (if (< n 0) 1 (countdown2 (- n 1))))))
countdown2)
,N)))
))
(void (instantiate-linklet l null))
[269cef5a6944e7] {jit-log-opt-loop
# Loop 1 ((let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)) : loop with 45 ops
[p0, p1]
+267: label(p0, p1, descr=TargetToken(139969532107040))
debug_merge_point(0, 0, '(let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)')
+272: guard_class(p1, 94043593117120, descr=<Guard0x7f4d324e94c0>) [p0, p1]
+291: p3 = getfield_gc_r(p1, descr=<FieldP pycket.cont.BaseCont.inst_marks 8>)
+295: guard_nonnull_class(p3, ConstClass(ForwardLink), descr=<Guard0x7f4d324e9520>) [p0, p1]
debug_merge_point(0, 0, '(< n 0)')
+313: guard_not_invalidated(descr=<Guard0x7f4d32398338>) [p0, p1]
+313: guard_class(p0, 94043593102984, descr=<Guard0x7f4d32398380>) [p0, p1]
+332: i6 = getfield_gc_i(p0, descr=<FieldS pycket.small_list.ConsEnvSize1Fixed.inst_vals_fixed_0 24 pure>)
+336: i8 = int_lt(i6, 0)
+340: guard_false(i8, descr=<Guard0x7f4d323983c8>) [p0, p1]
+346: p9 = getfield_gc_r(p0, descr=<FieldP pycket.env.ConsEnv.inst_current_linklet_instance 16 pure>)
+350: guard_isnull(p9, descr=<Guard0x7f4d32398410>) [p0, p1]
debug_merge_point(0, 0, '(if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))')
debug_merge_point(0, 0, '(let ([AppRand0 (- n 1)]) (countdown1 AppRand0))')
+359: p10 = getfield_gc_r(p0, descr=<FieldP pycket.env.ConsEnv.inst__prev 8 pure>)
debug_merge_point(0, 0, '(- n 1)')
+363: i12 = int_sub(i6, 1)
+367: guard_class(p10, 94043593096984, descr=<Guard0x7f4d32398458>) [p0, p1]
+379: p14 = getfield_gc_r(p10, descr=<FieldP pycket.env.ConsEnv.inst_current_linklet_instance 16 pure>)
+383: guard_isnull(p14, descr=<Guard0x7f4d323984a0>) [p0, p1]
debug_merge_point(0, 0, '(countdown1 AppRand0)')
+392: p15 = getfield_gc_r(p10, descr=<FieldP rpython.tool.pairtype.ConsEnvSize1.inst__vals_0 24 pure>)
+396: guard_nonnull_class(p15, 94043593108360, descr=<Guard0x7f4d324e9580>) [p0, p1]
+414: p17 = getfield_gc_r(p15, descr=<FieldP pycket.values.W_Closure.inst_caselam 8 pure>)
+425: guard_value(p17, ConstPtr(ptr18), descr=<Guard0x7f4d323984e8>) [p0, p1]
+434: p19 = getfield_gc_r(p15, descr=<FieldP rpython.tool.pairtype.W_ClosureSize1.inst__envs_0 24 pure>)
+438: i20 = instance_ptr_eq(p10, p19)
+441: guard_true(i20, descr=<Guard0x7f4d32398530>) [p0, p1]
+447: p21 = getfield_gc_r(p15, descr=<FieldP pycket.values.W_Closure.inst_current_linklet_instance 16 pure>)
+451: guard_isnull(p21, descr=<Guard0x7f4d32398578>) [p0, p1]
debug_merge_point(0, 0, '(let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)')
+460: label(p10, i12, p1, p3, p15, descr=TargetToken(139969532107120))
debug_merge_point(0, 0, '(let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)')
debug_merge_point(0, 0, '(< n 0)')
+496: guard_not_invalidated(descr=<Guard0x7f4d324e95e0>) [i12, p10, p1, p3]
+496: i23 = int_lt(i12, 0)
+500: guard_false(i23, descr=<Guard0x7f4d323985c0>) [i12, p10, p1, p3]
debug_merge_point(0, 0, '(if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))')
debug_merge_point(0, 0, '(let ([AppRand0 (- n 1)]) (countdown1 AppRand0))')
debug_merge_point(0, 0, '(- n 1)')
+506: i25 = int_sub(i12, 1)
debug_merge_point(0, 0, '(countdown1 AppRand0)')
debug_merge_point(0, 0, '(let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)')
+510: jump(p10, i25, p1, p3, p15, descr=TargetToken(139969532107120))
+528: --end of the loop--
[269cef5a6d4c8e] jit-log-opt-loop}
[269cef5a9d1a1a] {jit-log-opt-loop
# Loop 2 ((let ([if546 (< n 0)]) (if if546 1 (let ([AppRand778 (- n 1)]) (countdown2 AppRand778)))) from (countdown2 AppRand778)) : loop with 47 ops
[p0, p1]
+267: label(p0, p1, descr=TargetToken(139969532107200))
debug_merge_point(0, 0, '(let ([if546 (< n 0)]) (if if546 1 (let ([AppRand778 (- n 1)]) (countdown2 AppRand778)))) from (countdown2 AppRand778)')
+272: guard_class(p1, 94043593013984, descr=<Guard0x7f4d324e9640>) [p0, p1]
+291: p3 = getfield_gc_r(p1, descr=<FieldP pycket.cont.BaseCont.inst_marks 8>)
+295: guard_nonnull_class(p3, ConstClass(ForwardLink), descr=<Guard0x7f4d324e96a0>) [p0, p1]
debug_merge_point(0, 0, '(< n 0)')
+313: guard_not_invalidated(descr=<Guard0x7f4d32398608>) [p0, p1]
+313: guard_class(p0, 94043593102984, descr=<Guard0x7f4d32398650>) [p0, p1]
+332: i6 = getfield_gc_i(p0, descr=<FieldS pycket.small_list.ConsEnvSize1Fixed.inst_vals_fixed_0 24 pure>)
+336: i8 = int_lt(i6, 0)
+340: guard_false(i8, descr=<Guard0x7f4d32398698>) [p0, p1]
+346: p9 = getfield_gc_r(p0, descr=<FieldP pycket.env.ConsEnv.inst_current_linklet_instance 16 pure>)
+350: guard_nonnull(p9, descr=<Guard0x7f4d323986e0>) [p0, p1]
debug_merge_point(0, 0, '(if if546 1 (let ([AppRand778 (- n 1)]) (countdown2 AppRand778)))')
debug_merge_point(0, 0, '(let ([AppRand778 (- n 1)]) (countdown2 AppRand778))')
+359: p10 = getfield_gc_r(p0, descr=<FieldP pycket.env.ConsEnv.inst__prev 8 pure>)
debug_merge_point(0, 0, '(- n 1)')
+363: i12 = int_sub(i6, 1)
+367: guard_class(p10, 94043593096984, descr=<Guard0x7f4d32398728>) [p0, p1]
+379: p14 = getfield_gc_r(p10, descr=<FieldP pycket.env.ConsEnv.inst_current_linklet_instance 16 pure>)
+383: guard_nonnull(p14, descr=<Guard0x7f4d32398770>) [p0, p1]
debug_merge_point(0, 0, '(countdown2 AppRand778)')
+392: p15 = getfield_gc_r(p10, descr=<FieldP rpython.tool.pairtype.ConsEnvSize1.inst__vals_0 24 pure>)
+396: guard_nonnull_class(p15, 94043593108360, descr=<Guard0x7f4d324e9700>) [p0, p1]
+414: p17 = getfield_gc_r(p15, descr=<FieldP pycket.values.W_Closure.inst_caselam 8 pure>)
+425: guard_value(p17, ConstPtr(ptr18), descr=<Guard0x7f4d323987b8>) [p0, p1]
+434: p19 = getfield_gc_r(p15, descr=<FieldP rpython.tool.pairtype.W_ClosureSize1.inst__envs_0 24 pure>)
+438: i20 = instance_ptr_eq(p10, p19)
+441: guard_true(i20, descr=<Guard0x7f4d32398800>) [p0, p1]
+447: p21 = getfield_gc_r(p15, descr=<FieldP pycket.values.W_Closure.inst_current_linklet_instance 16 pure>)
+451: guard_nonnull(p21, descr=<Guard0x7f4d32398848>) [p0, p1]
debug_merge_point(0, 0, '(let ([if546 (< n 0)]) (if if546 1 (let ([AppRand778 (- n 1)]) (countdown2 AppRand778)))) from (countdown2 AppRand778)')
+460: p22 = same_as_r(p21)
+463: label(p10, p21, i12, p1, p3, p15, p22, descr=TargetToken(139969532107280))
debug_merge_point(0, 0, '(let ([if546 (< n 0)]) (if if546 1 (let ([AppRand778 (- n 1)]) (countdown2 AppRand778)))) from (countdown2 AppRand778)')
debug_merge_point(0, 0, '(< n 0)')
+496: guard_not_invalidated(descr=<Guard0x7f4d324e9760>) [i12, p21, p10, p1, p3]
+496: i24 = int_lt(i12, 0)
+500: guard_false(i24, descr=<Guard0x7f4d32398890>) [i12, p21, p10, p1, p3]
debug_merge_point(0, 0, '(if if546 1 (let ([AppRand778 (- n 1)]) (countdown2 AppRand778)))')
debug_merge_point(0, 0, '(let ([AppRand778 (- n 1)]) (countdown2 AppRand778))')
debug_merge_point(0, 0, '(- n 1)')
+506: i26 = int_sub(i12, 1)
debug_merge_point(0, 0, '(countdown2 AppRand778)')
+510: guard_nonnull(p22, descr=<Guard0x7f4d323988d8>) [i12, p21, p10, p1, p3]
debug_merge_point(0, 0, '(let ([if546 (< n 0)]) (if if546 1 (let ([AppRand778 (- n 1)]) (countdown2 AppRand778)))) from (countdown2 AppRand778)')
+519: jump(p10, p22, i26, p1, p3, p15, p22, descr=TargetToken(139969532107280))
+544: --end of the loop--
[269cef5a9fea28] jit-log-opt-loop}
[269cef5abda2b1] {jit-summary
Tracing: 2 0.001184
Backend: 2 0.000205
TOTAL: 0.002389
ops: 682
recorded ops: 149
calls: 0
guards: 42
opt ops: 91
opt guards: 33
opt guards shared: 25
forcings: 0
abort: trace too long: 0
abort: compiling: 0
abort: vable escape: 0
abort: bad loop: 0
abort: force quasi-immut: 0
nvirtuals: 6
nvholes: 0
nvreused: 0
vecopt tried: 0
vecopt success: 0
Total # of loops: 2
Total # of bridges: 0
Freed # of loops: 0
Freed # of bridges: 0
[269cef5abee47c] jit-summary}
[26a3d2e654558c] {jit-log-opt-loop
# Loop 1 ((let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)) : loop with 39 ops
[p0, p1]
+235: label(p0, p1, descr=TargetToken(139731155050528))
debug_merge_point(0, 0, '(let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)')
+240: guard_class(p1, 94131446050784, descr=<Guard0x7f15b1dc8020>) [p0, p1]
+259: p3 = getfield_gc_r(p1, descr=<FieldP pycket.cont.BaseCont.inst_marks 8>)
+263: guard_nonnull_class(p3, ConstClass(Link), descr=<Guard0x7f15b1dc8080>) [p0, p1]
debug_merge_point(0, 0, '(< n 0)')
+281: guard_not_invalidated(descr=<Guard0x7f15b1dca020>) [p0, p1]
+281: guard_class(p0, 94131446026032, descr=<Guard0x7f15b1dca068>) [p0, p1]
+300: i6 = getfield_gc_i(p0, descr=<FieldS pycket.small_list.ConsEnvSize1Fixed.inst_vals_fixed_0 16 pure>)
+304: i8 = int_lt(i6, 0)
+308: guard_false(i8, descr=<Guard0x7f15b1dca0b0>) [p0, p1]
debug_merge_point(0, 0, '(if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))')
debug_merge_point(0, 0, '(let ([AppRand0 (- n 1)]) (countdown1 AppRand0))')
+314: p9 = getfield_gc_r(p0, descr=<FieldP pycket.env.ConsEnv.inst__prev 8 pure>)
debug_merge_point(0, 0, '(- n 1)')
+318: i11 = int_sub(i6, 1)
debug_merge_point(0, 0, '(countdown1 AppRand0)')
+322: guard_class(p9, 94131446020752, descr=<Guard0x7f15b1dca0f8>) [p0, p1]
+334: p13 = getfield_gc_r(p9, descr=<FieldP rpython.tool.pairtype.ConsEnvSize1.inst__vals_0 16 pure>)
+338: guard_nonnull_class(p13, 94131446032080, descr=<Guard0x7f15b1dc80e0>) [p0, p1]
+356: p15 = getfield_gc_r(p13, descr=<FieldP pycket.values.W_Closure.inst_caselam 8 pure>)
+367: guard_value(p15, ConstPtr(ptr16), descr=<Guard0x7f15b1dca140>) [p0, p1]
+376: p17 = getfield_gc_r(p13, descr=<FieldP rpython.tool.pairtype.W_ClosureSize1.inst__envs_0 16 pure>)
+380: i18 = instance_ptr_eq(p9, p17)
+383: guard_true(i18, descr=<Guard0x7f15b1dca188>) [p0, p1]
debug_merge_point(0, 0, '(let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)')
+389: label(p9, i11, p1, p13, descr=TargetToken(139731155050608))
debug_merge_point(0, 0, '(let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)')
debug_merge_point(0, 0, '(< n 0)')
+416: guard_not_invalidated(descr=<Guard0x7f15b1dc8140>) [i11, p9, p1]
+416: i20 = int_lt(i11, 0)
+420: guard_false(i20, descr=<Guard0x7f15b1dca1d0>) [i11, p9, p1]
debug_merge_point(0, 0, '(if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))')
debug_merge_point(0, 0, '(let ([AppRand0 (- n 1)]) (countdown1 AppRand0))')
debug_merge_point(0, 0, '(- n 1)')
+426: i22 = int_sub(i11, 1)
debug_merge_point(0, 0, '(countdown1 AppRand0)')
debug_merge_point(0, 0, '(let ([if0 (< n 0)]) (if if0 1 (let ([AppRand0 (- n 1)]) (countdown1 AppRand0)))) from (countdown1 AppRand0)')
+430: jump(p9, i22, p1, p13, descr=TargetToken(139731155050608))
+448: --end of the loop--
[26a3d2e65dbe41] jit-log-opt-loop}
[26a3d2e67834b2] {jit-summary
Tracing: 1 0.001520
Backend: 1 0.000154
TOTAL: 0.002146
ops: 324
recorded ops: 71
calls: 0
guards: 18
opt ops: 39
opt guards: 13
opt guards shared: 9
forcings: 0
abort: trace too long: 0
abort: compiling: 0
abort: vable escape: 0
abort: bad loop: 0
abort: force quasi-immut: 0
nvirtuals: 4
nvholes: 0
nvreused: 0
vecopt tried: 0
vecopt success: 0
Total # of loops: 1
Total # of bridges: 0
Freed # of loops: 0
Freed # of bridges: 0
[26a3d2e6790e6e] jit-summary}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment