compile: add command line option to disable SFT optimization
authorJean-Sebastien Gelinas <calestar@gmail.com>
Thu, 27 Aug 2009 19:59:50 +0000 (15:59 -0400)
committerJean Privat <jean@pryen.org>
Tue, 1 Sep 2009 18:15:24 +0000 (14:15 -0400)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiling/compiling_global.nit
src/nitc.nit
src/program.nit

index 7123ad3..347d873 100644 (file)
@@ -78,13 +78,13 @@ redef class MMModule
        fun compile_mod_to_c(v: CompilerVisitor)
        do
                v.add_decl("extern const char *LOCATE_{name};")
-               if not v.program.tc.global then
+               if not v.program.tc.use_SFT_optimization then
                        v.add_decl("extern const int SFT_{name}[];")
                end
                var i = 0
                for e in local_table do
                        var value: String
-                       if v.program.tc.global then
+                       if v.program.tc.use_SFT_optimization then
                                value = "{e.value(v.program)}"
                        else
                                value = "SFT_{name}[{i}]"
@@ -116,7 +116,7 @@ redef class MMModule
        do
                v.add_instr("const char *LOCATE_{name} = \"{location.file}\";")
 
-               if v.program.tc.global or local_table.is_empty then
+               if v.program.tc.use_SFT_optimization or local_table.is_empty then
                        return
                end
 
index cb9b5b1..688f889 100644 (file)
@@ -30,6 +30,7 @@ special AbstractCompiler
        readable var _opt_boost: OptionBool = new OptionBool("Optimize compilation", "-O", "--boost")
        readable var _opt_no_cc: OptionBool = new OptionBool("Do not invoke C compiler", "--no_cc")
        readable var _opt_global: OptionBool = new OptionBool("Use global compilation", "--global")
+       readable var _opt_global_no_STF_opt: OptionBool = new OptionBool("Do not use SFT optimization", "--no-global-SFT-optimization")
        readable var _opt_clibdir: OptionString = new OptionString("NIT C library directory", "--clibdir")
        readable var _opt_bindir: OptionString = new OptionString("NIT tools directory", "--bindir")
        readable var _opt_compdir: OptionString = new OptionString("Intermediate compilation directory", "--compdir")
@@ -39,7 +40,7 @@ special AbstractCompiler
        init
        do
                super("nitc")
-               option_context.add_option(opt_output, opt_boost, opt_no_cc, opt_global, opt_clibdir, opt_bindir, opt_compdir, opt_extension_prefix, opt_dump)
+               option_context.add_option(opt_output, opt_boost, opt_no_cc, opt_global, opt_clibdir, opt_bindir, opt_compdir, opt_extension_prefix, opt_dump, opt_global_no_STF_opt)
        end
 
        redef fun process_options
@@ -51,6 +52,7 @@ special AbstractCompiler
                var ext = opt_extension_prefix.value
                if ext != null then ext_prefix = ext else ext_prefix = ""
                global = opt_global.value
+               use_SFT_optimization = not opt_global_no_STF_opt.value
                compdir = opt_compdir.value
                if compdir == null then
                        var dir = once ("NIT_COMPDIR".to_symbol).environ
index f0f2bb2..6952c42 100644 (file)
@@ -24,6 +24,11 @@ import mmloader
 
 redef class ToolContext
        readable writable var _global: Bool = false
+       writable var _use_SFT_optimization: Bool = true
+
+       # We can say that we are using SFT optimization *only* when we are
+       # doing global compilation and we enabled the command line option
+       fun use_SFT_optimization: Bool do return global and _use_SFT_optimization
 end
 
 # Instances of this class represent a program/library that will