Skip to content

Instantly share code, notes, and snippets.

@squeaky-pl
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squeaky-pl/8985748 to your computer and use it in GitHub Desktop.
Save squeaky-pl/8985748 to your computer and use it in GitHub Desktop.
from array import array
LOOP = 10000
a = array('B')
b = array('B')
c = array('H')
with open('/dev/urandom') as f:
a.fromfile(f, LOOP)
b.fromfile(f, LOOP)
with open('/dev/zero') as f:
c.fromfile(f, LOOP)
def add(a, b, c):
for i in range(LOOP):
c[i] = a[i] + b[i]
add(a, b, c)
[71cfc41c247b] {jit-log-opt-loop
# Loop 0 (<code object add, file 'test.py', line 18> #13 FOR_ITER) : loop with 126 ops
[p0, p1]
+80: p2 = getfield_gc(p0, descr=<FieldP pypy.interpreter.pyframe.PyFrame.inst_pycode 96>)
+91: p3 = getfield_gc(p0, descr=<FieldP pypy.interpreter.pyframe.PyFrame.inst_lastblock 80>)
+95: i4 = getfield_gc(p0, descr=<FieldS pypy.interpreter.pyframe.PyFrame.inst_valuestackdepth 104>)
+99: p5 = getfield_gc(p0, descr=<FieldP pypy.interpreter.pyframe.PyFrame.inst_w_f_trace 112>)
+103: p6 = getfield_gc(p0, descr=<FieldP pypy.interpreter.pyframe.PyFrame.inst_last_exception 64>)
+107: p7 = getfield_gc(p0, descr=<FieldP pypy.interpreter.pyframe.PyFrame.inst_w_globals 120>)
+111: i8 = getfield_gc(p0, descr=<FieldU pypy.interpreter.pyframe.PyFrame.inst_is_being_profiled 142>)
+119: i9 = getfield_gc(p0, descr=<FieldS pypy.interpreter.pyframe.PyFrame.inst_last_instr 72>)
+123: p10 = getfield_gc(p0, descr=<FieldP pypy.interpreter.pyframe.PyFrame.inst_locals_stack_w 88>)
+127: p12 = getarrayitem_gc(p10, 0, descr=<ArrayP 8>)
+132: p14 = getarrayitem_gc(p10, 1, descr=<ArrayP 8>)
+137: p16 = getarrayitem_gc(p10, 2, descr=<ArrayP 8>)
+142: p18 = getarrayitem_gc(p10, 3, descr=<ArrayP 8>)
+154: p20 = getarrayitem_gc(p10, 4, descr=<ArrayP 8>)
+166: p22 = getarrayitem_gc(p10, 5, descr=<ArrayP 8>)
+178: p24 = getarrayitem_gc(p10, 6, descr=<ArrayP 8>)
+190: p26 = getarrayitem_gc(p10, 7, descr=<ArrayP 8>)
+195: p27 = getfield_gc(p0, descr=<FieldP pypy.interpreter.pyframe.PyFrame.inst_cells 24>)
+195: label(p0, p1, p2, p3, i4, p5, p6, p7, i8, i9, p12, p14, p16, p18, p20, p22, p24, p26, descr=TargetToken(140314213095472))
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #13 FOR_ITER')
+237: guard_value(i4, 5, descr=<Guard0x7f9d72d34d40>) [i4, p1, p0, p2, p3, p5, p6, p7, i8, i9, p12, p14, p16, p18, p20, p22, p24, p26]
+247: guard_isnull(p5, descr=<Guard0x7f9d69aab4b0>) [p1, p0, p5, p2, p3, p6, p7, i8, p12, p14, p16, p18, p20, p22, p24, p26]
+256: guard_class(p20, 26155952, descr=<Guard0x7f9d69aab440>) [p1, p0, p20, p2, p3, p6, p7, i8, p12, p14, p16, p18, p22, p24, p26]
+275: p30 = getfield_gc(p20, descr=<FieldP pypy.objspace.std.iterobject.W_AbstractSeqIterObject.inst_w_seq 16>)
+279: guard_nonnull(p30, descr=<Guard0x7f9d69aab3d0>) [p1, p0, p20, p30, p2, p3, p6, p7, i8, p12, p14, p16, p18, p22, p24, p26]
+288: i31 = getfield_gc(p20, descr=<FieldS pypy.objspace.std.iterobject.W_AbstractSeqIterObject.inst_index 8>)
+292: p32 = getfield_gc(p30, descr=<FieldP pypy.objspace.std.listobject.W_ListObject.inst_strategy 16>)
+296: guard_class(p32, 26326184, descr=<Guard0x7f9d69aab360>) [p1, p0, p20, i31, p32, p30, p2, p3, p6, p7, i8, p12, p14, p16, p18, p22, p24, p26]
+309: p34 = getfield_gc(p30, descr=<FieldP pypy.objspace.std.listobject.W_ListObject.inst_lstorage 8>)
+313: i35 = getfield_gc_pure(p34, descr=<FieldS tuple3.item0 8>)
+317: i36 = getfield_gc_pure(p34, descr=<FieldS tuple3.item1 16>)
+321: i37 = getfield_gc_pure(p34, descr=<FieldS tuple3.item2 24>)
+325: i39 = int_lt(i31, 0)
guard_false(i39, descr=<Guard0x7f9d69aab2f0>) [p1, p0, p20, i31, i37, i36, i35, p2, p3, p6, p7, i8, p12, p14, p16, p18, p22, p24, p26]
+335: i40 = int_ge(i31, i37)
guard_false(i40, descr=<Guard0x7f9d69aab280>) [p1, p0, p20, i31, i36, i35, p2, p3, p6, p7, i8, p12, p14, p16, p18, p22, p24, p26]
+344: i41 = int_mul(i31, i36)
+351: i42 = int_add(i35, i41)
+357: i44 = int_add(i31, 1)
+361: setfield_gc(p20, i44, descr=<FieldS pypy.objspace.std.iterobject.W_AbstractSeqIterObject.inst_index 8>)
+365: guard_value(i8, 0, descr=<Guard0x7f9d69aab210>) [i8, p1, p0, p2, p3, p6, p7, p12, p14, p16, p18, p20, p24, p26, i42]
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #16 STORE_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #19 LOAD_FAST')
+375: guard_nonnull_class(p12, 26481720, descr=<Guard0x7f9d69aab1a0>) [p1, p0, p12, p2, p3, p6, p7, p14, p16, p20, p24, p26, i42]
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #22 LOAD_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #25 BINARY_SUBSCR')
+401: i47 = getfield_gc(p12, descr=<FieldS pypy.module.array.interp_array.W_ArrayBase.inst_len 24>)
+405: i49 = int_lt(i42, 0)
guard_false(i49, descr=<Guard0x7f9d69aab130>) [p1, p0, p12, i42, i47, p2, p3, p6, p7, p14, p16, p20, p26, None]
+415: i51 = int_lt(i42, i47)
guard_true(i51, descr=<Guard0x7f9d69aab0c0>) [p1, p0, p12, i42, p2, p3, p6, p7, p14, p16, p20, p26, None]
+424: i52 = getfield_gc(p12, descr=<FieldU pypy.module.array.interp_array.W_ArrayTypeB.inst_buffer 32>)
+428: i53 = getarrayitem_raw(i52, i42, descr=<ArrayU 1>)
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #26 LOAD_FAST')
+433: guard_nonnull_class(p14, 26481720, descr=<Guard0x7f9d69aab050>) [p1, p0, p14, p2, p3, p6, p7, p12, p16, p20, p26, i53, i42]
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #29 LOAD_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #32 BINARY_SUBSCR')
+452: i55 = getfield_gc(p14, descr=<FieldS pypy.module.array.interp_array.W_ArrayBase.inst_len 24>)
+456: i56 = int_lt(i42, i55)
guard_true(i56, descr=<Guard0x7f9d69aaafe0>) [p1, p0, p14, i42, p2, p3, p6, p7, p12, p16, p20, i53, None]
+465: i57 = getfield_gc(p14, descr=<FieldU pypy.module.array.interp_array.W_ArrayTypeB.inst_buffer 32>)
+476: i58 = getarrayitem_raw(i57, i42, descr=<ArrayU 1>)
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #33 BINARY_ADD')
+488: i59 = int_add_ovf(i53, i58)
guard_no_overflow(descr=<Guard0x7f9d69aaaf70>) [p1, p0, i59, p2, p3, p6, p7, p12, p14, p16, p20, i58, i53, i42]
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #34 LOAD_FAST')
+504: guard_nonnull_class(p16, 26483400, descr=<Guard0x7f9d69aaaf00>) [p1, p0, p16, p2, p3, p6, p7, p12, p14, p20, i59, None, None, i42]
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #37 LOAD_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #40 STORE_SUBSCR')
+523: i61 = getfield_gc(p16, descr=<FieldS pypy.module.array.interp_array.W_ArrayBase.inst_len 24>)
+527: i62 = int_lt(i42, i61)
guard_true(i62, descr=<Guard0x7f9d69aaae90>) [p1, p0, p16, i42, p2, p3, p6, p7, p12, p14, p20, i59, None, None, None]
+536: i64 = int_and(i59, 65535)
+550: i65 = int_ne(i64, i59)
guard_false(i65, descr=<Guard0x7f9d69aaae20>) [p1, p0, p16, i42, i59, i64, p2, p3, p6, p7, p12, p14, p20, None, None, None, None]
+563: i66 = getfield_gc(p16, descr=<FieldU pypy.module.array.interp_array.W_ArrayTypeH.inst_buffer 32>)
+574: setarrayitem_raw(i66, i42, i64, descr=<ArrayU 2>)
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #41 JUMP_ABSOLUTE')
+579: guard_not_invalidated(descr=<Guard0x7f9d69aaadb0>) [p1, p0, p2, p3, p6, p7, p12, p14, p16, p20, None, None, None, i42]
+579: i68 = getfield_raw(50779712, descr=<FieldS pypysig_long_struct.c_value 0>)
+587: i70 = int_lt(i68, 0)
guard_false(i70, descr=<Guard0x7f9d69aaad40>) [p1, p0, p2, p3, p6, p7, p12, p14, p16, p20, None, None, None, i42]
+597: guard_value(p2, ConstPtr(ptr71), descr=<Guard0x7f9d69aaacd0>) [p1, p0, p2, p3, p6, p7, p12, p14, p16, p20, None, None, None, i42]
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #13 FOR_ITER')
+616: label(p0, p1, p3, p6, p7, p12, p14, p16, i42, p20, i44, i37, i36, i35, i47, i52, i55, i57, i61, i66, descr=TargetToken(140314213095560))
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #13 FOR_ITER')
+630: i72 = int_ge(i44, i37)
guard_false(i72, descr=<Guard0x7f9d69aaac60>) [p1, p0, p20, i44, i36, i35, p3, p6, p7, p12, p14, p16, i42]
+639: i73 = int_mul(i44, i36)
+650: i74 = int_add(i35, i73)
+660: i75 = int_add(i44, 1)
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #16 STORE_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #19 LOAD_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #22 LOAD_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #25 BINARY_SUBSCR')
+664: setfield_gc(p20, i75, descr=<FieldS pypy.objspace.std.iterobject.W_AbstractSeqIterObject.inst_index 8>)
+675: i76 = int_lt(i74, 0)
guard_false(i76, descr=<Guard0x7f9d69aaab80>) [p1, p0, p12, i74, i47, p3, p6, p7, p14, p16, p20, None]
+685: i77 = int_lt(i74, i47)
guard_true(i77, descr=<Guard0x7f9d69aaab10>) [p1, p0, p12, i74, p3, p6, p7, p14, p16, p20, None]
+694: i78 = getarrayitem_raw(i52, i74, descr=<ArrayU 1>)
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #26 LOAD_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #29 LOAD_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #32 BINARY_SUBSCR')
+699: i79 = int_lt(i74, i55)
guard_true(i79, descr=<Guard0x7f9d69aaaa30>) [p1, p0, p14, i74, p3, p6, p7, p12, p16, p20, i78, None]
+708: i80 = getarrayitem_raw(i57, i74, descr=<ArrayU 1>)
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #33 BINARY_ADD')
+713: i81 = int_add_ovf(i78, i80)
guard_no_overflow(descr=<Guard0x7f9d69aaa9c0>) [p1, p0, i81, p3, p6, p7, p12, p14, p16, p20, i80, i74, i78, None]
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #34 LOAD_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #37 LOAD_FAST')
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #40 STORE_SUBSCR')
+725: i82 = int_lt(i74, i61)
guard_true(i82, descr=<Guard0x7f9d69aaa950>) [p1, p0, p16, i74, p3, p6, p7, p12, p14, p20, i81, None, None, None, None]
+734: i83 = int_and(i81, 65535)
+744: i84 = int_ne(i83, i81)
guard_false(i84, descr=<Guard0x7f9d69aaa8e0>) [p1, p0, p16, i74, i81, i83, p3, p6, p7, p12, p14, p20, None, None, None, None, None]
+753: setarrayitem_raw(i66, i74, i83, descr=<ArrayU 2>)
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #41 JUMP_ABSOLUTE')
+758: guard_not_invalidated(descr=<Guard0x7f9d69aaa870>) [p1, p0, p3, p6, p7, p12, p14, p16, p20, None, None, i74, None, None]
+758: i85 = getfield_raw(50779712, descr=<FieldS pypysig_long_struct.c_value 0>)
+766: i86 = int_lt(i85, 0)
guard_false(i86, descr=<Guard0x7f9d69aaa800>) [p1, p0, p3, p6, p7, p12, p14, p16, p20, None, None, i74, None, None]
debug_merge_point(0, 0, '<code object add. file 'test.py'. line 18> #13 FOR_ITER')
+776: jump(p0, p1, p3, p6, p7, p12, p14, p16, i74, p20, i75, i37, i36, i35, i47, i52, i55, i57, i61, i66, descr=TargetToken(140314213095560))
+795: --end of the loop--
[71cfc43195db] jit-log-opt-loop}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment