diff --git a/building/macos64ARMv8/common/Makefile.app b/building/macos64ARMv8/common/Makefile.app index adcccee785..886ac49193 100644 --- a/building/macos64ARMv8/common/Makefile.app +++ b/building/macos64ARMv8/common/Makefile.app @@ -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 diff --git a/building/macos64ARMv8/common/Makefile.vm b/building/macos64ARMv8/common/Makefile.vm index 09949a3a2f..d648dcc2d5 100644 --- a/building/macos64ARMv8/common/Makefile.vm +++ b/building/macos64ARMv8/common/Makefile.vm @@ -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 @@ -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)) diff --git a/building/macos64ARMv8/squeak.cog.spur/mvm b/building/macos64ARMv8/squeak.cog.spur/mvm index bd724e6930..a58a6df2b8 100755 --- a/building/macos64ARMv8/squeak.cog.spur/mvm +++ b/building/macos64ARMv8/squeak.cog.spur/mvm @@ -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;; @@ -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 diff --git a/building/macos64ARMv8/squeak.sista.spur/mvm b/building/macos64ARMv8/squeak.sista.spur/mvm index bd724e6930..a58a6df2b8 100755 --- a/building/macos64ARMv8/squeak.sista.spur/mvm +++ b/building/macos64ARMv8/squeak.sista.spur/mvm @@ -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;; @@ -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 diff --git a/building/macos64ARMv8/squeak.stack.spur/mvm b/building/macos64ARMv8/squeak.stack.spur/mvm index bd724e6930..a58a6df2b8 100755 --- a/building/macos64ARMv8/squeak.stack.spur/mvm +++ b/building/macos64ARMv8/squeak.stack.spur/mvm @@ -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;; @@ -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 diff --git a/building/macos64x64/common/Makefile.app b/building/macos64x64/common/Makefile.app index adcccee785..886ac49193 100644 --- a/building/macos64x64/common/Makefile.app +++ b/building/macos64x64/common/Makefile.app @@ -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 diff --git a/building/macos64x64/common/Makefile.vm b/building/macos64x64/common/Makefile.vm index 09949a3a2f..d648dcc2d5 100644 --- a/building/macos64x64/common/Makefile.vm +++ b/building/macos64x64/common/Makefile.vm @@ -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 @@ -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)) diff --git a/building/macos64x64/squeak.cog.spur/mvm b/building/macos64x64/squeak.cog.spur/mvm index bd724e6930..a58a6df2b8 100755 --- a/building/macos64x64/squeak.cog.spur/mvm +++ b/building/macos64x64/squeak.cog.spur/mvm @@ -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;; @@ -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 diff --git a/building/macos64x64/squeak.sista.spur/mvm b/building/macos64x64/squeak.sista.spur/mvm index bd724e6930..a58a6df2b8 100755 --- a/building/macos64x64/squeak.sista.spur/mvm +++ b/building/macos64x64/squeak.sista.spur/mvm @@ -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;; @@ -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 diff --git a/building/macos64x64/squeak.stack.spur/mvm b/building/macos64x64/squeak.stack.spur/mvm index bd724e6930..a58a6df2b8 100755 --- a/building/macos64x64/squeak.stack.spur/mvm +++ b/building/macos64x64/squeak.stack.spur/mvm @@ -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;; @@ -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 diff --git a/src/plugins/FilePlugin/FilePlugin.c b/src/plugins/FilePlugin/FilePlugin.c index 4ed8f7a597..1f81b742e2 100644 --- a/src/plugins/FilePlugin/FilePlugin.c +++ b/src/plugins/FilePlugin/FilePlugin.c @@ -1,9 +1,9 @@ /* Automatically generated by - VMPluginCodeGenerator VMMaker.oscog-eem.3216 uuid: 6a3c37f5-cdcd-4eda-874c-cd4ea7f427a2 + VMPluginCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - FilePlugin VMMaker.oscog-eem.3216 uuid: 6a3c37f5-cdcd-4eda-874c-cd4ea7f427a2 + FilePlugin VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "FilePlugin VMMaker.oscog-eem.3216 uuid: 6a3c37f5-cdcd-4eda-874c-cd4ea7f427a2 " __DATE__ ; +static char __buildInfo[] = "FilePlugin VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; #include "config.h" @@ -220,7 +220,7 @@ extern sqInt unpinObject(sqInt anObject); extern #endif struct VirtualMachine* interpreterProxy; -static const char *moduleName = "FilePlugin VMMaker.oscog-eem.3216 " INT_EXT; +static const char *moduleName = "FilePlugin VMMaker.oscog-eem.3339 " INT_EXT; static void * sCCPfn; static void * sCDFfn; static void * sCDPfn; @@ -734,6 +734,19 @@ primitiveDirectoryDelimitor(void) /* Two arguments - directory path, and simple file name; returns an array (see primitiveDirectoryLookup) describing the file or directory, or nil if it does not exist. + + Note that in general, the directory path name must not contain syntactic + sugar for the current platform (e.g., '.' or '..', or on Windows, forward + slashes instead of backslashes). These conventions are only fully + supported on Unix + platforms; on Windows, they are only supported for short non-UNC file + paths containing max 260 characters (for the full path concatenated from + the directory path, a backslash, and the file name): + DON'T: primitiveDirectoryEntry '\foo\.' ... + DON'T: primitiveDirectoryEntry '\foo\..' ... + DON'T (on Windows): primitiveDirectoryEntry '\foo/bar' ... + See the comment in sqWin32Directory.c for more details. + Primitive fails if the outer path does not identify a readable directory. (This is a lookup-by-name variant of primitiveDirectoryLookup.) */ @@ -849,6 +862,26 @@ primitiveDirectoryGetMacTypeAndCreator(void) return 0; } + +/* Two arguments - directory path, and an index to an item; returns an array + (see primitiveDirectoryLookup) describing the file or directory, or nil if + it does not exist. + + Note that in general, the directory path must not contain syntactic sugar + for the current platform (e.g., '.' or '..', or on Windows, forward + slashes instead of backslashes). These conventions are only fully + supported on Unix platforms; on Windows, they are only supported for short + non-UNC file paths containing max 260 characters: + DON'T: primitiveDirectoryLookup '' 'foo\.' + DON'T: primitiveDirectoryLookup '' foo\..' + DON'T (on Windows): primitiveDirectoryLookup '' 'foo/bar' + DO: primitiveDirectoryLookup '' '.' + See the comment in sqWin32Directory.c for more details. + + Primitive fails if the outer path does not identify a readable directory. + (For a lookup-by-name variant, see primitiveDirectoryEntry.) + */ + /* FilePlugin>>#primitiveDirectoryLookup */ EXPORT(sqInt) primitiveDirectoryLookup(void) diff --git a/src/spur32.cog.lowcode/cogit.h b/src/spur32.cog.lowcode/cogit.h index f3ba153a4a..c605498f9c 100644 --- a/src/spur32.cog.lowcode/cogit.h +++ b/src/spur32.cog.lowcode/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ @@ -99,9 +99,6 @@ extern usqIntptr_t (*ceGetFP)(void); extern usqIntptr_t (*ceGetSP)(void); extern void (*ceInvokeInterpret)(void); extern sqInt ceReturnToInterpreterTrampoline; -#if COGMTVM -extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; @@ -127,7 +124,6 @@ extern int traceFlags ; #define recordOverflowTrace() (traceFlags & 32) #define recordPrimTrace() (traceFlags & 8) #define recordSendTrace() (traceFlags & 2) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define numRegArgs() 2 #define fullBlockEntryOffset() cbEntryOffset #define fullBlockNoContextSwitchEntryOffset() cbNoSwitchEntryOffset diff --git a/src/spur32.cog.lowcode/cogitARMv5.c b/src/spur32.cog.lowcode/cogitARMv5.c index b5c5b6876d..e2f0bad0d3 100644 --- a/src/spur32.cog.lowcode/cogitARMv5.c +++ b/src/spur32.cog.lowcode/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -297,7 +297,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (84 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (84 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -2776,9 +2776,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2848,7 +2845,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -13460,11 +13456,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - sqInt fixupSize; - sqInt numberOfAbstractOpcodes; - sqInt opcodeSize; - usqInt startAddress1; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -13485,25 +13476,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; assertValidDualZone(); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes = numLowLevelLockOpcodes(backEnd); - numAbstractOpcodes = numberOfAbstractOpcodes; - opcodeSize = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize + fixupSize); - bzero(abstractOpcodes, opcodeSize + fixupSize); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress1 = methodZoneBase; - generateLowLevelTryLock(backEnd, vmOwnerAddress()); - outputInstructionsForGeneratedRuntimeAt(startAddress1); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress1); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress1); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur32.cog.lowcode/cogitIA32.c b/src/spur32.cog.lowcode/cogitIA32.c index 751374b944..145ab65860 100644 --- a/src/spur32.cog.lowcode/cogitIA32.c +++ b/src/spur32.cog.lowcode/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -295,7 +295,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (84 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (84 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -558,7 +558,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2707,9 +2706,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2786,7 +2782,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -6703,38 +6698,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogIA32Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt valueReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - valueReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | (1U << EAX)) - (1U << EAX))); - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperandoperand(MoveMwrR, 4, ESP, valueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, 0, EAX); - gen(LOCK); - genoperandoperand(CMPXCHGRAw, valueReg, vmOwnerLockAddress); - genoperand(SETE, ABIResultReg); - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogIA32Compiler>>#genMemCopy:to:constantSize: */ @@ -13075,16 +13038,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt valueReg; - sqInt vmOwnerLockAddress; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -13106,42 +13059,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 6 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - genoperand(RetN, 0); - goto l1; - } - valueReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | (1U << EAX)) - (1U << EAX))); - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperandoperand(MoveMwrR, 4, ESP, valueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, 0, EAX); - gen(LOCK); - genoperandoperand(CMPXCHGRAw, valueReg, vmOwnerLockAddress); - genoperand(SETE, ABIResultReg); - genoperand(RetN, 0); - l1: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur32.cog.lowcode/cointerp.c b/src/spur32.cog.lowcode/cointerp.c index 3fe182a261..69eda44e83 100644 --- a/src/spur32.cog.lowcode/cointerp.c +++ b/src/spur32.cog.lowcode/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1882,7 +1882,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1894,6 +1893,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2701,7 +2701,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -38971,7 +38971,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -39020,7 +39020,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -39038,7 +39038,7 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); @@ -40237,7 +40237,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -40851,7 +40851,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -43779,6 +43779,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -43800,6 +43802,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -78097,15 +78101,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -80559,7 +80555,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l6: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l10; } /* begin numSlotsOf: */ @@ -80589,7 +80585,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -81141,7 +81137,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - sqInt node; + usqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -87221,7 +87217,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt meth; @@ -87265,7 +87261,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -87283,7 +87279,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); diff --git a/src/spur32.cog.lowcode/cointerp.h b/src/spur32.cog.lowcode/cointerp.h index 292a3a6cd0..fc16c845fb 100644 --- a/src/spur32.cog.lowcode/cointerp.h +++ b/src/spur32.cog.lowcode/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3328 uuid: a1c7c55f-8829-4fcc-9a66-55ba7d1a8cef + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ diff --git a/src/spur32.cog.lowcode/gcc3x-cointerp.c b/src/spur32.cog.lowcode/gcc3x-cointerp.c index b0c2d17331..0afbd5d243 100644 --- a/src/spur32.cog.lowcode/gcc3x-cointerp.c +++ b/src/spur32.cog.lowcode/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1885,7 +1885,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1897,6 +1896,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2704,7 +2704,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -38980,7 +38980,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -39029,7 +39029,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -39047,7 +39047,7 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); @@ -40246,7 +40246,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -40860,7 +40860,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -43788,6 +43788,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -43809,6 +43811,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -78106,15 +78110,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -80568,7 +80564,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l6: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l10; } /* begin numSlotsOf: */ @@ -80598,7 +80594,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -81150,7 +81146,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - sqInt node; + usqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -87230,7 +87226,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt meth; @@ -87274,7 +87270,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -87292,7 +87288,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); diff --git a/src/spur32.cog/cogit.h b/src/spur32.cog/cogit.h index 8f9fe1eace..cc263ac258 100644 --- a/src/spur32.cog/cogit.h +++ b/src/spur32.cog/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ @@ -97,9 +97,6 @@ extern usqIntptr_t (*ceGetFP)(void); extern usqIntptr_t (*ceGetSP)(void); extern void (*ceInvokeInterpret)(void); extern sqInt ceReturnToInterpreterTrampoline; -#if COGMTVM -extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; @@ -125,7 +122,6 @@ extern int traceFlags ; #define recordOverflowTrace() (traceFlags & 32) #define recordPrimTrace() (traceFlags & 8) #define recordSendTrace() (traceFlags & 2) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define numRegArgs() 2 #define fullBlockEntryOffset() cbEntryOffset #define fullBlockNoContextSwitchEntryOffset() cbNoSwitchEntryOffset diff --git a/src/spur32.cog/cogitARMv5.c b/src/spur32.cog/cogitARMv5.c index 9e2b4406f1..3755b1cfdd 100644 --- a/src/spur32.cog/cogitARMv5.c +++ b/src/spur32.cog/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -273,7 +273,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (67 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (67 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -2595,9 +2595,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2667,7 +2664,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -12864,11 +12860,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - sqInt fixupSize; - sqInt numberOfAbstractOpcodes; - sqInt opcodeSize; - usqInt startAddress1; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -12887,25 +12878,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodCount = 0; assertValidDualZone(); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes = numLowLevelLockOpcodes(backEnd); - numAbstractOpcodes = numberOfAbstractOpcodes; - opcodeSize = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize + fixupSize); - bzero(abstractOpcodes, opcodeSize + fixupSize); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress1 = methodZoneBase; - generateLowLevelTryLock(backEnd, vmOwnerAddress()); - outputInstructionsForGeneratedRuntimeAt(startAddress1); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress1); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress1); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur32.cog/cogitIA32.c b/src/spur32.cog/cogitIA32.c index a6317bbf47..65ef10cb26 100644 --- a/src/spur32.cog/cogitIA32.c +++ b/src/spur32.cog/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -291,7 +291,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (67 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (67 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -520,7 +520,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2550,9 +2549,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2629,7 +2625,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -6536,38 +6531,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogIA32Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt valueReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - valueReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | (1U << EAX)) - (1U << EAX))); - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperandoperand(MoveMwrR, 4, ESP, valueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, 0, EAX); - gen(LOCK); - genoperandoperand(CMPXCHGRAw, valueReg, vmOwnerLockAddress); - genoperand(SETE, ABIResultReg); - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogIA32Compiler>>#genMemCopy:to:constantSize: */ @@ -12343,16 +12306,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt valueReg; - sqInt vmOwnerLockAddress; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -12372,42 +12325,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 6 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - genoperand(RetN, 0); - goto l1; - } - valueReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | (1U << EAX)) - (1U << EAX))); - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperandoperand(MoveMwrR, 4, ESP, valueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, 0, EAX); - gen(LOCK); - genoperandoperand(CMPXCHGRAw, valueReg, vmOwnerLockAddress); - genoperand(SETE, ABIResultReg); - genoperand(RetN, 0); - l1: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur32.cog/cointerp.c b/src/spur32.cog/cointerp.c index cdb78b0ca2..944ba1c72f 100644 --- a/src/spur32.cog/cointerp.c +++ b/src/spur32.cog/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1857,7 +1857,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1869,6 +1868,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2002,7 +2002,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2676,7 +2676,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -19156,7 +19156,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + usqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -19205,7 +19205,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -19223,7 +19223,7 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); @@ -20992,7 +20992,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -23906,6 +23906,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -23927,6 +23929,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -58129,15 +58133,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -61173,7 +61169,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -67218,7 +67214,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + usqInt index; usqInt length; sqInt mask; sqInt meth; @@ -67262,7 +67258,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -67280,7 +67276,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); diff --git a/src/spur32.cog/cointerp.h b/src/spur32.cog/cointerp.h index 39fef286a5..533964dfe9 100644 --- a/src/spur32.cog/cointerp.h +++ b/src/spur32.cog/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3328 uuid: a1c7c55f-8829-4fcc-9a66-55ba7d1a8cef + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ diff --git a/src/spur32.cog/cointerpmt.c b/src/spur32.cog/cointerpmt.c index f57a948242..b86b433941 100644 --- a/src/spur32.cog/cointerpmt.c +++ b/src/spur32.cog/cointerpmt.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreterMT VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreterMT VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -34,6 +34,7 @@ char *__interpBuildInfo = __buildInfo; #include "cointerpmt.h" #include "cogit.h" #include "sqAtomicOps.h" +#include /* StackInterpreter class>>preambleCCode */ @@ -144,6 +145,7 @@ warningat(const char *s, int l) { /* ditto with line number. */ #define DisownFlagsShift 7 #define DisownVMForFFICall 16 #define DisownVMForProcessorRelinquish 64 +#define DisownVMForThreading 32 #define EncounteredUnknownBytecode -6 #define EndOfRun 0x101 #define ExcessSignalsIndex 2 @@ -411,6 +413,7 @@ typedef struct { sqInt awolProcIndex; sqInt awolProcLength; sqInt awolProcesses[4]; + jmp_buf reenterThreadSchedulingLoop; } CogVMThread; @@ -460,6 +463,7 @@ static sqInt NoDbgRegParms startThreadForThreadInfo(CogVMThread *vmThread); static sqInt startThreadSubsystem(void); static void NoDbgRegParms startVMThread(CogVMThread *vmThread); static sqInt NoDbgRegParms threadIndexisCompatibleWith(sqInt aThreadIndex, sqInt processThreadId); +extern sqInt tryLockVMOwnerTo(sqInt threadIndex); static CogVMThread * unusedThreadInfo(void); static sqInt vmIsOwned(void); extern usqInt vmOwnerAddress(void); @@ -1827,7 +1831,7 @@ static struct foo { #else # define _iss static #endif -_iss sqInt vmOwner; +_iss volatile atomic_int vmOwner; _iss char * stackLimit; _iss char * stackPointer; _iss char * framePointer; @@ -1895,7 +1899,7 @@ _iss sqInt profileMethod; _iss sqInt profileSemaphore; _iss CogVMThread * disowningVMThread; _iss sqInt mobileStart; -_iss sqInt processHasThreadId; +_iss sqInt processHasThreadAffinity; _iss sqInt becomeEffectsFlags; _iss sqInt growHeadroom; _iss sqInt tenureThreshold; @@ -1912,12 +1916,12 @@ _iss usqInt freeOldSpaceStart; _iss sqInt extraRootCount; _iss sqInt gcPhaseInProgress; _iss sqInt invalidObjStackPage; -_iss sqInt maxWaitingPriority; _iss sqInt metaAccessorDepth; _iss usqInt objectAfterLastMobileObject; _iss sqInt previousRememberedSetSize; _iss sqInt tempOop2; _iss sqInt cogCompiledCodeCompactionCalledFor; +_iss sqInt maxWaitingPriority; _iss sqInt pendingFinalizationSignals; _iss sqInt validatedIntegerClassFlags; _iss usqInt firstMobileObject; @@ -1941,7 +1945,6 @@ _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; _iss sqInt foreignCallbackProcessSlot; _iss sqInt imageHeaderFlags; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt numThreadsIncrement; _iss FILE * scavengeLog; @@ -1955,6 +1958,7 @@ _iss sqInt foreignCallbackPriority; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2055,7 +2059,6 @@ _iss SpurNewSpaceSpace futureSpace; _iss SpurNewSpaceSpace eden; _iss float heapGrowthToSizeGCRatio; _iss sqOSThread vmOSThread; -_iss jmp_buf reenterThreadSchedulingLoop; _iss double tenuringProportion; #undef _iss #if SQ_USE_GLOBAL_STRUCT @@ -2093,7 +2096,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2769,7 +2772,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -2808,7 +2811,6 @@ volatile int sendTrace; #define assertProcessorStackPointersBelongToCurrentThread(ignored) 0 #define assertValidNewMethodPropertyFlags() 0 #define enterSmalltalkExecutive() enterSmalltalkExecutiveImplementation() -#define getMaxWaitingPriority() GIV(maxWaitingPriority) #define threadSchedulingLoop(vmThread) threadSchedulingLoopImplementation(vmThread) #define pageIndexForstackBasePlus1bytesPerPage(pointer,stkBasePlus1,pageByteSize) (((char *)(pointer) - (stkBasePlus1)) / (pageByteSize)) #define startOfMemory() heapBase @@ -6167,7 +6169,7 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G l717: /* end classAtIndex: */; GIV(traceLog)[GIV(traceLogIndex)] = classOrInteger; GIV(traceLog)[GIV(traceLogIndex) + 1] = GIV(messageSelector); - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForSelectorstartClass(GIV(messageSelector), classAtIndex(lkupClassTag)); @@ -7340,7 +7342,7 @@ GIV(bytecodeSetSelector) = ((((int) methodHeader11)) < 0 /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (numCopied > 0) { @@ -12356,7 +12358,7 @@ currentBytecode = (byteAtPointer(localIP)) + GIV(bytecodeSetSelector); /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (receiverIsOnStack) { @@ -12474,7 +12476,7 @@ currentBytecode = (byteAtPointer(localIP)) + GIV(bytecodeSetSelector); /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (numCopied > 0) { @@ -12783,8 +12785,7 @@ currentVMThread(void) sqInt index; /* begin vmThreadAt: */ - sqLowLevelMFence(); - index = GIV(vmOwner); + index = atomic_load((&GIV(vmOwner))); assert(((index >= 0) && (index <= GIV(numThreads)))); return (index > 0 ? GIV(threads)[index] @@ -12805,8 +12806,7 @@ getVMOSThread(void) static sqInt getVMOwner(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner); + return atomic_load((&GIV(vmOwner))); } @@ -12829,6 +12829,9 @@ growThreadInfosToAtLeast(sqInt index) newThreads = realloc(GIV(threads), (newNumThreads + 1) * sizeof(CogVMThread *)); if (!((newThreads != null) && (populatefromto(newThreads, GIV(numThreads) + 1, newNumThreads)))) { + + /* TODO: This cannot free 'newThreads', as that's going to mean 'threads' is freed as well. */ + abort(); free(newThreads); GIV(memoryIsScarce) = 1; return 0; @@ -12915,7 +12918,7 @@ startThreadForThreadInfo(CogVMThread *vmThread) { DECL_MAYBE_SQ_GLOBAL_STRUCT assert(((vmThread->state)) == null); (vmThread->state = CTMInitializing); - if ((ioNewOSThread(startVMThread, vmThread)) == 0) { + if ((ioNewOSThread(((void (*)(void*)) startVMThread), vmThread)) == 0) { ioTransferTimeslice(); return 1; } @@ -12940,11 +12943,13 @@ startThreadSubsystem(void) if (!(growThreadInfosToAtLeast(GIV(numThreadsIncrement) * 2))) { error("no memory to start thread system"); } - vmThread = GIV(threads)[(GIV(vmOwner) = 1)]; + atomic_store((&GIV(vmOwner)), 1); + vmThread = GIV(threads)[atomic_load((&GIV(vmOwner)))]; (vmThread->state = CTMInitializing); /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -12961,8 +12966,9 @@ static void NoDbgRegParms startVMThread(CogVMThread *vmThread) { /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -12978,9 +12984,23 @@ static sqInt NoDbgRegParms threadIndexisCompatibleWith(sqInt aThreadIndex, sqInt processThreadId) { assert(aThreadIndex > 0); - return (processThreadId >= 0 + return (processThreadId == 0) + || ((processThreadId >= 0 ? aThreadIndex == processThreadId - : aThreadIndex != (-processThreadId)); + : aThreadIndex != (-processThreadId))); +} + + /* CogThreadManager>>#tryLockVMOwnerTo: */ +sqInt +tryLockVMOwnerTo(sqInt threadIndex) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + int expected; + + assert(!((threadIndex == 0))); + /* begin doTryLockVMOwnerTo: */ + expected = 0; + return (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), threadIndex)) + || (expected == threadIndex); } @@ -13017,8 +13037,7 @@ unusedThreadInfo(void) static sqInt vmIsOwned(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner) > 0; + return (atomic_load((&GIV(vmOwner)))) != 0; } @@ -13028,6 +13047,7 @@ vmIsOwned(void) usqInt vmOwnerAddress(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT + error("Deprecated! Replaced by proper atomic functions"); return ((usqInt)((&GIV(vmOwner)))); } @@ -13038,12 +13058,15 @@ vmOwnerAddress(void) static sqInt NoDbgRegParms vmOwnerIsCompatibleWith(sqInt processThreadId) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); + sqInt aThreadIndex; + /* begin threadIndex:isCompatibleWith: */ - assert(GIV(vmOwner) > 0); - return (processThreadId >= 0 - ? GIV(vmOwner) == processThreadId - : GIV(vmOwner) != (-processThreadId)); + aThreadIndex = atomic_load((&GIV(vmOwner))); + assert(aThreadIndex > 0); + return (processThreadId == 0) + || ((processThreadId >= 0 + ? aThreadIndex == processThreadId + : aThreadIndex != (-processThreadId))); } @@ -13053,8 +13076,7 @@ vmOwnerIsCompatibleWith(sqInt processThreadId) static sqInt NoDbgRegParms vmOwnerIs(sqInt index) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner) == index; + return (atomic_load((&GIV(vmOwner)))) == index; } /* CogThreadManager>>#vmThreadAt: */ @@ -13081,16 +13103,23 @@ wakeVMThreadFor(sqInt index) assert((vmIsOwned()) && (!(vmOwnerIs(index)))); assert(((index >= 1) && (index <= GIV(numThreads)))); - /* begin setVMOwner: */ - GIV(vmOwner) = index; - sqLowLevelMFence(); + + /* Instead of going through a #disownVM: call, directly set the new VM owner. + This has the advantage of avoiding a race for the different threads to become the new + VM owner. + In Simulation, this means we need to simulate a thread-switch. */ vmThread = GIV(threads)[index]; + /* begin setVMOwner: */ + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != index)); + atomic_store((&GIV(vmOwner)), index); if (((vmThread->state)) == null) { startThreadForThreadInfo(vmThread); } else { - assert((((vmThread->state)) == CTMWantingOwnership) - || (((vmThread->state)) == CTMAssignableOrInVM)); + assert(((((vmThread->state)) == CTMWantingOwnership) + || (((vmThread->state)) == CTMAssignableOrInVM)) + || (((vmThread->state)) == CTMInitializing)); ioSignalOSSemaphore((&((vmThread->osSemaphore)))); } ioTransferTimeslice(); @@ -13112,7 +13141,7 @@ willingVMThread(void) threadWantingVM = (threadWilling = null); for (i = 1; i <= GIV(numThreads); i += 1) { - if (!(vmOwnerIs(i))) { + if (!((atomic_load((&GIV(vmOwner)))) == i)) { thread = GIV(threads)[i]; if (((thread->state)) == CTMWantingOwnership) { if ((threadWantingVM == null) @@ -15617,7 +15646,7 @@ ceTraceBlockActivation(void) selector = ((mframeHomeMethod(GIV(framePointer)))->methodObject); GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockActivation; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForreceiverisBlockfirstTemporary(((mframeHomeMethod(GIV(framePointer)))->methodObject), ((((usqInt)(longAt(GIV(framePointer) + FoxMethod)))) < (startOfMemory()) @@ -15653,7 +15682,7 @@ ceTraceLinkedSend(sqInt theReceiver) selector = (cogMethod->selector); GIV(traceLog)[GIV(traceLogIndex)] = classOrInteger; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForreceiverisBlockfirstTemporary((cogMethod->methodObject), theReceiver, 0, null); @@ -16204,7 +16233,7 @@ commenceCogCompiledCodeCompaction(void) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceCodeCompaction; GIV(traceLog)[GIV(traceLogIndex) + 1] = TraceCodeCompaction; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (recordPrimTrace()) { @@ -19488,7 +19517,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + usqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -19537,7 +19566,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -19555,7 +19584,7 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); @@ -20224,7 +20253,7 @@ preGCAction(sqInt gcModeArg) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = traceType; GIV(traceLog)[GIV(traceLogIndex) + 1] = traceType; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (recordPrimTrace()) { @@ -21331,7 +21360,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); - GIV(processHasThreadId) = ((headerFlags & 4) != 0); + GIV(processHasThreadAffinity) = ((headerFlags & 4) != 0); GIV(flagInterpretedMethods) = ((headerFlags & 8) != 0); /* was: noThreadingOfGUIThread := headerFlags anyMask: 32. a broken idea */ @@ -21348,9 +21377,9 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea /* i.e. has it not been set on the command line? */ upscaleDisplayIfHighDPI = (!(headerFlags & 0x400)); } - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { /* begin print: */ - fprintf(GIV(transcript), "warning, processHasThreadId flag is unset; cannot function as a threaded VM if so."); + fprintf(GIV(transcript), "warning, processHasThreadAffinity flag is unset; cannot function as a threaded VM if so."); cr(); } /* begin getWord32FromFile:swap: */ @@ -22912,7 +22941,7 @@ cedeToHigherPriorityThreads(void) sqInt objOop; sqInt objOop1; sqInt oop; - sqInt ownerIndex; + sqInt processAffinity; char *sp; char *sp1; char *theFP; @@ -22930,28 +22959,19 @@ cedeToHigherPriorityThreads(void) assert((oop & 1)); activePriority = (oop >> 1); /* begin ownerIndexOfThreadId: */ - threadId = (GIV(processHasThreadId) + threadId = (GIV(processHasThreadAffinity) ? longAt((activeProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)); - ownerIndex = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + processAffinity = ((threadId & 1) + ? (((threadId >> 1))) >> ThreadIdShift : 0); - if (ownerIndex == 0) { - /* begin currentVMThread */ - sqLowLevelMFence(); - index = GIV(vmOwner); - assert(((index >= 0) && (index <= GIV(numThreads)))); - activeThread = (index > 0 - ? GIV(threads)[index] - : 0); - } - else { - /* begin vmThreadAt: */ - assert(((ownerIndex >= 0) && (ownerIndex <= GIV(numThreads)))); - activeThread = (ownerIndex > 0 - ? GIV(threads)[ownerIndex] - : 0); - } + /* begin currentVMThread */ + index = atomic_load((&GIV(vmOwner))); + assert(((index >= 0) && (index <= GIV(numThreads)))); + activeThread = (index > 0 + ? GIV(threads)[index] + : 0); + assert(threadIndexisCompatibleWith((activeThread->index), processAffinity)); (activeThread->priority = activePriority); /* begin highestPriorityThreadIfHigherThan:expectedMax: */ @@ -22985,11 +23005,11 @@ cedeToHigherPriorityThreads(void) } if (highest == null) { vmThread = null; - goto l6; + goto l5; } if (((highest->priority)) <= activePriority) { vmThread = null; - goto l6; + goto l5; } /* begin setMaxWaitingPriorityTo: */ minPriority = (nextHighest == null @@ -22997,7 +23017,7 @@ cedeToHigherPriorityThreads(void) : (nextHighest->priority)); GIV(maxWaitingPriority) = minPriority; vmThread = highest; - l6: /* end highestPriorityThreadIfHigherThan:expectedMax: */; + l5: /* end highestPriorityThreadIfHigherThan:expectedMax: */; if ((vmThread == null) || (vmThread == activeThread)) { @@ -23024,10 +23044,10 @@ cedeToHigherPriorityThreads(void) : (byteAt((theFP + FoxIFrameFlags) + 2)) != 0)) { assert(isContext(frameContext(theFP))); activeContext = longAt(theFP + FoxThisContext); - goto l12; + goto l10; } activeContext = marryFrameSP(theFP, theSP); - l12: /* end ensureFrameIsMarried:SP: */; + l10: /* end ensureFrameIsMarried:SP: */; /* begin storePointer:ofObject:withValue: */ assert(!(isForwarded(activeProc))); if ((assert(isNonImmediate(activeProc)), @@ -23101,7 +23121,7 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertCStackWellAligned(); /* restore the stackLimit if it has been smashed. */ @@ -23230,7 +23250,7 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) /* Check whether the VM is unowned and needs to set a thread running to try and own it. - Do not attempt this if the image doesn't have a threadId inst var in + Do not attempt this if the image doesn't have a threadAffinity inst var in Process; the VM can't thread these images. */ @@ -23238,11 +23258,13 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) static void checkVMOwnershipFromHeartbeat(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT + int expected; + int expected1; CogVMThread *vmThread; sqLowLevelMFence(); - if (GIV(processHasThreadId) - && (vmOwnerIs(0))) { + if (GIV(processHasThreadAffinity) + && ((atomic_load((&GIV(vmOwner)))) == 0)) { /* begin ensureRunningVMThread: */ vmThread = willingVMThread(); if (!(vmThread == null)) { @@ -23252,7 +23274,13 @@ checkVMOwnershipFromHeartbeat(void) && (((vmThread->state)) != CTMWantingOwnership)) { goto l1; } - if (!(tryLockVMOwnerTo((vmThread->index)))) { + assert(((((vmThread->state)) == CTMAssignableOrInVM) + || (((vmThread->state)) == CTMInitializing)) + || (((vmThread->state)) == CTMWantingOwnership)); + if (!((assert(!((((vmThread->index)) == 0))), + (expected = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), (vmThread->index))) + || (expected == ((vmThread->index)))))) { /* someone beat us to it... */ goto l1; @@ -23270,11 +23298,15 @@ checkVMOwnershipFromHeartbeat(void) } vmThread = unusedThreadInfo(); if (!(vmThread == null)) { - if (tryLockVMOwnerTo((vmThread->index))) { + if ((assert(!((((vmThread->index)) == 0))), + (expected1 = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected1), (vmThread->index))) + || (expected1 == ((vmThread->index))))) { if (!(startThreadForThreadInfo(vmThread))) { /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); } } } @@ -23350,10 +23382,10 @@ disownVM(sqInt flags) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceDisownVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ((((usqInt)flags << 1) | 1)); - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { if (willNotThreadWarnCount < 10) { /* begin print: */ fprintf(GIV(transcript), "warning: VM parameter 48 indicates Process doesn't have threadId; VM will not thread"); @@ -23362,8 +23394,7 @@ disownVM(sqInt flags) } } /* begin currentVMThread */ - sqLowLevelMFence(); - index = GIV(vmOwner); + index = atomic_load((&GIV(vmOwner))); assert(((index >= 0) && (index <= GIV(numThreads)))); vmThread = (index > 0 ? GIV(threads)[index] @@ -23385,17 +23416,14 @@ disownVM(sqInt flags) GIV(relinquishing) = 1; sqLowLevelMFence(); } - disownCount += 1; - /* self cr; cr; print: 'disownVM Csp: '; printHex: vmThread cStackPointer; cr. - (0 to: 16 by: 4) do: - [:offset| - self print: ' *(esp+'; printNum: offset; print: ': '; printHex: (stackPages longAt: cogit processor sp + offset); cr]. - cogit processor printIntegerRegistersOn: Transcript. */ - /* OwnVMForeignThreadFlag indicates lowest-level of entry by a foreign - thread. If that's where we are then release the vmThread. Otherwise - indicate the vmThread is off doing something outside of the VM. */ - GIV(disowningVMThread) = vmThread; + /* If we're disowning the VM because there's no active process to run, + there's nothing to preempt later, so don't indicate that there's a disowningVMThread that + needs to be restored later. */ + disownCount += 1; + if ((fetchPointerofObject(ActiveProcessIndex, schedulerPointer())) != GIV(nilObj)) { + GIV(disowningVMThread) = vmThread; + } if (((flags & OwnVMForeignThreadFlag) != 0)) { /* I don't think this is quite right. Josh's use case is creating some foreign thread and then registering @@ -23419,8 +23447,9 @@ disownVM(sqInt flags) ? 0 : ProcessUnaffinedOnDisown))) | flags; /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); return result; } @@ -23469,7 +23498,7 @@ enterSmalltalkExecutiveImplementation(void) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertProcessorStackPointersBelongToCurrentThread(); assertCStackWellAligned(); ceCaptureCStackPointers(); @@ -23533,7 +23562,7 @@ getImageHeaderFlags(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT return ((((((((GIV(fullScreenFlag) + ((VMBIGENDIAN ? 0 - : 2))) + ((GIV(processHasThreadId) + : 2))) + ((GIV(processHasThreadAffinity) ? 4 : 0))) + ((GIV(flagInterpretedMethods) ? 8 @@ -23582,11 +23611,11 @@ isBoundProcess(sqInt aProcess) sqInt threadId1; /* begin isBoundThreadId: */ - threadId1 = (GIV(processHasThreadId) + threadId1 = (GIV(processHasThreadAffinity) ? longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)); threadId = ((threadId1 & 1) - ? ((usqInt)(((threadId1 >> 1)))) >> ThreadIdShift + ? (((threadId1 >> 1))) >> ThreadIdShift : 0); return ((threadId & 1)) && ((((threadId >> 1)) & 1) == 1); @@ -23635,7 +23664,7 @@ loadInitialContext(void) objOop1 = longAt((objOop4 + BaseHeaderSize) + (((int)((usqInt)(ValueIndex) << (shiftForWord()))))); activeProc = longAt((objOop1 + BaseHeaderSize) + (((int)((usqInt)(ActiveProcessIndex) << (shiftForWord()))))); assert((ownerIndexOfProcess(activeProc)) == 0); - GIV(activeProcessAffined) = (ownerIndexOfThreadId((GIV(processHasThreadId) + GIV(activeProcessAffined) = (ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? longAt((activeProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)))) != 0; } @@ -23766,7 +23795,7 @@ ownerIndexOfProcess(sqInt aProcess) sqInt threadId; /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -23775,7 +23804,7 @@ ownerIndexOfProcess(sqInt aProcess) threadId = GIV(nilObj); } return ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); } @@ -23784,7 +23813,7 @@ static sqInt NoDbgRegParms ownerIndexOfThreadId(sqInt threadId) { return ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); } @@ -23810,7 +23839,7 @@ ownVMFromUnidentifiedThread(void) if (((threadIndex = ioGetThreadLocalThreadIndex())) != 0) { /* this is a callback from a known thread */ - if (vmOwnerIs(threadIndex)) { + if ((atomic_load((&GIV(vmOwner)))) == threadIndex) { /* the VM has not been disowned */ assert((GIV(disowningVMThread) == null) @@ -23842,8 +23871,9 @@ ownVMFromUnidentifiedThread(void) } if ((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (((sqInt)((usqInt)(GIV(foreignCallbackProcessSlot)) << (shiftForWord())))))) != GIV(nilObj)) break; /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); if (((count += 1)) > 1000) { return -2; } @@ -23856,19 +23886,22 @@ ownVMFromUnidentifiedThread(void) vmThread = unusedThreadInfo(); if (!vmThread) { /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); return -1; } /* begin setVMOwner: */ indexOrZero = (vmThread->index); - GIV(vmOwner) = indexOrZero; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != indexOrZero)); + atomic_store((&GIV(vmOwner)), indexOrZero); (vmThread->state = CTMWantingOwnership); (vmThread->priority = GIV(foreignCallbackPriority)); /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -23905,6 +23938,8 @@ ownVM(sqInt threadIndexAndFlags) sqInt aMethodObj; sqInt cFramePointer; sqInt cStackPointer; + int expected; + int expected1; sqInt flags; StackPage *lastUsedPage; StackPage *lruOrFree; @@ -23950,10 +23985,20 @@ ownVM(sqInt threadIndexAndFlags) : 0); assert((((vmThread1->state)) == CTMUnavailable) || (((vmThread1->state)) == CTMWantingOwnership)); - if (!(tryLockVMOwnerTo(threadIndex))) { + if ((assert(!((threadIndex == 0))), + (expected1 = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected1), threadIndex)) + || (expected1 == threadIndex))) { + (vmThread1->state = CTMAssignableOrInVM); + } + else { (vmThread1->state = CTMWantingOwnership); - while (!((vmOwnerIs(threadIndex)) - || (tryLockVMOwnerTo(threadIndex)))) { + while (!(((atomic_load((&GIV(vmOwner)))) == threadIndex) + || ((assert(!((threadIndex == 0))), + /* begin doTryLockVMOwnerTo: */ + (expected = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), threadIndex)) + || (expected == threadIndex))))) { if (!(((vmThread1->priority)) == null)) { /* begin waitingPriorityIsAtLeast: */ minPriority = (vmThread1->priority); @@ -23963,7 +24008,7 @@ ownVM(sqInt threadIndexAndFlags) forceInterruptCheck(); } } - if (!(vmOwnerIs(threadIndex))) { + if (!((atomic_load((&GIV(vmOwner)))) == threadIndex)) { ioWaitOnOSSemaphore((&((vmThread1->osSemaphore)))); } } @@ -23985,7 +24030,7 @@ ownVM(sqInt threadIndexAndFlags) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceOwnVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ConstOne; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } return 0; @@ -24048,7 +24093,7 @@ ownVM(sqInt threadIndexAndFlags) assert(!(isOopForwarded(myProc))); longAtput((myProc + BaseHeaderSize) + (((int)((usqInt)(MyListIndex) << (shiftForWord())))), GIV(nilObj)); if ((((threadIndexAndFlags & ProcessUnaffinedOnDisown) != 0)) - && (!(isBoundThreadId(ownerIndexOfThreadId((GIV(processHasThreadId) + && (!(isBoundThreadId(ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? longAt((myProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj))))))) { /* begin setOwnerIndexOfProcess:to:bind: */ @@ -24162,7 +24207,7 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceOwnVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ConstTwo; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } return threadIndexAndFlags & OwnVMForeignThreadFlag; @@ -24214,7 +24259,7 @@ preemptDisowningThread(void) selector = (((usqInt)((GIV(disowningVMThread)->index)) << 1) | 1); GIV(traceLog)[GIV(traceLogIndex)] = TracePreemptDisowningThread; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } (GIV(disowningVMThread)->cStackPointer = GIV(CStackPointer)); @@ -24286,7 +24331,7 @@ preemptDisowningThread(void) preemptedThread = pushAWOLProcesson(activeProc, GIV(disowningVMThread)); GIV(disowningVMThread) = null; (preemptedThread->priority = quickFetchIntegerofObject(PriorityIndex, activeProc)); - if ((ownerIndexOfThreadId((GIV(processHasThreadId) + if ((ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? (/* begin fetchPointer:ofObject: */ longAt((activeProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord())))))) : /* begin nilObject */ GIV(nilObj)))) == 0) { @@ -24328,7 +24373,7 @@ primitiveProcessBindToThreadId(void) sqInt threadIdSlot; sqInt threadIdSlot1; - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { (GIV(primFailCode) = PrimErrUnsupported); return; } @@ -24351,11 +24396,11 @@ primitiveProcessBindToThreadId(void) return; } /* begin bindProcess:toId: */ - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { ec = PrimErrUnsupported; goto l8; } - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadIdField = longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24367,7 +24412,7 @@ primitiveProcessBindToThreadId(void) /* If aProcess is affined (temporarily bound to) a thread then the operation can only succeed if the newId is the same as that aProcess is affined to, or is zero (is unbinding). */ ownerIndex = ((threadIdField & 1) - ? ((usqInt)(((threadIdField >> 1)))) >> ThreadIdShift + ? (((threadIdField >> 1))) >> ThreadIdShift : 0); if ((((threadIdField & 1) ? ((((threadIdField >> 1)) & ((1U << ThreadIdShift) - 1)) != 0) @@ -24418,7 +24463,7 @@ primitiveProcessBindToThreadId(void) /* begin pop: */ GIV(stackPointer) += GIV(argumentCount) * BytesPerWord; /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24427,7 +24472,7 @@ primitiveProcessBindToThreadId(void) threadId = GIV(nilObj); } id = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); if ((aProcess == (fetchPointerofObject(ActiveProcessIndex, schedulerPointer()))) && (((GIV(activeProcessAffined) = id != 0)) @@ -24443,11 +24488,13 @@ primitiveProcessBindToThreadId(void) } -/* Answer the receiver's current thread Id or nil, where the receiver is a - Process. If the threadId is positive then the receiver is bound to the - thread with that id. - If the threadId is negative then the receiver is excluded from running on - the thread with that id. */ +/* Answer the receiver's current threadAffinity or nil, where the receiver is + a Process. + If the threadAffinity is positive then the receiver is bound to the thread + with that id. + If the threadAffinity is negative then the receiver is excluded from + running on the thread with that id. + */ /* CoInterpreterMT>>#primitiveProcessBoundThreadId */ EXPORT(void) @@ -24459,13 +24506,13 @@ primitiveProcessBoundThreadId(void) char *sp; sqInt threadId; - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { (GIV(primFailCode) = PrimErrUnsupported); return; } aProcess = longAt(GIV(stackPointer)); /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24474,7 +24521,7 @@ primitiveProcessBoundThreadId(void) threadId = GIV(nilObj); } id = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); /* begin methodReturnValue: */ oop = (id == 0 @@ -24546,8 +24593,7 @@ primitiveVMCurrentThreadId(void) char *sp; /* begin methodReturnInteger: */ - sqLowLevelMFence(); - integer = GIV(vmOwner); + integer = atomic_load((&GIV(vmOwner))); assert(!((failed()))); /* begin pop:thenPushInteger: */ longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), (((usqInt)integer << 1) | 1)); @@ -24790,30 +24836,36 @@ printAllStacks(void) static void NoDbgRegParms returnToSchedulingLoopAndReleaseVMOrWakeThreadsource(CogVMThread *vmThread, sqInt source) { DECL_MAYBE_SQ_GLOBAL_STRUCT + CogVMThread *activeThread; + sqInt index; sqInt ownerIndex; sqInt selector; + /* begin currentVMThread */ + index = atomic_load((&GIV(vmOwner))); + assert(((index >= 0) && (index <= GIV(numThreads)))); + activeThread = (index > 0 + ? GIV(threads)[index] + : 0); /* begin recordThreadSwitchTo:source: */ ownerIndex = (vmThread == null ? 0 : (vmThread->index)); if (recordEventTrace()) { /* begin recordTrace:thing:source: */ - selector = (((usqInt)((((sqInt)((usqInt)(ownerIndex) << 16))) + (getVMOwner())) << 1) | 1); + selector = (((usqInt)((((sqInt)((usqInt)(ownerIndex) << 16))) + (atomic_load((&GIV(vmOwner))))) << 1) | 1); GIV(traceLog)[GIV(traceLogIndex)] = TraceThreadSwitch; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (vmThread == null) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + disownVM(DisownVMForThreading); } else { wakeVMThreadFor((vmThread->index)); } - _longjmp(GIV(reenterThreadSchedulingLoop), 1); + _longjmp((activeThread->reenterThreadSchedulingLoop), 1); } @@ -24883,7 +24935,7 @@ sendInvokeCallbackContext(VMCallbackContext *vmCallbackContext) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertCStackWellAligned(); if (recordPrimTrace()) { /* begin fastLogPrim: */ @@ -25097,19 +25149,15 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) sqInt top; sqInt valuePointer; - _setjmp(GIV(reenterThreadSchedulingLoop)); + _setjmp((vmThread->reenterThreadSchedulingLoop)); do { assert(((vmThread->state)) == CTMAssignableOrInVM); if (tryLockVMOwnerTo((vmThread->index))) { + /* Yay, we're the VM owner! */ /* If relinquishing is true, then primitiveRelinquishProcessor has disowned the VM and only a returning call or callback should take ownership in that case. */ - if (GIV(relinquishing)) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); - } - else { + if (!GIV(relinquishing)) { /* begin tryToExecuteSmalltalk: */ assert(vmOwnerIs((vmThread->index))); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -25150,13 +25198,10 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) longAtput((objOop1 + BaseHeaderSize) + (((int)((usqInt)(ActiveProcessIndex) << (shiftForWord())))), activeProc); } if (activeProc == GIV(nilObj)) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); goto l20; } /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((activeProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -25165,7 +25210,7 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) threadId = GIV(nilObj); } ownerIndex = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); if ((ownerIndex == 0) || (vmOwnerIsCompatibleWith(ownerIndex))) { @@ -25264,13 +25309,12 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G wakeVMThreadFor(ownerIndex); l20: /* end tryToExecuteSmalltalk: */; } + disownVM(DisownVMForThreading); } - if (!(vmOwnerIs((vmThread->index)))) { - /* begin waitForWork: */ - assert(((vmThread->state)) == CTMAssignableOrInVM); - assert(!((vmOwnerIs((vmThread->index))))); - ioWaitOnOSSemaphore((&((vmThread->osSemaphore)))); - } + /* begin waitForWork: */ + (vmThread->state = CTMAssignableOrInVM); + assert(!((vmOwnerIs((vmThread->index))))); + ioWaitOnOSSemaphore((&((vmThread->osSemaphore)))); } while(1); } @@ -25297,9 +25341,9 @@ threadSwitchIfNecessaryfrom(sqInt newProc, sqInt sourceCode) if (GIV(deferThreadSwitch)) { return; } - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((newProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -25308,7 +25352,7 @@ threadSwitchIfNecessaryfrom(sqInt newProc, sqInt sourceCode) threadId = GIV(nilObj); } newProcOwnerIndex = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); if (!(((GIV(activeProcessAffined) = newProcOwnerIndex != 0)) && (!(vmOwnerIsCompatibleWith(newProcOwnerIndex))))) { @@ -25456,7 +25500,7 @@ transferTofrom(sqInt newProc, sqInt sourceCode) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceContextSwitch; GIV(traceLog)[GIV(traceLogIndex) + 1] = oldProc; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (sourceCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (sourceCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } /* begin ensureFrameIsMarried:SP: */ @@ -26610,6 +26654,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -26631,6 +26677,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -36060,7 +36108,7 @@ primitiveInvokeObjectAsMethod(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt i; sqInt lookupClassTag; - sqInt runArgs; + usqInt runArgs; sqInt runReceiver; char *sp; char *sp1; @@ -60822,15 +60870,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -63866,7 +63906,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -67552,8 +67592,8 @@ static sqInt getErrorObjectFromPrimFailCode(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt classIndex; - usqInt clone; - usqInt errObj; + sqInt clone; + sqInt errObj; sqInt fieldIndex; sqInt i; usqInt newObj; @@ -67897,7 +67937,7 @@ handleStackOverflow(void) : TraceIsFromInterpreter); GIV(traceLog)[GIV(traceLogIndex)] = TraceStackOverflow; GIV(traceLog)[GIV(traceLogIndex) + 1] = TraceStackOverflow; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if ((recordPrimTrace()) @@ -69705,7 +69745,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + usqInt index; usqInt length; sqInt mask; sqInt meth; @@ -69749,7 +69789,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -69767,7 +69807,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); @@ -81524,7 +81564,7 @@ GIV(totalHeapSizeIncludingBridges)))); GIV(primFailCode) = PrimErrInappropriate; goto l103; } - GIV(processHasThreadId) = ((arg & 1) != 0); + GIV(processHasThreadAffinity) = ((arg & 1) != 0); GIV(flagInterpretedMethods) = ((arg & 2) != 0); /* was: noThreadingOfGUIThread := flags anyMask: 8. a broken idea */ diff --git a/src/spur32.cog/cointerpmt.h b/src/spur32.cog/cointerpmt.h index 67a31a9f90..56eb796d25 100644 --- a/src/spur32.cog/cointerpmt.h +++ b/src/spur32.cog/cointerpmt.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ @@ -20,6 +20,7 @@ # define NeverInline /*empty*/ #endif +extern sqInt tryLockVMOwnerTo(sqInt threadIndex); extern usqInt vmOwnerAddress(void); extern sqInt accessorDepthForPrimitiveIndex(sqInt primIndex); extern usqInt argumentCountAddress(void); diff --git a/src/spur32.cog/gcc3x-cointerp.c b/src/spur32.cog/gcc3x-cointerp.c index e2e7270639..3c2569fc4b 100644 --- a/src/spur32.cog/gcc3x-cointerp.c +++ b/src/spur32.cog/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1860,7 +1860,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1872,6 +1871,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2005,7 +2005,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2679,7 +2679,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -19165,7 +19165,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + usqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -19214,7 +19214,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -19232,7 +19232,7 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); @@ -21001,7 +21001,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -23915,6 +23915,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -23936,6 +23938,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -58138,15 +58142,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -61182,7 +61178,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -67227,7 +67223,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + usqInt index; usqInt length; sqInt mask; sqInt meth; @@ -67271,7 +67267,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -67289,7 +67285,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); diff --git a/src/spur32.cog/gcc3x-cointerpmt.c b/src/spur32.cog/gcc3x-cointerpmt.c index 61e2a5c553..7d0ccf4b68 100644 --- a/src/spur32.cog/gcc3x-cointerpmt.c +++ b/src/spur32.cog/gcc3x-cointerpmt.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreterMT VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreterMT VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -37,6 +37,7 @@ char *__interpBuildInfo = __buildInfo; #include "cointerpmt.h" #include "cogit.h" #include "sqAtomicOps.h" +#include /* StackInterpreter class>>preambleCCode */ @@ -147,6 +148,7 @@ warningat(const char *s, int l) { /* ditto with line number. */ #define DisownFlagsShift 7 #define DisownVMForFFICall 16 #define DisownVMForProcessorRelinquish 64 +#define DisownVMForThreading 32 #define EncounteredUnknownBytecode -6 #define EndOfRun 0x101 #define ExcessSignalsIndex 2 @@ -414,6 +416,7 @@ typedef struct { sqInt awolProcIndex; sqInt awolProcLength; sqInt awolProcesses[4]; + jmp_buf reenterThreadSchedulingLoop; } CogVMThread; @@ -463,6 +466,7 @@ static sqInt NoDbgRegParms startThreadForThreadInfo(CogVMThread *vmThread); static sqInt startThreadSubsystem(void); static void NoDbgRegParms startVMThread(CogVMThread *vmThread); static sqInt NoDbgRegParms threadIndexisCompatibleWith(sqInt aThreadIndex, sqInt processThreadId); +extern sqInt tryLockVMOwnerTo(sqInt threadIndex); static CogVMThread * unusedThreadInfo(void); static sqInt vmIsOwned(void); extern usqInt vmOwnerAddress(void); @@ -1830,7 +1834,7 @@ static struct foo { #else # define _iss static #endif -_iss sqInt vmOwner; +_iss volatile atomic_int vmOwner; _iss char * stackLimit; _iss char * stackPointer; _iss char * framePointer; @@ -1898,7 +1902,7 @@ _iss sqInt profileMethod; _iss sqInt profileSemaphore; _iss CogVMThread * disowningVMThread; _iss sqInt mobileStart; -_iss sqInt processHasThreadId; +_iss sqInt processHasThreadAffinity; _iss sqInt becomeEffectsFlags; _iss sqInt growHeadroom; _iss sqInt tenureThreshold; @@ -1915,12 +1919,12 @@ _iss usqInt freeOldSpaceStart; _iss sqInt extraRootCount; _iss sqInt gcPhaseInProgress; _iss sqInt invalidObjStackPage; -_iss sqInt maxWaitingPriority; _iss sqInt metaAccessorDepth; _iss usqInt objectAfterLastMobileObject; _iss sqInt previousRememberedSetSize; _iss sqInt tempOop2; _iss sqInt cogCompiledCodeCompactionCalledFor; +_iss sqInt maxWaitingPriority; _iss sqInt pendingFinalizationSignals; _iss sqInt validatedIntegerClassFlags; _iss usqInt firstMobileObject; @@ -1944,7 +1948,6 @@ _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; _iss sqInt foreignCallbackProcessSlot; _iss sqInt imageHeaderFlags; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt numThreadsIncrement; _iss FILE * scavengeLog; @@ -1958,6 +1961,7 @@ _iss sqInt foreignCallbackPriority; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2058,7 +2062,6 @@ _iss SpurNewSpaceSpace futureSpace; _iss SpurNewSpaceSpace eden; _iss float heapGrowthToSizeGCRatio; _iss sqOSThread vmOSThread; -_iss jmp_buf reenterThreadSchedulingLoop; _iss double tenuringProportion; #undef _iss #if SQ_USE_GLOBAL_STRUCT @@ -2096,7 +2099,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2772,7 +2775,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -2811,7 +2814,6 @@ volatile int sendTrace; #define assertProcessorStackPointersBelongToCurrentThread(ignored) 0 #define assertValidNewMethodPropertyFlags() 0 #define enterSmalltalkExecutive() enterSmalltalkExecutiveImplementation() -#define getMaxWaitingPriority() GIV(maxWaitingPriority) #define threadSchedulingLoop(vmThread) threadSchedulingLoopImplementation(vmThread) #define pageIndexForstackBasePlus1bytesPerPage(pointer,stkBasePlus1,pageByteSize) (((char *)(pointer) - (stkBasePlus1)) / (pageByteSize)) #define startOfMemory() heapBase @@ -6176,7 +6178,7 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G l717: /* end classAtIndex: */; GIV(traceLog)[GIV(traceLogIndex)] = classOrInteger; GIV(traceLog)[GIV(traceLogIndex) + 1] = GIV(messageSelector); - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForSelectorstartClass(GIV(messageSelector), classAtIndex(lkupClassTag)); @@ -7349,7 +7351,7 @@ GIV(bytecodeSetSelector) = ((((int) methodHeader11)) < 0 /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (numCopied > 0) { @@ -12365,7 +12367,7 @@ currentBytecode = (byteAtPointer(localIP)) + GIV(bytecodeSetSelector); /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (receiverIsOnStack) { @@ -12483,7 +12485,7 @@ currentBytecode = (byteAtPointer(localIP)) + GIV(bytecodeSetSelector); /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (numCopied > 0) { @@ -12792,8 +12794,7 @@ currentVMThread(void) sqInt index; /* begin vmThreadAt: */ - sqLowLevelMFence(); - index = GIV(vmOwner); + index = atomic_load((&GIV(vmOwner))); assert(((index >= 0) && (index <= GIV(numThreads)))); return (index > 0 ? GIV(threads)[index] @@ -12814,8 +12815,7 @@ getVMOSThread(void) static sqInt getVMOwner(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner); + return atomic_load((&GIV(vmOwner))); } @@ -12838,6 +12838,9 @@ growThreadInfosToAtLeast(sqInt index) newThreads = realloc(GIV(threads), (newNumThreads + 1) * sizeof(CogVMThread *)); if (!((newThreads != null) && (populatefromto(newThreads, GIV(numThreads) + 1, newNumThreads)))) { + + /* TODO: This cannot free 'newThreads', as that's going to mean 'threads' is freed as well. */ + abort(); free(newThreads); GIV(memoryIsScarce) = 1; return 0; @@ -12924,7 +12927,7 @@ startThreadForThreadInfo(CogVMThread *vmThread) { DECL_MAYBE_SQ_GLOBAL_STRUCT assert(((vmThread->state)) == null); (vmThread->state = CTMInitializing); - if ((ioNewOSThread(startVMThread, vmThread)) == 0) { + if ((ioNewOSThread(((void (*)(void*)) startVMThread), vmThread)) == 0) { ioTransferTimeslice(); return 1; } @@ -12949,11 +12952,13 @@ startThreadSubsystem(void) if (!(growThreadInfosToAtLeast(GIV(numThreadsIncrement) * 2))) { error("no memory to start thread system"); } - vmThread = GIV(threads)[(GIV(vmOwner) = 1)]; + atomic_store((&GIV(vmOwner)), 1); + vmThread = GIV(threads)[atomic_load((&GIV(vmOwner)))]; (vmThread->state = CTMInitializing); /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -12970,8 +12975,9 @@ static void NoDbgRegParms startVMThread(CogVMThread *vmThread) { /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -12987,9 +12993,23 @@ static sqInt NoDbgRegParms threadIndexisCompatibleWith(sqInt aThreadIndex, sqInt processThreadId) { assert(aThreadIndex > 0); - return (processThreadId >= 0 + return (processThreadId == 0) + || ((processThreadId >= 0 ? aThreadIndex == processThreadId - : aThreadIndex != (-processThreadId)); + : aThreadIndex != (-processThreadId))); +} + + /* CogThreadManager>>#tryLockVMOwnerTo: */ +sqInt +tryLockVMOwnerTo(sqInt threadIndex) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + int expected; + + assert(!((threadIndex == 0))); + /* begin doTryLockVMOwnerTo: */ + expected = 0; + return (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), threadIndex)) + || (expected == threadIndex); } @@ -13026,8 +13046,7 @@ unusedThreadInfo(void) static sqInt vmIsOwned(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner) > 0; + return (atomic_load((&GIV(vmOwner)))) != 0; } @@ -13037,6 +13056,7 @@ vmIsOwned(void) usqInt vmOwnerAddress(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT + error("Deprecated! Replaced by proper atomic functions"); return ((usqInt)((&GIV(vmOwner)))); } @@ -13047,12 +13067,15 @@ vmOwnerAddress(void) static sqInt NoDbgRegParms vmOwnerIsCompatibleWith(sqInt processThreadId) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); + sqInt aThreadIndex; + /* begin threadIndex:isCompatibleWith: */ - assert(GIV(vmOwner) > 0); - return (processThreadId >= 0 - ? GIV(vmOwner) == processThreadId - : GIV(vmOwner) != (-processThreadId)); + aThreadIndex = atomic_load((&GIV(vmOwner))); + assert(aThreadIndex > 0); + return (processThreadId == 0) + || ((processThreadId >= 0 + ? aThreadIndex == processThreadId + : aThreadIndex != (-processThreadId))); } @@ -13062,8 +13085,7 @@ vmOwnerIsCompatibleWith(sqInt processThreadId) static sqInt NoDbgRegParms vmOwnerIs(sqInt index) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner) == index; + return (atomic_load((&GIV(vmOwner)))) == index; } /* CogThreadManager>>#vmThreadAt: */ @@ -13090,16 +13112,23 @@ wakeVMThreadFor(sqInt index) assert((vmIsOwned()) && (!(vmOwnerIs(index)))); assert(((index >= 1) && (index <= GIV(numThreads)))); - /* begin setVMOwner: */ - GIV(vmOwner) = index; - sqLowLevelMFence(); + + /* Instead of going through a #disownVM: call, directly set the new VM owner. + This has the advantage of avoiding a race for the different threads to become the new + VM owner. + In Simulation, this means we need to simulate a thread-switch. */ vmThread = GIV(threads)[index]; + /* begin setVMOwner: */ + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != index)); + atomic_store((&GIV(vmOwner)), index); if (((vmThread->state)) == null) { startThreadForThreadInfo(vmThread); } else { - assert((((vmThread->state)) == CTMWantingOwnership) - || (((vmThread->state)) == CTMAssignableOrInVM)); + assert(((((vmThread->state)) == CTMWantingOwnership) + || (((vmThread->state)) == CTMAssignableOrInVM)) + || (((vmThread->state)) == CTMInitializing)); ioSignalOSSemaphore((&((vmThread->osSemaphore)))); } ioTransferTimeslice(); @@ -13121,7 +13150,7 @@ willingVMThread(void) threadWantingVM = (threadWilling = null); for (i = 1; i <= GIV(numThreads); i += 1) { - if (!(vmOwnerIs(i))) { + if (!((atomic_load((&GIV(vmOwner)))) == i)) { thread = GIV(threads)[i]; if (((thread->state)) == CTMWantingOwnership) { if ((threadWantingVM == null) @@ -15626,7 +15655,7 @@ ceTraceBlockActivation(void) selector = ((mframeHomeMethod(GIV(framePointer)))->methodObject); GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockActivation; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForreceiverisBlockfirstTemporary(((mframeHomeMethod(GIV(framePointer)))->methodObject), ((((usqInt)(longAt(GIV(framePointer) + FoxMethod)))) < (startOfMemory()) @@ -15662,7 +15691,7 @@ ceTraceLinkedSend(sqInt theReceiver) selector = (cogMethod->selector); GIV(traceLog)[GIV(traceLogIndex)] = classOrInteger; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForreceiverisBlockfirstTemporary((cogMethod->methodObject), theReceiver, 0, null); @@ -16213,7 +16242,7 @@ commenceCogCompiledCodeCompaction(void) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceCodeCompaction; GIV(traceLog)[GIV(traceLogIndex) + 1] = TraceCodeCompaction; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (recordPrimTrace()) { @@ -19497,7 +19526,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + usqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -19546,7 +19575,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -19564,7 +19593,7 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); @@ -20233,7 +20262,7 @@ preGCAction(sqInt gcModeArg) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = traceType; GIV(traceLog)[GIV(traceLogIndex) + 1] = traceType; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (recordPrimTrace()) { @@ -21340,7 +21369,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); - GIV(processHasThreadId) = ((headerFlags & 4) != 0); + GIV(processHasThreadAffinity) = ((headerFlags & 4) != 0); GIV(flagInterpretedMethods) = ((headerFlags & 8) != 0); /* was: noThreadingOfGUIThread := headerFlags anyMask: 32. a broken idea */ @@ -21357,9 +21386,9 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea /* i.e. has it not been set on the command line? */ upscaleDisplayIfHighDPI = (!(headerFlags & 0x400)); } - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { /* begin print: */ - fprintf(GIV(transcript), "warning, processHasThreadId flag is unset; cannot function as a threaded VM if so."); + fprintf(GIV(transcript), "warning, processHasThreadAffinity flag is unset; cannot function as a threaded VM if so."); cr(); } /* begin getWord32FromFile:swap: */ @@ -22921,7 +22950,7 @@ cedeToHigherPriorityThreads(void) sqInt objOop; sqInt objOop1; sqInt oop; - sqInt ownerIndex; + sqInt processAffinity; char *sp; char *sp1; char *theFP; @@ -22939,28 +22968,19 @@ cedeToHigherPriorityThreads(void) assert((oop & 1)); activePriority = (oop >> 1); /* begin ownerIndexOfThreadId: */ - threadId = (GIV(processHasThreadId) + threadId = (GIV(processHasThreadAffinity) ? longAt((activeProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)); - ownerIndex = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + processAffinity = ((threadId & 1) + ? (((threadId >> 1))) >> ThreadIdShift : 0); - if (ownerIndex == 0) { - /* begin currentVMThread */ - sqLowLevelMFence(); - index = GIV(vmOwner); - assert(((index >= 0) && (index <= GIV(numThreads)))); - activeThread = (index > 0 - ? GIV(threads)[index] - : 0); - } - else { - /* begin vmThreadAt: */ - assert(((ownerIndex >= 0) && (ownerIndex <= GIV(numThreads)))); - activeThread = (ownerIndex > 0 - ? GIV(threads)[ownerIndex] - : 0); - } + /* begin currentVMThread */ + index = atomic_load((&GIV(vmOwner))); + assert(((index >= 0) && (index <= GIV(numThreads)))); + activeThread = (index > 0 + ? GIV(threads)[index] + : 0); + assert(threadIndexisCompatibleWith((activeThread->index), processAffinity)); (activeThread->priority = activePriority); /* begin highestPriorityThreadIfHigherThan:expectedMax: */ @@ -22994,11 +23014,11 @@ cedeToHigherPriorityThreads(void) } if (highest == null) { vmThread = null; - goto l6; + goto l5; } if (((highest->priority)) <= activePriority) { vmThread = null; - goto l6; + goto l5; } /* begin setMaxWaitingPriorityTo: */ minPriority = (nextHighest == null @@ -23006,7 +23026,7 @@ cedeToHigherPriorityThreads(void) : (nextHighest->priority)); GIV(maxWaitingPriority) = minPriority; vmThread = highest; - l6: /* end highestPriorityThreadIfHigherThan:expectedMax: */; + l5: /* end highestPriorityThreadIfHigherThan:expectedMax: */; if ((vmThread == null) || (vmThread == activeThread)) { @@ -23033,10 +23053,10 @@ cedeToHigherPriorityThreads(void) : (byteAt((theFP + FoxIFrameFlags) + 2)) != 0)) { assert(isContext(frameContext(theFP))); activeContext = longAt(theFP + FoxThisContext); - goto l12; + goto l10; } activeContext = marryFrameSP(theFP, theSP); - l12: /* end ensureFrameIsMarried:SP: */; + l10: /* end ensureFrameIsMarried:SP: */; /* begin storePointer:ofObject:withValue: */ assert(!(isForwarded(activeProc))); if ((assert(isNonImmediate(activeProc)), @@ -23110,7 +23130,7 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertCStackWellAligned(); /* restore the stackLimit if it has been smashed. */ @@ -23239,7 +23259,7 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) /* Check whether the VM is unowned and needs to set a thread running to try and own it. - Do not attempt this if the image doesn't have a threadId inst var in + Do not attempt this if the image doesn't have a threadAffinity inst var in Process; the VM can't thread these images. */ @@ -23247,11 +23267,13 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) static void checkVMOwnershipFromHeartbeat(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT + int expected; + int expected1; CogVMThread *vmThread; sqLowLevelMFence(); - if (GIV(processHasThreadId) - && (vmOwnerIs(0))) { + if (GIV(processHasThreadAffinity) + && ((atomic_load((&GIV(vmOwner)))) == 0)) { /* begin ensureRunningVMThread: */ vmThread = willingVMThread(); if (!(vmThread == null)) { @@ -23261,7 +23283,13 @@ checkVMOwnershipFromHeartbeat(void) && (((vmThread->state)) != CTMWantingOwnership)) { goto l1; } - if (!(tryLockVMOwnerTo((vmThread->index)))) { + assert(((((vmThread->state)) == CTMAssignableOrInVM) + || (((vmThread->state)) == CTMInitializing)) + || (((vmThread->state)) == CTMWantingOwnership)); + if (!((assert(!((((vmThread->index)) == 0))), + (expected = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), (vmThread->index))) + || (expected == ((vmThread->index)))))) { /* someone beat us to it... */ goto l1; @@ -23279,11 +23307,15 @@ checkVMOwnershipFromHeartbeat(void) } vmThread = unusedThreadInfo(); if (!(vmThread == null)) { - if (tryLockVMOwnerTo((vmThread->index))) { + if ((assert(!((((vmThread->index)) == 0))), + (expected1 = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected1), (vmThread->index))) + || (expected1 == ((vmThread->index))))) { if (!(startThreadForThreadInfo(vmThread))) { /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); } } } @@ -23359,10 +23391,10 @@ disownVM(sqInt flags) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceDisownVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ((((usqInt)flags << 1) | 1)); - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { if (willNotThreadWarnCount < 10) { /* begin print: */ fprintf(GIV(transcript), "warning: VM parameter 48 indicates Process doesn't have threadId; VM will not thread"); @@ -23371,8 +23403,7 @@ disownVM(sqInt flags) } } /* begin currentVMThread */ - sqLowLevelMFence(); - index = GIV(vmOwner); + index = atomic_load((&GIV(vmOwner))); assert(((index >= 0) && (index <= GIV(numThreads)))); vmThread = (index > 0 ? GIV(threads)[index] @@ -23394,17 +23425,14 @@ disownVM(sqInt flags) GIV(relinquishing) = 1; sqLowLevelMFence(); } - disownCount += 1; - /* self cr; cr; print: 'disownVM Csp: '; printHex: vmThread cStackPointer; cr. - (0 to: 16 by: 4) do: - [:offset| - self print: ' *(esp+'; printNum: offset; print: ': '; printHex: (stackPages longAt: cogit processor sp + offset); cr]. - cogit processor printIntegerRegistersOn: Transcript. */ - /* OwnVMForeignThreadFlag indicates lowest-level of entry by a foreign - thread. If that's where we are then release the vmThread. Otherwise - indicate the vmThread is off doing something outside of the VM. */ - GIV(disowningVMThread) = vmThread; + /* If we're disowning the VM because there's no active process to run, + there's nothing to preempt later, so don't indicate that there's a disowningVMThread that + needs to be restored later. */ + disownCount += 1; + if ((fetchPointerofObject(ActiveProcessIndex, schedulerPointer())) != GIV(nilObj)) { + GIV(disowningVMThread) = vmThread; + } if (((flags & OwnVMForeignThreadFlag) != 0)) { /* I don't think this is quite right. Josh's use case is creating some foreign thread and then registering @@ -23428,8 +23456,9 @@ disownVM(sqInt flags) ? 0 : ProcessUnaffinedOnDisown))) | flags; /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); return result; } @@ -23478,7 +23507,7 @@ enterSmalltalkExecutiveImplementation(void) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertProcessorStackPointersBelongToCurrentThread(); assertCStackWellAligned(); ceCaptureCStackPointers(); @@ -23542,7 +23571,7 @@ getImageHeaderFlags(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT return ((((((((GIV(fullScreenFlag) + ((VMBIGENDIAN ? 0 - : 2))) + ((GIV(processHasThreadId) + : 2))) + ((GIV(processHasThreadAffinity) ? 4 : 0))) + ((GIV(flagInterpretedMethods) ? 8 @@ -23591,11 +23620,11 @@ isBoundProcess(sqInt aProcess) sqInt threadId1; /* begin isBoundThreadId: */ - threadId1 = (GIV(processHasThreadId) + threadId1 = (GIV(processHasThreadAffinity) ? longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)); threadId = ((threadId1 & 1) - ? ((usqInt)(((threadId1 >> 1)))) >> ThreadIdShift + ? (((threadId1 >> 1))) >> ThreadIdShift : 0); return ((threadId & 1)) && ((((threadId >> 1)) & 1) == 1); @@ -23644,7 +23673,7 @@ loadInitialContext(void) objOop1 = longAt((objOop4 + BaseHeaderSize) + (((int)((usqInt)(ValueIndex) << (shiftForWord()))))); activeProc = longAt((objOop1 + BaseHeaderSize) + (((int)((usqInt)(ActiveProcessIndex) << (shiftForWord()))))); assert((ownerIndexOfProcess(activeProc)) == 0); - GIV(activeProcessAffined) = (ownerIndexOfThreadId((GIV(processHasThreadId) + GIV(activeProcessAffined) = (ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? longAt((activeProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)))) != 0; } @@ -23775,7 +23804,7 @@ ownerIndexOfProcess(sqInt aProcess) sqInt threadId; /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -23784,7 +23813,7 @@ ownerIndexOfProcess(sqInt aProcess) threadId = GIV(nilObj); } return ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); } @@ -23793,7 +23822,7 @@ static sqInt NoDbgRegParms ownerIndexOfThreadId(sqInt threadId) { return ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); } @@ -23819,7 +23848,7 @@ ownVMFromUnidentifiedThread(void) if (((threadIndex = ioGetThreadLocalThreadIndex())) != 0) { /* this is a callback from a known thread */ - if (vmOwnerIs(threadIndex)) { + if ((atomic_load((&GIV(vmOwner)))) == threadIndex) { /* the VM has not been disowned */ assert((GIV(disowningVMThread) == null) @@ -23851,8 +23880,9 @@ ownVMFromUnidentifiedThread(void) } if ((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (((sqInt)((usqInt)(GIV(foreignCallbackProcessSlot)) << (shiftForWord())))))) != GIV(nilObj)) break; /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); if (((count += 1)) > 1000) { return -2; } @@ -23865,19 +23895,22 @@ ownVMFromUnidentifiedThread(void) vmThread = unusedThreadInfo(); if (!vmThread) { /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); return -1; } /* begin setVMOwner: */ indexOrZero = (vmThread->index); - GIV(vmOwner) = indexOrZero; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != indexOrZero)); + atomic_store((&GIV(vmOwner)), indexOrZero); (vmThread->state = CTMWantingOwnership); (vmThread->priority = GIV(foreignCallbackPriority)); /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -23914,6 +23947,8 @@ ownVM(sqInt threadIndexAndFlags) sqInt aMethodObj; sqInt cFramePointer; sqInt cStackPointer; + int expected; + int expected1; sqInt flags; StackPage *lastUsedPage; StackPage *lruOrFree; @@ -23959,10 +23994,20 @@ ownVM(sqInt threadIndexAndFlags) : 0); assert((((vmThread1->state)) == CTMUnavailable) || (((vmThread1->state)) == CTMWantingOwnership)); - if (!(tryLockVMOwnerTo(threadIndex))) { + if ((assert(!((threadIndex == 0))), + (expected1 = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected1), threadIndex)) + || (expected1 == threadIndex))) { + (vmThread1->state = CTMAssignableOrInVM); + } + else { (vmThread1->state = CTMWantingOwnership); - while (!((vmOwnerIs(threadIndex)) - || (tryLockVMOwnerTo(threadIndex)))) { + while (!(((atomic_load((&GIV(vmOwner)))) == threadIndex) + || ((assert(!((threadIndex == 0))), + /* begin doTryLockVMOwnerTo: */ + (expected = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), threadIndex)) + || (expected == threadIndex))))) { if (!(((vmThread1->priority)) == null)) { /* begin waitingPriorityIsAtLeast: */ minPriority = (vmThread1->priority); @@ -23972,7 +24017,7 @@ ownVM(sqInt threadIndexAndFlags) forceInterruptCheck(); } } - if (!(vmOwnerIs(threadIndex))) { + if (!((atomic_load((&GIV(vmOwner)))) == threadIndex)) { ioWaitOnOSSemaphore((&((vmThread1->osSemaphore)))); } } @@ -23994,7 +24039,7 @@ ownVM(sqInt threadIndexAndFlags) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceOwnVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ConstOne; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } return 0; @@ -24057,7 +24102,7 @@ ownVM(sqInt threadIndexAndFlags) assert(!(isOopForwarded(myProc))); longAtput((myProc + BaseHeaderSize) + (((int)((usqInt)(MyListIndex) << (shiftForWord())))), GIV(nilObj)); if ((((threadIndexAndFlags & ProcessUnaffinedOnDisown) != 0)) - && (!(isBoundThreadId(ownerIndexOfThreadId((GIV(processHasThreadId) + && (!(isBoundThreadId(ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? longAt((myProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj))))))) { /* begin setOwnerIndexOfProcess:to:bind: */ @@ -24171,7 +24216,7 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceOwnVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ConstTwo; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } return threadIndexAndFlags & OwnVMForeignThreadFlag; @@ -24223,7 +24268,7 @@ preemptDisowningThread(void) selector = (((usqInt)((GIV(disowningVMThread)->index)) << 1) | 1); GIV(traceLog)[GIV(traceLogIndex)] = TracePreemptDisowningThread; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } (GIV(disowningVMThread)->cStackPointer = GIV(CStackPointer)); @@ -24295,7 +24340,7 @@ preemptDisowningThread(void) preemptedThread = pushAWOLProcesson(activeProc, GIV(disowningVMThread)); GIV(disowningVMThread) = null; (preemptedThread->priority = quickFetchIntegerofObject(PriorityIndex, activeProc)); - if ((ownerIndexOfThreadId((GIV(processHasThreadId) + if ((ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? (/* begin fetchPointer:ofObject: */ longAt((activeProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord())))))) : /* begin nilObject */ GIV(nilObj)))) == 0) { @@ -24337,7 +24382,7 @@ primitiveProcessBindToThreadId(void) sqInt threadIdSlot; sqInt threadIdSlot1; - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { (GIV(primFailCode) = PrimErrUnsupported); return; } @@ -24360,11 +24405,11 @@ primitiveProcessBindToThreadId(void) return; } /* begin bindProcess:toId: */ - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { ec = PrimErrUnsupported; goto l8; } - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadIdField = longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24376,7 +24421,7 @@ primitiveProcessBindToThreadId(void) /* If aProcess is affined (temporarily bound to) a thread then the operation can only succeed if the newId is the same as that aProcess is affined to, or is zero (is unbinding). */ ownerIndex = ((threadIdField & 1) - ? ((usqInt)(((threadIdField >> 1)))) >> ThreadIdShift + ? (((threadIdField >> 1))) >> ThreadIdShift : 0); if ((((threadIdField & 1) ? ((((threadIdField >> 1)) & ((1U << ThreadIdShift) - 1)) != 0) @@ -24427,7 +24472,7 @@ primitiveProcessBindToThreadId(void) /* begin pop: */ GIV(stackPointer) += GIV(argumentCount) * BytesPerWord; /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24436,7 +24481,7 @@ primitiveProcessBindToThreadId(void) threadId = GIV(nilObj); } id = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); if ((aProcess == (fetchPointerofObject(ActiveProcessIndex, schedulerPointer()))) && (((GIV(activeProcessAffined) = id != 0)) @@ -24452,11 +24497,13 @@ primitiveProcessBindToThreadId(void) } -/* Answer the receiver's current thread Id or nil, where the receiver is a - Process. If the threadId is positive then the receiver is bound to the - thread with that id. - If the threadId is negative then the receiver is excluded from running on - the thread with that id. */ +/* Answer the receiver's current threadAffinity or nil, where the receiver is + a Process. + If the threadAffinity is positive then the receiver is bound to the thread + with that id. + If the threadAffinity is negative then the receiver is excluded from + running on the thread with that id. + */ /* CoInterpreterMT>>#primitiveProcessBoundThreadId */ EXPORT(void) @@ -24468,13 +24515,13 @@ primitiveProcessBoundThreadId(void) char *sp; sqInt threadId; - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { (GIV(primFailCode) = PrimErrUnsupported); return; } aProcess = longAt(GIV(stackPointer)); /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24483,7 +24530,7 @@ primitiveProcessBoundThreadId(void) threadId = GIV(nilObj); } id = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); /* begin methodReturnValue: */ oop = (id == 0 @@ -24555,8 +24602,7 @@ primitiveVMCurrentThreadId(void) char *sp; /* begin methodReturnInteger: */ - sqLowLevelMFence(); - integer = GIV(vmOwner); + integer = atomic_load((&GIV(vmOwner))); assert(!((failed()))); /* begin pop:thenPushInteger: */ longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), (((usqInt)integer << 1) | 1)); @@ -24799,30 +24845,36 @@ printAllStacks(void) static void NoDbgRegParms returnToSchedulingLoopAndReleaseVMOrWakeThreadsource(CogVMThread *vmThread, sqInt source) { DECL_MAYBE_SQ_GLOBAL_STRUCT + CogVMThread *activeThread; + sqInt index; sqInt ownerIndex; sqInt selector; + /* begin currentVMThread */ + index = atomic_load((&GIV(vmOwner))); + assert(((index >= 0) && (index <= GIV(numThreads)))); + activeThread = (index > 0 + ? GIV(threads)[index] + : 0); /* begin recordThreadSwitchTo:source: */ ownerIndex = (vmThread == null ? 0 : (vmThread->index)); if (recordEventTrace()) { /* begin recordTrace:thing:source: */ - selector = (((usqInt)((((sqInt)((usqInt)(ownerIndex) << 16))) + (getVMOwner())) << 1) | 1); + selector = (((usqInt)((((sqInt)((usqInt)(ownerIndex) << 16))) + (atomic_load((&GIV(vmOwner))))) << 1) | 1); GIV(traceLog)[GIV(traceLogIndex)] = TraceThreadSwitch; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (vmThread == null) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + disownVM(DisownVMForThreading); } else { wakeVMThreadFor((vmThread->index)); } - _longjmp(GIV(reenterThreadSchedulingLoop), 1); + _longjmp((activeThread->reenterThreadSchedulingLoop), 1); } @@ -24892,7 +24944,7 @@ sendInvokeCallbackContext(VMCallbackContext *vmCallbackContext) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertCStackWellAligned(); if (recordPrimTrace()) { /* begin fastLogPrim: */ @@ -25106,19 +25158,15 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) sqInt top; sqInt valuePointer; - _setjmp(GIV(reenterThreadSchedulingLoop)); + _setjmp((vmThread->reenterThreadSchedulingLoop)); do { assert(((vmThread->state)) == CTMAssignableOrInVM); if (tryLockVMOwnerTo((vmThread->index))) { + /* Yay, we're the VM owner! */ /* If relinquishing is true, then primitiveRelinquishProcessor has disowned the VM and only a returning call or callback should take ownership in that case. */ - if (GIV(relinquishing)) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); - } - else { + if (!GIV(relinquishing)) { /* begin tryToExecuteSmalltalk: */ assert(vmOwnerIs((vmThread->index))); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -25159,13 +25207,10 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) longAtput((objOop1 + BaseHeaderSize) + (((int)((usqInt)(ActiveProcessIndex) << (shiftForWord())))), activeProc); } if (activeProc == GIV(nilObj)) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); goto l20; } /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((activeProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -25174,7 +25219,7 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) threadId = GIV(nilObj); } ownerIndex = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); if ((ownerIndex == 0) || (vmOwnerIsCompatibleWith(ownerIndex))) { @@ -25273,13 +25318,12 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G wakeVMThreadFor(ownerIndex); l20: /* end tryToExecuteSmalltalk: */; } + disownVM(DisownVMForThreading); } - if (!(vmOwnerIs((vmThread->index)))) { - /* begin waitForWork: */ - assert(((vmThread->state)) == CTMAssignableOrInVM); - assert(!((vmOwnerIs((vmThread->index))))); - ioWaitOnOSSemaphore((&((vmThread->osSemaphore)))); - } + /* begin waitForWork: */ + (vmThread->state = CTMAssignableOrInVM); + assert(!((vmOwnerIs((vmThread->index))))); + ioWaitOnOSSemaphore((&((vmThread->osSemaphore)))); } while(1); } @@ -25306,9 +25350,9 @@ threadSwitchIfNecessaryfrom(sqInt newProc, sqInt sourceCode) if (GIV(deferThreadSwitch)) { return; } - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((newProc + BaseHeaderSize) + (((int)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -25317,7 +25361,7 @@ threadSwitchIfNecessaryfrom(sqInt newProc, sqInt sourceCode) threadId = GIV(nilObj); } newProcOwnerIndex = ((threadId & 1) - ? ((usqInt)(((threadId >> 1)))) >> ThreadIdShift + ? (((threadId >> 1))) >> ThreadIdShift : 0); if (!(((GIV(activeProcessAffined) = newProcOwnerIndex != 0)) && (!(vmOwnerIsCompatibleWith(newProcOwnerIndex))))) { @@ -25465,7 +25509,7 @@ transferTofrom(sqInt newProc, sqInt sourceCode) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceContextSwitch; GIV(traceLog)[GIV(traceLogIndex) + 1] = oldProc; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (sourceCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (sourceCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } /* begin ensureFrameIsMarried:SP: */ @@ -26619,6 +26663,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -26640,6 +26686,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -36069,7 +36117,7 @@ primitiveInvokeObjectAsMethod(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt i; sqInt lookupClassTag; - sqInt runArgs; + usqInt runArgs; sqInt runReceiver; char *sp; char *sp1; @@ -60831,15 +60879,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -63875,7 +63915,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -67561,8 +67601,8 @@ static sqInt getErrorObjectFromPrimFailCode(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt classIndex; - usqInt clone; - usqInt errObj; + sqInt clone; + sqInt errObj; sqInt fieldIndex; sqInt i; usqInt newObj; @@ -67906,7 +67946,7 @@ handleStackOverflow(void) : TraceIsFromInterpreter); GIV(traceLog)[GIV(traceLogIndex)] = TraceStackOverflow; GIV(traceLog)[GIV(traceLogIndex) + 1] = TraceStackOverflow; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if ((recordPrimTrace()) @@ -69714,7 +69754,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + usqInt index; usqInt length; sqInt mask; sqInt meth; @@ -69758,7 +69798,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -69776,7 +69816,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); @@ -81533,7 +81573,7 @@ GIV(totalHeapSizeIncludingBridges)))); GIV(primFailCode) = PrimErrInappropriate; goto l103; } - GIV(processHasThreadId) = ((arg & 1) != 0); + GIV(processHasThreadAffinity) = ((arg & 1) != 0); GIV(flagInterpretedMethods) = ((arg & 2) != 0); /* was: noThreadingOfGUIThread := flags anyMask: 8. a broken idea */ diff --git a/src/spur32.sista/cogit.h b/src/spur32.sista/cogit.h index e37cc72f9f..04b4648cc2 100644 --- a/src/spur32.sista/cogit.h +++ b/src/spur32.sista/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ @@ -102,9 +102,6 @@ extern usqIntptr_t (*ceGetFP)(void); extern usqIntptr_t (*ceGetSP)(void); extern void (*ceInvokeInterpret)(void); extern sqInt ceReturnToInterpreterTrampoline; -#if COGMTVM -extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; @@ -130,7 +127,6 @@ extern int traceFlags ; #define recordOverflowTrace() (traceFlags & 32) #define recordPrimTrace() (traceFlags & 8) #define recordSendTrace() (traceFlags & 2) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define numRegArgs() 2 #define fullBlockEntryOffset() cbEntryOffset #define fullBlockNoContextSwitchEntryOffset() cbNoSwitchEntryOffset diff --git a/src/spur32.sista/cogitARMv5.c b/src/spur32.sista/cogitARMv5.c index 9c8395e79b..830f8f4f0b 100644 --- a/src/spur32.sista/cogitARMv5.c +++ b/src/spur32.sista/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -277,7 +277,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (69 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (69 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -2687,9 +2687,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2759,7 +2756,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -34382,11 +34378,6 @@ getJumpTargetPCAt(sqInt pc) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - sqInt fixupSize2; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - initialCounterValue = MaxCounterValue; initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, @@ -34408,25 +34399,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; assertValidDualZone(); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = numLowLevelLockOpcodes(backEnd); - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - generateLowLevelTryLock(backEnd, vmOwnerAddress()); - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur32.sista/cogitIA32.c b/src/spur32.sista/cogitIA32.c index 9cf71ecf90..4f331184f6 100644 --- a/src/spur32.sista/cogitIA32.c +++ b/src/spur32.sista/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -295,7 +295,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (69 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (69 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -526,7 +526,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2641,9 +2640,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2720,7 +2716,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -6634,38 +6629,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogIA32Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt valueReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - valueReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | (1U << EAX)) - (1U << EAX))); - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperandoperand(MoveMwrR, 4, ESP, valueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, 0, EAX); - gen(LOCK); - genoperandoperand(CMPXCHGRAw, valueReg, vmOwnerLockAddress); - genoperand(SETE, ABIResultReg); - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogIA32Compiler>>#genMemCopy:to:constantSize: */ @@ -31523,16 +31486,6 @@ getJumpTargetPCAt(sqInt pc) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt valueReg; - sqInt vmOwnerLockAddress; - initialCounterValue = MaxCounterValue; initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, @@ -31555,42 +31508,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 6 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - genoperand(RetN, 0); - goto l1; - } - valueReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | (1U << EAX)) - (1U << EAX))); - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperandoperand(MoveMwrR, 4, ESP, valueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, 0, EAX); - gen(LOCK); - genoperandoperand(CMPXCHGRAw, valueReg, vmOwnerLockAddress); - genoperand(SETE, ABIResultReg); - genoperand(RetN, 0); - l1: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur32.sista/cointerp.c b/src/spur32.sista/cointerp.c index 7b7587e6a1..cdec35d33a 100644 --- a/src/spur32.sista/cointerp.c +++ b/src/spur32.sista/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1873,7 +1873,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1885,6 +1884,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2692,7 +2692,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -23239,7 +23239,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -23853,7 +23853,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -26870,6 +26870,8 @@ primitiveSistaMethodPICAndCounterData(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -26891,6 +26893,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -61188,15 +61192,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -63650,7 +63646,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l6: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -63680,7 +63676,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -64232,7 +64228,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur32.sista/cointerp.h b/src/spur32.sista/cointerp.h index a4dcc39119..bc47944b85 100644 --- a/src/spur32.sista/cointerp.h +++ b/src/spur32.sista/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3328 uuid: a1c7c55f-8829-4fcc-9a66-55ba7d1a8cef + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ diff --git a/src/spur32.sista/gcc3x-cointerp.c b/src/spur32.sista/gcc3x-cointerp.c index 89647e54a0..0d7a930d78 100644 --- a/src/spur32.sista/gcc3x-cointerp.c +++ b/src/spur32.sista/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1876,7 +1876,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1888,6 +1887,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2695,7 +2695,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -23248,7 +23248,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -23862,7 +23862,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -26879,6 +26879,8 @@ primitiveSistaMethodPICAndCounterData(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -26900,6 +26902,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -61197,15 +61201,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -63659,7 +63655,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l6: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -63689,7 +63685,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -64241,7 +64237,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur32.stack.lowcode/gcc3x-interp.c b/src/spur32.stack.lowcode/gcc3x-interp.c index 5d91389909..f5cfb6b61a 100644 --- a/src/spur32.stack.lowcode/gcc3x-interp.c +++ b/src/spur32.stack.lowcode/gcc3x-interp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1608,7 +1608,6 @@ _iss sqInt rememberedSetLimit; _iss sqInt statSurvivorCount; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1620,6 +1619,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2387,7 +2387,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -38304,8 +38304,10 @@ primitiveSizeInBytesOfInstance(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -58892,15 +58894,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -73352,7 +73346,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/spur32.stack.lowcode/interp.c b/src/spur32.stack.lowcode/interp.c index be15272f7f..17d2fe2eef 100644 --- a/src/spur32.stack.lowcode/interp.c +++ b/src/spur32.stack.lowcode/interp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1605,7 +1605,6 @@ _iss sqInt rememberedSetLimit; _iss sqInt statSurvivorCount; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1617,6 +1616,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2384,7 +2384,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -38295,8 +38295,10 @@ primitiveSizeInBytesOfInstance(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -58883,15 +58885,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -73343,7 +73337,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/spur32.stack/gcc3x-interp.c b/src/spur32.stack/gcc3x-interp.c index 8dbc98dfa6..d643334316 100644 --- a/src/spur32.stack/gcc3x-interp.c +++ b/src/spur32.stack/gcc3x-interp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1582,7 +1582,6 @@ _iss sqInt rememberedSetLimit; _iss sqInt statSurvivorCount; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1594,6 +1593,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2361,7 +2361,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -25323,8 +25323,10 @@ primitiveSizeInBytesOfInstance(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -45839,15 +45841,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -60177,7 +60171,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/spur32.stack/interp.c b/src/spur32.stack/interp.c index 0e6172926d..fbc18edf61 100644 --- a/src/spur32.stack/interp.c +++ b/src/spur32.stack/interp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1579,7 +1579,6 @@ _iss sqInt rememberedSetLimit; _iss sqInt statSurvivorCount; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt preemptionYields; _iss FILE * scavengeLog; @@ -1591,6 +1590,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; _iss sqInt savedWindowSize; @@ -2358,7 +2358,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -25314,8 +25314,10 @@ primitiveSizeInBytesOfInstance(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -45830,15 +45832,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -60168,7 +60162,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/spur32.stack/validImage.c b/src/spur32.stack/validImage.c index 7c3a7c04a2..62c1a2df68 100644 --- a/src/spur32.stack/validImage.c +++ b/src/spur32.stack/validImage.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - ImageLeakChecker VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + ImageLeakChecker VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "ImageLeakChecker VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "ImageLeakChecker VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -993,7 +993,7 @@ sqInt extraVMMemory; sqInt ffiExceptionResponse; sqInt inIOProcessEvents; struct VirtualMachine* interpreterProxy; -const char *interpreterVersion = "Open Smalltalk ImageChecker VM [ImageLeakChecker VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk ImageChecker VM [ImageLeakChecker VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; char expensiveAsserts = 0; volatile int sendTrace; @@ -13769,7 +13769,7 @@ setImageHeaderFlagsFrom(sqInt headerFlags) GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/spur64.cog.lowcode/cogit.h b/src/spur64.cog.lowcode/cogit.h index f3ba153a4a..c605498f9c 100644 --- a/src/spur64.cog.lowcode/cogit.h +++ b/src/spur64.cog.lowcode/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ @@ -99,9 +99,6 @@ extern usqIntptr_t (*ceGetFP)(void); extern usqIntptr_t (*ceGetSP)(void); extern void (*ceInvokeInterpret)(void); extern sqInt ceReturnToInterpreterTrampoline; -#if COGMTVM -extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; @@ -127,7 +124,6 @@ extern int traceFlags ; #define recordOverflowTrace() (traceFlags & 32) #define recordPrimTrace() (traceFlags & 8) #define recordSendTrace() (traceFlags & 2) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define numRegArgs() 2 #define fullBlockEntryOffset() cbEntryOffset #define fullBlockNoContextSwitchEntryOffset() cbNoSwitchEntryOffset diff --git a/src/spur64.cog.lowcode/cogitARMv8.c b/src/spur64.cog.lowcode/cogitARMv8.c index b7c976e4c3..61ac37b9ff 100644 --- a/src/spur64.cog.lowcode/cogitARMv8.c +++ b/src/spur64.cog.lowcode/cogitARMv8.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -158,7 +158,6 @@ char *__cogitBuildInfo = __buildInfo; #define Extra0Reg 19 #define Extra1Reg 20 #define Extra2Reg 21 -#define Extra8Reg 27 #define Fill32 4 #define FirstAnnotation 64 #define FirstJump 12 @@ -345,7 +344,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (82 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (82 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -2847,9 +2846,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2861,14 +2857,12 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define dataCacheFlushRequired(ign) dataCacheFlushRequired #define dataCacheLineLength(ign) dataCacheLineLength #define flushDCacheFromto(me,startAddress,endAddress) ceFlushDCache(startAddress,endAddress) -#define hasAtomicInstructions(ign) hasAtomicInstructions #define inlineCacheValueForSelectorin(backEnd,selector,aCogMethod) indexForSelectorin(selector,aCogMethod) #define instructionCacheFlushRequired(ign) instructionCacheFlushRequired #define instructionCacheLineLength(ign) instructionCacheLineLength #define roundUpToMethodAlignment(ignored,numBytes) (((numBytes) + 15) & -16) #define setDataCacheFlushRequired(ign,b) dataCacheFlushRequired = b #define setDataCacheLineLength(ign,n) dataCacheLineLength = n -#define setHasAtomicInstructions(ign,b) hasAtomicInstructions = b #define setInstructionCacheFlushRequired(ign,b) instructionCacheFlushRequired = b #define setInstructionCacheLineLength(ign,n) instructionCacheLineLength = n #define cPICNumCases stackCheckOffset @@ -2928,7 +2922,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -4620,9 +4613,6 @@ detectFeaturesOnLinux(AbstractInstruction * self_in_detectFeaturesOnLinux) if ((instructionCacheLineLength(self_in_detectFeaturesOnLinux)) == 0) { setInstructionCacheLineLength(self_in_detectFeaturesOnLinux, 64); } -# if COGMTVM - setHasAtomicInstructions(self_in_detectFeaturesOnLinux, (((getauxval(AT_HWCAP)) & HWCAP_ATOMICS) != 0)); -# endif } #endif /* __linux__ */ @@ -4639,7 +4629,6 @@ detectFeaturesOnRawMachine(AbstractInstruction * self_in_detectFeaturesOnRawMach sqInt ctrEL0; sqInt fixupSize; usqIntptr_t (*getFeatureReg)(void); - sqInt idISAR0; sqInt opcodeSize; usqInt startAddress; @@ -4707,37 +4696,6 @@ detectFeaturesOnRawMachine(AbstractInstruction * self_in_detectFeaturesOnRawMach genoperand(MRS_ID_AA64ISAR0_EL1, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); -# if COGMTVM - /* begin resetMethodZoneBase: */ - methodZoneBase = startAddress; - /* begin ensureExecutableCodeZoneWithin: */ - -# if !DUAL_MAPPED_CODE_ZONE - /* begin makeCodeZoneExecutable */ -# if __APPLE__ && __MACH__ - pthread_jit_write_protect_np(1); - PJWPNSet = __LINE__; - if (!PJWPNState) { - PJWPNChange = __LINE__; - PJWPNState = 1; - } -# endif // __APPLE__ && __MACH__ -# endif // !DUAL_MAPPED_CODE_ZONE - idISAR0 = getFeatureReg(); - setHasAtomicInstructions(self_in_detectFeaturesOnRawMachine, ((((usqInt)(idISAR0)) >> 20) & 15) == 2); - /* begin ensureWritableCodeZone */ -# if !DUAL_MAPPED_CODE_ZONE - /* begin makeCodeZoneWritable */ -# if __APPLE__ && __MACH__ - pthread_jit_write_protect_np(0); - PJWPNClear = __LINE__; - if (PJWPNState) { - PJWPNChange = __LINE__; - PJWPNState = 0; - } -# endif // __APPLE__ && __MACH__ -# endif // !DUAL_MAPPED_CODE_ZONE -# endif // COGMTVM } #endif /* !__APPLE__ && !__linux__ */ @@ -13767,30 +13725,13 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - AbstractInstruction *anInstruction3; - AbstractInstruction *anInstruction4; - AbstractInstruction *anInstruction5; - AbstractInstruction *br; sqInt fixupSize; sqInt fixupSize1; - sqInt fixupSize2; - AbstractInstruction *ldaxr; - sqInt lockValueReg; sqInt numberOfAbstractOpcodes; sqInt numberOfAbstractOpcodes1; - sqInt numberOfAbstractOpcodes2; sqInt opcodeSize; sqInt opcodeSize1; - sqInt opcodeSize2; - sqInt reg; usqInt startAddress1; - usqInt startAddress2; - sqInt statusReg; - sqInt vmOwnerLockAddress; - sqInt vmOwnerLockAddressReg; initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, @@ -13815,10 +13756,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) # if __APPLE__ /* begin detectFeaturesOnMacOS */ -# if COGMTVM - setHasAtomicInstructions(((AbstractInstruction *) backEnd), 1); -# endif -# else // __APPLE__ +# else # if __linux__ detectFeaturesOnLinux(((AbstractInstruction *) backEnd)); # else @@ -13878,87 +13816,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) error("cache flushing method unknown for this platform"); # endif } - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 14 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - if (usesOutOfLineLiteral(anInstruction)) { - (anInstruction->dependent = locateLiteralsize(1, BytesPerOop)); - } - genoperand(RetN, 0); - goto l7; - } - - /* Holds the value of lock if unlocked (zero), receives the existing value of the lock */ - lockValueReg = CArg1Reg; - vmOwnerLockAddressReg = CArg2Reg; - if (hasAtomicInstructions(((AbstractInstruction *) backEnd))) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, lockValueReg); - if (usesOutOfLineLiteral(anInstruction1)) { - (anInstruction1->dependent = locateLiteralsize(0, BytesPerOop)); - } - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - if (usesOutOfLineLiteral(anInstruction2)) { - (anInstruction2->dependent = locateLiteralsize(vmOwnerLockAddress, BytesPerOop)); - } - genoperandoperandoperand(CASAL, lockValueReg, CArg0Reg, vmOwnerLockAddressReg); - br = genoperandoperand(CBNZ, 0, lockValueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction3 = genoperandoperand(MoveCqR, 1, ABIResultReg); - if (usesOutOfLineLiteral(anInstruction3)) { - (anInstruction3->dependent = locateLiteralsize(1, BytesPerOop)); - } - genoperand(RetN, 0); - jmpTarget(br, (assert(!((ABIResultReg == SPReg))), - genoperandoperand(CmpRR, ABIResultReg, lockValueReg))); - genoperandoperand(CSET, ABIResultReg, EQ); - genoperand(RetN, 0); - goto l7; - } - /* begin checkQuickConstant:forInstruction: */ - anInstruction4 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - if (usesOutOfLineLiteral(anInstruction4)) { - (anInstruction4->dependent = locateLiteralsize(vmOwnerLockAddress, BytesPerOop)); - } - /* begin MoveCq:R: */ - reg = (statusReg = CArg3Reg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction5 = genoperandoperand(MoveCqR, 0, reg); - if (usesOutOfLineLiteral(anInstruction5)) { - (anInstruction5->dependent = locateLiteralsize(0, BytesPerOop)); - } - ldaxr = genoperandoperand(LDAXR, lockValueReg, vmOwnerLockAddressReg); - br = genoperandoperand(CBNZ, 0, lockValueReg); - genoperandoperandoperand(STLXR, CArg0Reg, vmOwnerLockAddressReg, statusReg); - genoperandoperand(CBNZ, ((usqInt)ldaxr), statusReg); - genoperand(RetN, 0); - jmpTarget(br, gen(CLREX)); - assert(!((ABIResultReg == SPReg))); - genoperandoperand(CmpRR, ABIResultReg, lockValueReg); - genoperandoperand(CSET, ABIResultReg, EQ); - genoperand(RetN, 0); - l7: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur64.cog.lowcode/cogitX64SysV.c b/src/spur64.cog.lowcode/cogitX64SysV.c index 94546a5500..c4054ec949 100644 --- a/src/spur64.cog.lowcode/cogitX64SysV.c +++ b/src/spur64.cog.lowcode/cogitX64SysV.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -303,7 +303,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (80 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (80 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -1136,7 +1136,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2759,9 +2758,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2828,7 +2824,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -8941,17 +8936,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - AbstractInstruction *jumpEqual; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt vmOwnerLockAddress; - sqInt vmOwnerLockAddressReg; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -8973,49 +8957,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 8 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - goto l8; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - l8: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); @@ -26884,46 +26825,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogX64Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - AbstractInstruction *jumpEqual; - sqInt vmOwnerLockAddressReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogX64Compiler>>#genMemCopy:to:constantSize: */ diff --git a/src/spur64.cog.lowcode/cogitX64WIN64.c b/src/spur64.cog.lowcode/cogitX64WIN64.c index 207f9464be..95c9209658 100644 --- a/src/spur64.cog.lowcode/cogitX64WIN64.c +++ b/src/spur64.cog.lowcode/cogitX64WIN64.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -303,7 +303,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (80 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (80 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -1136,7 +1136,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2759,9 +2758,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2828,7 +2824,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -8983,17 +8978,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - AbstractInstruction *jumpEqual; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt vmOwnerLockAddress; - sqInt vmOwnerLockAddressReg; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -9015,49 +8999,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 8 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - goto l8; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - l8: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); @@ -26926,46 +26867,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogX64Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - AbstractInstruction *jumpEqual; - sqInt vmOwnerLockAddressReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogX64Compiler>>#genMemCopy:to:constantSize: */ diff --git a/src/spur64.cog.lowcode/cointerp.c b/src/spur64.cog.lowcode/cointerp.c index c145f2026c..91b8a6c919 100644 --- a/src/spur64.cog.lowcode/cointerp.c +++ b/src/spur64.cog.lowcode/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1915,7 +1915,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1927,6 +1926,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2049,7 +2049,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2719,7 +2719,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -40734,7 +40734,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -43658,6 +43658,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -43679,6 +43681,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -78866,15 +78870,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -81366,7 +81362,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l10; } /* begin numSlotsOf: */ @@ -81396,7 +81392,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -81948,7 +81944,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur64.cog.lowcode/cointerp.h b/src/spur64.cog.lowcode/cointerp.h index 0e4e4265fd..9067f6a177 100644 --- a/src/spur64.cog.lowcode/cointerp.h +++ b/src/spur64.cog.lowcode/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3328 uuid: a1c7c55f-8829-4fcc-9a66-55ba7d1a8cef + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ diff --git a/src/spur64.cog.lowcode/gcc3x-cointerp.c b/src/spur64.cog.lowcode/gcc3x-cointerp.c index dc1f8ca1e6..5b097d5bd2 100644 --- a/src/spur64.cog.lowcode/gcc3x-cointerp.c +++ b/src/spur64.cog.lowcode/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1918,7 +1918,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1930,6 +1929,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2052,7 +2052,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2722,7 +2722,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -40743,7 +40743,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -43667,6 +43667,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -43688,6 +43690,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -78875,15 +78879,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -81375,7 +81371,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l10; } /* begin numSlotsOf: */ @@ -81405,7 +81401,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -81957,7 +81953,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur64.cog/cogit.h b/src/spur64.cog/cogit.h index 8f9fe1eace..cc263ac258 100644 --- a/src/spur64.cog/cogit.h +++ b/src/spur64.cog/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ @@ -97,9 +97,6 @@ extern usqIntptr_t (*ceGetFP)(void); extern usqIntptr_t (*ceGetSP)(void); extern void (*ceInvokeInterpret)(void); extern sqInt ceReturnToInterpreterTrampoline; -#if COGMTVM -extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; @@ -125,7 +122,6 @@ extern int traceFlags ; #define recordOverflowTrace() (traceFlags & 32) #define recordPrimTrace() (traceFlags & 8) #define recordSendTrace() (traceFlags & 2) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define numRegArgs() 2 #define fullBlockEntryOffset() cbEntryOffset #define fullBlockNoContextSwitchEntryOffset() cbNoSwitchEntryOffset diff --git a/src/spur64.cog/cogitARMv8.c b/src/spur64.cog/cogitARMv8.c index d62e0306e7..dadafbd642 100644 --- a/src/spur64.cog/cogitARMv8.c +++ b/src/spur64.cog/cogitARMv8.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -145,7 +145,6 @@ char *__cogitBuildInfo = __buildInfo; #define Extra0Reg 19 #define Extra1Reg 20 #define Extra2Reg 21 -#define Extra8Reg 27 #define Fill32 4 #define FirstAnnotation 64 #define FirstJump 12 @@ -323,7 +322,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (69 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (69 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -2674,9 +2673,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2688,14 +2684,12 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define dataCacheFlushRequired(ign) dataCacheFlushRequired #define dataCacheLineLength(ign) dataCacheLineLength #define flushDCacheFromto(me,startAddress,endAddress) ceFlushDCache(startAddress,endAddress) -#define hasAtomicInstructions(ign) hasAtomicInstructions #define inlineCacheValueForSelectorin(backEnd,selector,aCogMethod) indexForSelectorin(selector,aCogMethod) #define instructionCacheFlushRequired(ign) instructionCacheFlushRequired #define instructionCacheLineLength(ign) instructionCacheLineLength #define roundUpToMethodAlignment(ignored,numBytes) (((numBytes) + 15) & -16) #define setDataCacheFlushRequired(ign,b) dataCacheFlushRequired = b #define setDataCacheLineLength(ign,n) dataCacheLineLength = n -#define setHasAtomicInstructions(ign,b) hasAtomicInstructions = b #define setInstructionCacheFlushRequired(ign,b) instructionCacheFlushRequired = b #define setInstructionCacheLineLength(ign,n) instructionCacheLineLength = n #define cPICNumCases stackCheckOffset @@ -2755,7 +2749,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -4437,9 +4430,6 @@ detectFeaturesOnLinux(AbstractInstruction * self_in_detectFeaturesOnLinux) if ((instructionCacheLineLength(self_in_detectFeaturesOnLinux)) == 0) { setInstructionCacheLineLength(self_in_detectFeaturesOnLinux, 64); } -# if COGMTVM - setHasAtomicInstructions(self_in_detectFeaturesOnLinux, (((getauxval(AT_HWCAP)) & HWCAP_ATOMICS) != 0)); -# endif } #endif /* __linux__ */ @@ -4456,7 +4446,6 @@ detectFeaturesOnRawMachine(AbstractInstruction * self_in_detectFeaturesOnRawMach sqInt ctrEL0; sqInt fixupSize; usqIntptr_t (*getFeatureReg)(void); - sqInt idISAR0; sqInt opcodeSize; usqInt startAddress; @@ -4524,37 +4513,6 @@ detectFeaturesOnRawMachine(AbstractInstruction * self_in_detectFeaturesOnRawMach genoperand(MRS_ID_AA64ISAR0_EL1, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); -# if COGMTVM - /* begin resetMethodZoneBase: */ - methodZoneBase = startAddress; - /* begin ensureExecutableCodeZoneWithin: */ - -# if !DUAL_MAPPED_CODE_ZONE - /* begin makeCodeZoneExecutable */ -# if __APPLE__ && __MACH__ - pthread_jit_write_protect_np(1); - PJWPNSet = __LINE__; - if (!PJWPNState) { - PJWPNChange = __LINE__; - PJWPNState = 1; - } -# endif // __APPLE__ && __MACH__ -# endif // !DUAL_MAPPED_CODE_ZONE - idISAR0 = getFeatureReg(); - setHasAtomicInstructions(self_in_detectFeaturesOnRawMachine, ((((usqInt)(idISAR0)) >> 20) & 15) == 2); - /* begin ensureWritableCodeZone */ -# if !DUAL_MAPPED_CODE_ZONE - /* begin makeCodeZoneWritable */ -# if __APPLE__ && __MACH__ - pthread_jit_write_protect_np(0); - PJWPNClear = __LINE__; - if (PJWPNState) { - PJWPNChange = __LINE__; - PJWPNState = 0; - } -# endif // __APPLE__ && __MACH__ -# endif // !DUAL_MAPPED_CODE_ZONE -# endif // COGMTVM } #endif /* !__APPLE__ && !__linux__ */ @@ -13290,30 +13248,13 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - AbstractInstruction *anInstruction3; - AbstractInstruction *anInstruction4; - AbstractInstruction *anInstruction5; - AbstractInstruction *br; sqInt fixupSize; sqInt fixupSize1; - sqInt fixupSize2; - AbstractInstruction *ldaxr; - sqInt lockValueReg; sqInt numberOfAbstractOpcodes; sqInt numberOfAbstractOpcodes1; - sqInt numberOfAbstractOpcodes2; sqInt opcodeSize; sqInt opcodeSize1; - sqInt opcodeSize2; - sqInt reg; usqInt startAddress1; - usqInt startAddress2; - sqInt statusReg; - sqInt vmOwnerLockAddress; - sqInt vmOwnerLockAddressReg; initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, @@ -13336,10 +13277,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) # if __APPLE__ /* begin detectFeaturesOnMacOS */ -# if COGMTVM - setHasAtomicInstructions(((AbstractInstruction *) backEnd), 1); -# endif -# else // __APPLE__ +# else # if __linux__ detectFeaturesOnLinux(((AbstractInstruction *) backEnd)); # else @@ -13399,87 +13337,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) error("cache flushing method unknown for this platform"); # endif } - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 14 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - if (usesOutOfLineLiteral(anInstruction)) { - (anInstruction->dependent = locateLiteralsize(1, BytesPerOop)); - } - genoperand(RetN, 0); - goto l7; - } - - /* Holds the value of lock if unlocked (zero), receives the existing value of the lock */ - lockValueReg = CArg1Reg; - vmOwnerLockAddressReg = CArg2Reg; - if (hasAtomicInstructions(((AbstractInstruction *) backEnd))) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, lockValueReg); - if (usesOutOfLineLiteral(anInstruction1)) { - (anInstruction1->dependent = locateLiteralsize(0, BytesPerOop)); - } - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - if (usesOutOfLineLiteral(anInstruction2)) { - (anInstruction2->dependent = locateLiteralsize(vmOwnerLockAddress, BytesPerOop)); - } - genoperandoperandoperand(CASAL, lockValueReg, CArg0Reg, vmOwnerLockAddressReg); - br = genoperandoperand(CBNZ, 0, lockValueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction3 = genoperandoperand(MoveCqR, 1, ABIResultReg); - if (usesOutOfLineLiteral(anInstruction3)) { - (anInstruction3->dependent = locateLiteralsize(1, BytesPerOop)); - } - genoperand(RetN, 0); - jmpTarget(br, (assert(!((ABIResultReg == SPReg))), - genoperandoperand(CmpRR, ABIResultReg, lockValueReg))); - genoperandoperand(CSET, ABIResultReg, EQ); - genoperand(RetN, 0); - goto l7; - } - /* begin checkQuickConstant:forInstruction: */ - anInstruction4 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - if (usesOutOfLineLiteral(anInstruction4)) { - (anInstruction4->dependent = locateLiteralsize(vmOwnerLockAddress, BytesPerOop)); - } - /* begin MoveCq:R: */ - reg = (statusReg = CArg3Reg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction5 = genoperandoperand(MoveCqR, 0, reg); - if (usesOutOfLineLiteral(anInstruction5)) { - (anInstruction5->dependent = locateLiteralsize(0, BytesPerOop)); - } - ldaxr = genoperandoperand(LDAXR, lockValueReg, vmOwnerLockAddressReg); - br = genoperandoperand(CBNZ, 0, lockValueReg); - genoperandoperandoperand(STLXR, CArg0Reg, vmOwnerLockAddressReg, statusReg); - genoperandoperand(CBNZ, ((usqInt)ldaxr), statusReg); - genoperand(RetN, 0); - jmpTarget(br, gen(CLREX)); - assert(!((ABIResultReg == SPReg))); - genoperandoperand(CmpRR, ABIResultReg, lockValueReg); - genoperandoperand(CSET, ABIResultReg, EQ); - genoperand(RetN, 0); - l7: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur64.cog/cogitX64SysV.c b/src/spur64.cog/cogitX64SysV.c index 4ccb00f768..49a04f3249 100644 --- a/src/spur64.cog/cogitX64SysV.c +++ b/src/spur64.cog/cogitX64SysV.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -298,7 +298,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (67 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (67 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -1030,7 +1030,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2602,9 +2601,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2671,7 +2667,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -8186,17 +8181,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - AbstractInstruction *jumpEqual; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt vmOwnerLockAddress; - sqInt vmOwnerLockAddressReg; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -8216,49 +8200,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 8 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - goto l8; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - l8: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); @@ -24758,46 +24699,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogX64Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - AbstractInstruction *jumpEqual; - sqInt vmOwnerLockAddressReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogX64Compiler>>#genMemCopy:to:constantSize: */ diff --git a/src/spur64.cog/cogitX64WIN64.c b/src/spur64.cog/cogitX64WIN64.c index 7a630a0aef..dfcf5cef5f 100644 --- a/src/spur64.cog/cogitX64WIN64.c +++ b/src/spur64.cog/cogitX64WIN64.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -298,7 +298,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (67 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (67 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -1030,7 +1030,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2602,9 +2601,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2671,7 +2667,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -8204,17 +8199,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - AbstractInstruction *jumpEqual; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt vmOwnerLockAddress; - sqInt vmOwnerLockAddressReg; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -8234,49 +8218,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 8 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - goto l8; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - l8: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); @@ -24776,46 +24717,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogX64Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - AbstractInstruction *jumpEqual; - sqInt vmOwnerLockAddressReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogX64Compiler>>#genMemCopy:to:constantSize: */ diff --git a/src/spur64.cog/cointerp.c b/src/spur64.cog/cointerp.c index abcf4be521..ba706e855f 100644 --- a/src/spur64.cog/cointerp.c +++ b/src/spur64.cog/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1891,7 +1891,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1903,6 +1902,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2695,7 +2695,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -20466,7 +20466,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -21080,7 +21080,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -23990,6 +23990,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -24011,6 +24013,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -33097,7 +33101,7 @@ primitiveInvokeObjectAsMethod(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt i; sqInt lookupClassTag; - usqInt runArgs; + sqInt runArgs; sqInt runReceiver; char *sp; char *sp1; @@ -55240,8 +55244,8 @@ outOfPlaceBecomeandcopyHashFlag(sqInt obj1, sqInt obj2, sqInt copyHashFlag) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt classIndex; sqInt classIndex1; - sqInt clone1; - sqInt clone2; + usqInt clone1; + usqInt clone2; sqInt format; sqInt format1; sqInt hash; @@ -59110,15 +59114,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -61610,7 +61606,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l10; } /* begin numSlotsOf: */ @@ -61640,7 +61636,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -62192,7 +62188,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur64.cog/cointerp.h b/src/spur64.cog/cointerp.h index 63f736bf13..147f430cc6 100644 --- a/src/spur64.cog/cointerp.h +++ b/src/spur64.cog/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3328 uuid: a1c7c55f-8829-4fcc-9a66-55ba7d1a8cef + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ diff --git a/src/spur64.cog/cointerpmt.c b/src/spur64.cog/cointerpmt.c index c75719439e..7b3933252a 100644 --- a/src/spur64.cog/cointerpmt.c +++ b/src/spur64.cog/cointerpmt.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreterMT VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreterMT VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -34,6 +34,7 @@ char *__interpBuildInfo = __buildInfo; #include "cointerpmt.h" #include "cogit.h" #include "sqAtomicOps.h" +#include /* StackInterpreter class>>preambleCCode */ @@ -144,6 +145,7 @@ warningat(const char *s, int l) { /* ditto with line number. */ #define DisownFlagsShift 7 #define DisownVMForFFICall 16 #define DisownVMForProcessorRelinquish 64 +#define DisownVMForThreading 32 #define EncounteredUnknownBytecode -6 #define EndOfRun 0x101 #define ExcessSignalsIndex 2 @@ -412,6 +414,7 @@ typedef struct { sqInt awolProcIndex; sqInt awolProcLength; sqInt awolProcesses[4]; + jmp_buf reenterThreadSchedulingLoop; } CogVMThread; @@ -461,6 +464,7 @@ static sqInt NoDbgRegParms startThreadForThreadInfo(CogVMThread *vmThread); static sqInt startThreadSubsystem(void); static void NoDbgRegParms startVMThread(CogVMThread *vmThread); static sqInt NoDbgRegParms threadIndexisCompatibleWith(sqInt aThreadIndex, sqInt processThreadId); +extern sqInt tryLockVMOwnerTo(sqInt threadIndex); static CogVMThread * unusedThreadInfo(void); static sqInt vmIsOwned(void); extern usqInt vmOwnerAddress(void); @@ -1850,7 +1854,7 @@ static struct foo { #else # define _iss static #endif -_iss sqInt vmOwner; +_iss volatile atomic_int vmOwner; _iss char * stackLimit; _iss char * stackPointer; _iss char * framePointer; @@ -1918,7 +1922,7 @@ _iss sqInt profileMethod; _iss sqInt profileSemaphore; _iss CogVMThread * disowningVMThread; _iss sqInt mobileStart; -_iss sqInt processHasThreadId; +_iss sqInt processHasThreadAffinity; _iss sqInt becomeEffectsFlags; _iss sqInt growHeadroom; _iss sqInt tenureThreshold; @@ -1935,12 +1939,12 @@ _iss usqInt freeOldSpaceStart; _iss sqInt extraRootCount; _iss sqInt gcPhaseInProgress; _iss sqInt invalidObjStackPage; -_iss sqInt maxWaitingPriority; _iss sqInt metaAccessorDepth; _iss usqInt objectAfterLastMobileObject; _iss sqInt previousRememberedSetSize; _iss sqInt tempOop2; _iss sqInt cogCompiledCodeCompactionCalledFor; +_iss sqInt maxWaitingPriority; _iss sqInt pendingFinalizationSignals; _iss sqInt validatedIntegerClassFlags; _iss usqInt firstMobileObject; @@ -1975,7 +1979,6 @@ _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; _iss sqInt foreignCallbackProcessSlot; _iss sqInt imageHeaderFlags; -_iss usqInt lowSpaceThreshold; _iss sqInt numThreadsIncrement; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1990,6 +1993,7 @@ _iss sqInt foreignCallbackPriority; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2078,7 +2082,6 @@ _iss SpurNewSpaceSpace futureSpace; _iss SpurNewSpaceSpace eden; _iss float heapGrowthToSizeGCRatio; _iss sqOSThread vmOSThread; -_iss jmp_buf reenterThreadSchedulingLoop; _iss double tenuringProportion; #undef _iss #if SQ_USE_GLOBAL_STRUCT @@ -2116,7 +2119,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2788,7 +2791,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2830,7 +2833,6 @@ volatile int sendTrace; #define assertProcessorStackPointersBelongToCurrentThread(ignored) 0 #define assertValidNewMethodPropertyFlags() 0 #define enterSmalltalkExecutive() enterSmalltalkExecutiveImplementation() -#define getMaxWaitingPriority() GIV(maxWaitingPriority) #define threadSchedulingLoop(vmThread) threadSchedulingLoopImplementation(vmThread) #define pageIndexForstackBasePlus1bytesPerPage(pointer,stkBasePlus1,pageByteSize) (((char *)(pointer) - (stkBasePlus1)) / (pageByteSize)) #define startOfMemory() heapBase @@ -6189,7 +6191,7 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G l741: /* end classAtIndex: */; GIV(traceLog)[GIV(traceLogIndex)] = classOrInteger; GIV(traceLog)[GIV(traceLogIndex) + 1] = GIV(messageSelector); - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForSelectorstartClass(GIV(messageSelector), classAtIndex(lkupClassTag)); @@ -7362,7 +7364,7 @@ GIV(bytecodeSetSelector) = ((((sqLong) methodHeader11)) < 0 /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (numCopied > 0) { @@ -12598,7 +12600,7 @@ currentBytecode = (byteAtPointer(localIP)) + GIV(bytecodeSetSelector); /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (receiverIsOnStack) { @@ -12716,7 +12718,7 @@ currentBytecode = (byteAtPointer(localIP)) + GIV(bytecodeSetSelector); /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (numCopied > 0) { @@ -13025,8 +13027,7 @@ currentVMThread(void) sqInt index; /* begin vmThreadAt: */ - sqLowLevelMFence(); - index = GIV(vmOwner); + index = atomic_load((&GIV(vmOwner))); assert(((index >= 0) && (index <= GIV(numThreads)))); return (index > 0 ? GIV(threads)[index] @@ -13047,8 +13048,7 @@ getVMOSThread(void) static sqInt getVMOwner(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner); + return atomic_load((&GIV(vmOwner))); } @@ -13071,6 +13071,9 @@ growThreadInfosToAtLeast(sqInt index) newThreads = realloc(GIV(threads), (newNumThreads + 1) * sizeof(CogVMThread *)); if (!((newThreads != null) && (populatefromto(newThreads, GIV(numThreads) + 1, newNumThreads)))) { + + /* TODO: This cannot free 'newThreads', as that's going to mean 'threads' is freed as well. */ + abort(); free(newThreads); GIV(memoryIsScarce) = 1; return 0; @@ -13157,7 +13160,7 @@ startThreadForThreadInfo(CogVMThread *vmThread) { DECL_MAYBE_SQ_GLOBAL_STRUCT assert(((vmThread->state)) == null); (vmThread->state = CTMInitializing); - if ((ioNewOSThread(startVMThread, vmThread)) == 0) { + if ((ioNewOSThread(((void (*)(void*)) startVMThread), vmThread)) == 0) { ioTransferTimeslice(); return 1; } @@ -13182,11 +13185,13 @@ startThreadSubsystem(void) if (!(growThreadInfosToAtLeast(GIV(numThreadsIncrement) * 2))) { error("no memory to start thread system"); } - vmThread = GIV(threads)[(GIV(vmOwner) = 1)]; + atomic_store((&GIV(vmOwner)), 1); + vmThread = GIV(threads)[atomic_load((&GIV(vmOwner)))]; (vmThread->state = CTMInitializing); /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -13203,8 +13208,9 @@ static void NoDbgRegParms startVMThread(CogVMThread *vmThread) { /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -13220,9 +13226,23 @@ static sqInt NoDbgRegParms threadIndexisCompatibleWith(sqInt aThreadIndex, sqInt processThreadId) { assert(aThreadIndex > 0); - return (processThreadId >= 0 + return (processThreadId == 0) + || ((processThreadId >= 0 ? aThreadIndex == processThreadId - : aThreadIndex != (-processThreadId)); + : aThreadIndex != (-processThreadId))); +} + + /* CogThreadManager>>#tryLockVMOwnerTo: */ +sqInt +tryLockVMOwnerTo(sqInt threadIndex) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + int expected; + + assert(!((threadIndex == 0))); + /* begin doTryLockVMOwnerTo: */ + expected = 0; + return (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), threadIndex)) + || (expected == threadIndex); } @@ -13259,8 +13279,7 @@ unusedThreadInfo(void) static sqInt vmIsOwned(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner) > 0; + return (atomic_load((&GIV(vmOwner)))) != 0; } @@ -13270,6 +13289,7 @@ vmIsOwned(void) usqInt vmOwnerAddress(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT + error("Deprecated! Replaced by proper atomic functions"); return ((usqInt)((&GIV(vmOwner)))); } @@ -13280,12 +13300,15 @@ vmOwnerAddress(void) static sqInt NoDbgRegParms vmOwnerIsCompatibleWith(sqInt processThreadId) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); + sqInt aThreadIndex; + /* begin threadIndex:isCompatibleWith: */ - assert(GIV(vmOwner) > 0); - return (processThreadId >= 0 - ? GIV(vmOwner) == processThreadId - : GIV(vmOwner) != (-processThreadId)); + aThreadIndex = atomic_load((&GIV(vmOwner))); + assert(aThreadIndex > 0); + return (processThreadId == 0) + || ((processThreadId >= 0 + ? aThreadIndex == processThreadId + : aThreadIndex != (-processThreadId))); } @@ -13295,8 +13318,7 @@ vmOwnerIsCompatibleWith(sqInt processThreadId) static sqInt NoDbgRegParms vmOwnerIs(sqInt index) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner) == index; + return (atomic_load((&GIV(vmOwner)))) == index; } /* CogThreadManager>>#vmThreadAt: */ @@ -13323,16 +13345,23 @@ wakeVMThreadFor(sqInt index) assert((vmIsOwned()) && (!(vmOwnerIs(index)))); assert(((index >= 1) && (index <= GIV(numThreads)))); - /* begin setVMOwner: */ - GIV(vmOwner) = index; - sqLowLevelMFence(); + + /* Instead of going through a #disownVM: call, directly set the new VM owner. + This has the advantage of avoiding a race for the different threads to become the new + VM owner. + In Simulation, this means we need to simulate a thread-switch. */ vmThread = GIV(threads)[index]; + /* begin setVMOwner: */ + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != index)); + atomic_store((&GIV(vmOwner)), index); if (((vmThread->state)) == null) { startThreadForThreadInfo(vmThread); } else { - assert((((vmThread->state)) == CTMWantingOwnership) - || (((vmThread->state)) == CTMAssignableOrInVM)); + assert(((((vmThread->state)) == CTMWantingOwnership) + || (((vmThread->state)) == CTMAssignableOrInVM)) + || (((vmThread->state)) == CTMInitializing)); ioSignalOSSemaphore((&((vmThread->osSemaphore)))); } ioTransferTimeslice(); @@ -13354,7 +13383,7 @@ willingVMThread(void) threadWantingVM = (threadWilling = null); for (i = 1; i <= GIV(numThreads); i += 1) { - if (!(vmOwnerIs(i))) { + if (!((atomic_load((&GIV(vmOwner)))) == i)) { thread = GIV(threads)[i]; if (((thread->state)) == CTMWantingOwnership) { if ((threadWantingVM == null) @@ -15845,7 +15874,7 @@ ceTraceBlockActivation(void) selector = ((mframeHomeMethod(GIV(framePointer)))->methodObject); GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockActivation; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForreceiverisBlockfirstTemporary(((mframeHomeMethod(GIV(framePointer)))->methodObject), ((((usqInt)(longAt(GIV(framePointer) + FoxMethod)))) < (startOfMemory()) @@ -15881,7 +15910,7 @@ ceTraceLinkedSend(sqInt theReceiver) selector = (cogMethod->selector); GIV(traceLog)[GIV(traceLogIndex)] = classOrInteger; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForreceiverisBlockfirstTemporary((cogMethod->methodObject), theReceiver, 0, null); @@ -16430,7 +16459,7 @@ commenceCogCompiledCodeCompaction(void) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceCodeCompaction; GIV(traceLog)[GIV(traceLogIndex) + 1] = TraceCodeCompaction; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (recordPrimTrace()) { @@ -20312,7 +20341,7 @@ preGCAction(sqInt gcModeArg) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = traceType; GIV(traceLog)[GIV(traceLogIndex) + 1] = traceType; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (recordPrimTrace()) { @@ -21419,7 +21448,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); - GIV(processHasThreadId) = ((headerFlags & 4) != 0); + GIV(processHasThreadAffinity) = ((headerFlags & 4) != 0); GIV(flagInterpretedMethods) = ((headerFlags & 8) != 0); /* was: noThreadingOfGUIThread := headerFlags anyMask: 32. a broken idea */ @@ -21436,9 +21465,9 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea /* i.e. has it not been set on the command line? */ upscaleDisplayIfHighDPI = (!(headerFlags & 0x400)); } - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { /* begin print: */ - fprintf(GIV(transcript), "warning, processHasThreadId flag is unset; cannot function as a threaded VM if so."); + fprintf(GIV(transcript), "warning, processHasThreadAffinity flag is unset; cannot function as a threaded VM if so."); cr(); } /* begin getWord32FromFile:swap: */ @@ -22996,7 +23025,7 @@ cedeToHigherPriorityThreads(void) sqInt objOop; sqInt objOop1; sqInt oop; - sqInt ownerIndex; + sqInt processAffinity; char *sp; char *sp1; char *theFP; @@ -23014,28 +23043,19 @@ cedeToHigherPriorityThreads(void) assert((((oop) & 7) == 1)); activePriority = (oop >> 3); /* begin ownerIndexOfThreadId: */ - threadId = (GIV(processHasThreadId) + threadId = (GIV(processHasThreadAffinity) ? longAt((activeProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)); - ownerIndex = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + processAffinity = ((((threadId) & 7) == 1) + ? (((threadId >> 3))) >> ThreadIdShift : 0); - if (ownerIndex == 0) { - /* begin currentVMThread */ - sqLowLevelMFence(); - index = GIV(vmOwner); - assert(((index >= 0) && (index <= GIV(numThreads)))); - activeThread = (index > 0 - ? GIV(threads)[index] - : 0); - } - else { - /* begin vmThreadAt: */ - assert(((ownerIndex >= 0) && (ownerIndex <= GIV(numThreads)))); - activeThread = (ownerIndex > 0 - ? GIV(threads)[ownerIndex] - : 0); - } + /* begin currentVMThread */ + index = atomic_load((&GIV(vmOwner))); + assert(((index >= 0) && (index <= GIV(numThreads)))); + activeThread = (index > 0 + ? GIV(threads)[index] + : 0); + assert(threadIndexisCompatibleWith((activeThread->index), processAffinity)); (activeThread->priority = activePriority); /* begin highestPriorityThreadIfHigherThan:expectedMax: */ @@ -23069,11 +23089,11 @@ cedeToHigherPriorityThreads(void) } if (highest == null) { vmThread = null; - goto l6; + goto l5; } if (((highest->priority)) <= activePriority) { vmThread = null; - goto l6; + goto l5; } /* begin setMaxWaitingPriorityTo: */ minPriority = (nextHighest == null @@ -23081,7 +23101,7 @@ cedeToHigherPriorityThreads(void) : (nextHighest->priority)); GIV(maxWaitingPriority) = minPriority; vmThread = highest; - l6: /* end highestPriorityThreadIfHigherThan:expectedMax: */; + l5: /* end highestPriorityThreadIfHigherThan:expectedMax: */; if ((vmThread == null) || (vmThread == activeThread)) { @@ -23108,10 +23128,10 @@ cedeToHigherPriorityThreads(void) : (byteAt((theFP + FoxIFrameFlags) + 2)) != 0)) { assert(isContext(frameContext(theFP))); activeContext = longAt(theFP + FoxThisContext); - goto l12; + goto l10; } activeContext = marryFrameSP(theFP, theSP); - l12: /* end ensureFrameIsMarried:SP: */; + l10: /* end ensureFrameIsMarried:SP: */; /* begin storePointer:ofObject:withValue: */ assert(!(isForwarded(activeProc))); if ((assert(isNonImmediate(activeProc)), @@ -23185,7 +23205,7 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertCStackWellAligned(); /* restore the stackLimit if it has been smashed. */ @@ -23314,7 +23334,7 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) /* Check whether the VM is unowned and needs to set a thread running to try and own it. - Do not attempt this if the image doesn't have a threadId inst var in + Do not attempt this if the image doesn't have a threadAffinity inst var in Process; the VM can't thread these images. */ @@ -23322,11 +23342,13 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) static void checkVMOwnershipFromHeartbeat(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT + int expected; + int expected1; CogVMThread *vmThread; sqLowLevelMFence(); - if (GIV(processHasThreadId) - && (vmOwnerIs(0))) { + if (GIV(processHasThreadAffinity) + && ((atomic_load((&GIV(vmOwner)))) == 0)) { /* begin ensureRunningVMThread: */ vmThread = willingVMThread(); if (!(vmThread == null)) { @@ -23336,7 +23358,13 @@ checkVMOwnershipFromHeartbeat(void) && (((vmThread->state)) != CTMWantingOwnership)) { goto l1; } - if (!(tryLockVMOwnerTo((vmThread->index)))) { + assert(((((vmThread->state)) == CTMAssignableOrInVM) + || (((vmThread->state)) == CTMInitializing)) + || (((vmThread->state)) == CTMWantingOwnership)); + if (!((assert(!((((vmThread->index)) == 0))), + (expected = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), (vmThread->index))) + || (expected == ((vmThread->index)))))) { /* someone beat us to it... */ goto l1; @@ -23354,11 +23382,15 @@ checkVMOwnershipFromHeartbeat(void) } vmThread = unusedThreadInfo(); if (!(vmThread == null)) { - if (tryLockVMOwnerTo((vmThread->index))) { + if ((assert(!((((vmThread->index)) == 0))), + (expected1 = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected1), (vmThread->index))) + || (expected1 == ((vmThread->index))))) { if (!(startThreadForThreadInfo(vmThread))) { /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); } } } @@ -23434,10 +23466,10 @@ disownVM(sqInt flags) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceDisownVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ((((usqInt)flags << 3) | 1)); - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { if (willNotThreadWarnCount < 10) { /* begin print: */ fprintf(GIV(transcript), "warning: VM parameter 48 indicates Process doesn't have threadId; VM will not thread"); @@ -23446,8 +23478,7 @@ disownVM(sqInt flags) } } /* begin currentVMThread */ - sqLowLevelMFence(); - index = GIV(vmOwner); + index = atomic_load((&GIV(vmOwner))); assert(((index >= 0) && (index <= GIV(numThreads)))); vmThread = (index > 0 ? GIV(threads)[index] @@ -23469,17 +23500,14 @@ disownVM(sqInt flags) GIV(relinquishing) = 1; sqLowLevelMFence(); } - disownCount += 1; - /* self cr; cr; print: 'disownVM Csp: '; printHex: vmThread cStackPointer; cr. - (0 to: 16 by: 4) do: - [:offset| - self print: ' *(esp+'; printNum: offset; print: ': '; printHex: (stackPages longAt: cogit processor sp + offset); cr]. - cogit processor printIntegerRegistersOn: Transcript. */ - /* OwnVMForeignThreadFlag indicates lowest-level of entry by a foreign - thread. If that's where we are then release the vmThread. Otherwise - indicate the vmThread is off doing something outside of the VM. */ - GIV(disowningVMThread) = vmThread; + /* If we're disowning the VM because there's no active process to run, + there's nothing to preempt later, so don't indicate that there's a disowningVMThread that + needs to be restored later. */ + disownCount += 1; + if ((fetchPointerofObject(ActiveProcessIndex, schedulerPointer())) != GIV(nilObj)) { + GIV(disowningVMThread) = vmThread; + } if (((flags & OwnVMForeignThreadFlag) != 0)) { /* I don't think this is quite right. Josh's use case is creating some foreign thread and then registering @@ -23503,8 +23531,9 @@ disownVM(sqInt flags) ? 0 : ProcessUnaffinedOnDisown))) | flags; /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); return result; } @@ -23553,7 +23582,7 @@ enterSmalltalkExecutiveImplementation(void) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertProcessorStackPointersBelongToCurrentThread(); assertCStackWellAligned(); ceCaptureCStackPointers(); @@ -23617,7 +23646,7 @@ getImageHeaderFlags(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT return ((((((((GIV(fullScreenFlag) + ((VMBIGENDIAN ? 0 - : 2))) + ((GIV(processHasThreadId) + : 2))) + ((GIV(processHasThreadAffinity) ? 4 : 0))) + ((GIV(flagInterpretedMethods) ? 8 @@ -23666,11 +23695,11 @@ isBoundProcess(sqInt aProcess) sqInt threadId1; /* begin isBoundThreadId: */ - threadId1 = (GIV(processHasThreadId) + threadId1 = (GIV(processHasThreadAffinity) ? longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)); threadId = ((((threadId1) & 7) == 1) - ? ((usqInt)(((threadId1 >> 3)))) >> ThreadIdShift + ? (((threadId1 >> 3))) >> ThreadIdShift : 0); return ((((threadId) & 7) == 1)) && ((((threadId >> 3)) & 1) == 1); @@ -23719,7 +23748,7 @@ loadInitialContext(void) objOop1 = longAt((objOop4 + BaseHeaderSize) + (((sqInt)((usqInt)(ValueIndex) << (shiftForWord()))))); activeProc = longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(ActiveProcessIndex) << (shiftForWord()))))); assert((ownerIndexOfProcess(activeProc)) == 0); - GIV(activeProcessAffined) = (ownerIndexOfThreadId((GIV(processHasThreadId) + GIV(activeProcessAffined) = (ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? longAt((activeProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)))) != 0; } @@ -23850,7 +23879,7 @@ ownerIndexOfProcess(sqInt aProcess) sqInt threadId; /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -23859,7 +23888,7 @@ ownerIndexOfProcess(sqInt aProcess) threadId = GIV(nilObj); } return ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); } @@ -23868,7 +23897,7 @@ static sqInt NoDbgRegParms ownerIndexOfThreadId(sqInt threadId) { return ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); } @@ -23894,7 +23923,7 @@ ownVMFromUnidentifiedThread(void) if (((threadIndex = ioGetThreadLocalThreadIndex())) != 0) { /* this is a callback from a known thread */ - if (vmOwnerIs(threadIndex)) { + if ((atomic_load((&GIV(vmOwner)))) == threadIndex) { /* the VM has not been disowned */ assert((GIV(disowningVMThread) == null) @@ -23926,8 +23955,9 @@ ownVMFromUnidentifiedThread(void) } if ((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (((sqInt)((usqInt)(GIV(foreignCallbackProcessSlot)) << (shiftForWord())))))) != GIV(nilObj)) break; /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); if (((count += 1)) > 1000) { return -2; } @@ -23940,19 +23970,22 @@ ownVMFromUnidentifiedThread(void) vmThread = unusedThreadInfo(); if (!vmThread) { /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); return -1; } /* begin setVMOwner: */ indexOrZero = (vmThread->index); - GIV(vmOwner) = indexOrZero; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != indexOrZero)); + atomic_store((&GIV(vmOwner)), indexOrZero); (vmThread->state = CTMWantingOwnership); (vmThread->priority = GIV(foreignCallbackPriority)); /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -23989,6 +24022,8 @@ ownVM(sqInt threadIndexAndFlags) sqInt aMethodObj; sqInt cFramePointer; sqInt cStackPointer; + int expected; + int expected1; sqInt flags; StackPage *lastUsedPage; StackPage *lruOrFree; @@ -24034,10 +24069,20 @@ ownVM(sqInt threadIndexAndFlags) : 0); assert((((vmThread1->state)) == CTMUnavailable) || (((vmThread1->state)) == CTMWantingOwnership)); - if (!(tryLockVMOwnerTo(threadIndex))) { + if ((assert(!((threadIndex == 0))), + (expected1 = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected1), threadIndex)) + || (expected1 == threadIndex))) { + (vmThread1->state = CTMAssignableOrInVM); + } + else { (vmThread1->state = CTMWantingOwnership); - while (!((vmOwnerIs(threadIndex)) - || (tryLockVMOwnerTo(threadIndex)))) { + while (!(((atomic_load((&GIV(vmOwner)))) == threadIndex) + || ((assert(!((threadIndex == 0))), + /* begin doTryLockVMOwnerTo: */ + (expected = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), threadIndex)) + || (expected == threadIndex))))) { if (!(((vmThread1->priority)) == null)) { /* begin waitingPriorityIsAtLeast: */ minPriority = (vmThread1->priority); @@ -24047,7 +24092,7 @@ ownVM(sqInt threadIndexAndFlags) forceInterruptCheck(); } } - if (!(vmOwnerIs(threadIndex))) { + if (!((atomic_load((&GIV(vmOwner)))) == threadIndex)) { ioWaitOnOSSemaphore((&((vmThread1->osSemaphore)))); } } @@ -24069,7 +24114,7 @@ ownVM(sqInt threadIndexAndFlags) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceOwnVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ConstOne; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } return 0; @@ -24132,7 +24177,7 @@ ownVM(sqInt threadIndexAndFlags) assert(!(isOopForwarded(myProc))); longAtput((myProc + BaseHeaderSize) + (((sqInt)((usqInt)(MyListIndex) << (shiftForWord())))), GIV(nilObj)); if ((((threadIndexAndFlags & ProcessUnaffinedOnDisown) != 0)) - && (!(isBoundThreadId(ownerIndexOfThreadId((GIV(processHasThreadId) + && (!(isBoundThreadId(ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? longAt((myProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj))))))) { /* begin setOwnerIndexOfProcess:to:bind: */ @@ -24246,7 +24291,7 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceOwnVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ConstTwo; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } return threadIndexAndFlags & OwnVMForeignThreadFlag; @@ -24298,7 +24343,7 @@ preemptDisowningThread(void) selector = (((usqInt)((GIV(disowningVMThread)->index)) << 3) | 1); GIV(traceLog)[GIV(traceLogIndex)] = TracePreemptDisowningThread; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } (GIV(disowningVMThread)->cStackPointer = GIV(CStackPointer)); @@ -24370,7 +24415,7 @@ preemptDisowningThread(void) preemptedThread = pushAWOLProcesson(activeProc, GIV(disowningVMThread)); GIV(disowningVMThread) = null; (preemptedThread->priority = quickFetchIntegerofObject(PriorityIndex, activeProc)); - if ((ownerIndexOfThreadId((GIV(processHasThreadId) + if ((ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? (/* begin fetchPointer:ofObject: */ longAt((activeProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord())))))) : /* begin nilObject */ GIV(nilObj)))) == 0) { @@ -24412,7 +24457,7 @@ primitiveProcessBindToThreadId(void) sqInt threadIdSlot; sqInt threadIdSlot1; - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { (GIV(primFailCode) = PrimErrUnsupported); return; } @@ -24435,11 +24480,11 @@ primitiveProcessBindToThreadId(void) return; } /* begin bindProcess:toId: */ - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { ec = PrimErrUnsupported; goto l8; } - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadIdField = longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24451,7 +24496,7 @@ primitiveProcessBindToThreadId(void) /* If aProcess is affined (temporarily bound to) a thread then the operation can only succeed if the newId is the same as that aProcess is affined to, or is zero (is unbinding). */ ownerIndex = ((((threadIdField) & 7) == 1) - ? ((usqInt)(((threadIdField >> 3)))) >> ThreadIdShift + ? (((threadIdField >> 3))) >> ThreadIdShift : 0); if ((((((threadIdField) & 7) == 1) ? ((((threadIdField >> 3)) & ((1U << ThreadIdShift) - 1)) != 0) @@ -24502,7 +24547,7 @@ primitiveProcessBindToThreadId(void) /* begin pop: */ GIV(stackPointer) += GIV(argumentCount) * BytesPerWord; /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24511,7 +24556,7 @@ primitiveProcessBindToThreadId(void) threadId = GIV(nilObj); } id = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); if ((aProcess == (fetchPointerofObject(ActiveProcessIndex, schedulerPointer()))) && (((GIV(activeProcessAffined) = id != 0)) @@ -24527,11 +24572,13 @@ primitiveProcessBindToThreadId(void) } -/* Answer the receiver's current thread Id or nil, where the receiver is a - Process. If the threadId is positive then the receiver is bound to the - thread with that id. - If the threadId is negative then the receiver is excluded from running on - the thread with that id. */ +/* Answer the receiver's current threadAffinity or nil, where the receiver is + a Process. + If the threadAffinity is positive then the receiver is bound to the thread + with that id. + If the threadAffinity is negative then the receiver is excluded from + running on the thread with that id. + */ /* CoInterpreterMT>>#primitiveProcessBoundThreadId */ EXPORT(void) @@ -24543,13 +24590,13 @@ primitiveProcessBoundThreadId(void) char *sp; sqInt threadId; - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { (GIV(primFailCode) = PrimErrUnsupported); return; } aProcess = longAt(GIV(stackPointer)); /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24558,7 +24605,7 @@ primitiveProcessBoundThreadId(void) threadId = GIV(nilObj); } id = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); /* begin methodReturnValue: */ oop = (id == 0 @@ -24630,8 +24677,7 @@ primitiveVMCurrentThreadId(void) char *sp; /* begin methodReturnInteger: */ - sqLowLevelMFence(); - integer = GIV(vmOwner); + integer = atomic_load((&GIV(vmOwner))); assert(!((failed()))); /* begin pop:thenPushInteger: */ longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), (((usqInt)integer << 3) | 1)); @@ -24874,30 +24920,36 @@ printAllStacks(void) static void NoDbgRegParms returnToSchedulingLoopAndReleaseVMOrWakeThreadsource(CogVMThread *vmThread, sqInt source) { DECL_MAYBE_SQ_GLOBAL_STRUCT + CogVMThread *activeThread; + sqInt index; sqInt ownerIndex; sqInt selector; + /* begin currentVMThread */ + index = atomic_load((&GIV(vmOwner))); + assert(((index >= 0) && (index <= GIV(numThreads)))); + activeThread = (index > 0 + ? GIV(threads)[index] + : 0); /* begin recordThreadSwitchTo:source: */ ownerIndex = (vmThread == null ? 0 : (vmThread->index)); if (recordEventTrace()) { /* begin recordTrace:thing:source: */ - selector = (((usqInt)((((sqInt)((usqInt)(ownerIndex) << 16))) + (getVMOwner())) << 3) | 1); + selector = (((usqInt)((((sqInt)((usqInt)(ownerIndex) << 16))) + (atomic_load((&GIV(vmOwner))))) << 3) | 1); GIV(traceLog)[GIV(traceLogIndex)] = TraceThreadSwitch; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (vmThread == null) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + disownVM(DisownVMForThreading); } else { wakeVMThreadFor((vmThread->index)); } - _longjmp(GIV(reenterThreadSchedulingLoop), 1); + _longjmp((activeThread->reenterThreadSchedulingLoop), 1); } @@ -24967,7 +25019,7 @@ sendInvokeCallbackContext(VMCallbackContext *vmCallbackContext) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertCStackWellAligned(); if (recordPrimTrace()) { /* begin fastLogPrim: */ @@ -25181,19 +25233,15 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) sqInt top; sqInt valuePointer; - _setjmp(GIV(reenterThreadSchedulingLoop)); + _setjmp((vmThread->reenterThreadSchedulingLoop)); do { assert(((vmThread->state)) == CTMAssignableOrInVM); if (tryLockVMOwnerTo((vmThread->index))) { + /* Yay, we're the VM owner! */ /* If relinquishing is true, then primitiveRelinquishProcessor has disowned the VM and only a returning call or callback should take ownership in that case. */ - if (GIV(relinquishing)) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); - } - else { + if (!GIV(relinquishing)) { /* begin tryToExecuteSmalltalk: */ assert(vmOwnerIs((vmThread->index))); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -25234,13 +25282,10 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) longAtput((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(ActiveProcessIndex) << (shiftForWord())))), activeProc); } if (activeProc == GIV(nilObj)) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); goto l20; } /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((activeProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -25249,7 +25294,7 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) threadId = GIV(nilObj); } ownerIndex = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); if ((ownerIndex == 0) || (vmOwnerIsCompatibleWith(ownerIndex))) { @@ -25348,13 +25393,12 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G wakeVMThreadFor(ownerIndex); l20: /* end tryToExecuteSmalltalk: */; } + disownVM(DisownVMForThreading); } - if (!(vmOwnerIs((vmThread->index)))) { - /* begin waitForWork: */ - assert(((vmThread->state)) == CTMAssignableOrInVM); - assert(!((vmOwnerIs((vmThread->index))))); - ioWaitOnOSSemaphore((&((vmThread->osSemaphore)))); - } + /* begin waitForWork: */ + (vmThread->state = CTMAssignableOrInVM); + assert(!((vmOwnerIs((vmThread->index))))); + ioWaitOnOSSemaphore((&((vmThread->osSemaphore)))); } while(1); } @@ -25381,9 +25425,9 @@ threadSwitchIfNecessaryfrom(sqInt newProc, sqInt sourceCode) if (GIV(deferThreadSwitch)) { return; } - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((newProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -25392,7 +25436,7 @@ threadSwitchIfNecessaryfrom(sqInt newProc, sqInt sourceCode) threadId = GIV(nilObj); } newProcOwnerIndex = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); if (!(((GIV(activeProcessAffined) = newProcOwnerIndex != 0)) && (!(vmOwnerIsCompatibleWith(newProcOwnerIndex))))) { @@ -25540,7 +25584,7 @@ transferTofrom(sqInt newProc, sqInt sourceCode) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceContextSwitch; GIV(traceLog)[GIV(traceLogIndex) + 1] = oldProc; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (sourceCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (sourceCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } /* begin ensureFrameIsMarried:SP: */ @@ -26694,6 +26738,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -26715,6 +26761,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -61803,15 +61851,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -64303,7 +64343,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l10; } /* begin numSlotsOf: */ @@ -64333,7 +64373,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -64885,7 +64925,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - sqInt node; + usqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -68901,7 +68941,7 @@ handleStackOverflow(void) : TraceIsFromInterpreter); GIV(traceLog)[GIV(traceLogIndex)] = TraceStackOverflow; GIV(traceLog)[GIV(traceLogIndex) + 1] = TraceStackOverflow; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if ((recordPrimTrace()) @@ -82470,7 +82510,7 @@ GIV(totalHeapSizeIncludingBridges)))); GIV(primFailCode) = PrimErrInappropriate; goto l103; } - GIV(processHasThreadId) = ((arg & 1) != 0); + GIV(processHasThreadAffinity) = ((arg & 1) != 0); GIV(flagInterpretedMethods) = ((arg & 2) != 0); /* was: noThreadingOfGUIThread := flags anyMask: 8. a broken idea */ diff --git a/src/spur64.cog/cointerpmt.h b/src/spur64.cog/cointerpmt.h index e9b543014c..1066f0a149 100644 --- a/src/spur64.cog/cointerpmt.h +++ b/src/spur64.cog/cointerpmt.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ @@ -20,6 +20,7 @@ # define NeverInline /*empty*/ #endif +extern sqInt tryLockVMOwnerTo(sqInt threadIndex); extern usqInt vmOwnerAddress(void); extern sqInt accessorDepthForPrimitiveIndex(sqInt primIndex); extern usqInt argumentCountAddress(void); diff --git a/src/spur64.cog/gcc3x-cointerp.c b/src/spur64.cog/gcc3x-cointerp.c index d39bf79e83..6d00377634 100644 --- a/src/spur64.cog/gcc3x-cointerp.c +++ b/src/spur64.cog/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1894,7 +1894,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1906,6 +1905,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2698,7 +2698,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -20475,7 +20475,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -21089,7 +21089,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -23999,6 +23999,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -24020,6 +24022,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -33106,7 +33110,7 @@ primitiveInvokeObjectAsMethod(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt i; sqInt lookupClassTag; - usqInt runArgs; + sqInt runArgs; sqInt runReceiver; char *sp; char *sp1; @@ -55249,8 +55253,8 @@ outOfPlaceBecomeandcopyHashFlag(sqInt obj1, sqInt obj2, sqInt copyHashFlag) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt classIndex; sqInt classIndex1; - sqInt clone1; - sqInt clone2; + usqInt clone1; + usqInt clone2; sqInt format; sqInt format1; sqInt hash; @@ -59119,15 +59123,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -61619,7 +61615,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l10; } /* begin numSlotsOf: */ @@ -61649,7 +61645,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -62201,7 +62197,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur64.cog/gcc3x-cointerpmt.c b/src/spur64.cog/gcc3x-cointerpmt.c index 725db9dcb6..0145aa5d70 100644 --- a/src/spur64.cog/gcc3x-cointerpmt.c +++ b/src/spur64.cog/gcc3x-cointerpmt.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreterMT VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreterMT VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -37,6 +37,7 @@ char *__interpBuildInfo = __buildInfo; #include "cointerpmt.h" #include "cogit.h" #include "sqAtomicOps.h" +#include /* StackInterpreter class>>preambleCCode */ @@ -147,6 +148,7 @@ warningat(const char *s, int l) { /* ditto with line number. */ #define DisownFlagsShift 7 #define DisownVMForFFICall 16 #define DisownVMForProcessorRelinquish 64 +#define DisownVMForThreading 32 #define EncounteredUnknownBytecode -6 #define EndOfRun 0x101 #define ExcessSignalsIndex 2 @@ -415,6 +417,7 @@ typedef struct { sqInt awolProcIndex; sqInt awolProcLength; sqInt awolProcesses[4]; + jmp_buf reenterThreadSchedulingLoop; } CogVMThread; @@ -464,6 +467,7 @@ static sqInt NoDbgRegParms startThreadForThreadInfo(CogVMThread *vmThread); static sqInt startThreadSubsystem(void); static void NoDbgRegParms startVMThread(CogVMThread *vmThread); static sqInt NoDbgRegParms threadIndexisCompatibleWith(sqInt aThreadIndex, sqInt processThreadId); +extern sqInt tryLockVMOwnerTo(sqInt threadIndex); static CogVMThread * unusedThreadInfo(void); static sqInt vmIsOwned(void); extern usqInt vmOwnerAddress(void); @@ -1853,7 +1857,7 @@ static struct foo { #else # define _iss static #endif -_iss sqInt vmOwner; +_iss volatile atomic_int vmOwner; _iss char * stackLimit; _iss char * stackPointer; _iss char * framePointer; @@ -1921,7 +1925,7 @@ _iss sqInt profileMethod; _iss sqInt profileSemaphore; _iss CogVMThread * disowningVMThread; _iss sqInt mobileStart; -_iss sqInt processHasThreadId; +_iss sqInt processHasThreadAffinity; _iss sqInt becomeEffectsFlags; _iss sqInt growHeadroom; _iss sqInt tenureThreshold; @@ -1938,12 +1942,12 @@ _iss usqInt freeOldSpaceStart; _iss sqInt extraRootCount; _iss sqInt gcPhaseInProgress; _iss sqInt invalidObjStackPage; -_iss sqInt maxWaitingPriority; _iss sqInt metaAccessorDepth; _iss usqInt objectAfterLastMobileObject; _iss sqInt previousRememberedSetSize; _iss sqInt tempOop2; _iss sqInt cogCompiledCodeCompactionCalledFor; +_iss sqInt maxWaitingPriority; _iss sqInt pendingFinalizationSignals; _iss sqInt validatedIntegerClassFlags; _iss usqInt firstMobileObject; @@ -1978,7 +1982,6 @@ _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; _iss sqInt foreignCallbackProcessSlot; _iss sqInt imageHeaderFlags; -_iss usqInt lowSpaceThreshold; _iss sqInt numThreadsIncrement; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1993,6 +1996,7 @@ _iss sqInt foreignCallbackPriority; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2081,7 +2085,6 @@ _iss SpurNewSpaceSpace futureSpace; _iss SpurNewSpaceSpace eden; _iss float heapGrowthToSizeGCRatio; _iss sqOSThread vmOSThread; -_iss jmp_buf reenterThreadSchedulingLoop; _iss double tenuringProportion; #undef _iss #if SQ_USE_GLOBAL_STRUCT @@ -2119,7 +2122,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2791,7 +2794,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2833,7 +2836,6 @@ volatile int sendTrace; #define assertProcessorStackPointersBelongToCurrentThread(ignored) 0 #define assertValidNewMethodPropertyFlags() 0 #define enterSmalltalkExecutive() enterSmalltalkExecutiveImplementation() -#define getMaxWaitingPriority() GIV(maxWaitingPriority) #define threadSchedulingLoop(vmThread) threadSchedulingLoopImplementation(vmThread) #define pageIndexForstackBasePlus1bytesPerPage(pointer,stkBasePlus1,pageByteSize) (((char *)(pointer) - (stkBasePlus1)) / (pageByteSize)) #define startOfMemory() heapBase @@ -6198,7 +6200,7 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G l741: /* end classAtIndex: */; GIV(traceLog)[GIV(traceLogIndex)] = classOrInteger; GIV(traceLog)[GIV(traceLogIndex) + 1] = GIV(messageSelector); - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForSelectorstartClass(GIV(messageSelector), classAtIndex(lkupClassTag)); @@ -7371,7 +7373,7 @@ GIV(bytecodeSetSelector) = ((((sqLong) methodHeader11)) < 0 /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (numCopied > 0) { @@ -12607,7 +12609,7 @@ currentBytecode = (byteAtPointer(localIP)) + GIV(bytecodeSetSelector); /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (receiverIsOnStack) { @@ -12725,7 +12727,7 @@ currentBytecode = (byteAtPointer(localIP)) + GIV(bytecodeSetSelector); /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockCreation; GIV(traceLog)[GIV(traceLogIndex) + 1] = newClosure; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromInterpreter + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (numCopied > 0) { @@ -13034,8 +13036,7 @@ currentVMThread(void) sqInt index; /* begin vmThreadAt: */ - sqLowLevelMFence(); - index = GIV(vmOwner); + index = atomic_load((&GIV(vmOwner))); assert(((index >= 0) && (index <= GIV(numThreads)))); return (index > 0 ? GIV(threads)[index] @@ -13056,8 +13057,7 @@ getVMOSThread(void) static sqInt getVMOwner(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner); + return atomic_load((&GIV(vmOwner))); } @@ -13080,6 +13080,9 @@ growThreadInfosToAtLeast(sqInt index) newThreads = realloc(GIV(threads), (newNumThreads + 1) * sizeof(CogVMThread *)); if (!((newThreads != null) && (populatefromto(newThreads, GIV(numThreads) + 1, newNumThreads)))) { + + /* TODO: This cannot free 'newThreads', as that's going to mean 'threads' is freed as well. */ + abort(); free(newThreads); GIV(memoryIsScarce) = 1; return 0; @@ -13166,7 +13169,7 @@ startThreadForThreadInfo(CogVMThread *vmThread) { DECL_MAYBE_SQ_GLOBAL_STRUCT assert(((vmThread->state)) == null); (vmThread->state = CTMInitializing); - if ((ioNewOSThread(startVMThread, vmThread)) == 0) { + if ((ioNewOSThread(((void (*)(void*)) startVMThread), vmThread)) == 0) { ioTransferTimeslice(); return 1; } @@ -13191,11 +13194,13 @@ startThreadSubsystem(void) if (!(growThreadInfosToAtLeast(GIV(numThreadsIncrement) * 2))) { error("no memory to start thread system"); } - vmThread = GIV(threads)[(GIV(vmOwner) = 1)]; + atomic_store((&GIV(vmOwner)), 1); + vmThread = GIV(threads)[atomic_load((&GIV(vmOwner)))]; (vmThread->state = CTMInitializing); /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -13212,8 +13217,9 @@ static void NoDbgRegParms startVMThread(CogVMThread *vmThread) { /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -13229,9 +13235,23 @@ static sqInt NoDbgRegParms threadIndexisCompatibleWith(sqInt aThreadIndex, sqInt processThreadId) { assert(aThreadIndex > 0); - return (processThreadId >= 0 + return (processThreadId == 0) + || ((processThreadId >= 0 ? aThreadIndex == processThreadId - : aThreadIndex != (-processThreadId)); + : aThreadIndex != (-processThreadId))); +} + + /* CogThreadManager>>#tryLockVMOwnerTo: */ +sqInt +tryLockVMOwnerTo(sqInt threadIndex) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + int expected; + + assert(!((threadIndex == 0))); + /* begin doTryLockVMOwnerTo: */ + expected = 0; + return (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), threadIndex)) + || (expected == threadIndex); } @@ -13268,8 +13288,7 @@ unusedThreadInfo(void) static sqInt vmIsOwned(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner) > 0; + return (atomic_load((&GIV(vmOwner)))) != 0; } @@ -13279,6 +13298,7 @@ vmIsOwned(void) usqInt vmOwnerAddress(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT + error("Deprecated! Replaced by proper atomic functions"); return ((usqInt)((&GIV(vmOwner)))); } @@ -13289,12 +13309,15 @@ vmOwnerAddress(void) static sqInt NoDbgRegParms vmOwnerIsCompatibleWith(sqInt processThreadId) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); + sqInt aThreadIndex; + /* begin threadIndex:isCompatibleWith: */ - assert(GIV(vmOwner) > 0); - return (processThreadId >= 0 - ? GIV(vmOwner) == processThreadId - : GIV(vmOwner) != (-processThreadId)); + aThreadIndex = atomic_load((&GIV(vmOwner))); + assert(aThreadIndex > 0); + return (processThreadId == 0) + || ((processThreadId >= 0 + ? aThreadIndex == processThreadId + : aThreadIndex != (-processThreadId))); } @@ -13304,8 +13327,7 @@ vmOwnerIsCompatibleWith(sqInt processThreadId) static sqInt NoDbgRegParms vmOwnerIs(sqInt index) { DECL_MAYBE_SQ_GLOBAL_STRUCT - sqLowLevelMFence(); - return GIV(vmOwner) == index; + return (atomic_load((&GIV(vmOwner)))) == index; } /* CogThreadManager>>#vmThreadAt: */ @@ -13332,16 +13354,23 @@ wakeVMThreadFor(sqInt index) assert((vmIsOwned()) && (!(vmOwnerIs(index)))); assert(((index >= 1) && (index <= GIV(numThreads)))); - /* begin setVMOwner: */ - GIV(vmOwner) = index; - sqLowLevelMFence(); + + /* Instead of going through a #disownVM: call, directly set the new VM owner. + This has the advantage of avoiding a race for the different threads to become the new + VM owner. + In Simulation, this means we need to simulate a thread-switch. */ vmThread = GIV(threads)[index]; + /* begin setVMOwner: */ + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != index)); + atomic_store((&GIV(vmOwner)), index); if (((vmThread->state)) == null) { startThreadForThreadInfo(vmThread); } else { - assert((((vmThread->state)) == CTMWantingOwnership) - || (((vmThread->state)) == CTMAssignableOrInVM)); + assert(((((vmThread->state)) == CTMWantingOwnership) + || (((vmThread->state)) == CTMAssignableOrInVM)) + || (((vmThread->state)) == CTMInitializing)); ioSignalOSSemaphore((&((vmThread->osSemaphore)))); } ioTransferTimeslice(); @@ -13363,7 +13392,7 @@ willingVMThread(void) threadWantingVM = (threadWilling = null); for (i = 1; i <= GIV(numThreads); i += 1) { - if (!(vmOwnerIs(i))) { + if (!((atomic_load((&GIV(vmOwner)))) == i)) { thread = GIV(threads)[i]; if (((thread->state)) == CTMWantingOwnership) { if ((threadWantingVM == null) @@ -15854,7 +15883,7 @@ ceTraceBlockActivation(void) selector = ((mframeHomeMethod(GIV(framePointer)))->methodObject); GIV(traceLog)[GIV(traceLogIndex)] = TraceBlockActivation; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForreceiverisBlockfirstTemporary(((mframeHomeMethod(GIV(framePointer)))->methodObject), ((((usqInt)(longAt(GIV(framePointer) + FoxMethod)))) < (startOfMemory()) @@ -15890,7 +15919,7 @@ ceTraceLinkedSend(sqInt theReceiver) selector = (cogMethod->selector); GIV(traceLog)[GIV(traceLogIndex)] = classOrInteger; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (TraceIsFromMachineCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; if (printOnTrace()) { printActivationNameForreceiverisBlockfirstTemporary((cogMethod->methodObject), theReceiver, 0, null); @@ -16439,7 +16468,7 @@ commenceCogCompiledCodeCompaction(void) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceCodeCompaction; GIV(traceLog)[GIV(traceLogIndex) + 1] = TraceCodeCompaction; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (recordPrimTrace()) { @@ -20321,7 +20350,7 @@ preGCAction(sqInt gcModeArg) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = traceType; GIV(traceLog)[GIV(traceLogIndex) + 1] = traceType; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (recordPrimTrace()) { @@ -21428,7 +21457,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); - GIV(processHasThreadId) = ((headerFlags & 4) != 0); + GIV(processHasThreadAffinity) = ((headerFlags & 4) != 0); GIV(flagInterpretedMethods) = ((headerFlags & 8) != 0); /* was: noThreadingOfGUIThread := headerFlags anyMask: 32. a broken idea */ @@ -21445,9 +21474,9 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea /* i.e. has it not been set on the command line? */ upscaleDisplayIfHighDPI = (!(headerFlags & 0x400)); } - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { /* begin print: */ - fprintf(GIV(transcript), "warning, processHasThreadId flag is unset; cannot function as a threaded VM if so."); + fprintf(GIV(transcript), "warning, processHasThreadAffinity flag is unset; cannot function as a threaded VM if so."); cr(); } /* begin getWord32FromFile:swap: */ @@ -23005,7 +23034,7 @@ cedeToHigherPriorityThreads(void) sqInt objOop; sqInt objOop1; sqInt oop; - sqInt ownerIndex; + sqInt processAffinity; char *sp; char *sp1; char *theFP; @@ -23023,28 +23052,19 @@ cedeToHigherPriorityThreads(void) assert((((oop) & 7) == 1)); activePriority = (oop >> 3); /* begin ownerIndexOfThreadId: */ - threadId = (GIV(processHasThreadId) + threadId = (GIV(processHasThreadAffinity) ? longAt((activeProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)); - ownerIndex = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + processAffinity = ((((threadId) & 7) == 1) + ? (((threadId >> 3))) >> ThreadIdShift : 0); - if (ownerIndex == 0) { - /* begin currentVMThread */ - sqLowLevelMFence(); - index = GIV(vmOwner); - assert(((index >= 0) && (index <= GIV(numThreads)))); - activeThread = (index > 0 - ? GIV(threads)[index] - : 0); - } - else { - /* begin vmThreadAt: */ - assert(((ownerIndex >= 0) && (ownerIndex <= GIV(numThreads)))); - activeThread = (ownerIndex > 0 - ? GIV(threads)[ownerIndex] - : 0); - } + /* begin currentVMThread */ + index = atomic_load((&GIV(vmOwner))); + assert(((index >= 0) && (index <= GIV(numThreads)))); + activeThread = (index > 0 + ? GIV(threads)[index] + : 0); + assert(threadIndexisCompatibleWith((activeThread->index), processAffinity)); (activeThread->priority = activePriority); /* begin highestPriorityThreadIfHigherThan:expectedMax: */ @@ -23078,11 +23098,11 @@ cedeToHigherPriorityThreads(void) } if (highest == null) { vmThread = null; - goto l6; + goto l5; } if (((highest->priority)) <= activePriority) { vmThread = null; - goto l6; + goto l5; } /* begin setMaxWaitingPriorityTo: */ minPriority = (nextHighest == null @@ -23090,7 +23110,7 @@ cedeToHigherPriorityThreads(void) : (nextHighest->priority)); GIV(maxWaitingPriority) = minPriority; vmThread = highest; - l6: /* end highestPriorityThreadIfHigherThan:expectedMax: */; + l5: /* end highestPriorityThreadIfHigherThan:expectedMax: */; if ((vmThread == null) || (vmThread == activeThread)) { @@ -23117,10 +23137,10 @@ cedeToHigherPriorityThreads(void) : (byteAt((theFP + FoxIFrameFlags) + 2)) != 0)) { assert(isContext(frameContext(theFP))); activeContext = longAt(theFP + FoxThisContext); - goto l12; + goto l10; } activeContext = marryFrameSP(theFP, theSP); - l12: /* end ensureFrameIsMarried:SP: */; + l10: /* end ensureFrameIsMarried:SP: */; /* begin storePointer:ofObject:withValue: */ assert(!(isForwarded(activeProc))); if ((assert(isNonImmediate(activeProc)), @@ -23194,7 +23214,7 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertCStackWellAligned(); /* restore the stackLimit if it has been smashed. */ @@ -23323,7 +23343,7 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) /* Check whether the VM is unowned and needs to set a thread running to try and own it. - Do not attempt this if the image doesn't have a threadId inst var in + Do not attempt this if the image doesn't have a threadAffinity inst var in Process; the VM can't thread these images. */ @@ -23331,11 +23351,13 @@ checkForEventsMayContextSwitch(sqInt mayContextSwitch) static void checkVMOwnershipFromHeartbeat(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT + int expected; + int expected1; CogVMThread *vmThread; sqLowLevelMFence(); - if (GIV(processHasThreadId) - && (vmOwnerIs(0))) { + if (GIV(processHasThreadAffinity) + && ((atomic_load((&GIV(vmOwner)))) == 0)) { /* begin ensureRunningVMThread: */ vmThread = willingVMThread(); if (!(vmThread == null)) { @@ -23345,7 +23367,13 @@ checkVMOwnershipFromHeartbeat(void) && (((vmThread->state)) != CTMWantingOwnership)) { goto l1; } - if (!(tryLockVMOwnerTo((vmThread->index)))) { + assert(((((vmThread->state)) == CTMAssignableOrInVM) + || (((vmThread->state)) == CTMInitializing)) + || (((vmThread->state)) == CTMWantingOwnership)); + if (!((assert(!((((vmThread->index)) == 0))), + (expected = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), (vmThread->index))) + || (expected == ((vmThread->index)))))) { /* someone beat us to it... */ goto l1; @@ -23363,11 +23391,15 @@ checkVMOwnershipFromHeartbeat(void) } vmThread = unusedThreadInfo(); if (!(vmThread == null)) { - if (tryLockVMOwnerTo((vmThread->index))) { + if ((assert(!((((vmThread->index)) == 0))), + (expected1 = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected1), (vmThread->index))) + || (expected1 == ((vmThread->index))))) { if (!(startThreadForThreadInfo(vmThread))) { /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); } } } @@ -23443,10 +23475,10 @@ disownVM(sqInt flags) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceDisownVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ((((usqInt)flags << 3) | 1)); - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { if (willNotThreadWarnCount < 10) { /* begin print: */ fprintf(GIV(transcript), "warning: VM parameter 48 indicates Process doesn't have threadId; VM will not thread"); @@ -23455,8 +23487,7 @@ disownVM(sqInt flags) } } /* begin currentVMThread */ - sqLowLevelMFence(); - index = GIV(vmOwner); + index = atomic_load((&GIV(vmOwner))); assert(((index >= 0) && (index <= GIV(numThreads)))); vmThread = (index > 0 ? GIV(threads)[index] @@ -23478,17 +23509,14 @@ disownVM(sqInt flags) GIV(relinquishing) = 1; sqLowLevelMFence(); } - disownCount += 1; - /* self cr; cr; print: 'disownVM Csp: '; printHex: vmThread cStackPointer; cr. - (0 to: 16 by: 4) do: - [:offset| - self print: ' *(esp+'; printNum: offset; print: ': '; printHex: (stackPages longAt: cogit processor sp + offset); cr]. - cogit processor printIntegerRegistersOn: Transcript. */ - /* OwnVMForeignThreadFlag indicates lowest-level of entry by a foreign - thread. If that's where we are then release the vmThread. Otherwise - indicate the vmThread is off doing something outside of the VM. */ - GIV(disowningVMThread) = vmThread; + /* If we're disowning the VM because there's no active process to run, + there's nothing to preempt later, so don't indicate that there's a disowningVMThread that + needs to be restored later. */ + disownCount += 1; + if ((fetchPointerofObject(ActiveProcessIndex, schedulerPointer())) != GIV(nilObj)) { + GIV(disowningVMThread) = vmThread; + } if (((flags & OwnVMForeignThreadFlag) != 0)) { /* I don't think this is quite right. Josh's use case is creating some foreign thread and then registering @@ -23512,8 +23540,9 @@ disownVM(sqInt flags) ? 0 : ProcessUnaffinedOnDisown))) | flags; /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); return result; } @@ -23562,7 +23591,7 @@ enterSmalltalkExecutiveImplementation(void) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertProcessorStackPointersBelongToCurrentThread(); assertCStackWellAligned(); ceCaptureCStackPointers(); @@ -23626,7 +23655,7 @@ getImageHeaderFlags(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT return ((((((((GIV(fullScreenFlag) + ((VMBIGENDIAN ? 0 - : 2))) + ((GIV(processHasThreadId) + : 2))) + ((GIV(processHasThreadAffinity) ? 4 : 0))) + ((GIV(flagInterpretedMethods) ? 8 @@ -23675,11 +23704,11 @@ isBoundProcess(sqInt aProcess) sqInt threadId1; /* begin isBoundThreadId: */ - threadId1 = (GIV(processHasThreadId) + threadId1 = (GIV(processHasThreadAffinity) ? longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)); threadId = ((((threadId1) & 7) == 1) - ? ((usqInt)(((threadId1 >> 3)))) >> ThreadIdShift + ? (((threadId1 >> 3))) >> ThreadIdShift : 0); return ((((threadId) & 7) == 1)) && ((((threadId >> 3)) & 1) == 1); @@ -23728,7 +23757,7 @@ loadInitialContext(void) objOop1 = longAt((objOop4 + BaseHeaderSize) + (((sqInt)((usqInt)(ValueIndex) << (shiftForWord()))))); activeProc = longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(ActiveProcessIndex) << (shiftForWord()))))); assert((ownerIndexOfProcess(activeProc)) == 0); - GIV(activeProcessAffined) = (ownerIndexOfThreadId((GIV(processHasThreadId) + GIV(activeProcessAffined) = (ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? longAt((activeProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj)))) != 0; } @@ -23859,7 +23888,7 @@ ownerIndexOfProcess(sqInt aProcess) sqInt threadId; /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -23868,7 +23897,7 @@ ownerIndexOfProcess(sqInt aProcess) threadId = GIV(nilObj); } return ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); } @@ -23877,7 +23906,7 @@ static sqInt NoDbgRegParms ownerIndexOfThreadId(sqInt threadId) { return ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); } @@ -23903,7 +23932,7 @@ ownVMFromUnidentifiedThread(void) if (((threadIndex = ioGetThreadLocalThreadIndex())) != 0) { /* this is a callback from a known thread */ - if (vmOwnerIs(threadIndex)) { + if ((atomic_load((&GIV(vmOwner)))) == threadIndex) { /* the VM has not been disowned */ assert((GIV(disowningVMThread) == null) @@ -23935,8 +23964,9 @@ ownVMFromUnidentifiedThread(void) } if ((longAt((GIV(specialObjectsOop) + BaseHeaderSize) + (((sqInt)((usqInt)(GIV(foreignCallbackProcessSlot)) << (shiftForWord())))))) != GIV(nilObj)) break; /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); if (((count += 1)) > 1000) { return -2; } @@ -23949,19 +23979,22 @@ ownVMFromUnidentifiedThread(void) vmThread = unusedThreadInfo(); if (!vmThread) { /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != 0)); + atomic_store((&GIV(vmOwner)), 0); return -1; } /* begin setVMOwner: */ indexOrZero = (vmThread->index); - GIV(vmOwner) = indexOrZero; - sqLowLevelMFence(); + assert(((getVMOwner()) != 0) + && ((getVMOwner()) != indexOrZero)); + atomic_store((&GIV(vmOwner)), indexOrZero); (vmThread->state = CTMWantingOwnership); (vmThread->priority = GIV(foreignCallbackPriority)); /* begin registerVMThread: */ - assert((((vmThread->state)) == CTMInitializing) - || (((vmThread->state)) == CTMWantingOwnership)); + assert(((((vmThread->state)) == CTMInitializing) + || (((vmThread->state)) == CTMWantingOwnership)) + && (((vmThread->osThread)) == null)); (vmThread->osThread = ioCurrentOSThread()); ioSetThreadLocalThreadIndex((vmThread->index)); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -23998,6 +24031,8 @@ ownVM(sqInt threadIndexAndFlags) sqInt aMethodObj; sqInt cFramePointer; sqInt cStackPointer; + int expected; + int expected1; sqInt flags; StackPage *lastUsedPage; StackPage *lruOrFree; @@ -24043,10 +24078,20 @@ ownVM(sqInt threadIndexAndFlags) : 0); assert((((vmThread1->state)) == CTMUnavailable) || (((vmThread1->state)) == CTMWantingOwnership)); - if (!(tryLockVMOwnerTo(threadIndex))) { + if ((assert(!((threadIndex == 0))), + (expected1 = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected1), threadIndex)) + || (expected1 == threadIndex))) { + (vmThread1->state = CTMAssignableOrInVM); + } + else { (vmThread1->state = CTMWantingOwnership); - while (!((vmOwnerIs(threadIndex)) - || (tryLockVMOwnerTo(threadIndex)))) { + while (!(((atomic_load((&GIV(vmOwner)))) == threadIndex) + || ((assert(!((threadIndex == 0))), + /* begin doTryLockVMOwnerTo: */ + (expected = 0), + (atomic_compare_exchange_strong((&GIV(vmOwner)), (&expected), threadIndex)) + || (expected == threadIndex))))) { if (!(((vmThread1->priority)) == null)) { /* begin waitingPriorityIsAtLeast: */ minPriority = (vmThread1->priority); @@ -24056,7 +24101,7 @@ ownVM(sqInt threadIndexAndFlags) forceInterruptCheck(); } } - if (!(vmOwnerIs(threadIndex))) { + if (!((atomic_load((&GIV(vmOwner)))) == threadIndex)) { ioWaitOnOSSemaphore((&((vmThread1->osSemaphore)))); } } @@ -24078,7 +24123,7 @@ ownVM(sqInt threadIndexAndFlags) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceOwnVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ConstOne; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } return 0; @@ -24141,7 +24186,7 @@ ownVM(sqInt threadIndexAndFlags) assert(!(isOopForwarded(myProc))); longAtput((myProc + BaseHeaderSize) + (((sqInt)((usqInt)(MyListIndex) << (shiftForWord())))), GIV(nilObj)); if ((((threadIndexAndFlags & ProcessUnaffinedOnDisown) != 0)) - && (!(isBoundThreadId(ownerIndexOfThreadId((GIV(processHasThreadId) + && (!(isBoundThreadId(ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? longAt((myProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))) : GIV(nilObj))))))) { /* begin setOwnerIndexOfProcess:to:bind: */ @@ -24255,7 +24300,7 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceOwnVM; GIV(traceLog)[GIV(traceLogIndex) + 1] = ConstTwo; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } return threadIndexAndFlags & OwnVMForeignThreadFlag; @@ -24307,7 +24352,7 @@ preemptDisowningThread(void) selector = (((usqInt)((GIV(disowningVMThread)->index)) << 3) | 1); GIV(traceLog)[GIV(traceLogIndex)] = TracePreemptDisowningThread; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (0 + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } (GIV(disowningVMThread)->cStackPointer = GIV(CStackPointer)); @@ -24379,7 +24424,7 @@ preemptDisowningThread(void) preemptedThread = pushAWOLProcesson(activeProc, GIV(disowningVMThread)); GIV(disowningVMThread) = null; (preemptedThread->priority = quickFetchIntegerofObject(PriorityIndex, activeProc)); - if ((ownerIndexOfThreadId((GIV(processHasThreadId) + if ((ownerIndexOfThreadId((GIV(processHasThreadAffinity) ? (/* begin fetchPointer:ofObject: */ longAt((activeProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord())))))) : /* begin nilObject */ GIV(nilObj)))) == 0) { @@ -24421,7 +24466,7 @@ primitiveProcessBindToThreadId(void) sqInt threadIdSlot; sqInt threadIdSlot1; - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { (GIV(primFailCode) = PrimErrUnsupported); return; } @@ -24444,11 +24489,11 @@ primitiveProcessBindToThreadId(void) return; } /* begin bindProcess:toId: */ - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { ec = PrimErrUnsupported; goto l8; } - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadIdField = longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24460,7 +24505,7 @@ primitiveProcessBindToThreadId(void) /* If aProcess is affined (temporarily bound to) a thread then the operation can only succeed if the newId is the same as that aProcess is affined to, or is zero (is unbinding). */ ownerIndex = ((((threadIdField) & 7) == 1) - ? ((usqInt)(((threadIdField >> 3)))) >> ThreadIdShift + ? (((threadIdField >> 3))) >> ThreadIdShift : 0); if ((((((threadIdField) & 7) == 1) ? ((((threadIdField >> 3)) & ((1U << ThreadIdShift) - 1)) != 0) @@ -24511,7 +24556,7 @@ primitiveProcessBindToThreadId(void) /* begin pop: */ GIV(stackPointer) += GIV(argumentCount) * BytesPerWord; /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24520,7 +24565,7 @@ primitiveProcessBindToThreadId(void) threadId = GIV(nilObj); } id = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); if ((aProcess == (fetchPointerofObject(ActiveProcessIndex, schedulerPointer()))) && (((GIV(activeProcessAffined) = id != 0)) @@ -24536,11 +24581,13 @@ primitiveProcessBindToThreadId(void) } -/* Answer the receiver's current thread Id or nil, where the receiver is a - Process. If the threadId is positive then the receiver is bound to the - thread with that id. - If the threadId is negative then the receiver is excluded from running on - the thread with that id. */ +/* Answer the receiver's current threadAffinity or nil, where the receiver is + a Process. + If the threadAffinity is positive then the receiver is bound to the thread + with that id. + If the threadAffinity is negative then the receiver is excluded from + running on the thread with that id. + */ /* CoInterpreterMT>>#primitiveProcessBoundThreadId */ EXPORT(void) @@ -24552,13 +24599,13 @@ primitiveProcessBoundThreadId(void) char *sp; sqInt threadId; - if (!GIV(processHasThreadId)) { + if (!GIV(processHasThreadAffinity)) { (GIV(primFailCode) = PrimErrUnsupported); return; } aProcess = longAt(GIV(stackPointer)); /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((aProcess + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -24567,7 +24614,7 @@ primitiveProcessBoundThreadId(void) threadId = GIV(nilObj); } id = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); /* begin methodReturnValue: */ oop = (id == 0 @@ -24639,8 +24686,7 @@ primitiveVMCurrentThreadId(void) char *sp; /* begin methodReturnInteger: */ - sqLowLevelMFence(); - integer = GIV(vmOwner); + integer = atomic_load((&GIV(vmOwner))); assert(!((failed()))); /* begin pop:thenPushInteger: */ longAtput((sp = GIV(stackPointer) + (((GIV(argumentCount) + 1) - 1) * BytesPerWord)), (((usqInt)integer << 3) | 1)); @@ -24883,30 +24929,36 @@ printAllStacks(void) static void NoDbgRegParms returnToSchedulingLoopAndReleaseVMOrWakeThreadsource(CogVMThread *vmThread, sqInt source) { DECL_MAYBE_SQ_GLOBAL_STRUCT + CogVMThread *activeThread; + sqInt index; sqInt ownerIndex; sqInt selector; + /* begin currentVMThread */ + index = atomic_load((&GIV(vmOwner))); + assert(((index >= 0) && (index <= GIV(numThreads)))); + activeThread = (index > 0 + ? GIV(threads)[index] + : 0); /* begin recordThreadSwitchTo:source: */ ownerIndex = (vmThread == null ? 0 : (vmThread->index)); if (recordEventTrace()) { /* begin recordTrace:thing:source: */ - selector = (((usqInt)((((sqInt)((usqInt)(ownerIndex) << 16))) + (getVMOwner())) << 3) | 1); + selector = (((usqInt)((((sqInt)((usqInt)(ownerIndex) << 16))) + (atomic_load((&GIV(vmOwner))))) << 3) | 1); GIV(traceLog)[GIV(traceLogIndex)] = TraceThreadSwitch; GIV(traceLog)[GIV(traceLogIndex) + 1] = selector; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if (vmThread == null) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); + disownVM(DisownVMForThreading); } else { wakeVMThreadFor((vmThread->index)); } - _longjmp(GIV(reenterThreadSchedulingLoop), 1); + _longjmp((activeThread->reenterThreadSchedulingLoop), 1); } @@ -24976,7 +25028,7 @@ sendInvokeCallbackContext(VMCallbackContext *vmCallbackContext) assert(vmIsOwned()); assert((((currentVMThread())->state)) == CTMAssignableOrInVM); assert((fetchPointerofObject(MyListIndex, activeProcess())) == (nilObject())); - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); assertCStackWellAligned(); if (recordPrimTrace()) { /* begin fastLogPrim: */ @@ -25190,19 +25242,15 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) sqInt top; sqInt valuePointer; - _setjmp(GIV(reenterThreadSchedulingLoop)); + _setjmp((vmThread->reenterThreadSchedulingLoop)); do { assert(((vmThread->state)) == CTMAssignableOrInVM); if (tryLockVMOwnerTo((vmThread->index))) { + /* Yay, we're the VM owner! */ /* If relinquishing is true, then primitiveRelinquishProcessor has disowned the VM and only a returning call or callback should take ownership in that case. */ - if (GIV(relinquishing)) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); - } - else { + if (!GIV(relinquishing)) { /* begin tryToExecuteSmalltalk: */ assert(vmOwnerIs((vmThread->index))); assert((ioGetThreadLocalThreadIndex()) == ((vmThread->index))); @@ -25243,13 +25291,10 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) longAtput((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(ActiveProcessIndex) << (shiftForWord())))), activeProc); } if (activeProc == GIV(nilObj)) { - /* begin releaseVM */ - GIV(vmOwner) = 0; - sqLowLevelMFence(); goto l20; } /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((activeProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -25258,7 +25303,7 @@ threadSchedulingLoopImplementation(CogVMThread *vmThread) threadId = GIV(nilObj); } ownerIndex = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); if ((ownerIndex == 0) || (vmOwnerIsCompatibleWith(ownerIndex))) { @@ -25357,13 +25402,12 @@ GIV(bytecodeSetSelector) = (headerIndicatesAlternateBytecodeSet(methodHeaderOf(G wakeVMThreadFor(ownerIndex); l20: /* end tryToExecuteSmalltalk: */; } + disownVM(DisownVMForThreading); } - if (!(vmOwnerIs((vmThread->index)))) { - /* begin waitForWork: */ - assert(((vmThread->state)) == CTMAssignableOrInVM); - assert(!((vmOwnerIs((vmThread->index))))); - ioWaitOnOSSemaphore((&((vmThread->osSemaphore)))); - } + /* begin waitForWork: */ + (vmThread->state = CTMAssignableOrInVM); + assert(!((vmOwnerIs((vmThread->index))))); + ioWaitOnOSSemaphore((&((vmThread->osSemaphore)))); } while(1); } @@ -25390,9 +25434,9 @@ threadSwitchIfNecessaryfrom(sqInt newProc, sqInt sourceCode) if (GIV(deferThreadSwitch)) { return; } - assertValidProcessorStackPointersForIndex(getVMOwner()); + assertValidProcessorStackPointersForIndex(atomic_load((&GIV(vmOwner)))); /* begin ownerIndexOfThreadId: */ - if (GIV(processHasThreadId)) { + if (GIV(processHasThreadAffinity)) { /* begin fetchPointer:ofObject: */ threadId = longAt((newProc + BaseHeaderSize) + (((sqInt)((usqInt)(ThreadIdIndex) << (shiftForWord()))))); } @@ -25401,7 +25445,7 @@ threadSwitchIfNecessaryfrom(sqInt newProc, sqInt sourceCode) threadId = GIV(nilObj); } newProcOwnerIndex = ((((threadId) & 7) == 1) - ? ((usqInt)(((threadId >> 3)))) >> ThreadIdShift + ? (((threadId >> 3))) >> ThreadIdShift : 0); if (!(((GIV(activeProcessAffined) = newProcOwnerIndex != 0)) && (!(vmOwnerIsCompatibleWith(newProcOwnerIndex))))) { @@ -25549,7 +25593,7 @@ transferTofrom(sqInt newProc, sqInt sourceCode) /* begin recordTrace:thing:source: */ GIV(traceLog)[GIV(traceLogIndex)] = TraceContextSwitch; GIV(traceLog)[GIV(traceLogIndex) + 1] = oldProc; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (sourceCode + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (sourceCode + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } /* begin ensureFrameIsMarried:SP: */ @@ -26703,6 +26747,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -26724,6 +26770,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -61812,15 +61860,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -64312,7 +64352,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l10; } /* begin numSlotsOf: */ @@ -64342,7 +64382,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -64894,7 +64934,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - sqInt node; + usqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -68910,7 +68950,7 @@ handleStackOverflow(void) : TraceIsFromInterpreter); GIV(traceLog)[GIV(traceLogIndex)] = TraceStackOverflow; GIV(traceLog)[GIV(traceLogIndex) + 1] = TraceStackOverflow; - GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((getVMOwner())) << 16))))); + GIV(traceLog)[GIV(traceLogIndex) + 2] = (source + ((((sqInt)((usqInt)((atomic_load((&GIV(vmOwner))))) << 16))))); GIV(traceLogIndex) = (GIV(traceLogIndex) + 3) % TraceBufferSize; } if ((recordPrimTrace()) @@ -82479,7 +82519,7 @@ GIV(totalHeapSizeIncludingBridges)))); GIV(primFailCode) = PrimErrInappropriate; goto l103; } - GIV(processHasThreadId) = ((arg & 1) != 0); + GIV(processHasThreadAffinity) = ((arg & 1) != 0); GIV(flagInterpretedMethods) = ((arg & 2) != 0); /* was: noThreadingOfGUIThread := flags anyMask: 8. a broken idea */ diff --git a/src/spur64.sista/cogit.h b/src/spur64.sista/cogit.h index e37cc72f9f..04b4648cc2 100644 --- a/src/spur64.sista/cogit.h +++ b/src/spur64.sista/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ @@ -102,9 +102,6 @@ extern usqIntptr_t (*ceGetFP)(void); extern usqIntptr_t (*ceGetSP)(void); extern void (*ceInvokeInterpret)(void); extern sqInt ceReturnToInterpreterTrampoline; -#if COGMTVM -extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; @@ -130,7 +127,6 @@ extern int traceFlags ; #define recordOverflowTrace() (traceFlags & 32) #define recordPrimTrace() (traceFlags & 8) #define recordSendTrace() (traceFlags & 2) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define numRegArgs() 2 #define fullBlockEntryOffset() cbEntryOffset #define fullBlockNoContextSwitchEntryOffset() cbNoSwitchEntryOffset diff --git a/src/spur64.sista/cogitARMv8.c b/src/spur64.sista/cogitARMv8.c index 1b4c9d2bd4..8a659c6aff 100644 --- a/src/spur64.sista/cogitARMv8.c +++ b/src/spur64.sista/cogitARMv8.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -146,7 +146,6 @@ char *__cogitBuildInfo = __buildInfo; #define Extra0Reg 19 #define Extra1Reg 20 #define Extra2Reg 21 -#define Extra8Reg 27 #define Fill32 4 #define FirstAnnotation 64 #define FirstJump 12 @@ -327,7 +326,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (71 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (71 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -2771,9 +2770,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2785,14 +2781,12 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define dataCacheFlushRequired(ign) dataCacheFlushRequired #define dataCacheLineLength(ign) dataCacheLineLength #define flushDCacheFromto(me,startAddress,endAddress) ceFlushDCache(startAddress,endAddress) -#define hasAtomicInstructions(ign) hasAtomicInstructions #define inlineCacheValueForSelectorin(backEnd,selector,aCogMethod) indexForSelectorin(selector,aCogMethod) #define instructionCacheFlushRequired(ign) instructionCacheFlushRequired #define instructionCacheLineLength(ign) instructionCacheLineLength #define roundUpToMethodAlignment(ignored,numBytes) (((numBytes) + 15) & -16) #define setDataCacheFlushRequired(ign,b) dataCacheFlushRequired = b #define setDataCacheLineLength(ign,n) dataCacheLineLength = n -#define setHasAtomicInstructions(ign,b) hasAtomicInstructions = b #define setInstructionCacheFlushRequired(ign,b) instructionCacheFlushRequired = b #define setInstructionCacheLineLength(ign,n) instructionCacheLineLength = n #define cPICNumCases stackCheckOffset @@ -2852,7 +2846,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -4541,9 +4534,6 @@ detectFeaturesOnLinux(AbstractInstruction * self_in_detectFeaturesOnLinux) if ((instructionCacheLineLength(self_in_detectFeaturesOnLinux)) == 0) { setInstructionCacheLineLength(self_in_detectFeaturesOnLinux, 64); } -# if COGMTVM - setHasAtomicInstructions(self_in_detectFeaturesOnLinux, (((getauxval(AT_HWCAP)) & HWCAP_ATOMICS) != 0)); -# endif } #endif /* __linux__ */ @@ -4560,7 +4550,6 @@ detectFeaturesOnRawMachine(AbstractInstruction * self_in_detectFeaturesOnRawMach sqInt ctrEL0; sqInt fixupSize; usqIntptr_t (*getFeatureReg)(void); - sqInt idISAR0; sqInt opcodeSize; usqInt startAddress; @@ -4628,37 +4617,6 @@ detectFeaturesOnRawMachine(AbstractInstruction * self_in_detectFeaturesOnRawMach genoperand(MRS_ID_AA64ISAR0_EL1, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); -# if COGMTVM - /* begin resetMethodZoneBase: */ - methodZoneBase = startAddress; - /* begin ensureExecutableCodeZoneWithin: */ - -# if !DUAL_MAPPED_CODE_ZONE - /* begin makeCodeZoneExecutable */ -# if __APPLE__ && __MACH__ - pthread_jit_write_protect_np(1); - PJWPNSet = __LINE__; - if (!PJWPNState) { - PJWPNChange = __LINE__; - PJWPNState = 1; - } -# endif // __APPLE__ && __MACH__ -# endif // !DUAL_MAPPED_CODE_ZONE - idISAR0 = getFeatureReg(); - setHasAtomicInstructions(self_in_detectFeaturesOnRawMachine, ((((usqInt)(idISAR0)) >> 20) & 15) == 2); - /* begin ensureWritableCodeZone */ -# if !DUAL_MAPPED_CODE_ZONE - /* begin makeCodeZoneWritable */ -# if __APPLE__ && __MACH__ - pthread_jit_write_protect_np(0); - PJWPNClear = __LINE__; - if (PJWPNState) { - PJWPNChange = __LINE__; - PJWPNState = 0; - } -# endif // __APPLE__ && __MACH__ -# endif // !DUAL_MAPPED_CODE_ZONE -# endif // COGMTVM } #endif /* !__APPLE__ && !__linux__ */ @@ -36841,30 +36799,13 @@ getJumpTargetPCAt(sqInt pc) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - AbstractInstruction *anInstruction3; - AbstractInstruction *anInstruction4; - AbstractInstruction *anInstruction5; - AbstractInstruction *br; sqInt fixupSize; sqInt fixupSize1; - sqInt fixupSize2; - AbstractInstruction *ldaxr; - sqInt lockValueReg; sqInt numberOfAbstractOpcodes; sqInt numberOfAbstractOpcodes1; - sqInt numberOfAbstractOpcodes2; sqInt opcodeSize; sqInt opcodeSize1; - sqInt opcodeSize2; - sqInt reg; usqInt startAddress1; - usqInt startAddress2; - sqInt statusReg; - sqInt vmOwnerLockAddress; - sqInt vmOwnerLockAddressReg; initialCounterValue = MaxCounterValue; initializeBackend(); @@ -36890,10 +36831,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) # if __APPLE__ /* begin detectFeaturesOnMacOS */ -# if COGMTVM - setHasAtomicInstructions(((AbstractInstruction *) backEnd), 1); -# endif -# else // __APPLE__ +# else # if __linux__ detectFeaturesOnLinux(((AbstractInstruction *) backEnd)); # else @@ -36953,87 +36891,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) error("cache flushing method unknown for this platform"); # endif } - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 14 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - if (usesOutOfLineLiteral(anInstruction)) { - (anInstruction->dependent = locateLiteralsize(1, BytesPerOop)); - } - genoperand(RetN, 0); - goto l7; - } - - /* Holds the value of lock if unlocked (zero), receives the existing value of the lock */ - lockValueReg = CArg1Reg; - vmOwnerLockAddressReg = CArg2Reg; - if (hasAtomicInstructions(((AbstractInstruction *) backEnd))) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, lockValueReg); - if (usesOutOfLineLiteral(anInstruction1)) { - (anInstruction1->dependent = locateLiteralsize(0, BytesPerOop)); - } - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - if (usesOutOfLineLiteral(anInstruction2)) { - (anInstruction2->dependent = locateLiteralsize(vmOwnerLockAddress, BytesPerOop)); - } - genoperandoperandoperand(CASAL, lockValueReg, CArg0Reg, vmOwnerLockAddressReg); - br = genoperandoperand(CBNZ, 0, lockValueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction3 = genoperandoperand(MoveCqR, 1, ABIResultReg); - if (usesOutOfLineLiteral(anInstruction3)) { - (anInstruction3->dependent = locateLiteralsize(1, BytesPerOop)); - } - genoperand(RetN, 0); - jmpTarget(br, (assert(!((ABIResultReg == SPReg))), - genoperandoperand(CmpRR, ABIResultReg, lockValueReg))); - genoperandoperand(CSET, ABIResultReg, EQ); - genoperand(RetN, 0); - goto l7; - } - /* begin checkQuickConstant:forInstruction: */ - anInstruction4 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - if (usesOutOfLineLiteral(anInstruction4)) { - (anInstruction4->dependent = locateLiteralsize(vmOwnerLockAddress, BytesPerOop)); - } - /* begin MoveCq:R: */ - reg = (statusReg = CArg3Reg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction5 = genoperandoperand(MoveCqR, 0, reg); - if (usesOutOfLineLiteral(anInstruction5)) { - (anInstruction5->dependent = locateLiteralsize(0, BytesPerOop)); - } - ldaxr = genoperandoperand(LDAXR, lockValueReg, vmOwnerLockAddressReg); - br = genoperandoperand(CBNZ, 0, lockValueReg); - genoperandoperandoperand(STLXR, CArg0Reg, vmOwnerLockAddressReg, statusReg); - genoperandoperand(CBNZ, ((usqInt)ldaxr), statusReg); - genoperand(RetN, 0); - jmpTarget(br, gen(CLREX)); - assert(!((ABIResultReg == SPReg))); - genoperandoperand(CmpRR, ABIResultReg, lockValueReg); - genoperandoperand(CSET, ABIResultReg, EQ); - genoperand(RetN, 0); - l7: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur64.sista/cogitX64SysV.c b/src/spur64.sista/cogitX64SysV.c index 1c503dbf18..8ac547af57 100644 --- a/src/spur64.sista/cogitX64SysV.c +++ b/src/spur64.sista/cogitX64SysV.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -300,7 +300,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (69 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (69 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -1058,7 +1058,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2697,9 +2696,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2766,7 +2762,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -25776,46 +25771,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogX64Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - AbstractInstruction *jumpEqual; - sqInt vmOwnerLockAddressReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogX64Compiler>>#genMemCopy:to:constantSize: */ @@ -34384,17 +34339,6 @@ getJumpTargetPCAt(sqInt pc) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - AbstractInstruction *jumpEqual; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt vmOwnerLockAddress; - sqInt vmOwnerLockAddressReg; - initialCounterValue = MaxCounterValue; initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, @@ -34417,49 +34361,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 8 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - goto l8; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - l8: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur64.sista/cogitX64WIN64.c b/src/spur64.sista/cogitX64WIN64.c index 1119aa7666..8d5eb0ca7d 100644 --- a/src/spur64.sista/cogitX64WIN64.c +++ b/src/spur64.sista/cogitX64WIN64.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -300,7 +300,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumSendTrampolines 4 #define NumSpecialSelectors 32 #define NumStoreTrampolines 5 -#define NumTrampolines (69 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 5 : 0)) +#define NumTrampolines (69 + (IMMUTABILITY ? 5 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -1058,7 +1058,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2697,9 +2696,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2766,7 +2762,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -25794,46 +25789,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogX64Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - AbstractInstruction *jumpEqual; - sqInt vmOwnerLockAddressReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogX64Compiler>>#genMemCopy:to:constantSize: */ @@ -34448,17 +34403,6 @@ getJumpTargetPCAt(sqInt pc) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - AbstractInstruction *jumpEqual; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt vmOwnerLockAddress; - sqInt vmOwnerLockAddressReg; - initialCounterValue = MaxCounterValue; initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, @@ -34481,49 +34425,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 8 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - /* begin RetN: */ - genoperand(RetN, 0); - goto l8; - } - vmOwnerLockAddressReg = CArg1Reg; - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperand(MoveCqR, 0, RAX); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, vmOwnerLockAddress, vmOwnerLockAddressReg); - gen(LOCK); - genoperandoperand(CMPXCHGRMr, CArg0Reg, vmOwnerLockAddressReg); - /* begin JumpZero: */ - jumpEqual = genConditionalBranchoperand(JumpZero, ((sqInt)0)); - /* begin CmpR:R: */ - assert(!((CArg0Reg == SPReg))); - genoperandoperand(CmpRR, CArg0Reg, RAX); - jmpTarget(jumpEqual, genoperand(SETE, ABIResultReg)); - /* begin RetN: */ - genoperand(RetN, 0); - l8: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/spur64.sista/cointerp.c b/src/spur64.sista/cointerp.c index 80f11d4265..d86b18f1df 100644 --- a/src/spur64.sista/cointerp.c +++ b/src/spur64.sista/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1906,7 +1906,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1918,6 +1917,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2040,7 +2040,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2710,7 +2710,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -23252,7 +23252,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -23866,7 +23866,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -26879,6 +26879,8 @@ primitiveSistaMethodPICAndCounterData(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -26900,6 +26902,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -62087,15 +62091,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -65169,7 +65165,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur64.sista/cointerp.h b/src/spur64.sista/cointerp.h index 5be5795b9f..01789ddd91 100644 --- a/src/spur64.sista/cointerp.h +++ b/src/spur64.sista/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3328 uuid: a1c7c55f-8829-4fcc-9a66-55ba7d1a8cef + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ diff --git a/src/spur64.sista/gcc3x-cointerp.c b/src/spur64.sista/gcc3x-cointerp.c index 77201bd6ae..9d8494487d 100644 --- a/src/spur64.sista/gcc3x-cointerp.c +++ b/src/spur64.sista/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1909,7 +1909,6 @@ _iss sqInt statSurvivorCount; _iss sqInt externalPrimitiveTableFirstFreeIndex; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1921,6 +1920,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2043,7 +2043,7 @@ static signed short primitiveMetadataTable[MaxPrimitiveIndex + 2 /* 584 */] = { /*78*/ 0, 0, /*80*/ -256,-256,-256, 4, 4, 0, 0x100, 0, 0x200,-256,-256, 0, 0, 0, 0x100,-256, 0,-256, /*98*/ 0, 0, -/*100*/ 260, 0x200, 0x100, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, +/*100*/ 260, 0x200, 0x200, 0x200,-256, 513,-256,-256,-256,-256, 0, 0x100, 0, 0,-256, /*115*/ 0x100, 0, 12, 260, 0, /*120*/ 524, 0x100,-256,-256, 1, 0, 0, 0, 0,-255,-256,-256, 0, 0, 0,-256, 0,-256,-256, /*139*/ 0, @@ -2713,7 +2713,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -23261,7 +23261,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -23875,7 +23875,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -26888,6 +26888,8 @@ primitiveSistaMethodPICAndCounterData(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -26909,6 +26911,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -62096,15 +62100,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -65178,7 +65174,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur64.stack.lowcode/gcc3x-interp.c b/src/spur64.stack.lowcode/gcc3x-interp.c index 60a5d4e0c2..256c9653c1 100644 --- a/src/spur64.stack.lowcode/gcc3x-interp.c +++ b/src/spur64.stack.lowcode/gcc3x-interp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1640,7 +1640,6 @@ _iss sqInt rememberedSetLimit; _iss sqInt statSurvivorCount; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1652,6 +1651,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2404,7 +2404,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; int displayWidth; int displayDepth; @@ -38951,8 +38951,10 @@ primitiveSmallFloatTruncated(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -59693,15 +59695,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -74209,7 +74203,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/spur64.stack.lowcode/interp.c b/src/spur64.stack.lowcode/interp.c index 6a74b3dfc5..abec286144 100644 --- a/src/spur64.stack.lowcode/interp.c +++ b/src/spur64.stack.lowcode/interp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1637,7 +1637,6 @@ _iss sqInt rememberedSetLimit; _iss sqInt statSurvivorCount; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1649,6 +1648,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2401,7 +2401,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; int displayWidth; int displayDepth; @@ -38942,8 +38942,10 @@ primitiveSmallFloatTruncated(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -59684,15 +59686,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -74200,7 +74194,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/spur64.stack/gcc3x-interp.c b/src/spur64.stack/gcc3x-interp.c index eb99f7a178..df4057ed28 100644 --- a/src/spur64.stack/gcc3x-interp.c +++ b/src/spur64.stack/gcc3x-interp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1615,7 +1615,6 @@ _iss sqInt rememberedSetLimit; _iss sqInt statSurvivorCount; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1627,6 +1626,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2379,7 +2379,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; int displayWidth; int displayDepth; @@ -26189,8 +26189,10 @@ primitiveSmallFloatTruncated(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -46866,15 +46868,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -61260,7 +61254,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/spur64.stack/interp.c b/src/spur64.stack/interp.c index a0ea6591a5..b42a18fac5 100644 --- a/src/spur64.stack/interp.c +++ b/src/spur64.stack/interp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1612,7 +1612,6 @@ _iss sqInt rememberedSetLimit; _iss sqInt statSurvivorCount; _iss sqInt firstFieldOfRememberedSet; _iss sqInt firstSegmentSize; -_iss usqInt lowSpaceThreshold; _iss sqInt preemptionYields; _iss FILE * scavengeLog; _iss usqLong statIOProcessEvents; @@ -1624,6 +1623,7 @@ _iss sqInt edenBytes; _iss sqInt fullScreenFlag; _iss usqInt lastHash; _iss sqInt lastMethodCacheProbeWrite; +_iss usqInt lowSpaceThreshold; _iss sqInt multipleBytecodeSetsActive; _iss sqInt newFinalization; _iss sqInt rememberedSetRedZone; @@ -2376,7 +2376,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; int displayWidth; int displayDepth; @@ -26180,8 +26180,10 @@ primitiveSmallFloatTruncated(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -46857,15 +46859,7 @@ GIV(totalHeapSizeIncludingBridges) - (GIV(numSegments) * (2 * BaseHeaderSize)))) return 1; } } - if (GIV(lowSpaceThreshold) > GIV(totalFreeOldSpace)) { - - /* space is low */ - - /* avoid signalling low space twice */ - GIV(lowSpaceThreshold) = 0; - return 0; - } - return 1; + return GIV(lowSpaceThreshold) <= GIV(totalFreeOldSpace); } @@ -61251,7 +61245,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/spur64.stack/validImage.c b/src/spur64.stack/validImage.c index 262c12ea47..c40871c886 100644 --- a/src/spur64.stack/validImage.c +++ b/src/spur64.stack/validImage.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - ImageLeakChecker VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + ImageLeakChecker VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "ImageLeakChecker VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "ImageLeakChecker VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1000,7 +1000,7 @@ sqInt extraVMMemory; sqInt ffiExceptionResponse; sqInt inIOProcessEvents; struct VirtualMachine* interpreterProxy; -const char *interpreterVersion = "Open Smalltalk ImageChecker VM [ImageLeakChecker VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk ImageChecker VM [ImageLeakChecker VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; int displayDepth; int displayHeight; @@ -13970,7 +13970,7 @@ setImageHeaderFlagsFrom(sqInt headerFlags) GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/v3.cog/cogit.h b/src/v3.cog/cogit.h index fdb7e96176..0c9db7a490 100644 --- a/src/v3.cog/cogit.h +++ b/src/v3.cog/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ @@ -92,9 +92,6 @@ extern usqIntptr_t (*ceGetFP)(void); extern usqIntptr_t (*ceGetSP)(void); extern void (*ceInvokeInterpret)(void); extern sqInt ceReturnToInterpreterTrampoline; -#if COGMTVM -extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; @@ -120,7 +117,6 @@ extern int traceFlags ; #define recordOverflowTrace() (traceFlags & 32) #define recordPrimTrace() (traceFlags & 8) #define recordSendTrace() (traceFlags & 2) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define numRegArgs() 1 #define fullBlockEntryOffset() cbEntryOffset #define fullBlockNoContextSwitchEntryOffset() cbNoSwitchEntryOffset diff --git a/src/v3.cog/cogitARMv5.c b/src/v3.cog/cogitARMv5.c index 8927a215fb..3701b47f38 100644 --- a/src/v3.cog/cogitARMv5.c +++ b/src/v3.cog/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -264,7 +264,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumOopsPerNSC 6 #define NumSendTrampolines 4 #define NumSpecialSelectors 32 -#define NumTrampolines (54 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 0 : 0)) +#define NumTrampolines (54 + (IMMUTABILITY ? 0 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -2206,9 +2206,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2278,7 +2275,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -11904,11 +11900,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - sqInt fixupSize; - sqInt numberOfAbstractOpcodes; - sqInt opcodeSize; - usqInt startAddress1; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -11927,25 +11918,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodCount = 0; assertValidDualZone(); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes = numLowLevelLockOpcodes(backEnd); - numAbstractOpcodes = numberOfAbstractOpcodes; - opcodeSize = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize + fixupSize); - bzero(abstractOpcodes, opcodeSize + fixupSize); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress1 = methodZoneBase; - generateLowLevelTryLock(backEnd, vmOwnerAddress()); - outputInstructionsForGeneratedRuntimeAt(startAddress1); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress1); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress1); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/v3.cog/cogitIA32.c b/src/v3.cog/cogitIA32.c index 39e91b864e..975a2be3f4 100644 --- a/src/v3.cog/cogitIA32.c +++ b/src/v3.cog/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGenerator VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -279,7 +279,7 @@ char *__cogitBuildInfo = __buildInfo; #define NumOopsPerNSC 6 #define NumSendTrampolines 4 #define NumSpecialSelectors 32 -#define NumTrampolines (54 + (COGMTVM ? 1 : 0) + (IMMUTABILITY ? 0 : 0)) +#define NumTrampolines (54 + (IMMUTABILITY ? 0 : 0)) #define OrCqR 109 #define OrCqRR 125 #define OrCwR 117 @@ -507,7 +507,6 @@ static sqInt NoDbgRegParms dispatchConcretize(AbstractInstruction * self_in_disp static sqInt NoDbgRegParms dispatchConcretizeProcessorSpecific(AbstractInstruction * self_in_dispatchConcretizeProcessorSpecific); static sqInt NoDbgRegParms fullCallsAreRelative(AbstractInstruction * self_in_fullCallsAreRelative); static AbstractInstruction * NoDbgRegParms genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDivisor, sqInt abstractRegDividend, sqInt abstractRegQuotient, sqInt abstractRegRemainder); -static AbstractInstruction * NoDbgRegParms generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress); static void NoDbgRegParms genMemCopytoconstantSize(AbstractInstruction * self_in_genMemCopytoconstantSize, sqInt originalSourceReg, sqInt originalDestReg, sqInt size); static void NoDbgRegParms genMemCopytosize(AbstractInstruction * self_in_genMemCopytosize, sqInt originalSourceReg, sqInt originalDestReg, sqInt originalSize); static AbstractInstruction * NoDbgRegParms genMulRR(AbstractInstruction * self_in_genMulRR, sqInt regSource, sqInt regDest); @@ -2159,9 +2158,6 @@ void (*ceEnterCogCodePopReceiverReg)(void); usqIntptr_t (*ceGetFP)(void); usqIntptr_t (*ceGetSP)(void); void (*ceInvokeInterpret)(void); -#if COGMTVM -usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); -#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2238,7 +2234,6 @@ void (*realCEEnterCogCodePopReceiverReg)(void); #define reportError(n) warning("compilation error") #define setHasMovableLiteral(b) (hasMovableLiteral = (b)) #define setHasYoungReferent(b) (hasYoungReferent = (b)) -#define tryLockVMOwnerTo(value) ceTryLockVMOwner(value) #define varBaseAddress() varBaseAddress #define nextOpenPIC methodObject #define nextOpenPICHack hack hack hack i.e. the getter macro does all the work @@ -6129,38 +6124,6 @@ genDivRRQuoRem(AbstractInstruction * self_in_genDivRRQuoRem, sqInt abstractRegDi } -/* Generate a function that attempts to lock the vmOwnerLock and answers if - it succeeded. - */ - - /* CogIA32Compiler>>#generateLowLevelTryLock: */ -static AbstractInstruction * NoDbgRegParms -generateLowLevelTryLock(AbstractInstruction * self_in_generateLowLevelTryLock, sqInt vmOwnerLockAddress) -{ - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt valueReg; - - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - genoperand(RetN, 0); - return self_in_generateLowLevelTryLock; - } - valueReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | (1U << EAX)) - (1U << EAX))); - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperandoperand(MoveMwrR, 4, ESP, valueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, 0, EAX); - gen(LOCK); - genoperandoperand(CMPXCHGRAw, valueReg, vmOwnerLockAddress); - genoperand(SETE, ABIResultReg); - genoperand(RetN, 0); - return 0; -} - - /* Get the abstract registers for ECX, EDI and ESI */ /* CogIA32Compiler>>#genMemCopy:to:constantSize: */ @@ -11416,16 +11379,6 @@ initializeBackend(void) void initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) { - AbstractInstruction *anInstruction; - AbstractInstruction *anInstruction1; - AbstractInstruction *anInstruction2; - sqInt fixupSize2; - sqInt numberOfAbstractOpcodes2; - sqInt opcodeSize2; - usqInt startAddress2; - sqInt valueReg; - sqInt vmOwnerLockAddress; - initializeBackend(); sqMakeMemoryExecutableFromToCodeToDataDelta(startAddress, endAddress, # if DUAL_MAPPED_CODE_ZONE @@ -11445,42 +11398,6 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ - /* begin generateVMOwnerLockFunctions */ -# if COGMTVM - /* begin allocateOpcodes:bytecodes: */ - numberOfAbstractOpcodes2 = 6 /* numLowLevelLockOpcodes */; - numAbstractOpcodes = numberOfAbstractOpcodes2; - opcodeSize2 = (sizeof(CogAbstractInstruction)) * numAbstractOpcodes; - fixupSize2 = (sizeof(CogBytecodeFixup)) * numAbstractOpcodes; - abstractOpcodes = alloca(opcodeSize2 + fixupSize2); - bzero(abstractOpcodes, opcodeSize2 + fixupSize2); - fixups = ((void *)((((usqInt)abstractOpcodes)) + opcodeSize2)); - zeroOpcodeIndexForNewOpcodes(); - labelCounter = 0; - zeroOpcodeIndex(); - startAddress2 = methodZoneBase; - /* begin generateLowLevelTryLock: */ - vmOwnerLockAddress = vmOwnerAddress(); - if (vmOwnerLockAddress == 0) { - /* begin checkQuickConstant:forInstruction: */ - anInstruction = genoperandoperand(MoveCqR, 1, ABIResultReg); - genoperand(RetN, 0); - goto l1; - } - valueReg = availableRegisterOrNoneIn(((ABICallerSavedRegisterMask | (1U << EAX)) - (1U << EAX))); - /* begin checkQuickConstant:forInstruction: */ - anInstruction1 = genoperandoperandoperand(MoveMwrR, 4, ESP, valueReg); - /* begin checkQuickConstant:forInstruction: */ - anInstruction2 = genoperandoperand(MoveCqR, 0, EAX); - gen(LOCK); - genoperandoperand(CMPXCHGRAw, valueReg, vmOwnerLockAddress); - genoperand(SETE, ABIResultReg); - genoperand(RetN, 0); - l1: /* end generateLowLevelTryLock: */; - outputInstructionsForGeneratedRuntimeAt(startAddress2); - recordGeneratedRunTimeaddress("ceTryLockVMOwner", startAddress2); - ceTryLockVMOwner = ((usqIntptr_t (*)(usqIntptr_t)) startAddress2); -# endif // COGMTVM genGetLeafCallStackPointers(); generateStackPointerCapture(); generateTrampolines(); diff --git a/src/v3.cog/cointerp.c b/src/v3.cog/cointerp.c index 086f293a2a..3ef44f18b4 100644 --- a/src/v3.cog/cointerp.c +++ b/src/v3.cog/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -2271,7 +2271,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -15104,7 +15104,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; sqInt oop; char *rcvrAddress; sqInt rcvrOrClosure; @@ -15732,7 +15732,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -18466,6 +18466,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -18487,6 +18489,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. diff --git a/src/v3.cog/cointerp.h b/src/v3.cog/cointerp.h index 5e18c07cfa..698ce99ff4 100644 --- a/src/v3.cog/cointerp.h +++ b/src/v3.cog/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3328 uuid: a1c7c55f-8829-4fcc-9a66-55ba7d1a8cef + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ diff --git a/src/v3.cog/gcc3x-cointerp.c b/src/v3.cog/gcc3x-cointerp.c index 6920bbda1b..9382464e46 100644 --- a/src/v3.cog/gcc3x-cointerp.c +++ b/src/v3.cog/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -2274,7 +2274,7 @@ sqInt debugCallbackReturns; sqInt suppressHeartbeatFlag; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -15113,7 +15113,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - usqInt numTemps; + sqInt numTemps; sqInt oop; char *rcvrAddress; sqInt rcvrOrClosure; @@ -15741,7 +15741,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 : 0); @@ -18475,6 +18475,8 @@ primitiveSignal(void) /* Save a normal snapshot under the same name as it was loaded unless it has been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. @@ -18496,6 +18498,8 @@ primitiveSnapshot(void) /* Save an embedded snapshot. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. Override to jump to the interpreter because the machine code zone is now void. diff --git a/src/v3.stack/gcc3x-interp.c b/src/v3.stack/gcc3x-interp.c index 48f89259f0..ce436ad8eb 100644 --- a/src/v3.stack/gcc3x-interp.c +++ b/src/v3.stack/gcc3x-interp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1976,7 +1976,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -18798,8 +18798,10 @@ primitiveSize(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -40173,7 +40175,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1 diff --git a/src/v3.stack/interp.c b/src/v3.stack/interp.c index 5c4e26bee4..d8b59c3cb0 100644 --- a/src/v3.stack/interp.c +++ b/src/v3.stack/interp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 from - StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec + StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3332 uuid: c611edf1-6978-4222-99d0-0370a8f40bec " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.3339 uuid: b1c834e2-5de7-464c-aeb5-4f2a7b8812d6 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1973,7 +1973,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt cannotDeferDisplayUpdates; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3332]"; +const char *interpreterVersion = "Open Smalltalk Stack VM [StackInterpreterPrimitives VMMaker.oscog-eem.3339]"; sqInt suppressHeartbeatFlag; char expensiveAsserts = 0; int (*showSurfaceFn)(sqIntptr_t, int, int, int, int); @@ -18789,8 +18789,10 @@ primitiveSize(void) } -/* save a normal snapshot under the same name as it was loaded unless it has - been renamed by the last primitiveImageName +/* Save a normal snapshot under the same name as it was loaded unless it has + been renamed by the last primitiveImageName. + Note that when executed this primitive answers false, but when the + resulting image is run afresh, the primitive answers true. */ /* InterpreterPrimitives>>#primitiveSnapshot */ @@ -40164,7 +40166,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea GIV(imageHeaderFlags) = headerFlags; GIV(fullScreenFlag) = headerFlags & 1; - /* processHasThreadId := headerFlags anyMask: 4. specific to CoInterpreterMT */ + /* processHasThreadAffinity := headerFlags anyMask: 4. specific to CoInterpreterMT */ /* flagInterpretedMethods := headerFlags anyMask: 8. specific to CoInterpreter */ GIV(imageFloatsBigEndian) = ((!(headerFlags & 2)) ? 1