From: Jean Privat Date: Thu, 27 Mar 2014 20:33:56 +0000 (-0400) Subject: nitgs: add --direct-call-monomorph and --inline-some-methods X-Git-Tag: v0.6.6~132^2~6 X-Git-Url: http://nitlanguage.org?hp=f8ca2a2208339aed2eb8e43b04f92249865be2d7 nitgs: add --direct-call-monomorph and --inline-some-methods These code-generation-level global optimizations allow the separate compiler to: * first, use a direct call, instead of a VFT call when RTA gives inform that a callsite is monomorph (and that the receiver is a nonnull non parametric type) * second, to inline static call when the mmethoddef is tagged accordingly (we reuse the `can_inline` service of the global compiler) **DISCLAMER** The point of these optimizations is to evaluate some extreme optimizations, thus to bound the gain of much less aggressive optimizations. Real direct call and inlining optimizations SHOULD be applied on the AST or (some intermediate code level) to be combinable with other optimizations. Some numbers for `nitg --separate nitg.nit`: # base (no option) total number of invocations: 45833 invocations by VFT send: 34556 (75.39%) invocations by direct call: 9955 (21.72%) invocations by inlinning: 1322 (2.88%) user time 0m10.2s # with --direct-call-monomorph total number of invocations: 45833 invocations by VFT send: 9259 (20.20%) invocations by direct call: 35199 (76.79%) invocations by inlinning: 1375 (3.00%) user 0m10.1s # with --direct-call-monomorph and --inline-some-methods total number of invocations: 46657 invocations by VFT send: 9701 (20.79%) invocations by direct call: 26239 (56.23%) invocations by inlinning: 10717 (22.96%) user 0m10.0s Discussion about the number: Something is fishy, while there is a high reduction of VFT or direct calls, there is no real gain in CPU time. Points to investigate: * the optimized invocations are not in the hot path TODO gather dynamic numbers * my CPU is very efficient when dealing with direct call and indirect calls TODO test on pratchett * some issues with the measurements or with the measurer TODO go to sleep Signed-off-by: Jean Privat ---