From 262bf6fbddf19eb1b365de91aab36c7d4578c135 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 18 Nov 2015 16:06:12 -0800 Subject: start to special-case asm math builtins --- src/asm2wasm.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 588754580..5614329d0 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -34,6 +34,8 @@ IString GLOBAL("global"), NAN_("NaN"), INFINITY_("Infinity"), ASM2WASM("asm2wasm"), F64_REM("f64-rem"), F64_TO_INT("f64-to-int"), + GLOBAL_MATH("global.Math"), + ABS("abs"), DEBUGGER("debugger"); @@ -534,6 +536,16 @@ void Asm2WasmBuilder::processAsm(Ref ast) { IString name = pair.first; Import& import = *pair.second; if (importedFunctionTypes.find(name) != importedFunctionTypes.end()) { + // special math builtins + if (import.module == GLOBAL_MATH) { + IString base = import.base; + if (base == ABS /* XXX, this should be overloaded */) { + import.type = FunctionType(); + import.type.params.push_back(f64); + import.type.result = f64; + continue; + } + } import.type = importedFunctionTypes[name]; } else if (import.module != ASM2WASM) { // special-case the special module // never actually used -- cgit v1.2.3