forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mt-cannon: Implement mips logic (ethereum-optimism#11188)
* cannon: Copy over singlethreaded impls as a starting point * cannon: Update mips property access to work with MTState * cannon: Add new syscall constants * mt-cannon: Implement clone syscall * mt-cannon: Implement remaining new syscalls * mt-cannon: Implement thread traversal changes to mipsStep() * mt-cannon: Add logger, log when max steps reached * mt-cannon: Implement onWaitComplete() * mt-cannon: Implement thread manipulation methods Also, use slices of pointers for the thread stacks * mt-cannon: Move thread traversal fns to mips.go * mt-cannon: Fix issue where wakeup traversal never stops * mt-cannon: Fix issue where we can end up popping an empty stack * mt-cannon: Move thread definitions to new thread.go file * cannon: Add compile-time type checks for FPVM(State) impls * mt-cannon: Add new threaded StackTracker * mt-cannon: Update proof generation to include thread proof * mt-cannon: Move FPVM compile-time type check * cannon: Run common vm tests across all FPVM impls * cannon: Cut OpenMIPS clone test * cannon: Cleanup - fix some discrepancies, clarify constant * cannon: Disable mem profiling in op-program instead of patch.go * cannon: Consolidate calls to program.PatchGo * cannon: Disable program.PatchGo in MTCannon tests * mt-cannon: Add multithreaded program test * cannon: Only run sleep check for single-threaded cannon * op-program: Update profiling before dependency init fns are called * mt-cannon: Track stack on thread clone, handled popped threads * mt-cannon: Panic if unrecognized syscall is executed * mt-cannon: Panic if unexpected flags are passed to SysClone * mt-cannon: Add some tests for EncodeThreadProof() * mt-cannon: Add some more tests around threadProof edge cases * mt-cannon: Minimize logging * cannon: Update go version in cannon/example/multithreaded/go.mod Co-authored-by: Inphi <[email protected]> * mt-cannon: Rework clone behavior based on feedback * mt-cannon: Rework wakeup logic * mt-cannon: Cleanup - simplify clone, refine logging * Revert "cannon: Cut OpenMIPS clone test" This reverts commit d876d6a. * mt-cannon: Skip open-mips clone test add todos * mt-cannon: Handle munmap syscall * mt-cannon: Exit if the last thread exits * cannon: Clarify skip comment * cannon: Add some todos * cannon: Add guard around logging --------- Co-authored-by: Inphi <[email protected]>
- Loading branch information
Showing
27 changed files
with
1,268 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module multithreaded | ||
|
||
go 1.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime" | ||
"sync" | ||
"sync/atomic" | ||
) | ||
|
||
func main() { | ||
// try some concurrency! | ||
var wg sync.WaitGroup | ||
wg.Add(2) | ||
var x atomic.Int32 | ||
go func() { | ||
x.Add(2) | ||
wg.Done() | ||
}() | ||
go func() { | ||
x.Add(40) | ||
wg.Done() | ||
}() | ||
wg.Wait() | ||
fmt.Printf("waitgroup result: %d\n", x.Load()) | ||
|
||
// channels | ||
a := make(chan int, 1) | ||
b := make(chan int) | ||
c := make(chan int) | ||
go func() { | ||
t0 := <-a | ||
b <- t0 | ||
}() | ||
go func() { | ||
t1 := <-b | ||
c <- t1 | ||
}() | ||
a <- 1234 | ||
out := <-c | ||
fmt.Printf("channels result: %d\n", out) | ||
|
||
// try a GC! (the runtime might not have run one yet) | ||
runtime.GC() | ||
_, _ = os.Stdout.Write([]byte("GC complete!\n")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.