summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/emscripten-optimizer/parser.h2
-rw-r--r--src/pass.cpp21
-rw-r--r--test/unit.asm.js4
-rw-r--r--test/unit.fromasm9
-rw-r--r--test/unit.fromasm.imprecise9
-rw-r--r--test/unit.wast9
-rw-r--r--test/unit.wast.fromBinary9
7 files changed, 60 insertions, 3 deletions
diff --git a/src/emscripten-optimizer/parser.h b/src/emscripten-optimizer/parser.h
index 367c831e2..9429ff87f 100644
--- a/src/emscripten-optimizer/parser.h
+++ b/src/emscripten-optimizer/parser.h
@@ -237,7 +237,7 @@ class Parser {
while (1) {
if (*src >= '0' && *src <= '9') { num *= 16; num += *src - '0'; }
else if (*src >= 'a' && *src <= 'f') { num *= 16; num += *src - 'a' + 10; }
- else if (*src >= 'A' && *src <= 'F') { num *= 16; num += *src - 'F' + 10; }
+ else if (*src >= 'A' && *src <= 'F') { num *= 16; num += *src - 'A' + 10; }
else break;
src++;
}
diff --git a/src/pass.cpp b/src/pass.cpp
index b0d4a316e..1a8aaabc9 100644
--- a/src/pass.cpp
+++ b/src/pass.cpp
@@ -68,20 +68,37 @@ void PassRunner::addDefaultOptimizationPasses() {
}
void PassRunner::run(Module* module) {
+ std::chrono::high_resolution_clock::time_point beforeEverything;
+ size_t padding = 0;
+ if (debug) {
+ std::cerr << "[PassRunner] running passes..." << std::endl;
+ beforeEverything = std::chrono::high_resolution_clock::now();
+ for (auto pass : passes) {
+ padding = std::max(padding, pass->name.size());
+ }
+ }
for (auto pass : passes) {
currPass = pass;
std::chrono::high_resolution_clock::time_point before;
if (debug) {
- std::cerr << "[PassRunner] running pass: " << pass->name << std::endl;
+ std::cerr << "[PassRunner] running pass: " << pass->name << "... ";
+ for (size_t i = 0; i < padding - pass->name.size(); i++) {
+ std::cerr << ' ';
+ }
before = std::chrono::high_resolution_clock::now();
}
pass->run(this, module);
if (debug) {
auto after = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = after - before;
- std::cerr << "[PassRunner] pass took " << diff.count() << " seconds." << std::endl;
+ std::cerr << diff.count() << " seconds." << std::endl;
}
}
+ if (debug) {
+ auto after = std::chrono::high_resolution_clock::now();
+ std::chrono::duration<double> diff = after - beforeEverything;
+ std::cerr << "[PassRunner] passes took " << diff.count() << " seconds." << std::endl;
+ }
}
template<class P>
diff --git a/test/unit.asm.js b/test/unit.asm.js
index cd432da5c..df731148a 100644
--- a/test/unit.asm.js
+++ b/test/unit.asm.js
@@ -52,6 +52,10 @@ function asm(global, env, buffer) {
var x = 0;
return !x;
}
+ function hexLiterals() {
+ var i = 0;
+ i = 0x0 + 0x12ABCdef + 0xFEDcba90;
+ }
function conversions() {
var i = 0, d = 0.0, f = Math_fround(0);
i = ~~d;
diff --git a/test/unit.fromasm b/test/unit.fromasm
index d426f377d..b54b4564c 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -119,6 +119,15 @@
)
)
)
+ (func $hexLiterals
+ (i32.add
+ (i32.add
+ (i32.const 0)
+ (i32.const 313249263)
+ )
+ (i32.const -19088752)
+ )
+ )
(func $conversions
(local $i i32)
(local $d f64)
diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise
index 613180bbd..ae9b4d70c 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -117,6 +117,15 @@
)
)
)
+ (func $hexLiterals
+ (i32.add
+ (i32.add
+ (i32.const 0)
+ (i32.const 313249263)
+ )
+ (i32.const -19088752)
+ )
+ )
(func $conversions
(local $i i32)
(local $d f64)
diff --git a/test/unit.wast b/test/unit.wast
index 164c6c651..6c37dd9f3 100644
--- a/test/unit.wast
+++ b/test/unit.wast
@@ -134,6 +134,15 @@
(i32.const 0)
)
)
+ (func $hexLiterals
+ (i32.add
+ (i32.add
+ (i32.const 0)
+ (i32.const 313249263)
+ )
+ (i32.const -19088752)
+ )
+ )
(func $conversions
(local $i i32)
(local $d f64)
diff --git a/test/unit.wast.fromBinary b/test/unit.wast.fromBinary
index b399d35ff..e99eb1309 100644
--- a/test/unit.wast.fromBinary
+++ b/test/unit.wast.fromBinary
@@ -137,6 +137,15 @@
(i32.const 0)
)
)
+ (func $hexLiterals (type $1)
+ (i32.add
+ (i32.add
+ (i32.const 0)
+ (i32.const 313249263)
+ )
+ (i32.const -19088752)
+ )
+ )
(func $conversions (type $1)
(local $var$0 i32)
(local $var$1 f64)