Skip to content
Permalink
Browse files

Fixed #754 -- improved, dramatically, the performance of method_missing

  • Loading branch information
alex committed Jun 19, 2013
1 parent e80a8b6 commit cb4f154f8d8f8efaf272281ebce7ecd104c8dd69
Showing with 60 additions and 1 deletion.
  1. +59 −0 tests/jit/test_basic.py
  2. +1 −1 topaz/objspace.py
@@ -105,3 +105,62 @@ def test_constant_string(self, topaz, tmpdir):
setfield_gc(p21, 41, descr=<FieldS topaz.executioncontext.ExecutionContext.inst_last_instr 24>)
jump(p0, p1, p3, p4, p5, p6, p9, i41, p19, p21, p27, descr=TargetToken(4310789600))
""")

def test_method_missing(self, topaz, tmpdir):
traces = self.run(topaz, tmpdir, """
i = 0
while i < 10000
Array.try_convert(1)
i += 1
end
""")
self.assert_matches(traces[0].loop, """
label(p0, p1, p3, p4, p6, p9, i55, p18, p21, p23, p29, descr=TargetToken(4323643288))
debug_merge_point(0, 0, '<main> at LOAD_DEREF')
debug_merge_point(0, 0, '<main> at LOAD_CONST')
debug_merge_point(0, 0, '<main> at SEND')
setfield_gc(p23, 21, descr=<FieldS topaz.executioncontext.ExecutionContext.inst_last_instr 24>)
guard_not_invalidated(descr=<Guard0x101c26c50>)
p58 = force_token()
i59 = int_lt(i55, 10000)
guard_true(i59, descr=<Guard0x101c26bd8>)
debug_merge_point(0, 0, '<main> at JUMP_IF_FALSE')
debug_merge_point(0, 0, '<main> at LOAD_SCOPE')
debug_merge_point(0, 0, '<main> at LOAD_LOCAL_CONSTANT')
debug_merge_point(0, 0, '<main> at LOAD_CONST')
debug_merge_point(0, 0, '<main> at SEND')
p60 = force_token()
debug_merge_point(1, 1, 'try_convert at LOAD_SCOPE')
debug_merge_point(1, 1, 'try_convert at LOAD_LOCAL_CONSTANT')
debug_merge_point(1, 1, 'try_convert at LOAD_DEREF')
debug_merge_point(1, 1, 'try_convert at LOAD_SCOPE')
debug_merge_point(1, 1, 'try_convert at LOAD_LOCAL_CONSTANT')
debug_merge_point(1, 1, 'try_convert at LOAD_CONST')
debug_merge_point(1, 1, 'try_convert at SEND')
p61 = force_token()
p62 = force_token()
p63 = force_token()
p64 = force_token()
p65 = force_token()
p66 = force_token()
p67 = force_token()
p68 = force_token()
p69 = force_token()
p70 = force_token()
p71 = force_token()
debug_merge_point(1, 1, 'try_convert at RETURN')
p72 = force_token()
debug_merge_point(0, 0, '<main> at DISCARD_TOP')
debug_merge_point(0, 0, '<main> at LOAD_DEREF')
debug_merge_point(0, 0, '<main> at LOAD_CONST')
debug_merge_point(0, 0, '<main> at SEND')
p73 = force_token()
i74 = int_add(i55, 1)
debug_merge_point(0, 0, '<main> at STORE_DEREF')
debug_merge_point(0, 0, '<main> at DISCARD_TOP')
debug_merge_point(0, 0, '<main> at JUMP')
debug_merge_point(0, 0, '<main> at LOAD_DEREF')
setfield_gc(p23, 48, descr=<FieldS topaz.executioncontext.ExecutionContext.inst_last_instr 24>)
setfield_gc(p1, p72, descr=<FieldP topaz.frame.Frame.vable_token 32>)
jump(p0, p1, p3, p4, p6, p9, i74, p18, p21, p23, p29, descr=TargetToken(4323643288))
""")
@@ -622,7 +622,7 @@ def _send_raw(self, name, raw_method, w_receiver, w_cls, args_w, block):
"undefined method `%s' for %s" % (name, class_name)
)
else:
args_w.insert(0, self.newsymbol(name))
args_w = [self.newsymbol(name)] + args_w
return method_missing.call(self, w_receiver, args_w, block)
return raw_method.call(self, w_receiver, args_w, block)

0 comments on commit cb4f154

Please sign in to comment.
You can’t perform that action at this time.