Skip to content

Commit e54c491

Browse files
Got it compiling for abi tests, still panicked but getting there
1 parent e7aa99f commit e54c491

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

compiler/natives/src/internal/abi/type.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,12 @@ func CopyStruct(dst, src *js.Object, typ *Type) {
462462
dst.Set(prop, src.Get(prop))
463463
}
464464
}
465+
466+
//gopherjs:purge Uses unsafeSliceFor
467+
func (t *Type) GcSlice(begin, end uintptr) []byte
468+
469+
//gopherjs:purge Uses unsafe.String or stringHeader
470+
func unsafeStringFor(b *byte, l int) string
471+
472+
//gopherjs:purge Uses unsafe.Slice or sliceHeader
473+
func unsafeSliceFor(b *byte, l int) []byte

compiler/natives/src/internal/abi/utils.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import (
99
)
1010

1111
// GOPHERJS: These utils are being added because they are common between
12-
// reflect and reflectlite.
12+
// reflect and reflectlite. The [Go proverb](https://go-proverbs.github.io/),
13+
// "A little copying is better than a little dependency," isn't applicable
14+
// when both reflect and reflectlite already depend on ABI. We can reduce
15+
// our native overrides in both locations by putting common code here.
1316

1417
//gopherjs:new
1518
type errorString struct {

compiler/natives/src/reflect/type.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,15 @@ func StructOf(fields []StructField) Type {
229229
}
230230
return toRType(abi.ReflectType(typ))
231231
}
232+
233+
//gopherjs:purge Used in original MapOf and not used in override MapOf by GopherJS
234+
func bucketOf(ktyp, etyp *abi.Type) *abi.Type
235+
236+
//gopherjs:purge Relates to GC programs not valid for GopherJS
237+
func (t *rtype) gcSlice(begin, end uintptr) []byte
238+
239+
//gopherjs:purge Relates to GC programs not valid for GopherJS
240+
func emitGCMask(out []byte, base uintptr, typ *abi.Type, n uintptr)
241+
242+
//gopherjs:purge Relates to GC programs not valid for GopherJS
243+
func appendGCProg(dst []byte, typ *abi.Type) []byte

compiler/natives/src/sync/sync.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,13 @@ func runtime_nanotime() int64
8787
func throw(s string) {
8888
js.Global.Call("$throwRuntimeError", s)
8989
}
90+
91+
// GOPHERJS: This is identical to the original but without the go:linkname
92+
// that can not be handled right now, "can not insert local implementation..."
93+
// TODO(grantnelson-wf): Remove once linking works both directions.
94+
//
95+
//gopherjs:replace
96+
func syscall_hasWaitingReaders(rw *RWMutex) bool {
97+
r := rw.readerCount.Load()
98+
return r < 0 && r+rwmutexMaxReaders > 0
99+
}

compiler/natives/src/syscall/syscall_js_wasm.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package syscall
22

33
import (
4+
"sync"
45
"syscall/js"
56
_ "unsafe" // go:linkname
67
)
@@ -52,6 +53,14 @@ func unsetenv_c(k string) {
5253
//go:linkname godebug_notify runtime.godebug_notify
5354
func godebug_notify(key, value string)
5455

56+
// GOPHERJS: This was replaced so that we could add the go:linkname since
57+
// sync.syscall_hasWaitingReaders had a link we can't handle right now,
58+
// "can not insert local implementation..."
59+
// TODO(grantnelson-wf): Remove once linking works both directions.
60+
//
61+
//go:linkname hasWaitingReaders sync.syscall_hasWaitingReaders
62+
func hasWaitingReaders(rw *sync.RWMutex) bool
63+
5564
func setStat(st *Stat_t, jsSt js.Value) {
5665
// This method is an almost-exact copy of upstream, except for 4 places where
5766
// time stamps are obtained as floats in lieu of int64. Upstream wasm emulates

0 commit comments

Comments
 (0)