From: Jean Privat Date: Thu, 3 Apr 2014 20:06:32 +0000 (-0400) Subject: Merge: Nitgs optims X-Git-Tag: v0.6.6~132 X-Git-Url: http://nitlanguage.org Merge: Nitgs optims Some optimizations on the nitg-s side (low level). Some use the new call-graph mechanism. Pull-Request: #372 Reviewed-by: Alexis Laferrière --- 09a5a53a9b7bd2aa30bfa8350fddeea448df4204 diff --cc src/separate_compiler.nit index 2352646,96978f0..92cd821 --- a/src/separate_compiler.nit +++ b/src/separate_compiler.nit @@@ -1078,12 -1104,51 +1104,51 @@@ class SeparateCompilerVisito else self.add("{res} = 1; /* arg is null and recv is not */") end - if maybenull then - self.add("\}") - end - return res + self.add("\}") # closes the null case + self.add("if (0) \{") # what follow is useless, CC will drop it end end + return res + end + + private fun table_send(mmethod: MMethod, arguments: Array[RuntimeVariable], const_color: String): nullable RuntimeVariable + do + compiler.modelbuilder.nb_invok_by_tables += 1 + if compiler.modelbuilder.toolcontext.opt_invocation_metrics.value then add("count_invoke_by_tables++;") + + assert arguments.length == mmethod.intro.msignature.arity + 1 else debug("Invalid arity for {mmethod}. {arguments.length} arguments given.") + var recv = arguments.first + + var res0 = before_send(mmethod, arguments) + + var res: nullable RuntimeVariable + var msignature = mmethod.intro.msignature.resolve_for(mmethod.intro.mclassdef.bound_mtype, mmethod.intro.mclassdef.bound_mtype, mmethod.intro.mclassdef.mmodule, true) + var ret = msignature.return_mtype + if mmethod.is_new then + ret = arguments.first.mtype + res = self.new_var(ret) + else if ret == null then + res = null + else + res = self.new_var(ret) + end + - var s = new Buffer - var ss = new Buffer ++ var s = new FlatBuffer ++ var ss = new FlatBuffer + + s.append("val*") + ss.append("{recv}") + for i in [0..msignature.arity[ do + var a = arguments[i+1] + var t = msignature.mparameters[i].mtype + if i == msignature.vararg_rank then + t = arguments[i+1].mcasttype + end + s.append(", {t.ctype}") + a = self.autobox(a, t) + ss.append(", {a}") + end + var r if ret == null then r = "void" else r = ret.ctype