nitg-s: avoid `flatten_class_hierarchy` on intern method static call
authorJean Privat <jean@pryen.org>
Tue, 23 Jul 2013 16:11:08 +0000 (12:11 -0400)
committerJean Privat <jean@pryen.org>
Tue, 23 Jul 2013 16:11:08 +0000 (12:11 -0400)
just do the lookup on the realmainmodule to avoid flatten on various
mmodules. since the method is intern, the result is the same anyway.

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

src/abstract_compiler.nit
src/separate_compiler.nit

index f56e922..8fe53e5 100644 (file)
@@ -243,8 +243,12 @@ end
 abstract class AbstractCompiler
        type VISITOR: AbstractCompilerVisitor
 
-       # The main module of the program
-       var mainmodule: MModule protected writable
+       # The main module of the program currently compiled
+       # Is assigned during the separate compilation
+       var mainmodule: MModule writable
+
+       # The real main module of the program
+       var realmainmodule: MModule
 
        # The modeulbuilder used to know the model and the AST
        var modelbuilder: ModelBuilder protected writable
@@ -255,6 +259,7 @@ abstract class AbstractCompiler
        init(mainmodule: MModule, modelbuilder: ModelBuilder)
        do
                self.mainmodule = mainmodule
+               self.realmainmodule = mainmodule
                self.modelbuilder = modelbuilder
        end
 
index 8967946..2a72e79 100644 (file)
@@ -866,7 +866,13 @@ class SeparateCompilerVisitor
        redef fun send(mmethod, arguments)
        do
                if arguments.first.mcasttype.ctype != "val*" then
-                       return self.monomorphic_send(mmethod, arguments.first.mcasttype, arguments)
+                       # In order to shortcut the primitive, we need to find the most specific method
+                       # Howverr, because of performance (no flattening), we always work on the realmainmodule
+                       var m = self.compiler.mainmodule
+                       self.compiler.mainmodule = self.compiler.realmainmodule
+                       var res = self.monomorphic_send(mmethod, arguments.first.mcasttype, arguments)
+                       self.compiler.mainmodule = m
+                       return res
                end
 
                var res: nullable RuntimeVariable