aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/internal/obj')
-rw-r--r--src/cmd/internal/obj/link.go42
-rw-r--r--src/cmd/internal/obj/wasm/wasmobj.go8
2 files changed, 45 insertions, 5 deletions
diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go
index c34a769a82..7530690185 100644
--- a/src/cmd/internal/obj/link.go
+++ b/src/cmd/internal/obj/link.go
@@ -603,6 +603,48 @@ func ParseABI(abistr string) (ABI, bool) {
}
}
+// ABISet is a bit set of ABI values.
+type ABISet uint8
+
+const (
+ // ABISetCallable is the set of all ABIs any function could
+ // potentially be called using.
+ ABISetCallable ABISet = (1 << ABI0) | (1 << ABIInternal)
+)
+
+// Ensure ABISet is big enough to hold all ABIs.
+var _ ABISet = 1 << (ABICount - 1)
+
+func ABISetOf(abi ABI) ABISet {
+ return 1 << abi
+}
+
+func (a *ABISet) Set(abi ABI, value bool) {
+ if value {
+ *a |= 1 << abi
+ } else {
+ *a &^= 1 << abi
+ }
+}
+
+func (a *ABISet) Get(abi ABI) bool {
+ return (*a>>abi)&1 != 0
+}
+
+func (a ABISet) String() string {
+ s := "{"
+ for i := ABI(0); a != 0; i++ {
+ if a&(1<<i) != 0 {
+ if s != "{" {
+ s += ","
+ }
+ s += i.String()
+ a &^= 1 << i
+ }
+ }
+ return s + "}"
+}
+
// Attribute is a set of symbol attributes.
type Attribute uint32
diff --git a/src/cmd/internal/obj/wasm/wasmobj.go b/src/cmd/internal/obj/wasm/wasmobj.go
index 2e9890d86c..ceeae7a257 100644
--- a/src/cmd/internal/obj/wasm/wasmobj.go
+++ b/src/cmd/internal/obj/wasm/wasmobj.go
@@ -144,11 +144,9 @@ func instinit(ctxt *obj.Link) {
gcWriteBarrier = ctxt.LookupABI("runtime.gcWriteBarrier", obj.ABIInternal)
sigpanic = ctxt.LookupABI("runtime.sigpanic", obj.ABIInternal)
deferreturn = ctxt.LookupABI("runtime.deferreturn", obj.ABIInternal)
- // jmpdefer is defined in assembly as ABI0, but what we're
- // looking for is the *call* to jmpdefer from the Go function
- // deferreturn, so we're looking for the ABIInternal version
- // of jmpdefer that's called by Go.
- jmpdefer = ctxt.LookupABI(`"".jmpdefer`, obj.ABIInternal)
+ // jmpdefer is defined in assembly as ABI0. The compiler will
+ // generate a direct ABI0 call from Go, so look for that.
+ jmpdefer = ctxt.LookupABI(`"".jmpdefer`, obj.ABI0)
}
func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {