Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.3339
Browse files Browse the repository at this point in the history
Now the MT vm is using C intrinsics there are no trampolines for the COGMTVM
configuration.

First mostly stable version of the Threaded FFI.

Most important changes are:
1. Use C11 atomic instructions for the vmOwner.
This simplifies the CPXCHG instruction and should make this a lot more resistant to breaking due to compiler optimizations.

2. Fix a critical bug when reentering the threadSchedulingLoop
Previously this used the wrong jmp_buf, therefore a thread that tried to return to its threadSchedulingLoop might end up in the threadSchedulingLoop of ANOTHER thread!

With these two changes in place, the VM runs mostly stable whilst switching between two threads in the spurreader image.
There are still some bugs to fix, especially in the scheduler, as well as synchronizing access to the threads variable.
But this is good progress for now.

Rename CoInterpreterMT's processHasThreadId inst var to processHasThreadAffinity in the wake of Kernel-eem.1523.

First commit of Leon Matthes' work to revive the threaded FFI (committed by eem on behalf of LM cuz of Monticello permissions on source.squeak.org).

Fix simulation so that the current processor register state reflects the current Smalltalk process. Eliot's first attempt was a bit broken.  This approach of manually switching register states in tryLockVMOwnerTo: preserves fast simulation because we're not changing register state on every send to the processor object as was the case with the original MultiProcessor wrapper. Check for a missing register state by setting the register state for stack, frame & pc pointers to zero.  Label the processes spawned by the simulation so they show up nicely in the process browser.

releaseVM was used several places where disownVM: should have been used.

Simplify cedeToHigherPriorityThreads; the VM can't be unowned when invoked.

Nuke some unneeded halts.

minor clean-up/commentary.

Help myself by documenting what the snapshotPrimitive answers (false for snapshot, true for resume).

Simplify SpurMemoryManager>>#sufficientSpaceAfterGC:. Nuke an unused link reg related utility in the Cogit. Add the CogVMSimulator's fklush method to the STackInterpreterSimulator to ensure that GC progress is printed immediately while simulating.

Build: upgrade the 64=bit macos Makefilews so they can build MT VMs. mvm in
squeak.*.spur dirs now takes a -T arg and builds with -DCOGMTVM=1 in build??mt
to SqueakMT*.app
  • Loading branch information
eliotmiranda committed Oct 14, 2023
1 parent 330d677 commit ec421b9
Show file tree
Hide file tree
Showing 74 changed files with 1,530 additions and 2,822 deletions.
3 changes: 3 additions & 0 deletions building/macos64ARMv8/common/Makefile.app
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ ifeq ($(USEPLUGINASDYLIB),)
USEPLUGINASDYLIB:=FALSE
endif

ifeq ($(THREADING),multi)
APPNAME:=$(APPNAME)MT
endif
ifeq ($(CONFIGURATION),debug)
APP:=$(APPNAME)Debug.app
VM_IDENTIFIER:=$(APPIDENTIFIER)Debug
Expand Down
4 changes: 4 additions & 0 deletions building/macos64ARMv8/common/Makefile.vm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ else # default CONFIGURATION=product
endif
ifeq ($(THREADING),multi)
MAKERSRC:=$(wildcard $(VMSRCDIR)/gcc3x-*interpmt.c $(VMSRCDIR)/cogit.c)
BUILD:=$(BUILD)mt
else
MAKERSRC:=$(wildcard $(VMSRCDIR)/gcc3x-*interp.c $(VMSRCDIR)/cogit.c)
endif
Expand Down Expand Up @@ -128,6 +129,9 @@ TZ:=$(shell date +%Z)
DEFS:= -DUSE_GLOBAL_STRUCT=0 -DNO_ISNAN=1 \
-DUSE_INLINE_MEMORY_ACCESSORS -D'TZ="$(TZ)"' \
-DUSE_METAL=1 -DHAVE_CONFIG_H=1
ifeq ($(THREADING),multi)
DEFS:=-DCOGMTVM=1 $(DEFS)
endif
XDEFS:= -DSQUEAK_BUILTIN_PLUGIN
CFLAGS:= $(OFLAGS) $(COGDEFS) $(DEBUGVM) $(DEFS) $(XDEFS)
INCLUDES:= $(addprefix -I,. $(SRCDIRS))
Expand Down
35 changes: 24 additions & 11 deletions building/macos64ARMv8/squeak.cog.spur/mvm
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash
set -e
A=;D=;F=
# A=all(a,d,f) T=Threaded a=assert d=debug f=fast
A=;D=;F=;T=
if [ $# = 0 ]; then
A=1;D=1;F=1
else
while getopts 'ASTadf?' opt "$@"; do
case $opt in
A) A=1;D=1;F=1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) echo -T not yet implemented\; use -A for now 1>&1; exit 1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) T=THREADING=multi;;
a) A=1;;
d) D=1;;
f) F=1;;
Expand All @@ -23,12 +24,24 @@ else
shift `expr $OPTIND - 1`
fi
if ../../../scripts/checkSCCSversion ; then exit 1; fi
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
if [ -z "$T" ]; then
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
fi
else
if [ -n "$D" ]; then
make $@ $T debug 2>&1 | tee LOGTD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ $T assert 2>&1 | tee LOGTA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ $T 2>&1 | tee LOGTF ; test ${PIPESTATUS[0]} -eq 0
fi
fi
35 changes: 24 additions & 11 deletions building/macos64ARMv8/squeak.sista.spur/mvm
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash
set -e
A=;D=;F=
# A=all(a,d,f) T=Threaded a=assert d=debug f=fast
A=;D=;F=;T=
if [ $# = 0 ]; then
A=1;D=1;F=1
else
while getopts 'ASTadf?' opt "$@"; do
case $opt in
A) A=1;D=1;F=1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) echo -T not yet implemented\; use -A for now 1>&1; exit 1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) T=THREADING=multi;;
a) A=1;;
d) D=1;;
f) F=1;;
Expand All @@ -23,12 +24,24 @@ else
shift `expr $OPTIND - 1`
fi
if ../../../scripts/checkSCCSversion ; then exit 1; fi
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
if [ -z "$T" ]; then
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
fi
else
if [ -n "$D" ]; then
make $@ $T debug 2>&1 | tee LOGTD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ $T assert 2>&1 | tee LOGTA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ $T 2>&1 | tee LOGTF ; test ${PIPESTATUS[0]} -eq 0
fi
fi
35 changes: 24 additions & 11 deletions building/macos64ARMv8/squeak.stack.spur/mvm
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash
set -e
A=;D=;F=
# A=all(a,d,f) T=Threaded a=assert d=debug f=fast
A=;D=;F=;T=
if [ $# = 0 ]; then
A=1;D=1;F=1
else
while getopts 'ASTadf?' opt "$@"; do
case $opt in
A) A=1;D=1;F=1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) echo -T not yet implemented\; use -A for now 1>&1; exit 1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) T=THREADING=multi;;
a) A=1;;
d) D=1;;
f) F=1;;
Expand All @@ -23,12 +24,24 @@ else
shift `expr $OPTIND - 1`
fi
if ../../../scripts/checkSCCSversion ; then exit 1; fi
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
if [ -z "$T" ]; then
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
fi
else
if [ -n "$D" ]; then
make $@ $T debug 2>&1 | tee LOGTD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ $T assert 2>&1 | tee LOGTA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ $T 2>&1 | tee LOGTF ; test ${PIPESTATUS[0]} -eq 0
fi
fi
3 changes: 3 additions & 0 deletions building/macos64x64/common/Makefile.app
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ ifeq ($(USEPLUGINASDYLIB),)
USEPLUGINASDYLIB:=FALSE
endif

ifeq ($(THREADING),multi)
APPNAME:=$(APPNAME)MT
endif
ifeq ($(CONFIGURATION),debug)
APP:=$(APPNAME)Debug.app
VM_IDENTIFIER:=$(APPIDENTIFIER)Debug
Expand Down
4 changes: 4 additions & 0 deletions building/macos64x64/common/Makefile.vm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ else # default CONFIGURATION=product
endif
ifeq ($(THREADING),multi)
MAKERSRC:=$(wildcard $(VMSRCDIR)/gcc3x-*interpmt.c $(VMSRCDIR)/cogit.c)
BUILD:=$(BUILD)mt
else
MAKERSRC:=$(wildcard $(VMSRCDIR)/gcc3x-*interp.c $(VMSRCDIR)/cogit.c)
endif
Expand Down Expand Up @@ -128,6 +129,9 @@ TZ:=$(shell date +%Z)
DEFS:= -DUSE_GLOBAL_STRUCT=0 -DNO_ISNAN=1 \
-DUSE_INLINE_MEMORY_ACCESSORS -D'TZ="$(TZ)"' \
-DUSE_METAL=1 -DHAVE_CONFIG_H=1
ifeq ($(THREADING),multi)
DEFS:=-DCOGMTVM=1 $(DEFS)
endif
XDEFS:= -DSQUEAK_BUILTIN_PLUGIN
CFLAGS:= $(OFLAGS) $(COGDEFS) $(DEBUGVM) $(DEFS) $(XDEFS)
INCLUDES:= $(addprefix -I,. $(SRCDIRS))
Expand Down
35 changes: 24 additions & 11 deletions building/macos64x64/squeak.cog.spur/mvm
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash
set -e
A=;D=;F=
# A=all(a,d,f) T=Threaded a=assert d=debug f=fast
A=;D=;F=;T=
if [ $# = 0 ]; then
A=1;D=1;F=1
else
while getopts 'ASTadf?' opt "$@"; do
case $opt in
A) A=1;D=1;F=1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) echo -T not yet implemented\; use -A for now 1>&1; exit 1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) T=THREADING=multi;;
a) A=1;;
d) D=1;;
f) F=1;;
Expand All @@ -23,12 +24,24 @@ else
shift `expr $OPTIND - 1`
fi
if ../../../scripts/checkSCCSversion ; then exit 1; fi
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
if [ -z "$T" ]; then
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
fi
else
if [ -n "$D" ]; then
make $@ $T debug 2>&1 | tee LOGTD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ $T assert 2>&1 | tee LOGTA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ $T 2>&1 | tee LOGTF ; test ${PIPESTATUS[0]} -eq 0
fi
fi
35 changes: 24 additions & 11 deletions building/macos64x64/squeak.sista.spur/mvm
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash
set -e
A=;D=;F=
# A=all(a,d,f) T=Threaded a=assert d=debug f=fast
A=;D=;F=;T=
if [ $# = 0 ]; then
A=1;D=1;F=1
else
while getopts 'ASTadf?' opt "$@"; do
case $opt in
A) A=1;D=1;F=1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) echo -T not yet implemented\; use -A for now 1>&1; exit 1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) T=THREADING=multi;;
a) A=1;;
d) D=1;;
f) F=1;;
Expand All @@ -23,12 +24,24 @@ else
shift `expr $OPTIND - 1`
fi
if ../../../scripts/checkSCCSversion ; then exit 1; fi
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
if [ -z "$T" ]; then
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
fi
else
if [ -n "$D" ]; then
make $@ $T debug 2>&1 | tee LOGTD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ $T assert 2>&1 | tee LOGTA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ $T 2>&1 | tee LOGTF ; test ${PIPESTATUS[0]} -eq 0
fi
fi
35 changes: 24 additions & 11 deletions building/macos64x64/squeak.stack.spur/mvm
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash
set -e
A=;D=;F=
# A=all(a,d,f) T=Threaded a=assert d=debug f=fast
A=;D=;F=;T=
if [ $# = 0 ]; then
A=1;D=1;F=1
else
while getopts 'ASTadf?' opt "$@"; do
case $opt in
A) A=1;D=1;F=1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) echo -T not yet implemented\; use -A for now 1>&1; exit 1;;
S) echo -S not yet implemented\; use -A for now 1>&1; exit 1;;
T) T=THREADING=multi;;
a) A=1;;
d) D=1;;
f) F=1;;
Expand All @@ -23,12 +24,24 @@ else
shift `expr $OPTIND - 1`
fi
if ../../../scripts/checkSCCSversion ; then exit 1; fi
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
if [ -z "$T" ]; then
if [ -n "$D" ]; then
make $@ debug 2>&1 | tee LOGD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ assert 2>&1 | tee LOGA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ 2>&1 | tee LOGF ; test ${PIPESTATUS[0]} -eq 0
fi
else
if [ -n "$D" ]; then
make $@ $T debug 2>&1 | tee LOGTD ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$A" ]; then
make $@ $T assert 2>&1 | tee LOGTA ; test ${PIPESTATUS[0]} -eq 0
fi
if [ -n "$F" ]; then
make $@ $T 2>&1 | tee LOGTF ; test ${PIPESTATUS[0]} -eq 0
fi
fi
Loading

0 comments on commit ec421b9

Please sign in to comment.