nitgs: opt_direct_call_monomorph call `before_send` to deal with special cases
authorJean Privat <jean@pryen.org>
Fri, 28 Mar 2014 13:03:59 +0000 (09:03 -0400)
committerJean Privat <jean@pryen.org>
Tue, 1 Apr 2014 15:06:55 +0000 (11:06 -0400)
Thus null receiver and other special case are correctly handled in the
optimized path.

Signed-off-by: Jean Privat <jean@pryen.org>

src/separate_compiler.nit

index 01ac4fa..96978f0 100644 (file)
@@ -1012,13 +1012,21 @@ class SeparateCompilerVisitor
        do
                var rta = compiler.runtime_type_analysis
                var recv = args.first.mtype
-               if compiler.modelbuilder.toolcontext.opt_direct_call_monomorph.value and rta != null and recv isa MClassType then
+               if compiler.modelbuilder.toolcontext.opt_direct_call_monomorph.value and rta != null then
                        var tgs = rta.live_targets(callsite)
                        if tgs.length == 1 then
                                # DIRECT CALL
                                var mmethod = callsite.mproperty
                                self.varargize(mmethod.intro, mmethod.intro.msignature.as(not null), args)
-                               return call(tgs.first, recv, args)
+                               var res0 = before_send(mmethod, args)
+                               var res = call(tgs.first, tgs.first.mclassdef.bound_mtype, args)
+                               if res0 != null then
+                                       assert res != null
+                                       self.assign(res0, res)
+                                       res = res0
+                               end
+                               add("\}") # close the before_send
+                               return res
                        end
                end
                return super