mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 21:43:40 +00:00
compiler: work around i64 limitation in JavaScript
JavaScript does not support i64 directly, so make sure we pass a pointer instead which can be read from JavaScript. This is a temporary workaround which should be removed once JavaScript supports some form of i64 (probably in the form of BigInt).
This commit is contained in:
@@ -64,6 +64,15 @@ func Compile(pkgName, outpath string, spec *TargetSpec, config *BuildConfig, act
|
||||
return err
|
||||
}
|
||||
|
||||
// Browsers cannot handle external functions that have type i64 because it
|
||||
// cannot be represented exactly in JavaScript (JS only has doubles). To
|
||||
// keep functions interoperable, pass int64 types as pointers to
|
||||
// stack-allocated values.
|
||||
if strings.HasPrefix(spec.Triple, "wasm") {
|
||||
c.ExternalInt64AsPtr()
|
||||
c.Verify()
|
||||
}
|
||||
|
||||
// Optimization levels here are roughly the same as Clang, but probably not
|
||||
// exactly.
|
||||
switch config.opt {
|
||||
|
||||
Reference in New Issue
Block a user