[Mono-bugs] [Bug 81663][Wis] Changed - Performance: Delegate optimization, DLR and IronPython

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu May 24 07:24:59 EDT 2007

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by lupus at ximian.com.


--- shadow/81663	2007-05-23 18:08:53.000000000 -0400
+++ shadow/81663.tmp.27029	2007-05-24 07:24:59.000000000 -0400
@@ -119,6 +119,36 @@
 ------- Additional Comments From vargaz at gmail.com  2007-05-23 18:08 -------
 Created an attachment (id=19305)
+------- Additional Comments From lupus at ximian.com  2007-05-24 07:24 -------
+Sadly it's not possible to implement the idea in arch-indep code as it
+is highly specific to the call convention ABI, otherwise you just pay
+the additional overhead of an indirect call vs a direct call, as you
+found out, so the patch is no indication of the expected performance.
+As an example of how this would look like, the
+delegate_invoke_with_target would be implemented in mini-amd64.c with:
+  amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RDI, G_STRUCT_OFFSET
+(MonoDelegate, method_ptr), 8);
+  amd64_mov_reg_membase (code, AMD64_RDI, AMD64_RDI, G_STRUCT_OFFSET
+(MonoDelegate, target), 8);
+  amd64_jump_reg (code, AMD64_RAX);
+(changing rdi to account for struct return types). This code is much
+faster than the one produced by your patch, especially with many
+This may require changes for the mono_delegate_trampoline() handling
+to remove assumptions about the current way of invoking delegates.
+We should likely have a new delegate magic trampoline which is
+installed in the invoke_impl you added (this would remove the huge
+overhead your change adds to the delegate ctor). This magic trampoline
+would have easy access to the delegate object so it it completely
+generic (one instance of the trampoline in the system vs one
+trampoline per method/delegate type) and it can replace invoke_impl
+according to the target and prev fields in the delegate.

More information about the mono-bugs mailing list