diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/js-optimizer.js | 5 | ||||
-rw-r--r-- | tools/shared.py | 21 |
2 files changed, 21 insertions, 5 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index e889c7a3..d22de39c 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -193,6 +193,11 @@ function unGlobalize(ast) { // - and in library/shell code too! - we should never rely on // undefined being assigned. So we can simply remove those assignments. // +// Note: An inlined function that kept a large value referenced, may +// keep that references when inlined, if we remove the setting to +// undefined. This is not dangerous in compiled code, but might be +// in supporting code (for example, holding on to the HEAP when copying). +// // This pass assumes that unGlobalize has been run, so undefined // is now explicit. function removeAssignsToUndefined(ast) { diff --git a/tools/shared.py b/tools/shared.py index 632cf633..0aead08a 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -144,11 +144,22 @@ def read_pgo_data(filename): 'overflows_lines': overflows_lines } -# Settings - -class Dummy: pass - -Settings = Dummy() # A global singleton. Not pretty, but nicer than passing |, settings| everywhere +# Settings. A global singleton. Not pretty, but nicer than passing |, settings| everywhere + +class Settings: + @classmethod + def reset(self): + global Settings + class Settings2: + reset = Settings.reset + load_defaults = Settings.load_defaults + Settings = Settings2 + + @classmethod + def load_defaults(self): + ''' Load the JS settings into Python ''' + settings = open(path_from_root('src', 'settings.js')).read().replace('var ', 'Settings.').replace('//', '#') + exec(settings) # Building |