Commit 20a205d0 authored by Camil Staps's avatar Camil Staps 🍃

Minor optimizations, mainly for Reals in the wasm interpreter

parent 39a6d9af
Pipeline #24465 failed with stages
in 10 minutes and 25 seconds
......@@ -235,11 +235,16 @@ intp = new Uint8Array(intp);
if (scriptArgs.indexOf('--extract-code') >= 0) {
var obj = wasmExtractCode(intp.module, 'best');
const extractable = ['interpret'];
var exports = {};
for (var f in intp.instance.exports)
exports[intp.instance.exports[f].name] = f;
obj.segments.filter(seg => seg.kind == 0).map(function (seg) {
obj.segments.filter(function (seg) {
return seg.kind == 0 &&
extractable.indexOf(exports[seg.funcIndex]) >= 0;
}).map(function (seg) {
var name = seg.funcIndex in exports ? exports[seg.funcIndex] : ('_'+seg.funcIndex);
var filename = 'disas-'+name+'.bin';
var code = obj.code.subarray(seg.funcBodyBegin, seg.funcBodyEnd);
......
......@@ -281,7 +281,14 @@ optimize set e = case e of
Ediv t signed a b -> Ediv t signed (optimize set a) (optimize set b)
Erem t signed a b -> Erem t signed (optimize set a) (optimize set b)
Eeq t a b -> Eeq t (optimize set a) (optimize set b)
Eeq t a b -> case oa of
Econst _ v | is_zero v -> Eeqz t ob
_ -> case ob of
Econst _ v | is_zero v -> Eeqz t oa
_ -> Eeq t oa ob
with
oa = optimize set a
ob = optimize set b
Ene t a b -> Ene t (optimize set a) (optimize set b)
Elt t signed a b -> Elt t signed (optimize set a) (optimize set b)
Egt t signed a b -> Egt t signed (optimize set a) (optimize set b)
......@@ -306,9 +313,15 @@ optimize set e = case e of
e
-> Ewrap to fr e
Eextend to fr e -> Eextend to fr (optimize set e)
Ereinterpret to fr e -> Ereinterpret to fr (optimize set e)
Etrunc to fr e -> Etrunc to fr (optimize set e)
Econvert to fr e -> Econvert to fr (optimize set e)
Ereinterpret to fr e -> case optimize set e of
Eload ltype stype signed o a | fr==ltype
-> Eload to stype signed o a
e
-> Ereinterpret to fr e
Etrunc to fr e -> Etrunc to fr (optimize set e)
Econvert to fr e -> Econvert to fr (optimize set e)
Ivar _ -> e
Iref t1 t2 o a -> Eload t1 t2 DontCare o (optimize set a)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment