fix: properly align atomic counters

This commit is contained in:
Marc Vertes
2019-11-08 00:34:04 +01:00
committed by Traefiker Bot
parent a6ecebab92
commit 773147ef71

View File

@@ -53,11 +53,14 @@ type receiver struct {
// frame contains values for the current execution level (a function context)
type frame struct {
// id is an atomic counter used for cancellation, only access
// via newFrame/runid/setrunid/clone.
// Located at start of struct to ensure proper aligment.
id uint64
anc *frame // ancestor frame (global space)
data []reflect.Value // values
id uint64 // for cancellation, only access via newFrame/runid/setrunid/clone.
mutex sync.RWMutex
deferred [][]reflect.Value // defer stack
recovered interface{} // to handle panic recover
@@ -108,6 +111,12 @@ type opt struct {
// Interpreter contains global resources and state
type Interpreter struct {
// id is an atomic counter counter used for run cancellation,
// only accessed via runid/stop
// Located at start of struct to ensure proper alignment on 32 bit
// architectures.
id uint64
Name string // program name
opt // user settable options
@@ -117,8 +126,6 @@ type Interpreter struct {
binPkg Exports // binary packages used in interpreter, indexed by path
rdir map[string]bool // for src import cycle detection
id uint64 // for cancellation, only accessed via runid/stop
mutex sync.RWMutex
frame *frame // program data storage during execution
universe *scope // interpreter global level scope