mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
compiler: adding a few more ignored init calls
These calls are generated in the JavaScript target (syscall/js and syscall with GOOS=js), but they are not used at the moment. So ignore them until they're needed.
This commit is contained in:
+13
-3
@@ -14,6 +14,16 @@ import (
|
||||
"golang.org/x/tools/go/ssa"
|
||||
)
|
||||
|
||||
// Ignore these calls (replace with a zero return value) when encountered during
|
||||
// interpretation.
|
||||
var ignoreInitCalls = map[string]struct{}{
|
||||
"syscall.runtime_envs": struct{}{},
|
||||
"syscall/js.predefValue": struct{}{},
|
||||
"(syscall/js.Value).Get": struct{}{},
|
||||
"(syscall/js.Value).New": struct{}{},
|
||||
"(syscall/js.Value).Int": struct{}{},
|
||||
}
|
||||
|
||||
// Interpret instructions as far as possible, and drop those instructions from
|
||||
// the basic block.
|
||||
func (p *Program) Interpret(block *ssa.BasicBlock, dumpSSA bool) error {
|
||||
@@ -81,9 +91,9 @@ func (p *Program) interpret(instrs []ssa.Instruction, paramKeys []*ssa.Parameter
|
||||
if callee == nil {
|
||||
return i, nil // don't understand dynamic dispatch
|
||||
}
|
||||
if callee.String() == "syscall.runtime_envs" {
|
||||
// TODO: replace this with some //go:linkname magic.
|
||||
// For now, do as if it returned a zero-length slice.
|
||||
if _, ok := ignoreInitCalls[callee.String()]; ok && callee.Signature.Results().Len() == 1 {
|
||||
// These calls are not needed and can be ignored, for the time
|
||||
// being.
|
||||
var err error
|
||||
locals[instr], err = p.getZeroValue(callee.Signature.Results().At(0).Type())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user