aboutsummaryrefslogtreecommitdiff
path: root/src/relooper
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-07 14:02:19 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-07 14:02:19 -0800
commit7d249fbeb1ffea43e705f180a67abdfbe2fbae42 (patch)
tree789727cd4f43e381ec403c051ec861203d4a6b98 /src/relooper
parent79f0cfe423103c7c857c0abc2362608d64878c13 (diff)
add asm.js mode to relooper, for label comparisons1.2.1
Diffstat (limited to 'src/relooper')
-rw-r--r--src/relooper/Relooper.cpp12
-rw-r--r--src/relooper/Relooper.h4
-rw-r--r--src/relooper/emscripten/Makefile18
-rw-r--r--src/relooper/emscripten/glue.js3
4 files changed, 18 insertions, 19 deletions
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;