]> Cypherpunks repositories - gostls13.git/commit
runtime: don't use maps in js note implementation
authorMichael Pratt <mpratt@google.com>
Thu, 27 Jun 2024 21:18:51 +0000 (17:18 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 1 Aug 2024 19:13:58 +0000 (19:13 +0000)
commit2caf638e2f8abf3ed765d553164fc3e46e1bf407
tree1f2fd579c1901b4c182e729ea4b46a4beefee406
parent38f0a829aa041cbe5f694da52d733352aa5b70bc
runtime: don't use maps in js note implementation

notes are used in sensitive locations in the runtime, such as those with
write barriers forbidden. Maps aren't designed for this sort of internal
use.

Notably, newm -> notewakeup doesn't allow write barriers, but mapaccess1
-> panic contains write barriers. The js runtime only builds right now
because the map access is optimized to mapaccess1_fast64, which happens
to not have a panic call.

The initial swisstable map implementation doesn't have a fast64 variant.
While we could add one, it is a bad idea in general to use a map in such
a fragile location. Simplify the implementation by storing the metadata
directly in the note, and using a linked list for checkTimeouts.

For #54766.

Cq-Include-Trybots: luci.golang.try:gotip-js-wasm
Change-Id: Ib9d39f064ae4ad32dcc873f799428717eb6c2d5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/595558
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/lock_js.go
src/runtime/note_js.go [new file with mode: 0644]
src/runtime/note_other.go [new file with mode: 0644]
src/runtime/runtime2.go