aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-15 16:54:28 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-15 18:26:40 -0700
commit52712de67e16d36dd9c1325850c05fd14b00c621 (patch)
treed0da6ec4d4ba73a089fafb5bbd81106e04470304 /src
parent2a408cc988e83353556a910a7dfe3cf021d7cd44 (diff)
when we are calling an implemented function, call it using the signature it is implemented as, to avoid issues with LLVM casting for no reason
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js7
-rw-r--r--src/modules.js9
2 files changed, 15 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 38581ce4..e86a345d 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1498,7 +1498,12 @@ function JSify(data, functionsOnly, givenFunctions) {
var returnType = 'void';
if ((byPointer || ASM_JS) && hasReturn) {
- returnType = getReturnType(type);
+ if (callIdent in Functions.implementedFunctions) {
+ // LLVM sometimes bitcasts for no reason. We must call using the exact same type as the actual function is generated as
+ returnType = Functions.getSignatureReturnType(Functions.implementedFunctions[callIdent]);
+ } else {
+ returnType = getReturnType(type);
+ }
}
if (byPointer) {
diff --git a/src/modules.js b/src/modules.js
index 53d97817..8cfc38de 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -258,6 +258,15 @@ var Functions = {
return sig;
},
+ getSignatureReturnType: function(sig) {
+ switch(sig[0]) {
+ case 'v': return 'void';
+ case 'i': return 'i32';
+ case 'f': return 'double';
+ default: throw 'what is this sig? ' + sig;
+ }
+ },
+
// Mark a function as needing indexing. Python will coordinate them all
getIndex: function(ident, doNotCreate, sig) {
if (doNotCreate && !(ident in this.indexedFunctions)) {