diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-01-07 14:02:19 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-01-07 14:02:19 -0800 |
commit | 7d249fbeb1ffea43e705f180a67abdfbe2fbae42 (patch) | |
tree | 789727cd4f43e381ec403c051ec861203d4a6b98 | |
parent | 79f0cfe423103c7c857c0abc2362608d64878c13 (diff) |
add asm.js mode to relooper, for label comparisons1.2.1
-rw-r--r-- | src/jsifier.js | 2 | ||||
-rw-r--r-- | src/relooper/Relooper.cpp | 12 | ||||
-rw-r--r-- | src/relooper/Relooper.h | 4 | ||||
-rw-r--r-- | src/relooper/emscripten/Makefile | 18 | ||||
-rw-r--r-- | src/relooper/emscripten/glue.js | 3 | ||||
-rw-r--r-- | tools/shared.py | 4 |
6 files changed, 22 insertions, 21 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 64ac707b..24af5b6d 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -724,6 +724,8 @@ function JSify(data, functionsOnly, givenFunctions) { //Relooper.setDebug(1); Relooper.init(); + if (ASM_JS) Relooper.setAsmJSMode(1); + var blockMap = {}; // add blocks for (var i = 0; i < block.labels.length; i++) { diff --git a/src/relooper/Relooper.cpp b/src/relooper/Relooper.cpp index 933fda96..fe151364 100644 --- a/src/relooper/Relooper.cpp +++ b/src/relooper/Relooper.cpp @@ -58,6 +58,8 @@ void PutIndented(const char *String) { *OutputBuffer = 0; } +static int AsmJS = 0; + // Indenter #if EMSCRIPTEN @@ -271,7 +273,7 @@ void MultipleShape::Render(bool InLoop) { RenderLoopPrefix(); bool First = true; for (BlockShapeMap::iterator iter = InnerMap.begin(); iter != InnerMap.end(); iter++) { - PrintIndented("%sif (label == %d) {\n", First ? "" : "else ", iter->first->Id); + PrintIndented("%sif (label%s == %d) {\n", First ? "" : "else ", AsmJS ? "|0" : "", iter->first->Id); First = false; Indenter::Indent(); iter->second->Render(InLoop); @@ -977,6 +979,10 @@ void Relooper::MakeOutputBuffer(int Size) { OutputBufferSize = Size; } +void Relooper::SetAsmJSMode(int On) { + AsmJS = On; +} + #if DEBUG // Debugging @@ -1018,6 +1024,10 @@ void rl_make_output_buffer(int size) { Relooper::SetOutputBuffer((char*)malloc(size), size); } +void rl_set_asm_js_mode(int on) { + Relooper::SetAsmJSMode(on); +} + void *rl_new_block(const char *text) { Block *ret = new Block(text); #if DEBUG diff --git a/src/relooper/Relooper.h b/src/relooper/Relooper.h index 08ac8e40..eac03738 100644 --- a/src/relooper/Relooper.h +++ b/src/relooper/Relooper.h @@ -200,6 +200,9 @@ struct Relooper { // Creates an output buffer. Must call this or SetOutputBuffer. static void MakeOutputBuffer(int Size); + + // Sets asm.js mode on or off (default is off) + static void SetAsmJSMode(int On); }; typedef std::set<Block*> BlockSet; @@ -231,6 +234,7 @@ extern "C" { RELOOPERDLL_API void rl_set_output_buffer(char *buffer, int size); RELOOPERDLL_API void rl_make_output_buffer(int size); +RELOOPERDLL_API void rl_set_asm_js_mode(int on); RELOOPERDLL_API void *rl_new_block(const char *text); RELOOPERDLL_API void rl_delete_block(void *block); RELOOPERDLL_API void rl_block_add_branch_to(void *from, void *to, const char *condition, const char *code); diff --git a/src/relooper/emscripten/Makefile b/src/relooper/emscripten/Makefile deleted file mode 100644 index 277dd538..00000000 --- a/src/relooper/emscripten/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -EMSCRIPTEN = ~/Dev/emscripten -EMCC = $(EMSCRIPTEN)/emcc -BINDINGS_GENERATOR = $(EMSCRIPTEN)/tools/bindings_generator.py -NATIVIZER = $(EMSCRIPTEN)/tools/nativize_llvm.py - -all: relooper.js - -relooper.js: - $(EMCC) -O2 ../Relooper.cpp -I.. --post-js glue.js -o relooper.raw.js -s TOTAL_MEMORY=52428800 -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE='["memcpy", "memset", "malloc", "free", "puts"]' - echo "// Relooper, (C) 2012 Alon Zakai, MIT license, https://github.com/kripken/Relooper" > relooper.js - echo "var Relooper = (function() {" >> relooper.js - cat relooper.raw.js >> relooper.js - echo " return Module.Relooper;" >> relooper.js - echo "})();" >> relooper.js - -clean: - rm relooper.js - diff --git a/src/relooper/emscripten/glue.js b/src/relooper/emscripten/glue.js index 15998acf..36922185 100644 --- a/src/relooper/emscripten/glue.js +++ b/src/relooper/emscripten/glue.js @@ -49,6 +49,9 @@ RelooperGlue['setDebug'] = function(debug) { _rl_set_debugging(+!!debug); }; + RelooperGlue['setAsmJSMode'] = function(on) { + _rl_set_asm_js_mode(on); + }; Module['Relooper'] = RelooperGlue; diff --git a/tools/shared.py b/tools/shared.py index 7977b37a..d51312dc 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -172,7 +172,7 @@ def check_node_version(): # we re-check sanity when the settings are changed) # We also re-check sanity and clear the cache when the version changes -EMSCRIPTEN_VERSION = '1.2.0' +EMSCRIPTEN_VERSION = '1.2.1' def check_sanity(force=False): try: @@ -1127,7 +1127,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e Building.emcc(os.path.join('relooper', 'Relooper.cpp'), ['-I' + os.path.join('relooper'), '--post-js', os.path.join('relooper', 'emscripten', 'glue.js'), '-s', 'TOTAL_MEMORY=52428800', - '-s', 'EXPORTED_FUNCTIONS=["_rl_set_output_buffer","_rl_make_output_buffer","_rl_new_block","_rl_delete_block","_rl_block_add_branch_to","_rl_new_relooper","_rl_delete_relooper","_rl_relooper_add_block","_rl_relooper_calculate","_rl_relooper_render"]', + '-s', 'EXPORTED_FUNCTIONS=["_rl_set_output_buffer","_rl_make_output_buffer","_rl_new_block","_rl_delete_block","_rl_block_add_branch_to","_rl_new_relooper","_rl_delete_relooper","_rl_relooper_add_block","_rl_relooper_calculate","_rl_relooper_render", "_rl_set_asm_js_mode"]', '-s', 'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=["memcpy", "memset", "malloc", "free", "puts"]', '-O' + str(opt_level), '--closure', '0'], raw) f = open(RELOOPER, 'w') |