diff --git a/build.win32x86/common/Makefile b/build.win32x86/common/Makefile index 6fae9d231b..aa42c3f5e3 100644 --- a/build.win32x86/common/Makefile +++ b/build.win32x86/common/Makefile @@ -1,309 +1,309 @@ -############################################################################# -# Common Makefile for Win32 VM using gcc, cygwin and gnu make -# Do make init to allow make -n to function. -############################################################################# - -############################################################################# -# Parameters: -# VM the name of the exe to build, defaults to Squeak (=> Squeak.exe) -# VM_NAME the name the VM will print when reporting, defaults to $(VM) -# VMSRCDIR the directory containing the interpreter, optional cogit and interp.h -# CONFIGURATION configuration of VM to build from product, assert & debug -# THREADING whether to build a multi-threaded FFI VM - -.PHONY: all -all: default - -VM?=Squeak -VM_NAME?=$(VM) -CONFIGURATION=product -THREADING=single - -# Is this a Croquet VM (defaults to OGL instead of D3D)? -CROQUET:=-DCROQUET - -############################################################################# -# Default locations -# - -ifeq ($(THREADING),multi) - ifeq ($(CONFIGURATION),product) - BUILD:=buildmt - else ifeq ($(CONFIGURATION),assert) - BUILD:=buildmtast - else - BUILD:=buildmtdbg - endif -else - ifeq ($(CONFIGURATION),product) - BUILD:=build - else ifeq ($(CONFIGURATION),assert) - BUILD:=buildast - else - BUILD:=builddbg - endif -endif -$(shell mkdir -p deps >/dev/null) # deps is the dependencies directory -PLUGINSRCDIR:= ../../src -OBJDIR:= $(BUILD)/vm - -PLATDIR:=../../platforms -CROSSDIR:=$(PLATDIR)/Cross/vm -WIN32DIR:=$(PLATDIR)/win32/vm -WIN32PLUGINSDIR:=$(PLATDIR)/win32/plugins -WIN32MISCDIR:=$(PLATDIR)/win32/misc -WIN32UTILDIR:=$(PLATDIR)/win32/util - -CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp) -WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp) -ifeq ($(THREADING),multi) -MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interpmt.c $(VMSRCDIR)/cogit.c) -else -MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interp.c $(VMSRCDIR)/cogit.c) -endif -VMSRC:= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC)) - -VPATH:= $(VMSRCDIR) $(WIN32DIR) $(CROSSDIR) - -############################################################################# -# The internal (.lib) and external (.dll) plugins -# -include plugins.ext -include plugins.int - -LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS))) -DLLS:= $(addprefix $(OBJDIR)/, $(addsuffix .dll, $(EXTERNAL_PLUGINS))) - -############################################################################# -# The third-party libraries -# -ifneq ($(THIRDPARTYLIBS),) -include ../common/Makefile.lib.extra -THIRDPARTYPREREQS:=$(THIRDPARTYCACHEDIR) $(THIRDPARTYOUTDIR) -endif - -############################################################################# -# Generic VM source file definitions -# -VMOBJ:= $(VMSRC:.c=.o) -VMOBJ:= $(addprefix $(OBJDIR)/,$(VMOBJ)) - -############################################################################# -# SqueakVM definitions -# -ifeq ($(CONFIGURATION),product) -VMEXE:= $(OBJDIR)/$(VM)Unstripped.exe -CONSOLEVMEXE:= $(OBJDIR)/$(VM)ConsoleUnstripped.exe -STRIPEXE:= $(OBJDIR)/$(VM).exe -STRIPCONSOLEEXE:= $(OBJDIR)/$(VM)Console.exe -else -VMEXE:= $(OBJDIR)/$(VM).exe -CONSOLEVMEXE:= $(OBJDIR)/$(VM)Console.exe -STRIPEXE:= -STRIPCONSOLEEXE:= -endif -VMDEF:= $(VM).def -VMEXP:= $(OBJDIR)/$(VM).exp -VMMAP:= $(OBJDIR)/$(VM).map -CONSOLEVMMAP:= $(OBJDIR)/$(VM)Console.map -VMLIB:= $(VM).lib -VMRES:= $(VM).res -VMDEFIN:=$(VM).def.in -BTOBJ:= $(OBJDIR)/btext.o -ETOBJ:= $(OBJDIR)/etext.o - -.PRECIOUS: mkNamedPrims.exe - -############################################################################# -# DirectX definitions - NOT USED - superseded by mingw provided files -# -DXDIR:= $(PLATDIR)/win32/third-party/dx9sdk/Include - -############################################################################# -# Toolchain -# -include ../common/Makefile.tools - -INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC) - -.SUFFIXES: -.SUFFIXES: .ccg .cc .c .o .s .i .rc .res .cg .hg .ccg .cpp - -############################################################################# -# Common build rules -# - -default: print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(STRIPEXE) $(STRIPCONSOLEEXE) nukelibs - -svnver: - echo $(RC) $(RCFLAGS) - -productmt:; - $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product THREADING=multi $(@,product=) default - -product:; - $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product THREADING=single $(@,product=) default - -assertmt: - $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=assert THREADING=multi $(@,assert=) default - -assert: - $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=assert THREADING=single $(@,assert=) default - -debugmt: - $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=debug THREADING=multi $(@,debug=) default - -debug: - $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=debug THREADING=single $(@,debug=) default - -# Do make init to allow make -n to function. -init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe - -cleanall: clean cleanmt cleanast cleanmtast cleandbg cleanmtdbg - -clean: - rm -rf sqNamedPrims.h mkNamedPrims.exe build - -cleanmt: - rm -rf sqNamedPrims.h mkNamedPrims.exe buildmt - -cleanast: - rm -rf sqNamedPrims.h mkNamedPrims.exe buildast - -cleanmtast: - rm -rf sqNamedPrims.h mkNamedPrims.exe buildmtast - -cleandbg: - rm -rf sqNamedPrims.h mkNamedPrims.exe builddbg - -cleanmtdbg: - rm -rf sqNamedPrims.h mkNamedPrims.exe buildmtdbg - -nukelibs: - rm $(LIBS) - -print-settings: - $(info ---------------- Makefile settings ------------------ ) - $(info CONFIGURATION=$(CONFIGURATION) ) - $(info THREADING=$(THREADING) ) - $(info VPATH=$(VPATH) ) - $(info INCLUDES=$(INCLUDES) ) - $(info CFLAGS=$(CFLAGS) ) - $(info INTERNAL_PLUGINS=$(INTERNAL_PLUGINS) ) - $(info EXTERNAL_PLUGINS=$(EXTERNAL_PLUGINS) ) - $(info OBJDIR=$(OBJDIR) ) - $(info LIBS=$(LIBS) ) - $(info DLLS=$(DLLS) ) - $(info ----------------------------------------------------- ) - -print-objects: - $(info ---------------- Makefile objects ------------------ ) - $(info VMOBJ=$(VMOBJ) ) - $(info ----------------------------------------------------- ) - -ignore := $(addsuffix .%, $(basename $(wildcard $(BUILD)/vm/*.ignore))) - -mingw32ver.exe: $(WIN32UTILDIR)/mingw32ver.c - $(CC) -o $@ -O1 -mconsole -m32 $< - -mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c - $(CC) -o $@ -mconsole -m32 $< - -$(BTOBJ): $(WIN32MISCDIR)/btext.c - $(CC) -c -o $@ -fomit-frame-pointer -O2 $< - -$(ETOBJ): $(WIN32MISCDIR)/etext.c - $(CC) -c -o $@ -fomit-frame-pointer -O2 $< - -vm: $(VMEXE) - -$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) - $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c - $(LD) $(LDFLAGS) -o $(VMEXE) \ - $(BTOBJ) $(VMOBJ) $(VMEXP) $(OBJDIR)/resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) - $(NM) --numeric-sort --defined-only -f bsd $(VMEXE) >$(VMMAP) - -$(CONSOLEVMEXE): $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) - $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c - $(LD) $(CONSOLELDFLAGS) -o $(CONSOLEVMEXE) \ - $(BTOBJ) $(VMOBJ) $(VMEXP) $(OBJDIR)/resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) - $(NM) --numeric-sort --defined-only -f bsd $(CONSOLEVMEXE) >$(CONSOLEVMMAP) - -ifneq ($STRIPEXE,) -$(STRIPEXE): $(VMEXE) - $(STRIP) --strip-unneeded -o $(STRIPEXE) $(VMEXE) - $(OBJCOPY) --add-gnu-debuglink=$(VMEXE) $(STRIPEXE) - -$(STRIPCONSOLEEXE): $(CONSOLEVMEXE) - $(STRIP) --strip-unneeded -o $(STRIPCONSOLEEXE) $(CONSOLEVMEXE) - $(OBJCOPY) --add-gnu-debuglink=$(CONSOLEVMEXE) $(STRIPCONSOLEEXE) -endif - -$(OBJDIR): - @-mkdir $(BUILD) - mkdir $(OBJDIR) -ifneq ($(INTERNAL_PLUGINS),) - mkdir $(addprefix $(BUILD)/, $(INTERNAL_PLUGINS)) -endif -ifneq ($(EXTERNAL_PLUGINS),) - mkdir $(addprefix $(BUILD)/, $(EXTERNAL_PLUGINS)) -endif - -############################################################################# -# The exports for named primitives from Squeak (required by VM) -# -$(VMDEF) $(VMEXP) $(VMLIB): $(VMOBJ) - $(DLLTOOL) --input-def $(VMDEFIN) --output-def $(OBJDIR)/$(VMDEF) --output-exp $(VMEXP) --output-lib $(OBJDIR)/$(VMLIB) $(VMOBJ) - -############################################################################# -# Building plugins -# - -.PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.dll - -# Check for Makefile in win32 plugins directory otherwise use default Makefile -plugin-makefile = $(realpath $(firstword $(wildcard $(WIN32PLUGINSDIR)/$(1)/Makefile.plugin ../common/Makefile.plugin))) - -# Internal plugin. Build as lib then link in lib -$(OBJDIR)/%.lib: $(call plugin-makefile,$(*F)) - @-mkdir -p $(BUILD)/$(*F) - rm -f $(BUILD)/vm/$(*F).ignore - $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ - -f $(call plugin-makefile,$(*F)) \ - CONFIGURATION=$(CONFIGURATION) TOOLPREFIX=$(TOOLPREFIX) \ - THIRDPARTYOUTDIR=$(THIRDPARTYOUTDIR) \ - PLATDIR=$(PLATDIR) PLUGINSRCDIR=$(PLUGINSRCDIR) VMSRCDIR=$(VMSRCDIR) \ - LIBNAME=$(*F) COGDEFS="$(COGDEFS)" XDEFS=-DSQUEAK_BUILTIN_PLUGIN \ - $(OBJDIR)/$(*F).lib - -# External plugin. Build as dll and copy to vm dir ($(OBJDIR)). -$(OBJDIR)/%.dll: $(call plugin-makefile,$(*F)) - @-mkdir -p $(BUILD)/$(*F) - rm -f $(BUILD)/$(*F).ignore - $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ - -f $(call plugin-makefile,$(*F)) \ - CONFIGURATION=$(CONFIGURATION) TOOLPREFIX=$(TOOLPREFIX) \ - PLATDIR=$(PLATDIR) PLUGINSRCDIR=$(PLUGINSRCDIR) VMSRCDIR=$(VMSRCDIR) \ - THIRDPARTYOUTDIR=$(THIRDPARTYOUTDIR) \ - COGDEFS="$(COGDEFS)" LIBNAME=$(*F) $(OBJDIR)/$(*F).dll - -############################################################################# -# Basic rules -# -include ../common/Makefile.rules - -$(VMRES): $(VM).rc - $(RC) $(RCFLAGS) -i $(VM).rc -o $(OBJDIR)/$@ - $(CP) $(VM).exe.manifest $(OBJDIR) - $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest - -resource.o: $(VMRES) - $(RC) $(RCFLAGS) -i $(OBJDIR)/$< -o $(OBJDIR)/$@ - -############################################################################# -# Extra specific dependencies -# -sqNamedPrims.h: plugins.int mkNamedPrims.exe - ./mkNamedPrims.exe $(INTERNAL_PLUGINS) > sqNamedPrims.h - -$(OBJDIR)/sqNamedPrims.o: sqNamedPrims.c sqNamedPrims.h +############################################################################# +# Common Makefile for Win32 VM using gcc, cygwin and gnu make +# Do make init to allow make -n to function. +############################################################################# + +############################################################################# +# Parameters: +# VM the name of the exe to build, defaults to Squeak (=> Squeak.exe) +# VM_NAME the name the VM will print when reporting, defaults to $(VM) +# VMSRCDIR the directory containing the interpreter, optional cogit and interp.h +# CONFIGURATION configuration of VM to build from product, assert & debug +# THREADING whether to build a multi-threaded FFI VM + +.PHONY: all +all: default + +VM?=Squeak +VM_NAME?=$(VM) +CONFIGURATION=product +THREADING=single + +# Is this a Croquet VM (defaults to OGL instead of D3D)? +CROQUET:=-DCROQUET + +############################################################################# +# Default locations +# + +ifeq ($(THREADING),multi) + ifeq ($(CONFIGURATION),product) + BUILD:=buildmt + else ifeq ($(CONFIGURATION),assert) + BUILD:=buildmtast + else + BUILD:=buildmtdbg + endif +else + ifeq ($(CONFIGURATION),product) + BUILD:=build + else ifeq ($(CONFIGURATION),assert) + BUILD:=buildast + else + BUILD:=builddbg + endif +endif +$(shell mkdir -p deps >/dev/null) # deps is the dependencies directory +PLUGINSRCDIR:= ../../src +OBJDIR:= $(BUILD)/vm + +PLATDIR:=../../platforms +CROSSDIR:=$(PLATDIR)/Cross/vm +WIN32DIR:=$(PLATDIR)/win32/vm +WIN32PLUGINSDIR:=$(PLATDIR)/win32/plugins +WIN32MISCDIR:=$(PLATDIR)/win32/misc +WIN32UTILDIR:=$(PLATDIR)/win32/util + +CROSSSRC:= $(wildcard $(CROSSDIR)/*.c) $(wildcard $(CROSSDIR)/*.cpp) +WIN32SRC:= $(wildcard $(WIN32DIR)/*.c) $(wildcard $(WIN32DIR)/*.cpp) +ifeq ($(THREADING),multi) +MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interpmt.c $(VMSRCDIR)/cogit.c) +else +MAKERSRC:= $(wildcard $(VMSRCDIR)/gcc3x-*interp.c $(VMSRCDIR)/cogit.c) +endif +VMSRC:= $(notdir $(MAKERSRC) $(WIN32SRC) $(CROSSSRC)) + +VPATH:= $(VMSRCDIR) $(WIN32DIR) $(CROSSDIR) + +############################################################################# +# The internal (.lib) and external (.dll) plugins +# +include plugins.ext +include plugins.int + +LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS))) +DLLS:= $(addprefix $(OBJDIR)/, $(addsuffix .dll, $(EXTERNAL_PLUGINS))) + +############################################################################# +# The third-party libraries +# +ifneq ($(THIRDPARTYLIBS),) +include ../common/Makefile.lib.extra +THIRDPARTYPREREQS:=$(THIRDPARTYCACHEDIR) $(THIRDPARTYOUTDIR) +endif + +############################################################################# +# Generic VM source file definitions +# +VMOBJ:= $(VMSRC:.c=.o) +VMOBJ:= $(addprefix $(OBJDIR)/,$(VMOBJ)) + +############################################################################# +# SqueakVM definitions +# +ifeq ($(CONFIGURATION),product) +VMEXE:= $(OBJDIR)/$(VM)Unstripped.exe +CONSOLEVMEXE:= $(OBJDIR)/$(VM)ConsoleUnstripped.exe +STRIPEXE:= $(OBJDIR)/$(VM).exe +STRIPCONSOLEEXE:= $(OBJDIR)/$(VM)Console.exe +else +VMEXE:= $(OBJDIR)/$(VM).exe +CONSOLEVMEXE:= $(OBJDIR)/$(VM)Console.exe +STRIPEXE:= +STRIPCONSOLEEXE:= +endif +VMDEF:= $(VM).def +VMEXP:= $(OBJDIR)/$(VM).exp +VMMAP:= $(OBJDIR)/$(VM).map +CONSOLEVMMAP:= $(OBJDIR)/$(VM)Console.map +VMLIB:= $(VM).lib +VMRES:= $(VM).res +VMDEFIN:=$(VM).def.in +BTOBJ:= $(OBJDIR)/btext.o +ETOBJ:= $(OBJDIR)/etext.o + +.PRECIOUS: mkNamedPrims.exe + +############################################################################# +# DirectX definitions - NOT USED - superseded by mingw provided files +# +DXDIR:= $(PLATDIR)/win32/third-party/dx9sdk/Include + +############################################################################# +# Toolchain +# +include ../common/Makefile.tools + +INCLUDES:= -I. -I$(VMSRCDIR) -I$(WIN32DIR) -I$(CROSSDIR) $(XINC) + +.SUFFIXES: +.SUFFIXES: .ccg .cc .c .o .s .i .rc .res .cg .hg .ccg .cpp + +############################################################################# +# Common build rules +# + +default: print-settings init $(VMEXE) $(CONSOLEVMEXE) $(DLLS) $(STRIPEXE) $(STRIPCONSOLEEXE) nukelibs + +svnver: + echo $(RC) $(RCFLAGS) + +productmt:; + $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product THREADING=multi $(@,product=) default + +product:; + $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=product THREADING=single $(@,product=) default + +assertmt: + $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=assert THREADING=multi $(@,assert=) default + +assert: + $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=assert THREADING=single $(@,assert=) default + +debugmt: + $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=debug THREADING=multi $(@,debug=) default + +debug: + $(MAKE) -f $(MAKEFILE_LIST) CONFIGURATION=debug THREADING=single $(@,debug=) default + +# Do make init to allow make -n to function. +init: $(THIRDPARTYPREREQS) $(OBJDIR) mkNamedPrims.exe + +cleanall: clean cleanmt cleanast cleanmtast cleandbg cleanmtdbg + +clean: + rm -rf sqNamedPrims.h mkNamedPrims.exe build + +cleanmt: + rm -rf sqNamedPrims.h mkNamedPrims.exe buildmt + +cleanast: + rm -rf sqNamedPrims.h mkNamedPrims.exe buildast + +cleanmtast: + rm -rf sqNamedPrims.h mkNamedPrims.exe buildmtast + +cleandbg: + rm -rf sqNamedPrims.h mkNamedPrims.exe builddbg + +cleanmtdbg: + rm -rf sqNamedPrims.h mkNamedPrims.exe buildmtdbg + +nukelibs: + rm $(LIBS) + +print-settings: + $(info ---------------- Makefile settings ------------------) + $(info CONFIGURATION=$(CONFIGURATION)) + $(info THREADING=$(THREADING)) + $(info VPATH=$(VPATH)) + $(info INCLUDES=$(INCLUDES)) + $(info CFLAGS=$(CFLAGS)) + $(info INTERNAL_PLUGINS=$(INTERNAL_PLUGINS)) + $(info EXTERNAL_PLUGINS=$(EXTERNAL_PLUGINS)) + $(info OBJDIR=$(OBJDIR)) + $(info LIBS=$(LIBS)) + $(info DLLS=$(DLLS)) + $(info -----------------------------------------------------) + +print-objects: + $(info ---------------- Makefile objects ------------------) + $(info VMOBJ=$(VMOBJ)) + $(info -----------------------------------------------------) + +ignore := $(addsuffix .%, $(basename $(wildcard $(BUILD)/vm/*.ignore))) + +mingw32ver.exe: $(WIN32UTILDIR)/mingw32ver.c + $(CC) -o $@ -O1 -mconsole -m32 $< + +mkNamedPrims.exe: $(WIN32UTILDIR)/mkNamedPrims.c + $(CC) -o $@ -mconsole -m32 $< + +$(BTOBJ): $(WIN32MISCDIR)/btext.c + $(CC) -c -o $@ -fomit-frame-pointer -O2 $< + +$(ETOBJ): $(WIN32MISCDIR)/etext.c + $(CC) -c -o $@ -fomit-frame-pointer -O2 $< + +vm: $(VMEXE) + +$(VMEXE): $(OBJDIR) $(THIRDPARTYLIBS) $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) + $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c + $(LD) $(LDFLAGS) -o $(VMEXE) \ + $(BTOBJ) $(VMOBJ) $(VMEXP) $(OBJDIR)/resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + $(NM) --numeric-sort --defined-only -f bsd $(VMEXE) >$(VMMAP) + +$(CONSOLEVMEXE): $(VMOBJ) $(LIBS) $(VMEXP) resource.o $(BTOBJ) $(ETOBJ) + $(CC) -o $(OBJDIR)/version.o $(CFLAGS) $(INCLUDES) $(DEFS) -c $(WIN32DIR)/version.c + $(LD) $(CONSOLELDFLAGS) -o $(CONSOLEVMEXE) \ + $(BTOBJ) $(VMOBJ) $(VMEXP) $(OBJDIR)/resource.o $(filter-out $(call ignore), $(LIBS)) $(STDLIBS) $(ETOBJ) + $(NM) --numeric-sort --defined-only -f bsd $(CONSOLEVMEXE) >$(CONSOLEVMMAP) + +ifneq ($STRIPEXE,) +$(STRIPEXE): $(VMEXE) + $(STRIP) --strip-unneeded -o $(STRIPEXE) $(VMEXE) + $(OBJCOPY) --add-gnu-debuglink=$(VMEXE) $(STRIPEXE) + +$(STRIPCONSOLEEXE): $(CONSOLEVMEXE) + $(STRIP) --strip-unneeded -o $(STRIPCONSOLEEXE) $(CONSOLEVMEXE) + $(OBJCOPY) --add-gnu-debuglink=$(CONSOLEVMEXE) $(STRIPCONSOLEEXE) +endif + +$(OBJDIR): + @-mkdir $(BUILD) + mkdir $(OBJDIR) +ifneq ($(INTERNAL_PLUGINS),) + mkdir $(addprefix $(BUILD)/, $(INTERNAL_PLUGINS)) +endif +ifneq ($(EXTERNAL_PLUGINS),) + mkdir $(addprefix $(BUILD)/, $(EXTERNAL_PLUGINS)) +endif + +############################################################################# +# The exports for named primitives from Squeak (required by VM) +# +$(VMDEF) $(VMEXP) $(VMLIB): $(VMOBJ) + $(DLLTOOL) --input-def $(VMDEFIN) --output-def $(OBJDIR)/$(VMDEF) --output-exp $(VMEXP) --output-lib $(OBJDIR)/$(VMLIB) $(VMOBJ) + +############################################################################# +# Building plugins +# + +.PHONY: $(OBJDIR)/%.lib $(OBJDIR)/%.dll + +# Check for Makefile in win32 plugins directory otherwise use default Makefile +plugin-makefile = $(realpath $(firstword $(wildcard $(WIN32PLUGINSDIR)/$(1)/Makefile.plugin ../common/Makefile.plugin))) + +# Internal plugin. Build as lib then link in lib +$(OBJDIR)/%.lib: $(call plugin-makefile,$(*F)) + @-mkdir -p $(BUILD)/$(*F) + rm -f $(BUILD)/vm/$(*F).ignore + $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ + -f $(call plugin-makefile,$(*F)) \ + CONFIGURATION=$(CONFIGURATION) TOOLPREFIX=$(TOOLPREFIX) \ + THIRDPARTYOUTDIR=$(THIRDPARTYOUTDIR) \ + PLATDIR=$(PLATDIR) PLUGINSRCDIR=$(PLUGINSRCDIR) VMSRCDIR=$(VMSRCDIR) \ + LIBNAME=$(*F) COGDEFS="$(COGDEFS)" XDEFS=-DSQUEAK_BUILTIN_PLUGIN \ + $(OBJDIR)/$(*F).lib + +# External plugin. Build as dll and copy to vm dir ($(OBJDIR)). +$(OBJDIR)/%.dll: $(call plugin-makefile,$(*F)) + @-mkdir -p $(BUILD)/$(*F) + rm -f $(BUILD)/$(*F).ignore + $(MAKE) $(MFLAGS) BUILD=$(BUILD) \ + -f $(call plugin-makefile,$(*F)) \ + CONFIGURATION=$(CONFIGURATION) TOOLPREFIX=$(TOOLPREFIX) \ + PLATDIR=$(PLATDIR) PLUGINSRCDIR=$(PLUGINSRCDIR) VMSRCDIR=$(VMSRCDIR) \ + THIRDPARTYOUTDIR=$(THIRDPARTYOUTDIR) \ + COGDEFS="$(COGDEFS)" LIBNAME=$(*F) $(OBJDIR)/$(*F).dll + +############################################################################# +# Basic rules +# +include ../common/Makefile.rules + +$(VMRES): $(VM).rc + $(RC) $(RCFLAGS) -i $(VM).rc -o $(OBJDIR)/$@ + $(CP) $(VM).exe.manifest $(OBJDIR) + $(CP) $(VM).exe.manifest $(OBJDIR)/$(VM)Console.exe.manifest + +resource.o: $(VMRES) + $(RC) $(RCFLAGS) -i $(OBJDIR)/$< -o $(OBJDIR)/$@ + +############################################################################# +# Extra specific dependencies +# +sqNamedPrims.h: plugins.int mkNamedPrims.exe + ./mkNamedPrims.exe $(INTERNAL_PLUGINS) > sqNamedPrims.h + +$(OBJDIR)/sqNamedPrims.o: sqNamedPrims.c sqNamedPrims.h diff --git a/build.win32x86/newspeak.cog.spur/Makefile b/build.win32x86/newspeak.cog.spur/Makefile index 112138392b..fdbc5d370e 100644 --- a/build.win32x86/newspeak.cog.spur/Makefile +++ b/build.win32x86/newspeak.cog.spur/Makefile @@ -1,12 +1,18 @@ -############################################################################# -# Makefile for Win32 Cog Spur Newspeak VM using gcc-3.4.x and cygwin -# Do make init to allow make -n to function. -############################################################################# - -# The name of the VM to build -VM:=nsvm -VM_NAME:=Newspeak Virtual Machine - -VMSRCDIR:= ../../nsspursrc/vm - -include ../common/Makefile +############################################################################# +# Makefile for Win32 Cog Spur Newspeak VM using gcc-3.4.x and cygwin +# Do make init to allow make -n to function. +############################################################################# + +# The name of the VM to build +VM:=nsvm +VM_NAME:=Newspeak Virtual Machine + +VMSRCDIR:= ../../nsspursrc/vm + +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) +include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win32x86/newspeak.stack.spur/Makefile b/build.win32x86/newspeak.stack.spur/Makefile index f95df2741b..7981f1b662 100644 --- a/build.win32x86/newspeak.stack.spur/Makefile +++ b/build.win32x86/newspeak.stack.spur/Makefile @@ -1,12 +1,18 @@ -############################################################################# -# Makefile for Win32 Stack Spur Newspeak VM using gcc-3.4.x and cygwin -# Do make init to allow make -n to function. -############################################################################# - -# The name of the VM to build -VM:=nsvm -VM_NAME:=Newspeak Virtual Machine - -VMSRCDIR:= ../../nsspurstacksrc/vm - -include ../common/Makefile +############################################################################# +# Makefile for Win32 Stack Spur Newspeak VM using gcc-3.4.x and cygwin +# Do make init to allow make -n to function. +############################################################################# + +# The name of the VM to build +VM:=nsvm +VM_NAME:=Newspeak Virtual Machine + +VMSRCDIR:= ../../nsspurstacksrc/vm + +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) +include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win32x86/pharo.cog.spur/Makefile b/build.win32x86/pharo.cog.spur/Makefile index 2d40cde398..87f74957ae 100644 --- a/build.win32x86/pharo.cog.spur/Makefile +++ b/build.win32x86/pharo.cog.spur/Makefile @@ -1,32 +1,32 @@ -############################################################################# -# Makefile for Win32 Cog Spur PharoVM using gcc and cygwin -# Do make init to allow make -n to function. -############################################################################# - -VM:=Pharo -VM_NAME:=Pharo Virtual Machine - -VMSRCDIR:=../../spursrc/vm -COGDEFS:= -DPharoVM=1 - -THIRDPARTYLIBS:=pkgconfig openssl libssh2 libgit2 libsdl2 zlib libpng freetype2 pixman cairo libgcc - -include ../common/Makefile - -# third-party libraries -# -include ../third-party/Makefile.pkgconfig -include ../third-party/Makefile.freetype2 -include ../third-party/Makefile.openssl -include ../third-party/Makefile.libssh2 -include ../third-party/Makefile.libgit2 -include ../third-party/Makefile.libsdl2 -include ../third-party/Makefile.zlib -include ../third-party/Makefile.pixman -include ../third-party/Makefile.libpng -include ../third-party/Makefile.cairo -include ../third-party/Makefile.libgcc - -# Since SDLDisplayPlugin will be included as internal plugin, we need to add the library to the path -# add to the end to allow thirdparty vars to be defined. +############################################################################# +# Makefile for Win32 Cog Spur PharoVM using gcc and cygwin +# Do make init to allow make -n to function. +############################################################################# + +VM:=Pharo +VM_NAME:=Pharo Virtual Machine + +VMSRCDIR:=../../spursrc/vm +COGDEFS:= -DPharoVM=1 + +THIRDPARTYLIBS:=pkgconfig openssl libssh2 libgit2 libsdl2 zlib libpng freetype2 pixman cairo libgcc + +include ../common/Makefile + +# third-party libraries +# +include ../third-party/Makefile.pkgconfig +include ../third-party/Makefile.freetype2 +include ../third-party/Makefile.openssl +include ../third-party/Makefile.libssh2 +include ../third-party/Makefile.libgit2 +include ../third-party/Makefile.libsdl2 +include ../third-party/Makefile.zlib +include ../third-party/Makefile.pixman +include ../third-party/Makefile.libpng +include ../third-party/Makefile.cairo +include ../third-party/Makefile.libgcc + +# Since SDLDisplayPlugin will be included as internal plugin, we need to add the library to the path +# add to the end to allow thirdparty vars to be defined. STDLIBS+= -L$(THIRDPARTYOUTDIR)/lib -lSDL2 diff --git a/build.win32x86/pharo.sista.spur/Makefile b/build.win32x86/pharo.sista.spur/Makefile index 565ebc3c5a..5625ce502f 100644 --- a/build.win32x86/pharo.sista.spur/Makefile +++ b/build.win32x86/pharo.sista.spur/Makefile @@ -1,34 +1,34 @@ -############################################################################# -# Makefile for Win32 Cog Spur PharoVM using gcc and cygwin -# Do make init to allow make -n to function. -############################################################################# - -VM:=Pharo -VM_NAME:=Pharo Virtual Machine - -VMSRCDIR:=../../spursistasrc/vm -COGDEFS:= -DPharoVM=1 - -THIRDPARTYLIBS:=pkgconfig openssl libssh2 libgit2 libsdl2 zlib libpng freetype2 pixman cairo libgcc - -COMPILER_TO_USE:=clang - -include ../common/Makefile - -# third-party libraries -# -include ../third-party/Makefile.pkgconfig -include ../third-party/Makefile.freetype2 -include ../third-party/Makefile.openssl -include ../third-party/Makefile.libssh2 -include ../third-party/Makefile.libgit2 -include ../third-party/Makefile.libsdl2 -include ../third-party/Makefile.zlib -include ../third-party/Makefile.pixman -include ../third-party/Makefile.libpng -include ../third-party/Makefile.cairo -include ../third-party/Makefile.libgcc - -# Since SDLDisplayPlugin will be included as internal plugin, we need to add the library to the path -# add to the end to allow thirdparty vars to be defined. -STDLIBS+= -L$(THIRDPARTYOUTDIR)/lib -lSDL2 +############################################################################# +# Makefile for Win32 Cog Spur PharoVM using gcc and cygwin +# Do make init to allow make -n to function. +############################################################################# + +VM:=Pharo +VM_NAME:=Pharo Virtual Machine + +VMSRCDIR:=../../spursistasrc/vm +COGDEFS:= -DPharoVM=1 + +THIRDPARTYLIBS:=pkgconfig openssl libssh2 libgit2 libsdl2 zlib libpng freetype2 pixman cairo libgcc + +COMPILER_TO_USE:=clang + +include ../common/Makefile + +# third-party libraries +# +include ../third-party/Makefile.pkgconfig +include ../third-party/Makefile.freetype2 +include ../third-party/Makefile.openssl +include ../third-party/Makefile.libssh2 +include ../third-party/Makefile.libgit2 +include ../third-party/Makefile.libsdl2 +include ../third-party/Makefile.zlib +include ../third-party/Makefile.pixman +include ../third-party/Makefile.libpng +include ../third-party/Makefile.cairo +include ../third-party/Makefile.libgcc + +# Since SDLDisplayPlugin will be included as internal plugin, we need to add the library to the path +# add to the end to allow thirdparty vars to be defined. +STDLIBS+= -L$(THIRDPARTYOUTDIR)/lib -lSDL2 diff --git a/build.win32x86/pharo.stack.spur/Makefile b/build.win32x86/pharo.stack.spur/Makefile index 879f338014..e9c7d0c263 100644 --- a/build.win32x86/pharo.stack.spur/Makefile +++ b/build.win32x86/pharo.stack.spur/Makefile @@ -1,38 +1,38 @@ -############################################################################# -# Makefile for Win32 Stack Spur PharoVM using gcc and cygwin -# Do make init to allow make -n to function. -############################################################################# - -VM:=Pharo -VM_NAME:=Pharo Virtual Machine - -VMSRCDIR:=../../spurstacksrc/vm -# NOTES: -# STACK_ALIGN_BYTES=16 is needed in mingw and FFI (and I suppose on other modules too). -# ALLOCA_LIES_SO_USE_GETSP=0 Some compilers return the stack address+4 on alloca function, -# then FFI module needs to adjust that. It is NOT the case of mingw. -# For more information see this thread: http://forum.world.st/There-are-something-fishy-with-FFI-plugin-td4584226.html -#COGDEFS:= -DPharoVM=1 -DSTACK_ALIGN_BYTES=16 -DALLOCA_LIES_SO_USE_GETSP=0 -COGDEFS:= -DPharoVM=1 - -THIRDPARTYLIBS:=pkgconfig openssl libssh2 libgit2 libsdl2 zlib libpng freetype2 pixman cairo libgcc - -include ../common/Makefile - -# third-party libraries -# -include ../third-party/Makefile.pkgconfig -include ../third-party/Makefile.freetype2 -include ../third-party/Makefile.openssl -include ../third-party/Makefile.libssh2 -include ../third-party/Makefile.libgit2 -include ../third-party/Makefile.libsdl2 -include ../third-party/Makefile.zlib -include ../third-party/Makefile.pixman -include ../third-party/Makefile.libpng -include ../third-party/Makefile.cairo -include ../third-party/Makefile.libgcc - -# Since SDLDisplayPlugin will be included as internal plugin, we need to add the library to the path -# add to the end to allow thirdparty vars to be defined. +############################################################################# +# Makefile for Win32 Stack Spur PharoVM using gcc and cygwin +# Do make init to allow make -n to function. +############################################################################# + +VM:=Pharo +VM_NAME:=Pharo Virtual Machine + +VMSRCDIR:=../../spurstacksrc/vm +# NOTES: +# STACK_ALIGN_BYTES=16 is needed in mingw and FFI (and I suppose on other modules too). +# ALLOCA_LIES_SO_USE_GETSP=0 Some compilers return the stack address+4 on alloca function, +# then FFI module needs to adjust that. It is NOT the case of mingw. +# For more information see this thread: http://forum.world.st/There-are-something-fishy-with-FFI-plugin-td4584226.html +#COGDEFS:= -DPharoVM=1 -DSTACK_ALIGN_BYTES=16 -DALLOCA_LIES_SO_USE_GETSP=0 +COGDEFS:= -DPharoVM=1 + +THIRDPARTYLIBS:=pkgconfig openssl libssh2 libgit2 libsdl2 zlib libpng freetype2 pixman cairo libgcc + +include ../common/Makefile + +# third-party libraries +# +include ../third-party/Makefile.pkgconfig +include ../third-party/Makefile.freetype2 +include ../third-party/Makefile.openssl +include ../third-party/Makefile.libssh2 +include ../third-party/Makefile.libgit2 +include ../third-party/Makefile.libsdl2 +include ../third-party/Makefile.zlib +include ../third-party/Makefile.pixman +include ../third-party/Makefile.libpng +include ../third-party/Makefile.cairo +include ../third-party/Makefile.libgcc + +# Since SDLDisplayPlugin will be included as internal plugin, we need to add the library to the path +# add to the end to allow thirdparty vars to be defined. STDLIBS+= -L$(THIRDPARTYOUTDIR)/lib -lSDL2 diff --git a/build.win32x86/squeak.cog.spur.lowcode/Makefile b/build.win32x86/squeak.cog.spur.lowcode/Makefile index 5cfe997175..adf17bd707 100644 --- a/build.win32x86/squeak.cog.spur.lowcode/Makefile +++ b/build.win32x86/squeak.cog.spur.lowcode/Makefile @@ -9,4 +9,10 @@ VMSRCDIR:=../../spurlowcodesrc/vm COGDEFS:= COMPILER_TO_USE:=clang +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win32x86/squeak.cog.spur/Makefile b/build.win32x86/squeak.cog.spur/Makefile index f674626dc4..7a0c37851c 100644 --- a/build.win32x86/squeak.cog.spur/Makefile +++ b/build.win32x86/squeak.cog.spur/Makefile @@ -1,9 +1,15 @@ -############################################################################# -# Makefile for Win32 Cog Spur Squeak VM using gcc-3.4.x and cygwin -# Do make init to allow make -n to function. -############################################################################# - -VM:=Squeak -VMSRCDIR:=../../spursrc/vm - -include ../common/Makefile +############################################################################# +# Makefile for Win32 Cog Spur Squeak VM using gcc-3.4.x and cygwin +# Do make init to allow make -n to function. +############################################################################# + +VM:=Squeak +VMSRCDIR:=../../spursrc/vm + +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) +include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win32x86/squeak.cog.v3/Makefile b/build.win32x86/squeak.cog.v3/Makefile index f8e525c3f6..4302af462f 100644 --- a/build.win32x86/squeak.cog.v3/Makefile +++ b/build.win32x86/squeak.cog.v3/Makefile @@ -1,9 +1,15 @@ -############################################################################# -# Makefile for Win32 Cog Squeak VM using gcc-3.4.x and cygwin -# Do make init to allow make -n to function. -############################################################################# - -VM:=Squeak -VMSRCDIR:=../../src/vm - -include ../common/Makefile +############################################################################# +# Makefile for Win32 Cog Squeak VM using gcc-3.4.x and cygwin +# Do make init to allow make -n to function. +############################################################################# + +VM:=Squeak +VMSRCDIR:=../../src/vm + +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) +include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win32x86/squeak.sista.spur/Makefile b/build.win32x86/squeak.sista.spur/Makefile index d342d6ffb5..924b2ce9ec 100644 --- a/build.win32x86/squeak.sista.spur/Makefile +++ b/build.win32x86/squeak.sista.spur/Makefile @@ -1,11 +1,17 @@ -############################################################################# -# Makefile for Win32 Cog Spur Squeak VM using gcc-3.4.x and cygwin -# Do make init to allow make -n to function. -############################################################################# - -VM:=Squeak -VMSRCDIR:=../../spursistasrc/vm - -COMPILER_TO_USE:=clang - -include ../common/Makefile +############################################################################# +# Makefile for Win32 Cog Spur Squeak VM using gcc-3.4.x and cygwin +# Do make init to allow make -n to function. +############################################################################# + +VM:=Squeak +VMSRCDIR:=../../spursistasrc/vm + +COMPILER_TO_USE:=clang + +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) +include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win32x86/squeak.stack.spur/Makefile b/build.win32x86/squeak.stack.spur/Makefile index 080985c241..9743c17847 100644 --- a/build.win32x86/squeak.stack.spur/Makefile +++ b/build.win32x86/squeak.stack.spur/Makefile @@ -1,9 +1,15 @@ -############################################################################# -# Makefile for Win32 Stack Spur Squeak VM using gcc-3.4.x and cygwin -# Do make init to allow make -n to function. -############################################################################# - -VM:=Squeak -VMSRCDIR:=../../spurstacksrc/vm - -include ../common/Makefile +############################################################################# +# Makefile for Win32 Stack Spur Squeak VM using gcc-3.4.x and cygwin +# Do make init to allow make -n to function. +############################################################################# + +VM:=Squeak +VMSRCDIR:=../../spurstacksrc/vm + +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) +include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win32x86/squeak.stack.v3/Makefile b/build.win32x86/squeak.stack.v3/Makefile index aa67ab32c5..e82276c149 100644 --- a/build.win32x86/squeak.stack.v3/Makefile +++ b/build.win32x86/squeak.stack.v3/Makefile @@ -1,9 +1,15 @@ -############################################################################# -# Makefile for Win32 Stack Squeak VM using gcc-3.4.x and cygwin -# Do make init to allow make -n to function. -############################################################################# - -VM:=Squeak -VMSRCDIR:=../../stacksrc/vm - -include ../common/Makefile +############################################################################# +# Makefile for Win32 Stack Squeak VM using gcc-3.4.x and cygwin +# Do make init to allow make -n to function. +############################################################################# + +VM:=Squeak +VMSRCDIR:=../../stacksrc/vm + +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) +include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win64x64/newspeak.cog.spur/Makefile b/build.win64x64/newspeak.cog.spur/Makefile index a264fa12eb..8ca34c7758 100644 --- a/build.win64x64/newspeak.cog.spur/Makefile +++ b/build.win64x64/newspeak.cog.spur/Makefile @@ -9,4 +9,10 @@ VM_NAME:=Newspeak Virtual Machine VMSRCDIR:= ../../nsspur64src/vm +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win64x64/newspeak.stack.spur/Makefile b/build.win64x64/newspeak.stack.spur/Makefile index 7209991334..fd701e93f2 100644 --- a/build.win64x64/newspeak.stack.spur/Makefile +++ b/build.win64x64/newspeak.stack.spur/Makefile @@ -9,4 +9,10 @@ VM_NAME:=Newspeak Virtual Machine VMSRCDIR:= ../../nsspurstack64src/vm +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win64x64/squeak.cog.spur/Makefile b/build.win64x64/squeak.cog.spur/Makefile index 909f7145b1..2b4d0dc3a5 100644 --- a/build.win64x64/squeak.cog.spur/Makefile +++ b/build.win64x64/squeak.cog.spur/Makefile @@ -6,4 +6,10 @@ VM:=Squeak VMSRCDIR:=../../spur64src/vm +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/build.win64x64/squeak.stack.spur/Makefile b/build.win64x64/squeak.stack.spur/Makefile index e24553c140..087ded7ed5 100644 --- a/build.win64x64/squeak.stack.spur/Makefile +++ b/build.win64x64/squeak.stack.spur/Makefile @@ -6,4 +6,10 @@ VM:=Squeak VMSRCDIR:=../../spurstack64src/vm +# This variable is set by VS Native Tools Command Prompts, not for cygwin wins +VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) +ifeq ($(VSCMD_ARG_HOST_ARCH),) include ../common/Makefile +else +include ../common/Makefile.msvc +endif diff --git a/nsspur64src/vm/cogit.h b/nsspur64src/vm/cogit.h index 15b2d419ac..ad41160c05 100644 --- a/nsspur64src/vm/cogit.h +++ b/nsspur64src/vm/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ diff --git a/nsspur64src/vm/cogitX64SysV.c b/nsspur64src/vm/cogitX64SysV.c index 89cce02892..ccf07d6df5 100644 --- a/nsspur64src/vm/cogitX64SysV.c +++ b/nsspur64src/vm/cogitX64SysV.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -538,7 +538,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallNewspeakSend(sqInt callTarget); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); @@ -3809,39 +3808,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1ULL << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallNewspeakSend: */ static AbstractInstruction * NoDbgRegParms CallNewspeakSend(sqInt callTarget) @@ -7813,7 +7779,15 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address1; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction11; + AbstractInstruction *anInstruction2; + AbstractInstruction *anInstruction21; + AbstractInstruction *anInstruction31; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction41; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -7829,7 +7803,61 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l25; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction11 = genoperandoperand(MoveCqR, -2 - null, RDI); + } + else { + if (null != RDI) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDI); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction21 = genoperandoperand(MoveCqR, -2 - null, RSI); + } + else { + if (null != RSI) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RSI); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction31 = genoperandoperand(MoveCqR, -2 - null, RDX); + } + else { + if (null != RDX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction41 = genoperandoperand(MoveCqR, -2 - null, RCX); + } + else { + if (null != RCX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RCX); + } + } + assert(0 <= 4); + ((AbstractInstruction *) backEnd); + l25: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction2 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin PushR: */ + genoperand(PushR, ABIResultReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/nsspur64src/vm/cogitX64WIN64.c b/nsspur64src/vm/cogitX64WIN64.c index c54b1189ab..21ca650551 100644 --- a/nsspur64src/vm/cogitX64WIN64.c +++ b/nsspur64src/vm/cogitX64WIN64.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -538,7 +538,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallNewspeakSend(sqInt callTarget); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); @@ -3809,39 +3808,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1ULL << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallNewspeakSend: */ static AbstractInstruction * NoDbgRegParms CallNewspeakSend(sqInt callTarget) @@ -7821,7 +7787,16 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address1; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction2; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction5; + AbstractInstruction *anInstruction6; + AbstractInstruction *anInstruction7; + AbstractInstruction *anInstruction8; + AbstractInstruction *anInstruction9; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -7837,7 +7812,65 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + + /* WIN64 ABI allways reserve shadow space on the stack for callee to save up to 4 register parameters */ + /* begin checkQuickConstant:forInstruction: */ + anInstruction9 = genoperandoperand(SubCqR, 32, RSP); + ((AbstractInstruction *) backEnd); + goto l25; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction5 = genoperandoperand(MoveCqR, -2 - null, RCX); + } + else { + if (null != RCX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RCX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction6 = genoperandoperand(MoveCqR, -2 - null, RDX); + } + else { + if (null != RDX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction7 = genoperandoperand(MoveCqR, -2 - null, R8); + } + else { + if (null != R8) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, R8); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction8 = genoperandoperand(MoveCqR, -2 - null, R9); + } + else { + if (null != R9) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, R9); + } + } + assert(0 <= 4); + ((AbstractInstruction *) backEnd); + l25: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction2 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin PushR: */ + genoperand(PushR, ABIResultReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/nsspur64src/vm/cointerp.c b/nsspur64src/vm/cointerp.c index d6e4ec2920..1f60ec4433 100644 --- a/nsspur64src/vm/cointerp.c +++ b/nsspur64src/vm/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -529,6 +529,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1280,7 +1281,7 @@ extern sqInt nonIndexablePointerFormat(void); static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1775,6 +1776,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2639,7 +2641,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Newspeak Virtual Machine [ Open Smalltalk, Spur] CoInterpreterPrimitives_VMMaker.oscog-eem.2736"; +const char *interpreterVersion = "Newspeak Virtual Machine [ Open Smalltalk, Spur] CoInterpreterPrimitives_VMMaker.oscog-eem.2737"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2772,17 +2774,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2814,6 +2833,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -15470,7 +15492,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15861,7 +15882,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -17243,7 +17263,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -18252,6 +18271,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -48972,7 +48998,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - sqInt numMediatedSlots; + usqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -55480,7 +55506,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -sqInt +usqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -58723,7 +58749,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l10: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l11; } /* begin numSlotsOf: */ @@ -58755,7 +58781,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l11: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -58809,7 +58835,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l12: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l13; } /* begin numSlotsOf: */ @@ -58841,7 +58867,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l13: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -58896,7 +58922,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop11))); contextSize = (sp >> 3); l14: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l15; } /* begin numSlotsOf: */ @@ -58928,7 +58954,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l15: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -62061,10 +62087,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - sqInt numPointerSlots; - sqInt numPointerSlots1; - sqInt numPointerSlots2; - sqInt numPointerSlots3; + usqInt numPointerSlots; + usqInt numPointerSlots1; + usqInt numPointerSlots2; + usqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -67219,8 +67245,8 @@ static sqInt getErrorObjectFromPrimFailCode(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt classIndex; - sqInt clone; - sqInt errObj; + usqInt clone; + usqInt errObj; sqInt fieldIndex; sqInt i; usqInt newObj; diff --git a/nsspur64src/vm/cointerp.h b/nsspur64src/vm/cointerp.h index e60769a20e..86a07bbd55 100644 --- a/nsspur64src/vm/cointerp.h +++ b/nsspur64src/vm/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -63,6 +63,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); @@ -250,7 +251,7 @@ extern sqInt minSlotsForShortening(void); extern sqInt nilObject(void); extern sqInt nonIndexablePointerFormat(void); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); extern sqInt numStrongSlotsOfWeakling(sqInt objOop); extern sqInt objectAfter(sqInt objOop); diff --git a/nsspur64src/vm/gcc3x-cointerp.c b/nsspur64src/vm/gcc3x-cointerp.c index 22fa5740c2..734f25bf3b 100644 --- a/nsspur64src/vm/gcc3x-cointerp.c +++ b/nsspur64src/vm/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -532,6 +532,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1283,7 +1284,7 @@ extern sqInt nonIndexablePointerFormat(void); static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1778,6 +1779,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2642,7 +2644,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Newspeak Virtual Machine [ Open Smalltalk, Spur] CoInterpreterPrimitives_VMMaker.oscog-eem.2736"; +const char *interpreterVersion = "Newspeak Virtual Machine [ Open Smalltalk, Spur] CoInterpreterPrimitives_VMMaker.oscog-eem.2737"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2775,17 +2777,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2823,6 +2842,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -15479,7 +15501,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15870,7 +15891,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -17252,7 +17272,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -18261,6 +18280,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -48981,7 +49007,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - sqInt numMediatedSlots; + usqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -55489,7 +55515,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -sqInt +usqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -58732,7 +58758,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l10: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l11; } /* begin numSlotsOf: */ @@ -58764,7 +58790,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l11: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -58818,7 +58844,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l12: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l13; } /* begin numSlotsOf: */ @@ -58850,7 +58876,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l13: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -58905,7 +58931,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop11))); contextSize = (sp >> 3); l14: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l15; } /* begin numSlotsOf: */ @@ -58937,7 +58963,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l15: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -62070,10 +62096,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - sqInt numPointerSlots; - sqInt numPointerSlots1; - sqInt numPointerSlots2; - sqInt numPointerSlots3; + usqInt numPointerSlots; + usqInt numPointerSlots1; + usqInt numPointerSlots2; + usqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -67228,8 +67254,8 @@ static sqInt getErrorObjectFromPrimFailCode(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt classIndex; - sqInt clone; - sqInt errObj; + usqInt clone; + usqInt errObj; sqInt fieldIndex; sqInt i; usqInt newObj; diff --git a/nsspursrc/vm/cogit.h b/nsspursrc/vm/cogit.h index 15b2d419ac..ad41160c05 100644 --- a/nsspursrc/vm/cogit.h +++ b/nsspursrc/vm/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ diff --git a/nsspursrc/vm/cogitARMv5.c b/nsspursrc/vm/cogitARMv5.c index c5a06a3435..711e626c08 100644 --- a/nsspursrc/vm/cogitARMv5.c +++ b/nsspursrc/vm/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -12370,7 +12370,9 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + sqInt jumpTarget; sqInt quickConstant; usqInt startAddress; @@ -12389,7 +12391,15 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + genMarshallNArgsargargargarg(backEnd, 0, null, null, null, null); + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin gen:literal:operand: */ + checkLiteralforInstruction(address, genoperandoperand(MoveAwR, address, LinkReg)); + /* begin JumpFull: */ + jumpTarget = ((usqInt)interpret); + /* begin gen:literal: */ + checkLiteralforInstruction(((sqInt)jumpTarget), genoperand(JumpFull, ((sqInt)jumpTarget))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/nsspursrc/vm/cogitIA32.c b/nsspursrc/vm/cogitIA32.c index e1ef55347f..3f43b6e27e 100644 --- a/nsspursrc/vm/cogitIA32.c +++ b/nsspursrc/vm/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -589,7 +589,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallNewspeakSend(sqInt callTarget); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); @@ -8125,42 +8124,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *abstractInstruction; - AbstractInstruction *anInstruction; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin annotateCall: */ - anInstruction = genoperand(CallFull, callTarget); - abstractInstruction = anInstruction; - (abstractInstruction->annotation = IsRelativeCall); - lastInst = abstractInstruction; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallNewspeakSend: */ static AbstractInstruction * NoDbgRegParms CallNewspeakSend(sqInt callTarget) @@ -12081,6 +12044,13 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + AbstractInstruction *abstractInstruction; + sqInt address1; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction6; + AbstractInstruction *anInstruction7; + sqInt literal3; + sqInt literal4; usqInt startAddress; startAddress = methodZoneBase; @@ -12091,7 +12061,30 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l3; + if (null < NoReg) { + /* begin checkQuickConstant:forInstruction: */ + literal3 = -2 - null; + anInstruction4 = genoperand(PushCq, -2 - null); + } + else { + genoperand(PushR, null); + } + ((AbstractInstruction *) backEnd); + l3: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction6 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin genSubstituteReturnAddressR: */ + genoperand(PushR, ABIResultReg); + /* begin annotateCall: */ + literal4 = ((sqInt)(((usqInt)interpret))); + anInstruction7 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); + abstractInstruction = anInstruction7; + (abstractInstruction->annotation = IsRelativeCall); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/nsspursrc/vm/cogitMIPSEL.c b/nsspursrc/vm/cogitMIPSEL.c index 484fd1c48e..25fac5c827 100644 --- a/nsspursrc/vm/cogitMIPSEL.c +++ b/nsspursrc/vm/cogitMIPSEL.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -539,7 +539,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallNewspeakSend(sqInt callTarget); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); @@ -3689,39 +3688,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallNewspeakSend: */ static AbstractInstruction * NoDbgRegParms CallNewspeakSend(sqInt callTarget) @@ -6065,7 +6031,7 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, static sqInt NoDbgRegParms cPICCompactAndIsNowEmpty(CogMethod *cPIC) { - usqInt entryPoint; + sqInt entryPoint; sqInt followingAddress; sqInt i; sqInt methods[MaxCPICCases]; @@ -6166,7 +6132,7 @@ cPICHasForwardedClass(CogMethod *cPIC) static sqInt NoDbgRegParms cPICHasFreedTargets(CogMethod *cPIC) { - sqInt entryPoint; + usqInt entryPoint; sqInt i; sqInt pc; CogMethod *targetMethod; @@ -7673,7 +7639,15 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction1; + AbstractInstruction *anInstruction11; + AbstractInstruction *anInstruction21; + AbstractInstruction *anInstruction31; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction5; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -7689,7 +7663,50 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l16; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction5 = genoperandoperand(MoveCqR, -2 - null, A0); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A0); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction11 = genoperandoperand(MoveCqR, -2 - null, A1); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A1); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction21 = genoperandoperand(MoveCqR, -2 - null, A2); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A2); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction31 = genoperandoperand(MoveCqR, -2 - null, A3); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A3); + } + ((AbstractInstruction *) backEnd); + l16: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction1 = genoperandoperand(MoveAwR, address, LinkReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/nsspursrc/vm/cointerp.c b/nsspursrc/vm/cointerp.c index 73b331a176..5a17d3f7a3 100644 --- a/nsspursrc/vm/cointerp.c +++ b/nsspursrc/vm/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -528,6 +528,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1751,6 +1752,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2618,7 +2620,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Newspeak Virtual Machine [ Open Smalltalk, Spur] CoInterpreterPrimitives_VMMaker.oscog-eem.2736"; +const char *interpreterVersion = "Newspeak Virtual Machine [ Open Smalltalk, Spur] CoInterpreterPrimitives_VMMaker.oscog-eem.2737"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2744,17 +2746,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2786,6 +2805,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -15249,7 +15271,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15642,7 +15663,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -17042,7 +17062,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -18059,6 +18078,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -61725,7 +61751,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l5: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l9; } /* begin numSlotsOf: */ @@ -61755,7 +61781,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l9: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -66331,8 +66357,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; diff --git a/nsspursrc/vm/cointerp.h b/nsspursrc/vm/cointerp.h index 819de02c86..5ca3241533 100644 --- a/nsspursrc/vm/cointerp.h +++ b/nsspursrc/vm/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -63,6 +63,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); diff --git a/nsspursrc/vm/gcc3x-cointerp.c b/nsspursrc/vm/gcc3x-cointerp.c index 2eb7441ab5..d54f8ac804 100644 --- a/nsspursrc/vm/gcc3x-cointerp.c +++ b/nsspursrc/vm/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -531,6 +531,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1754,6 +1755,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2621,7 +2623,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Newspeak Virtual Machine [ Open Smalltalk, Spur] CoInterpreterPrimitives_VMMaker.oscog-eem.2736"; +const char *interpreterVersion = "Newspeak Virtual Machine [ Open Smalltalk, Spur] CoInterpreterPrimitives_VMMaker.oscog-eem.2737"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2747,17 +2749,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2795,6 +2814,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -15258,7 +15280,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15651,7 +15672,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -17051,7 +17071,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -18068,6 +18087,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -61734,7 +61760,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l5: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l9; } /* begin numSlotsOf: */ @@ -61764,7 +61790,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l9: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -66340,8 +66366,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; diff --git a/platforms/Cross/vm/sq.h b/platforms/Cross/vm/sq.h index 5d894dd622..6e85102700 100644 --- a/platforms/Cross/vm/sq.h +++ b/platforms/Cross/vm/sq.h @@ -226,6 +226,22 @@ sqInt sqGetFilenameFromString(char * aCharBuffer, char * aFilenameString, sqInt #include "sqPlatformSpecific.h" +/* getReturnAddress optionally defined here rather than in sqPlatformSpecific.h + * to reduce duplication. The GCC intrinics are provided by other compilers too. + */ +#if COGVM && !defined(getReturnAddress) +# if _MSVC +# define getReturnAddress() _ReturnAddress() +# include +# pragma intrinsic(_ReturnAddress) +# elif defined(__GNUC__) /* gcc, clang, icc etc */ +# define getReturnAddress() __builtin_extract_return_addr(__builtin_return_address(0)) +# else +# error "Cog requires getReturnAddress defining for the current platform." +# endif +#endif /* COG && !defined(getReturnAddress */ + + /* Interpreter entry points. */ /* Disable Intel compiler inlining of error which is used for breakpoints */ diff --git a/spur64src/vm/cogit.h b/spur64src/vm/cogit.h index 0935d46968..fb4b4da56e 100644 --- a/spur64src/vm/cogit.h +++ b/spur64src/vm/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ diff --git a/spur64src/vm/cogitX64SysV.c b/spur64src/vm/cogitX64SysV.c index 26ba62c6fb..f2d7db442f 100644 --- a/spur64src/vm/cogitX64SysV.c +++ b/spur64src/vm/cogitX64SysV.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -535,7 +535,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -3786,39 +3785,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1ULL << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -7771,7 +7737,15 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address1; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction11; + AbstractInstruction *anInstruction2; + AbstractInstruction *anInstruction21; + AbstractInstruction *anInstruction31; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction41; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -7787,7 +7761,61 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l25; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction11 = genoperandoperand(MoveCqR, -2 - null, RDI); + } + else { + if (null != RDI) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDI); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction21 = genoperandoperand(MoveCqR, -2 - null, RSI); + } + else { + if (null != RSI) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RSI); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction31 = genoperandoperand(MoveCqR, -2 - null, RDX); + } + else { + if (null != RDX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction41 = genoperandoperand(MoveCqR, -2 - null, RCX); + } + else { + if (null != RCX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RCX); + } + } + assert(0 <= 4); + ((AbstractInstruction *) backEnd); + l25: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction2 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin PushR: */ + genoperand(PushR, ABIResultReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spur64src/vm/cogitX64WIN64.c b/spur64src/vm/cogitX64WIN64.c index 364d3775ff..36fa6c5ae9 100644 --- a/spur64src/vm/cogitX64WIN64.c +++ b/spur64src/vm/cogitX64WIN64.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -535,7 +535,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -3786,39 +3785,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1ULL << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -7779,7 +7745,16 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address1; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction2; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction5; + AbstractInstruction *anInstruction6; + AbstractInstruction *anInstruction7; + AbstractInstruction *anInstruction8; + AbstractInstruction *anInstruction9; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -7795,7 +7770,65 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + + /* WIN64 ABI allways reserve shadow space on the stack for callee to save up to 4 register parameters */ + /* begin checkQuickConstant:forInstruction: */ + anInstruction9 = genoperandoperand(SubCqR, 32, RSP); + ((AbstractInstruction *) backEnd); + goto l25; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction5 = genoperandoperand(MoveCqR, -2 - null, RCX); + } + else { + if (null != RCX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RCX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction6 = genoperandoperand(MoveCqR, -2 - null, RDX); + } + else { + if (null != RDX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction7 = genoperandoperand(MoveCqR, -2 - null, R8); + } + else { + if (null != R8) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, R8); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction8 = genoperandoperand(MoveCqR, -2 - null, R9); + } + else { + if (null != R9) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, R9); + } + } + assert(0 <= 4); + ((AbstractInstruction *) backEnd); + l25: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction2 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin PushR: */ + genoperand(PushR, ABIResultReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spur64src/vm/cointerp.c b/spur64src/vm/cointerp.c index c53b035330..1f2f3ec723 100644 --- a/spur64src/vm/cointerp.c +++ b/spur64src/vm/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -513,6 +513,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1263,7 +1264,7 @@ extern sqInt nonIndexablePointerFormat(void); static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1749,6 +1750,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2609,7 +2611,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2742,17 +2744,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2785,6 +2804,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -14030,7 +14052,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14245,7 +14266,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15055,7 +15075,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16068,6 +16087,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -47184,7 +47210,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - usqInt numMediatedSlots; + sqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -53692,7 +53718,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -usqInt +sqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -56935,7 +56961,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l10: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l11; } /* begin numSlotsOf: */ @@ -56967,7 +56993,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l11: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -57021,7 +57047,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l12: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l13; } /* begin numSlotsOf: */ @@ -57053,7 +57079,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l13: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -57108,7 +57134,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop11))); contextSize = (sp >> 3); l14: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l15; } /* begin numSlotsOf: */ @@ -57140,7 +57166,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l15: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -60270,10 +60296,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - usqInt numPointerSlots; - usqInt numPointerSlots1; - usqInt numPointerSlots2; - usqInt numPointerSlots3; + sqInt numPointerSlots; + sqInt numPointerSlots1; + sqInt numPointerSlots2; + sqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; diff --git a/spur64src/vm/cointerp.h b/spur64src/vm/cointerp.h index 14b1b33fd3..7763ac1baf 100644 --- a/spur64src/vm/cointerp.h +++ b/spur64src/vm/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -58,6 +58,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); @@ -245,7 +246,7 @@ extern sqInt minSlotsForShortening(void); extern sqInt nilObject(void); extern sqInt nonIndexablePointerFormat(void); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); extern sqInt numStrongSlotsOfWeakling(sqInt objOop); extern sqInt objectAfter(sqInt objOop); diff --git a/spur64src/vm/cointerpmt.c b/spur64src/vm/cointerpmt.c index 35710c385c..706bd003a9 100644 --- a/spur64src/vm/cointerpmt.c +++ b/spur64src/vm/cointerpmt.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -570,6 +570,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms divorceAMachineCodeFrameWithCogMethodin(CogMethod *cogMethod, StackPage *aStackPage); @@ -1344,7 +1345,7 @@ extern sqInt nonIndexablePointerFormat(void); static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1825,6 +1826,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2703,7 +2705,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2837,17 +2839,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2880,6 +2899,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -14504,7 +14526,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14719,7 +14740,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15529,7 +15549,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16542,6 +16561,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -49624,7 +49650,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - usqInt numMediatedSlots; + sqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -56147,7 +56173,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -usqInt +sqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -59390,7 +59416,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l10: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l11; } /* begin numSlotsOf: */ @@ -59422,7 +59448,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l11: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59476,7 +59502,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l12: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l13; } /* begin numSlotsOf: */ @@ -59508,7 +59534,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l13: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59563,7 +59589,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop11))); contextSize = (sp >> 3); l14: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l15; } /* begin numSlotsOf: */ @@ -59595,7 +59621,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l15: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -62732,10 +62758,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - usqInt numPointerSlots; - usqInt numPointerSlots1; - usqInt numPointerSlots2; - usqInt numPointerSlots3; + sqInt numPointerSlots; + sqInt numPointerSlots1; + sqInt numPointerSlots2; + sqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -63301,7 +63327,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l7: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l8; } /* begin numSlotsOf: */ @@ -63330,7 +63356,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) l5: /* end methodHeaderFromSavedFirstField: */; assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l8: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { diff --git a/spur64src/vm/cointerpmt.h b/spur64src/vm/cointerpmt.h index fa466a577c..6577413221 100644 --- a/spur64src/vm/cointerpmt.h +++ b/spur64src/vm/cointerpmt.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -60,6 +60,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); @@ -249,7 +250,7 @@ extern sqInt minSlotsForShortening(void); extern sqInt nilObject(void); extern sqInt nonIndexablePointerFormat(void); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); extern sqInt numStrongSlotsOfWeakling(sqInt objOop); extern sqInt objectAfter(sqInt objOop); diff --git a/spur64src/vm/gcc3x-cointerp.c b/spur64src/vm/gcc3x-cointerp.c index a2dcadf585..b1cf8366da 100644 --- a/spur64src/vm/gcc3x-cointerp.c +++ b/spur64src/vm/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -516,6 +516,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1266,7 +1267,7 @@ extern sqInt nonIndexablePointerFormat(void); static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1752,6 +1753,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2612,7 +2614,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2745,17 +2747,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2794,6 +2813,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -14039,7 +14061,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14254,7 +14275,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15064,7 +15084,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16077,6 +16096,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -47193,7 +47219,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - usqInt numMediatedSlots; + sqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -53701,7 +53727,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -usqInt +sqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -56944,7 +56970,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l10: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l11; } /* begin numSlotsOf: */ @@ -56976,7 +57002,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l11: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -57030,7 +57056,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l12: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l13; } /* begin numSlotsOf: */ @@ -57062,7 +57088,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l13: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -57117,7 +57143,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop11))); contextSize = (sp >> 3); l14: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l15; } /* begin numSlotsOf: */ @@ -57149,7 +57175,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l15: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -60279,10 +60305,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - usqInt numPointerSlots; - usqInt numPointerSlots1; - usqInt numPointerSlots2; - usqInt numPointerSlots3; + sqInt numPointerSlots; + sqInt numPointerSlots1; + sqInt numPointerSlots2; + sqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; diff --git a/spur64src/vm/gcc3x-cointerpmt.c b/spur64src/vm/gcc3x-cointerpmt.c index d121d62be9..fb6522054d 100644 --- a/spur64src/vm/gcc3x-cointerpmt.c +++ b/spur64src/vm/gcc3x-cointerpmt.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -573,6 +573,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms divorceAMachineCodeFrameWithCogMethodin(CogMethod *cogMethod, StackPage *aStackPage); @@ -1347,7 +1348,7 @@ extern sqInt nonIndexablePointerFormat(void); static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1828,6 +1829,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2706,7 +2708,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2840,17 +2842,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2889,6 +2908,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -14513,7 +14535,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14728,7 +14749,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15538,7 +15558,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16551,6 +16570,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -49633,7 +49659,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - usqInt numMediatedSlots; + sqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -56156,7 +56182,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -usqInt +sqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -59399,7 +59425,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l10: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l11; } /* begin numSlotsOf: */ @@ -59431,7 +59457,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l11: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59485,7 +59511,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l12: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l13; } /* begin numSlotsOf: */ @@ -59517,7 +59543,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l13: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59572,7 +59598,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop11))); contextSize = (sp >> 3); l14: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l15; } /* begin numSlotsOf: */ @@ -59604,7 +59630,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l15: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -62741,10 +62767,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - usqInt numPointerSlots; - usqInt numPointerSlots1; - usqInt numPointerSlots2; - usqInt numPointerSlots3; + sqInt numPointerSlots; + sqInt numPointerSlots1; + sqInt numPointerSlots2; + sqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -63310,7 +63336,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l7: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l8; } /* begin numSlotsOf: */ @@ -63339,7 +63365,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) l5: /* end methodHeaderFromSavedFirstField: */; assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l8: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { diff --git a/spurlowcode64src/vm/cogit.h b/spurlowcode64src/vm/cogit.h index e04553ad6f..86c5b9e55c 100644 --- a/spurlowcode64src/vm/cogit.h +++ b/spurlowcode64src/vm/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ diff --git a/spurlowcode64src/vm/cogitX64SysV.c b/spurlowcode64src/vm/cogitX64SysV.c index 39a413c67e..63f1f6a39b 100644 --- a/spurlowcode64src/vm/cogitX64SysV.c +++ b/spurlowcode64src/vm/cogitX64SysV.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -574,7 +574,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -3957,39 +3956,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1ULL << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -8458,7 +8424,15 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address1; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction11; + AbstractInstruction *anInstruction2; + AbstractInstruction *anInstruction21; + AbstractInstruction *anInstruction31; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction41; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -8474,7 +8448,61 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l25; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction11 = genoperandoperand(MoveCqR, -2 - null, RDI); + } + else { + if (null != RDI) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDI); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction21 = genoperandoperand(MoveCqR, -2 - null, RSI); + } + else { + if (null != RSI) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RSI); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction31 = genoperandoperand(MoveCqR, -2 - null, RDX); + } + else { + if (null != RDX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction41 = genoperandoperand(MoveCqR, -2 - null, RCX); + } + else { + if (null != RCX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RCX); + } + } + assert(0 <= 4); + ((AbstractInstruction *) backEnd); + l25: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction2 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin PushR: */ + genoperand(PushR, ABIResultReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spurlowcode64src/vm/cogitX64WIN64.c b/spurlowcode64src/vm/cogitX64WIN64.c index c06b50062d..5c6c34081c 100644 --- a/spurlowcode64src/vm/cogitX64WIN64.c +++ b/spurlowcode64src/vm/cogitX64WIN64.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -574,7 +574,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -3957,39 +3956,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1ULL << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -8490,7 +8456,16 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address1; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction2; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction5; + AbstractInstruction *anInstruction6; + AbstractInstruction *anInstruction7; + AbstractInstruction *anInstruction8; + AbstractInstruction *anInstruction9; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -8506,7 +8481,65 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + + /* WIN64 ABI allways reserve shadow space on the stack for callee to save up to 4 register parameters */ + /* begin checkQuickConstant:forInstruction: */ + anInstruction9 = genoperandoperand(SubCqR, 32, RSP); + ((AbstractInstruction *) backEnd); + goto l25; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction5 = genoperandoperand(MoveCqR, -2 - null, RCX); + } + else { + if (null != RCX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RCX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction6 = genoperandoperand(MoveCqR, -2 - null, RDX); + } + else { + if (null != RDX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction7 = genoperandoperand(MoveCqR, -2 - null, R8); + } + else { + if (null != R8) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, R8); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction8 = genoperandoperand(MoveCqR, -2 - null, R9); + } + else { + if (null != R9) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, R9); + } + } + assert(0 <= 4); + ((AbstractInstruction *) backEnd); + l25: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction2 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin PushR: */ + genoperand(PushR, ABIResultReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spurlowcode64src/vm/cointerp.c b/spurlowcode64src/vm/cointerp.c index e3accac864..20172e0de9 100644 --- a/spurlowcode64src/vm/cointerp.c +++ b/spurlowcode64src/vm/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -517,6 +517,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1773,6 +1774,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2635,7 +2637,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2768,17 +2770,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2813,6 +2832,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -33618,7 +33640,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -33833,7 +33854,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -34645,7 +34665,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -35699,6 +35718,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -80643,7 +80669,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l7: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l8; } /* begin numSlotsOf: */ @@ -80672,7 +80698,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) l5: /* end methodHeaderFromSavedFirstField: */; assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l8: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -85058,8 +85084,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; diff --git a/spurlowcode64src/vm/cointerp.h b/spurlowcode64src/vm/cointerp.h index f6d5b55409..68f378863f 100644 --- a/spurlowcode64src/vm/cointerp.h +++ b/spurlowcode64src/vm/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -59,6 +59,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); diff --git a/spurlowcode64src/vm/gcc3x-cointerp.c b/spurlowcode64src/vm/gcc3x-cointerp.c index 5c8a8075f5..4cdcd5a6b4 100644 --- a/spurlowcode64src/vm/gcc3x-cointerp.c +++ b/spurlowcode64src/vm/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -520,6 +520,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1776,6 +1777,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2638,7 +2640,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2771,17 +2773,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2822,6 +2841,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -33627,7 +33649,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -33842,7 +33863,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -34654,7 +34674,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -35708,6 +35727,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -80652,7 +80678,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l7: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l8; } /* begin numSlotsOf: */ @@ -80681,7 +80707,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) l5: /* end methodHeaderFromSavedFirstField: */; assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l8: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -85067,8 +85093,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; diff --git a/spurlowcodesrc/vm/cogit.h b/spurlowcodesrc/vm/cogit.h index e04553ad6f..86c5b9e55c 100644 --- a/spurlowcodesrc/vm/cogit.h +++ b/spurlowcodesrc/vm/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ diff --git a/spurlowcodesrc/vm/cogitARMv5.c b/spurlowcodesrc/vm/cogitARMv5.c index cd041f6322..5aedd3d62f 100644 --- a/spurlowcodesrc/vm/cogitARMv5.c +++ b/spurlowcodesrc/vm/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -12824,7 +12824,9 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + sqInt jumpTarget; sqInt quickConstant; usqInt startAddress; @@ -12843,7 +12845,15 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + genMarshallNArgsargargargarg(backEnd, 0, null, null, null, null); + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin gen:literal:operand: */ + checkLiteralforInstruction(address, genoperandoperand(MoveAwR, address, LinkReg)); + /* begin JumpFull: */ + jumpTarget = ((usqInt)interpret); + /* begin gen:literal: */ + checkLiteralforInstruction(((sqInt)jumpTarget), genoperand(JumpFull, ((sqInt)jumpTarget))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spurlowcodesrc/vm/cogitIA32.c b/spurlowcodesrc/vm/cogitIA32.c index b50696d781..861a0c6257 100644 --- a/spurlowcodesrc/vm/cogitIA32.c +++ b/spurlowcodesrc/vm/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -625,7 +625,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -8294,42 +8293,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *abstractInstruction; - AbstractInstruction *anInstruction; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin annotateCall: */ - anInstruction = genoperand(CallFull, callTarget); - abstractInstruction = anInstruction; - (abstractInstruction->annotation = IsRelativeCall); - lastInst = abstractInstruction; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -12689,6 +12652,13 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + AbstractInstruction *abstractInstruction; + sqInt address1; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction6; + AbstractInstruction *anInstruction7; + sqInt literal3; + sqInt literal4; usqInt startAddress; startAddress = methodZoneBase; @@ -12699,7 +12669,30 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l3; + if (null < NoReg) { + /* begin checkQuickConstant:forInstruction: */ + literal3 = -2 - null; + anInstruction4 = genoperand(PushCq, -2 - null); + } + else { + genoperand(PushR, null); + } + ((AbstractInstruction *) backEnd); + l3: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction6 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin genSubstituteReturnAddressR: */ + genoperand(PushR, ABIResultReg); + /* begin annotateCall: */ + literal4 = ((sqInt)(((usqInt)interpret))); + anInstruction7 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); + abstractInstruction = anInstruction7; + (abstractInstruction->annotation = IsRelativeCall); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spurlowcodesrc/vm/cogitMIPSEL.c b/spurlowcodesrc/vm/cogitMIPSEL.c index 1c4b368fde..111d6d8833 100644 --- a/spurlowcodesrc/vm/cogitMIPSEL.c +++ b/spurlowcodesrc/vm/cogitMIPSEL.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -600,7 +600,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -3861,39 +3860,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -6532,7 +6498,7 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, static sqInt NoDbgRegParms cPICCompactAndIsNowEmpty(CogMethod *cPIC) { - usqInt entryPoint; + sqInt entryPoint; sqInt followingAddress; sqInt i; sqInt methods[MaxCPICCases]; @@ -6633,7 +6599,7 @@ cPICHasForwardedClass(CogMethod *cPIC) static sqInt NoDbgRegParms cPICHasFreedTargets(CogMethod *cPIC) { - sqInt entryPoint; + usqInt entryPoint; sqInt i; sqInt pc; CogMethod *targetMethod; @@ -8192,7 +8158,15 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction1; + AbstractInstruction *anInstruction11; + AbstractInstruction *anInstruction21; + AbstractInstruction *anInstruction31; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction5; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -8208,7 +8182,50 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l16; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction5 = genoperandoperand(MoveCqR, -2 - null, A0); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A0); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction11 = genoperandoperand(MoveCqR, -2 - null, A1); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A1); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction21 = genoperandoperand(MoveCqR, -2 - null, A2); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A2); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction31 = genoperandoperand(MoveCqR, -2 - null, A3); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A3); + } + ((AbstractInstruction *) backEnd); + l16: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction1 = genoperandoperand(MoveAwR, address, LinkReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spurlowcodesrc/vm/cointerp.c b/spurlowcodesrc/vm/cointerp.c index ea642ed10d..db8d1f714d 100644 --- a/spurlowcodesrc/vm/cointerp.c +++ b/spurlowcodesrc/vm/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -516,6 +516,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1256,7 +1257,7 @@ static sqInt NoDbgRegParms num32BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms num64BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1750,6 +1751,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2615,7 +2617,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2741,17 +2743,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2786,6 +2805,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -33600,7 +33622,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -33815,7 +33836,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -34637,7 +34657,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -35699,6 +35718,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -38548,8 +38574,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -38598,7 +38623,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; @@ -38616,12 +38641,10 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((objOop1 & (tagMask())) == 0) && (((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun()))) == 0)) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } mnuMethod = objOop1; goto l11; @@ -66302,7 +66325,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - sqInt numMediatedSlots; + usqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -66334,7 +66357,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS here but that requires access to framePointer. */ /* begin numSlotsOfMarriedContext: */ contextSize = stackPointerIndexForFrame(frameOfMarriedContext(objOop)); - numMediatedSlots = CtxtTempFrameStart + contextSize; + numMediatedSlots = ((sqInt) (CtxtTempFrameStart + contextSize)); for (i1 = 0; i1 < numMediatedSlots; i1 += 1) { oop = fetchPointerofMarriedContext(i1, objOop); assert(!(isOopForwarded(copy))); @@ -72833,7 +72856,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -sqInt +usqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -76059,7 +76082,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop1))); contextSize = (sp >> 1); l11: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l12; } /* begin numSlotsOf: */ @@ -76092,7 +76115,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l12: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -76146,7 +76169,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop1))); contextSize = (sp >> 1); l13: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l14; } /* begin numSlotsOf: */ @@ -76179,7 +76202,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l14: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -76234,7 +76257,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop11))); contextSize = (sp >> 1); l15: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l16; } /* begin numSlotsOf: */ @@ -76267,7 +76290,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l16: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -79361,10 +79384,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - sqInt numPointerSlots; - sqInt numPointerSlots1; - sqInt numPointerSlots2; - sqInt numPointerSlots3; + usqInt numPointerSlots; + usqInt numPointerSlots1; + usqInt numPointerSlots2; + usqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -79934,7 +79957,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l5: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l9; } /* begin numSlotsOf: */ @@ -79964,7 +79987,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l9: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -84365,8 +84388,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; @@ -86388,8 +86411,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt meth; @@ -86433,7 +86455,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; @@ -86451,12 +86473,10 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((objOop1 & (tagMask())) == 0) && (((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun()))) == 0)) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } meth = objOop1; goto l8; diff --git a/spurlowcodesrc/vm/cointerp.h b/spurlowcodesrc/vm/cointerp.h index b717ed2ab2..a75267f05c 100644 --- a/spurlowcodesrc/vm/cointerp.h +++ b/spurlowcodesrc/vm/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -59,6 +59,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); @@ -247,7 +248,7 @@ extern sqInt minSlotsForShortening(void); extern sqInt nilObject(void); extern sqInt nonIndexablePointerFormat(void); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); extern sqInt numStrongSlotsOfWeakling(sqInt objOop); extern sqInt objectAfter(sqInt objOop); diff --git a/spurlowcodesrc/vm/gcc3x-cointerp.c b/spurlowcodesrc/vm/gcc3x-cointerp.c index 70e846e074..20d7e11595 100644 --- a/spurlowcodesrc/vm/gcc3x-cointerp.c +++ b/spurlowcodesrc/vm/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -519,6 +519,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1259,7 +1260,7 @@ static sqInt NoDbgRegParms num32BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms num64BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1753,6 +1754,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2618,7 +2620,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2744,17 +2746,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2795,6 +2814,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -33609,7 +33631,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -33824,7 +33845,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -34646,7 +34666,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -35708,6 +35727,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -38557,8 +38583,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -38607,7 +38632,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; @@ -38625,12 +38650,10 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((objOop1 & (tagMask())) == 0) && (((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun()))) == 0)) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } mnuMethod = objOop1; goto l11; @@ -66311,7 +66334,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - sqInt numMediatedSlots; + usqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -66343,7 +66366,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS here but that requires access to framePointer. */ /* begin numSlotsOfMarriedContext: */ contextSize = stackPointerIndexForFrame(frameOfMarriedContext(objOop)); - numMediatedSlots = CtxtTempFrameStart + contextSize; + numMediatedSlots = ((sqInt) (CtxtTempFrameStart + contextSize)); for (i1 = 0; i1 < numMediatedSlots; i1 += 1) { oop = fetchPointerofMarriedContext(i1, objOop); assert(!(isOopForwarded(copy))); @@ -72842,7 +72865,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -sqInt +usqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -76068,7 +76091,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop1))); contextSize = (sp >> 1); l11: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l12; } /* begin numSlotsOf: */ @@ -76101,7 +76124,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l12: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -76155,7 +76178,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop1))); contextSize = (sp >> 1); l13: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l14; } /* begin numSlotsOf: */ @@ -76188,7 +76211,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l14: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -76243,7 +76266,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop11))); contextSize = (sp >> 1); l15: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l16; } /* begin numSlotsOf: */ @@ -76276,7 +76299,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l16: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -79370,10 +79393,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - sqInt numPointerSlots; - sqInt numPointerSlots1; - sqInt numPointerSlots2; - sqInt numPointerSlots3; + usqInt numPointerSlots; + usqInt numPointerSlots1; + usqInt numPointerSlots2; + usqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -79943,7 +79966,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l5: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l9; } /* begin numSlotsOf: */ @@ -79973,7 +79996,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l9: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -84374,8 +84397,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; @@ -86397,8 +86420,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt meth; @@ -86442,7 +86464,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; @@ -86460,12 +86482,10 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((objOop1 & (tagMask())) == 0) && (((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun()))) == 0)) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } meth = objOop1; goto l8; diff --git a/spursista64src/vm/cogit.h b/spursista64src/vm/cogit.h index 0f418c16a7..bf8c9043cc 100644 --- a/spursista64src/vm/cogit.h +++ b/spursista64src/vm/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ diff --git a/spursista64src/vm/cogitX64SysV.c b/spursista64src/vm/cogitX64SysV.c index c3f6a4a16b..45681db1a8 100644 --- a/spursista64src/vm/cogitX64SysV.c +++ b/spursista64src/vm/cogitX64SysV.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -539,7 +539,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -3926,39 +3925,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1ULL << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -7926,7 +7892,15 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address1; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction11; + AbstractInstruction *anInstruction2; + AbstractInstruction *anInstruction21; + AbstractInstruction *anInstruction31; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction41; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -7942,7 +7916,61 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l25; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction11 = genoperandoperand(MoveCqR, -2 - null, RDI); + } + else { + if (null != RDI) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDI); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction21 = genoperandoperand(MoveCqR, -2 - null, RSI); + } + else { + if (null != RSI) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RSI); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction31 = genoperandoperand(MoveCqR, -2 - null, RDX); + } + else { + if (null != RDX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction41 = genoperandoperand(MoveCqR, -2 - null, RCX); + } + else { + if (null != RCX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RCX); + } + } + assert(0 <= 4); + ((AbstractInstruction *) backEnd); + l25: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction2 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin PushR: */ + genoperand(PushR, ABIResultReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spursista64src/vm/cogitX64WIN64.c b/spursista64src/vm/cogitX64WIN64.c index 9629e8ae04..b9f387e25e 100644 --- a/spursista64src/vm/cogitX64WIN64.c +++ b/spursista64src/vm/cogitX64WIN64.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -539,7 +539,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -3926,39 +3925,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1ULL << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -7934,7 +7900,16 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address1; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction2; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction5; + AbstractInstruction *anInstruction6; + AbstractInstruction *anInstruction7; + AbstractInstruction *anInstruction8; + AbstractInstruction *anInstruction9; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -7950,7 +7925,65 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + + /* WIN64 ABI allways reserve shadow space on the stack for callee to save up to 4 register parameters */ + /* begin checkQuickConstant:forInstruction: */ + anInstruction9 = genoperandoperand(SubCqR, 32, RSP); + ((AbstractInstruction *) backEnd); + goto l25; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction5 = genoperandoperand(MoveCqR, -2 - null, RCX); + } + else { + if (null != RCX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RCX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction6 = genoperandoperand(MoveCqR, -2 - null, RDX); + } + else { + if (null != RDX) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, RDX); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction7 = genoperandoperand(MoveCqR, -2 - null, R8); + } + else { + if (null != R8) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, R8); + } + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction8 = genoperandoperand(MoveCqR, -2 - null, R9); + } + else { + if (null != R9) { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, R9); + } + } + assert(0 <= 4); + ((AbstractInstruction *) backEnd); + l25: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction2 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin PushR: */ + genoperand(PushR, ABIResultReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spursista64src/vm/cointerp.c b/spursista64src/vm/cointerp.c index b60e435a8a..74b7adcdf7 100644 --- a/spursista64src/vm/cointerp.c +++ b/spursista64src/vm/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -517,6 +517,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1277,7 +1278,7 @@ static sqInt NoDbgRegParms num32BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms num64BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1765,6 +1766,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2625,7 +2627,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2758,17 +2760,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2801,6 +2820,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -16614,7 +16636,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16990,7 +17011,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -17802,7 +17822,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -18856,6 +18875,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -50110,7 +50136,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - sqInt numMediatedSlots; + usqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -56680,7 +56706,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -sqInt +usqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -59923,7 +59949,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l10: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l11; } /* begin numSlotsOf: */ @@ -59955,7 +59981,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l11: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -60009,7 +60035,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l12: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l13; } /* begin numSlotsOf: */ @@ -60041,7 +60067,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l13: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -60096,7 +60122,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop11))); contextSize = (sp >> 3); l14: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l15; } /* begin numSlotsOf: */ @@ -60128,7 +60154,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l15: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -63268,10 +63294,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - sqInt numPointerSlots; - sqInt numPointerSlots1; - sqInt numPointerSlots2; - sqInt numPointerSlots3; + usqInt numPointerSlots; + usqInt numPointerSlots1; + usqInt numPointerSlots2; + usqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; diff --git a/spursista64src/vm/cointerp.h b/spursista64src/vm/cointerp.h index 6f6c74c637..a0d096ba6f 100644 --- a/spursista64src/vm/cointerp.h +++ b/spursista64src/vm/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -60,6 +60,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); @@ -248,7 +249,7 @@ extern sqInt minSlotsForShortening(void); extern sqInt nilObject(void); extern sqInt nonIndexablePointerFormat(void); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); extern sqInt numStrongSlotsOfWeakling(sqInt objOop); extern sqInt objectAfter(sqInt objOop); diff --git a/spursista64src/vm/gcc3x-cointerp.c b/spursista64src/vm/gcc3x-cointerp.c index d40105cfb4..5d256a37d0 100644 --- a/spursista64src/vm/gcc3x-cointerp.c +++ b/spursista64src/vm/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -520,6 +520,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1280,7 +1281,7 @@ static sqInt NoDbgRegParms num32BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms num64BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1768,6 +1769,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2628,7 +2630,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -2761,17 +2763,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2810,6 +2829,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -16623,7 +16645,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16999,7 +17020,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -17811,7 +17831,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -18865,6 +18884,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 3) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -50119,7 +50145,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - sqInt numMediatedSlots; + usqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -56689,7 +56715,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -sqInt +usqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -59932,7 +59958,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l10: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l11; } /* begin numSlotsOf: */ @@ -59964,7 +59990,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l11: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -60018,7 +60044,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop1))); contextSize = (sp >> 3); l12: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l13; } /* begin numSlotsOf: */ @@ -60050,7 +60076,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l13: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -60105,7 +60131,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(objOop11))); contextSize = (sp >> 3); l14: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l15; } /* begin numSlotsOf: */ @@ -60137,7 +60163,7 @@ printReferencesTo(sqInt anOop) } assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l15: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -63277,10 +63303,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - sqInt numPointerSlots; - sqInt numPointerSlots1; - sqInt numPointerSlots2; - sqInt numPointerSlots3; + usqInt numPointerSlots; + usqInt numPointerSlots1; + usqInt numPointerSlots2; + usqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; diff --git a/spursistasrc/vm/cogit.h b/spursistasrc/vm/cogit.h index 0f418c16a7..bf8c9043cc 100644 --- a/spursistasrc/vm/cogit.h +++ b/spursistasrc/vm/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ diff --git a/spursistasrc/vm/cogitARMv5.c b/spursistasrc/vm/cogitARMv5.c index 8fa4e11f26..002c5aa883 100644 --- a/spursistasrc/vm/cogitARMv5.c +++ b/spursistasrc/vm/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -12497,7 +12497,9 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + sqInt jumpTarget; sqInt quickConstant; usqInt startAddress; @@ -12516,7 +12518,15 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + genMarshallNArgsargargargarg(backEnd, 0, null, null, null, null); + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin gen:literal:operand: */ + checkLiteralforInstruction(address, genoperandoperand(MoveAwR, address, LinkReg)); + /* begin JumpFull: */ + jumpTarget = ((usqInt)interpret); + /* begin gen:literal: */ + checkLiteralforInstruction(((sqInt)jumpTarget), genoperand(JumpFull, ((sqInt)jumpTarget))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spursistasrc/vm/cogitIA32.c b/spursistasrc/vm/cogitIA32.c index 6544543671..9597f47c0b 100644 --- a/spursistasrc/vm/cogitIA32.c +++ b/spursistasrc/vm/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -593,7 +593,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -8234,42 +8233,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *abstractInstruction; - AbstractInstruction *anInstruction; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin annotateCall: */ - anInstruction = genoperand(CallFull, callTarget); - abstractInstruction = anInstruction; - (abstractInstruction->annotation = IsRelativeCall); - lastInst = abstractInstruction; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -12186,6 +12149,13 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + AbstractInstruction *abstractInstruction; + sqInt address1; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction6; + AbstractInstruction *anInstruction7; + sqInt literal3; + sqInt literal4; usqInt startAddress; startAddress = methodZoneBase; @@ -12196,7 +12166,30 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l3; + if (null < NoReg) { + /* begin checkQuickConstant:forInstruction: */ + literal3 = -2 - null; + anInstruction4 = genoperand(PushCq, -2 - null); + } + else { + genoperand(PushR, null); + } + ((AbstractInstruction *) backEnd); + l3: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction6 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin genSubstituteReturnAddressR: */ + genoperand(PushR, ABIResultReg); + /* begin annotateCall: */ + literal4 = ((sqInt)(((usqInt)interpret))); + anInstruction7 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); + abstractInstruction = anInstruction7; + (abstractInstruction->annotation = IsRelativeCall); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spursistasrc/vm/cogitMIPSEL.c b/spursistasrc/vm/cogitMIPSEL.c index 4c28c1e18e..3d5164c172 100644 --- a/spursistasrc/vm/cogitMIPSEL.c +++ b/spursistasrc/vm/cogitMIPSEL.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -542,7 +542,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -3803,39 +3802,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -6197,7 +6163,7 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, static sqInt NoDbgRegParms cPICCompactAndIsNowEmpty(CogMethod *cPIC) { - usqInt entryPoint; + sqInt entryPoint; sqInt followingAddress; sqInt i; sqInt methods[MaxCPICCases]; @@ -7786,7 +7752,15 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction1; + AbstractInstruction *anInstruction11; + AbstractInstruction *anInstruction21; + AbstractInstruction *anInstruction31; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction5; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -7802,7 +7776,50 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l16; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction5 = genoperandoperand(MoveCqR, -2 - null, A0); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A0); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction11 = genoperandoperand(MoveCqR, -2 - null, A1); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A1); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction21 = genoperandoperand(MoveCqR, -2 - null, A2); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A2); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction31 = genoperandoperand(MoveCqR, -2 - null, A3); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A3); + } + ((AbstractInstruction *) backEnd); + l16: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction1 = genoperandoperand(MoveAwR, address, LinkReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; @@ -10167,7 +10184,7 @@ static void NoDbgRegParms relocateCallsInClosedPIC(CogMethod *cPIC) { sqInt callDelta; - usqInt entryPoint; + sqInt entryPoint; sqInt i; sqInt pc; sqLong refDelta; diff --git a/spursistasrc/vm/cointerp.c b/spursistasrc/vm/cointerp.c index 8dbe58e9f2..bd047710ef 100644 --- a/spursistasrc/vm/cointerp.c +++ b/spursistasrc/vm/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -516,6 +516,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1253,7 +1254,7 @@ static sqInt NoDbgRegParms num32BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms num64BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1742,6 +1743,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2605,7 +2607,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2731,17 +2733,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2774,6 +2793,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -16466,7 +16488,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16842,7 +16863,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -17664,7 +17684,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -18726,6 +18745,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -49364,7 +49390,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - sqInt numMediatedSlots; + usqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -49396,7 +49422,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS here but that requires access to framePointer. */ /* begin numSlotsOfMarriedContext: */ contextSize = stackPointerIndexForFrame(frameOfMarriedContext(objOop)); - numMediatedSlots = CtxtTempFrameStart + contextSize; + numMediatedSlots = ((sqInt) (CtxtTempFrameStart + contextSize)); for (i1 = 0; i1 < numMediatedSlots; i1 += 1) { oop = fetchPointerofMarriedContext(i1, objOop); assert(!(isOopForwarded(copy))); @@ -55895,7 +55921,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -sqInt +usqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -59121,7 +59147,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop1))); contextSize = (sp >> 1); l11: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l12; } /* begin numSlotsOf: */ @@ -59154,7 +59180,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l12: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59208,7 +59234,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop1))); contextSize = (sp >> 1); l13: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l14; } /* begin numSlotsOf: */ @@ -59241,7 +59267,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l14: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59296,7 +59322,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop11))); contextSize = (sp >> 1); l15: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l16; } /* begin numSlotsOf: */ @@ -59329,7 +59355,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l16: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -62423,10 +62449,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - sqInt numPointerSlots; - sqInt numPointerSlots1; - sqInt numPointerSlots2; - sqInt numPointerSlots3; + usqInt numPointerSlots; + usqInt numPointerSlots1; + usqInt numPointerSlots2; + usqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; diff --git a/spursistasrc/vm/cointerp.h b/spursistasrc/vm/cointerp.h index 0141910c46..5afac52208 100644 --- a/spursistasrc/vm/cointerp.h +++ b/spursistasrc/vm/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -60,6 +60,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); @@ -246,7 +247,7 @@ extern sqInt minSlotsForShortening(void); extern sqInt nilObject(void); extern sqInt nonIndexablePointerFormat(void); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); extern sqInt numStrongSlotsOfWeakling(sqInt objOop); extern sqInt objectAfter(sqInt objOop); diff --git a/spursistasrc/vm/gcc3x-cointerp.c b/spursistasrc/vm/gcc3x-cointerp.c index c0de0150a9..26bf947bf0 100644 --- a/spursistasrc/vm/gcc3x-cointerp.c +++ b/spursistasrc/vm/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -519,6 +519,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1256,7 +1257,7 @@ static sqInt NoDbgRegParms num32BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms num64BitUnitsOf(sqInt objOop); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern sqInt numPointerSlotsOf(sqInt objOop); +extern usqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -1745,6 +1746,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2608,7 +2610,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2734,17 +2736,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2783,6 +2802,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -16475,7 +16497,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16851,7 +16872,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -17673,7 +17693,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -18735,6 +18754,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -49373,7 +49399,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - sqInt numMediatedSlots; + usqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -49405,7 +49431,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS here but that requires access to framePointer. */ /* begin numSlotsOfMarriedContext: */ contextSize = stackPointerIndexForFrame(frameOfMarriedContext(objOop)); - numMediatedSlots = CtxtTempFrameStart + contextSize; + numMediatedSlots = ((sqInt) (CtxtTempFrameStart + contextSize)); for (i1 = 0; i1 < numMediatedSlots; i1 += 1) { oop = fetchPointerofMarriedContext(i1, objOop); assert(!(isOopForwarded(copy))); @@ -55904,7 +55930,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -sqInt +usqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -59130,7 +59156,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop1))); contextSize = (sp >> 1); l11: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l12; } /* begin numSlotsOf: */ @@ -59163,7 +59189,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l12: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59217,7 +59243,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop1))); contextSize = (sp >> 1); l13: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l14; } /* begin numSlotsOf: */ @@ -59250,7 +59276,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l14: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59305,7 +59331,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(objOop11))); contextSize = (sp >> 1); l15: /* end fetchStackPointerOf: */; - i = CtxtTempFrameStart + contextSize; + i = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l16; } /* begin numSlotsOf: */ @@ -59338,7 +59364,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = numLiterals + LiteralStart; + i = ((usqInt) (numLiterals + LiteralStart)); l16: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((objOop11 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -62432,10 +62458,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - sqInt numPointerSlots; - sqInt numPointerSlots1; - sqInt numPointerSlots2; - sqInt numPointerSlots3; + usqInt numPointerSlots; + usqInt numPointerSlots1; + usqInt numPointerSlots2; + usqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; diff --git a/spursrc/vm/cogit.h b/spursrc/vm/cogit.h index 0935d46968..fb4b4da56e 100644 --- a/spursrc/vm/cogit.h +++ b/spursrc/vm/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ diff --git a/spursrc/vm/cogitARMv5.c b/spursrc/vm/cogitARMv5.c index 876ee357d0..07e03b0e24 100644 --- a/spursrc/vm/cogitARMv5.c +++ b/spursrc/vm/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -12338,7 +12338,9 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + sqInt jumpTarget; sqInt quickConstant; usqInt startAddress; @@ -12357,7 +12359,15 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + genMarshallNArgsargargargarg(backEnd, 0, null, null, null, null); + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin gen:literal:operand: */ + checkLiteralforInstruction(address, genoperandoperand(MoveAwR, address, LinkReg)); + /* begin JumpFull: */ + jumpTarget = ((usqInt)interpret); + /* begin gen:literal: */ + checkLiteralforInstruction(((sqInt)jumpTarget), genoperand(JumpFull, ((sqInt)jumpTarget))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spursrc/vm/cogitIA32.c b/spursrc/vm/cogitIA32.c index 33f5980430..0ac336cf1f 100644 --- a/spursrc/vm/cogitIA32.c +++ b/spursrc/vm/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -586,7 +586,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -8092,42 +8091,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *abstractInstruction; - AbstractInstruction *anInstruction; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin annotateCall: */ - anInstruction = genoperand(CallFull, callTarget); - abstractInstruction = anInstruction; - (abstractInstruction->annotation = IsRelativeCall); - lastInst = abstractInstruction; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -12029,6 +11992,13 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + AbstractInstruction *abstractInstruction; + sqInt address1; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction6; + AbstractInstruction *anInstruction7; + sqInt literal3; + sqInt literal4; usqInt startAddress; startAddress = methodZoneBase; @@ -12039,7 +12009,30 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l3; + if (null < NoReg) { + /* begin checkQuickConstant:forInstruction: */ + literal3 = -2 - null; + anInstruction4 = genoperand(PushCq, -2 - null); + } + else { + genoperand(PushR, null); + } + ((AbstractInstruction *) backEnd); + l3: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction6 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin genSubstituteReturnAddressR: */ + genoperand(PushR, ABIResultReg); + /* begin annotateCall: */ + literal4 = ((sqInt)(((usqInt)interpret))); + anInstruction7 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); + abstractInstruction = anInstruction7; + (abstractInstruction->annotation = IsRelativeCall); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spursrc/vm/cogitMIPSEL.c b/spursrc/vm/cogitMIPSEL.c index 795f815bcf..9cb432e202 100644 --- a/spursrc/vm/cogitMIPSEL.c +++ b/spursrc/vm/cogitMIPSEL.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -536,7 +536,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCmpCqR(sqInt quickConstant, sqInt reg); @@ -3666,39 +3665,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Cogit>>#CallRT:registersToBeSavedMask: */ static AbstractInstruction * NoDbgRegParms CallRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) @@ -6005,7 +5971,7 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, static sqInt NoDbgRegParms cPICCompactAndIsNowEmpty(CogMethod *cPIC) { - usqInt entryPoint; + sqInt entryPoint; sqInt followingAddress; sqInt i; sqInt methods[MaxCPICCases]; @@ -6106,7 +6072,7 @@ cPICHasForwardedClass(CogMethod *cPIC) static sqInt NoDbgRegParms cPICHasFreedTargets(CogMethod *cPIC) { - usqInt entryPoint; + sqInt entryPoint; sqInt i; sqInt pc; CogMethod *targetMethod; @@ -7633,7 +7599,15 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction1; + AbstractInstruction *anInstruction11; + AbstractInstruction *anInstruction21; + AbstractInstruction *anInstruction31; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction5; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -7649,7 +7623,50 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l16; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction5 = genoperandoperand(MoveCqR, -2 - null, A0); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A0); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction11 = genoperandoperand(MoveCqR, -2 - null, A1); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A1); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction21 = genoperandoperand(MoveCqR, -2 - null, A2); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A2); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction31 = genoperandoperand(MoveCqR, -2 - null, A3); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A3); + } + ((AbstractInstruction *) backEnd); + l16: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction1 = genoperandoperand(MoveAwR, address, LinkReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/spursrc/vm/cointerp.c b/spursrc/vm/cointerp.c index 196b2860c4..29c0dedcdf 100644 --- a/spursrc/vm/cointerp.c +++ b/spursrc/vm/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -512,6 +512,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1725,6 +1726,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2588,7 +2590,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2714,17 +2716,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2757,6 +2776,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -13791,7 +13813,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14006,7 +14027,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14826,7 +14846,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15847,6 +15866,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -18691,8 +18717,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -18741,7 +18766,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; @@ -18759,12 +18784,10 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((objOop1 & (tagMask())) == 0) && (((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun()))) == 0)) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } mnuMethod = objOop1; goto l11; @@ -59902,7 +59925,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l5: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l9; } /* begin numSlotsOf: */ @@ -59932,7 +59955,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l9: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -66321,8 +66344,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt meth; @@ -66366,7 +66388,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; @@ -66384,12 +66406,10 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((objOop1 & (tagMask())) == 0) && (((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun()))) == 0)) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } meth = objOop1; goto l8; diff --git a/spursrc/vm/cointerp.h b/spursrc/vm/cointerp.h index f2edfee2b1..f88ed78c0c 100644 --- a/spursrc/vm/cointerp.h +++ b/spursrc/vm/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -58,6 +58,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); diff --git a/spursrc/vm/cointerpmt.c b/spursrc/vm/cointerpmt.c index a38832612f..d291c00d02 100644 --- a/spursrc/vm/cointerpmt.c +++ b/spursrc/vm/cointerpmt.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -569,6 +569,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms divorceAMachineCodeFrameWithCogMethodin(CogMethod *cogMethod, StackPage *aStackPage); @@ -1801,6 +1802,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2682,7 +2684,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2809,17 +2811,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2852,6 +2871,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -14265,7 +14287,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14480,7 +14501,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15300,7 +15320,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16321,6 +16340,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) diff --git a/spursrc/vm/cointerpmt.h b/spursrc/vm/cointerpmt.h index a062446123..e808eded7c 100644 --- a/spursrc/vm/cointerpmt.h +++ b/spursrc/vm/cointerpmt.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -60,6 +60,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); extern void dumpPrimTraceLog(void); diff --git a/spursrc/vm/gcc3x-cointerp.c b/spursrc/vm/gcc3x-cointerp.c index 2d238db48a..b3b31496ed 100644 --- a/spursrc/vm/gcc3x-cointerp.c +++ b/spursrc/vm/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -515,6 +515,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms deferStackLimitSmashAroundwith(void (*functionSymbol)(sqInt), sqInt arg); @@ -1728,6 +1729,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2591,7 +2593,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2717,17 +2719,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2766,6 +2785,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -13800,7 +13822,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14015,7 +14036,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14835,7 +14855,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15856,6 +15875,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) @@ -18700,8 +18726,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -18750,7 +18775,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; @@ -18768,12 +18793,10 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((objOop1 & (tagMask())) == 0) && (((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun()))) == 0)) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } mnuMethod = objOop1; goto l11; @@ -59911,7 +59934,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj))); contextSize = (sp >> 1); l5: /* end fetchStackPointerOf: */; - numPointerSlots = CtxtTempFrameStart + contextSize; + numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); goto l9; } /* begin numSlotsOf: */ @@ -59941,7 +59964,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = numLiterals + LiteralStart; + numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); l9: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -66330,8 +66353,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt meth; @@ -66375,7 +66397,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; @@ -66393,12 +66415,10 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((objOop1 & (tagMask())) == 0) && (((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun()))) == 0)) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } meth = objOop1; goto l8; diff --git a/spursrc/vm/gcc3x-cointerpmt.c b/spursrc/vm/gcc3x-cointerpmt.c index 82e257092f..ef80fe03cd 100644 --- a/spursrc/vm/gcc3x-cointerpmt.c +++ b/spursrc/vm/gcc3x-cointerpmt.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -572,6 +572,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); static sqInt NoDbgRegParms divorceAMachineCodeFrameWithCogMethodin(CogMethod *cogMethod, StackPage *aStackPage); @@ -1804,6 +1805,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2685,7 +2687,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2812,17 +2814,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2861,6 +2880,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -14274,7 +14296,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -14489,7 +14510,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -15309,7 +15329,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -16330,6 +16349,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#cStackPointerAddress */ usqInt cStackPointerAddress(void) diff --git a/src/vm/cogit.h b/src/vm/cogit.h index 41f7dd1d5a..aa16063b4a 100644 --- a/src/vm/cogit.h +++ b/src/vm/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ diff --git a/src/vm/cogitARMv5.c b/src/vm/cogitARMv5.c index 82de588a68..27e6d441a0 100644 --- a/src/vm/cogitARMv5.c +++ b/src/vm/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -11397,7 +11397,9 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + sqInt jumpTarget; sqInt quickConstant; usqInt startAddress; @@ -11416,7 +11418,15 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + genMarshallNArgsargargargarg(backEnd, 0, null, null, null, null); + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin gen:literal:operand: */ + checkLiteralforInstruction(address, genoperandoperand(MoveAwR, address, LinkReg)); + /* begin JumpFull: */ + jumpTarget = ((usqInt)interpret); + /* begin gen:literal: */ + checkLiteralforInstruction(((sqInt)jumpTarget), genoperand(JumpFull, ((sqInt)jumpTarget))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/src/vm/cogitIA32.c b/src/vm/cogitIA32.c index 7ce21f6f37..303925b027 100644 --- a/src/vm/cogitIA32.c +++ b/src/vm/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -576,7 +576,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRT(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); extern void callCogCodePopReceiver(void); @@ -7665,42 +7664,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *abstractInstruction; - AbstractInstruction *anInstruction; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin annotateCall: */ - anInstruction = genoperand(CallFull, callTarget); - abstractInstruction = anInstruction; - (abstractInstruction->annotation = IsRelativeCall); - lastInst = abstractInstruction; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Big assumption here that calls and jumps look the same as regards their displacement. This works on at least x86, ARM and x86_64. */ @@ -11109,6 +11072,13 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + AbstractInstruction *abstractInstruction; + sqInt address1; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction6; + AbstractInstruction *anInstruction7; + sqInt literal3; + sqInt literal4; usqInt startAddress; startAddress = methodZoneBase; @@ -11119,7 +11089,30 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l3; + if (null < NoReg) { + /* begin checkQuickConstant:forInstruction: */ + literal3 = -2 - null; + anInstruction4 = genoperand(PushCq, -2 - null); + } + else { + genoperand(PushR, null); + } + ((AbstractInstruction *) backEnd); + l3: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address1 = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction6 = genoperandoperand(MoveAwR, address1, ABIResultReg); + /* begin genSubstituteReturnAddressR: */ + genoperand(PushR, ABIResultReg); + /* begin annotateCall: */ + literal4 = ((sqInt)(((usqInt)interpret))); + anInstruction7 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); + abstractInstruction = anInstruction7; + (abstractInstruction->annotation = IsRelativeCall); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; diff --git a/src/vm/cogitMIPSEL.c b/src/vm/cogitMIPSEL.c index 112883e56a..b35e09ccb1 100644 --- a/src/vm/cogitMIPSEL.c +++ b/src/vm/cogitMIPSEL.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGenerator VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -525,7 +525,6 @@ static void assertValidDualZone(void); static sqInt NoDbgRegParms availableRegisterOrNoneIn(sqInt liveRegsMask); static sqInt NoDbgRegParms blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg); extern sqInt bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod); -static AbstractInstruction * NoDbgRegParms CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved); static AbstractInstruction * NoDbgRegParms CallRT(sqInt callTarget); static AbstractInstruction * NoDbgRegParms gCall(sqInt callTarget); extern void callCogCodePopReceiver(void); @@ -3234,39 +3233,6 @@ bytecodePCForstartBcpcin(sqInt mcpc, sqInt startbcpc, CogBlockMethod *cogMethod) return 0; } - /* Cogit>>#CallFullRT:registersToBeSavedMask: */ -static AbstractInstruction * NoDbgRegParms -CallFullRTregistersToBeSavedMask(sqInt callTarget, sqInt registersToBeSaved) -{ - AbstractInstruction *anInstruction1; - sqInt callerSavedRegsToBeSaved; - AbstractInstruction *lastInst; - sqInt reg; - sqInt registersToBePushed; - - reg = 0; - callerSavedRegsToBeSaved = CallerSavedRegisterMask & registersToBeSaved; - registersToBePushed = callerSavedRegsToBeSaved; - reg = 0; - while (registersToBePushed != 0) { - if (registersToBePushed & 1) { - genoperand(PushR, reg); - } - reg += 1; - registersToBePushed = (registersToBePushed) >> 1; - } - /* begin checkLiteral:forInstruction: */ - anInstruction1 = genoperand(CallFull, callTarget); - lastInst = anInstruction1; - while (reg > 0) { - reg -= 1; - if (callerSavedRegsToBeSaved & (1U << reg)) { - lastInst = genoperand(PopR, reg); - } - } - return lastInst; -} - /* Big assumption here that calls and jumps look the same as regards their displacement. This works on at least x86, ARM and x86_64. */ @@ -6706,7 +6672,15 @@ genInnerPICAbortTrampoline(char *name) static usqInt genInvokeInterpretTrampoline(void) { + sqInt address; AbstractInstruction *anInstruction; + AbstractInstruction *anInstruction1; + AbstractInstruction *anInstruction11; + AbstractInstruction *anInstruction21; + AbstractInstruction *anInstruction31; + AbstractInstruction *anInstruction4; + AbstractInstruction *anInstruction5; + sqInt literal1; sqInt quickConstant; usqInt startAddress; @@ -6722,7 +6696,50 @@ genInvokeInterpretTrampoline(void) else { genLoadCStackPointer(backEnd); } - CallFullRTregistersToBeSavedMask(interpret, 0 /* emptyRegisterMask */); + /* begin genMarshallNArgs:arg:arg:arg:arg: */ + ((AbstractInstruction *) backEnd); + goto l16; + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction5 = genoperandoperand(MoveCqR, -2 - null, A0); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A0); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction11 = genoperandoperand(MoveCqR, -2 - null, A1); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A1); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction21 = genoperandoperand(MoveCqR, -2 - null, A2); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A2); + } + if (null < NoReg) { + /* begin MoveCq:R: */ + anInstruction31 = genoperandoperand(MoveCqR, -2 - null, A3); + } + else { + /* begin MoveR:R: */ + genoperandoperand(MoveRR, null, A3); + } + ((AbstractInstruction *) backEnd); + l16: /* end genMarshallNArgs:arg:arg:arg:arg: */; + /* begin MoveAw:R: */ + address = cReturnAddressAddress(); + /* begin checkLiteral:forInstruction: */ + anInstruction1 = genoperandoperand(MoveAwR, address, LinkReg); + /* begin checkLiteral:forInstruction: */ + literal1 = ((sqInt)(((usqInt)interpret))); + anInstruction4 = genoperand(JumpFull, ((sqInt)(((usqInt)interpret)))); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceInvokeInterpret", startAddress); return startAddress; @@ -9092,7 +9109,7 @@ static void NoDbgRegParms relocateCallsInClosedPIC(CogMethod *cPIC) { sqInt callDelta; - sqInt entryPoint; + usqInt entryPoint; sqInt i; sqInt pc; sqInt refDelta; diff --git a/src/vm/cointerp.c b/src/vm/cointerp.c index ae3ace5ff2..8f46087876 100644 --- a/src/vm/cointerp.c +++ b/src/vm/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -465,6 +465,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); @@ -1429,6 +1430,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2211,7 +2213,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2294,17 +2296,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2334,6 +2353,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -9490,7 +9512,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -9670,7 +9691,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -10435,7 +10455,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -11228,6 +11247,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#createClosureNumArgs:numCopied:startpc: */ sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP) @@ -32846,7 +32872,7 @@ eeInstantiateSmallClassnumSlots(sqInt classPointer, sqInt numSlots) { DECL_MAYBE_SQ_GLOBAL_STRUCT usqInt hash; int hdrSize; - sqInt header1; + usqInt header1; sqInt header2; usqInt newChunk; usqInt newFreeStart; diff --git a/src/vm/cointerp.h b/src/vm/cointerp.h index c99e9dcda6..c14fc556dc 100644 --- a/src/vm/cointerp.h +++ b/src/vm/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -55,6 +55,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); diff --git a/src/vm/cointerpmt.c b/src/vm/cointerpmt.c index fc4c785d3c..b552d56289 100644 --- a/src/vm/cointerpmt.c +++ b/src/vm/cointerpmt.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -522,6 +522,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); @@ -1504,6 +1505,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2304,7 +2306,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2388,17 +2390,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2428,6 +2447,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -9963,7 +9985,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -10143,7 +10164,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -10908,7 +10928,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -11701,6 +11720,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#createClosureNumArgs:numCopied:startpc: */ sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP) @@ -40490,7 +40516,7 @@ instantiateClassindexableSize(sqInt classPointer, sqInt size) sqInt bm1; sqInt byteSize; sqInt byteSize1; - sqInt cClass; + usqInt cClass; sqInt classFormat; sqInt classOop; usqInt end; @@ -40499,7 +40525,7 @@ instantiateClassindexableSize(sqInt classPointer, sqInt size) sqInt format; usqInt hash; sqInt hdrSize; - sqInt header1; + usqInt header1; sqInt header3; usqInt i; sqInt minFree; diff --git a/src/vm/cointerpmt.h b/src/vm/cointerpmt.h index 449bc2bb28..4d62f07712 100644 --- a/src/vm/cointerpmt.h +++ b/src/vm/cointerpmt.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ @@ -57,6 +57,7 @@ extern sqInt checkIfCFramePointerInUse(void); extern void clearTraceLog(void); extern CogMethod * cogMethodOf(sqInt aMethodOop); extern void compilationBreakpointFor(sqInt selectorOop); +extern usqInt cReturnAddressAddress(void); extern sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); diff --git a/src/vm/gcc3x-cointerp.c b/src/vm/gcc3x-cointerp.c index ea9cbd7bb4..1989dc12f0 100644 --- a/src/vm/gcc3x-cointerp.c +++ b/src/vm/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -468,6 +468,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); @@ -1432,6 +1433,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2214,7 +2216,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2297,17 +2299,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2343,6 +2362,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -9499,7 +9521,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -9679,7 +9700,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -10444,7 +10464,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -11237,6 +11256,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#createClosureNumArgs:numCopied:startpc: */ sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP) @@ -32855,7 +32881,7 @@ eeInstantiateSmallClassnumSlots(sqInt classPointer, sqInt numSlots) { DECL_MAYBE_SQ_GLOBAL_STRUCT usqInt hash; int hdrSize; - sqInt header1; + usqInt header1; sqInt header2; usqInt newChunk; usqInt newFreeStart; diff --git a/src/vm/gcc3x-cointerpmt.c b/src/vm/gcc3x-cointerpmt.c index b46416f7d6..3121f7242c 100644 --- a/src/vm/gcc3x-cointerpmt.c +++ b/src/vm/gcc3x-cointerpmt.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 from - CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 + CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 */ -static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2736 uuid: 1dd4c38f-c0b4-4edd-9165-f4a54a988fe7 " __DATE__ ; +static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.2737 uuid: ca691460-8bf3-48df-91dd-3132219b7bc4 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -525,6 +525,7 @@ extern CogMethod * cogMethodOf(sqInt aMethodOop); static void commenceCogCompiledCodeCompaction(void); extern void compilationBreakpointFor(sqInt selectorOop); static sqInt NoDbgRegParms contextInstructionPointerframe(sqInt theIP, char *theFP); +extern usqInt cReturnAddressAddress(void); extern sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP); extern usqInt cStackPointerAddress(void); extern sqInt defaultNativeStackFrameSize(void); @@ -1507,6 +1508,7 @@ _iss char * stackPointer; _iss char * framePointer; _iss volatile usqIntptr_t CStackPointer; _iss volatile usqIntptr_t CFramePointer; +_iss volatile usqIntptr_t CReturnAddress; _iss char * stackLimit; _iss usqInt scavengeThreshold; _iss usqInt freeStart; @@ -2307,7 +2309,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2736]"; +const char *interpreterVersion = "Open Smalltalk Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.2737]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -2391,17 +2393,34 @@ volatile int sendTrace; -/* This is the main interpreter loop. It normally loops forever, fetching and - executing bytecodes. When running in the context of a browser plugin VM, - however, it must return control to the browser periodically. This should - done only when the state of the currently running Squeak thread is safely - stored in the object heap. Since this is the case at the moment that a - check for interrupts is performed, that is when we return to the browser - if it is time to do so. Interrupt checks happen quite frequently. - */ +/* This is the main interpreter loop. + In a pure interpreter it loops forever, fetching and executing bytecodes. + With the Cogit JIT executing code as well, the interpreter is reentered + from machine code + whenever the machine code wants to interpret a method instead of executing + its machine + code. Entry into the interpreter is done via a ''jump call'' in machine + code that uses + CFramePointer and CStackPointer to find the base of the C stack (set in + CoInterpreter>> enterSmalltalkExecutiveImplementation) and substitutes + CReturnAddress as the return + address in the code so it always appears that interpret has been called + from CoInterpreter>>enterSmalltalkExecutiveImplementation, which may be + important to, + for example, C exception handling inside the VM. + + When running in the context of a browser plugin VM the interpreter must + return control + to the browser periodically. This should done only when the state of the + currently running + Squeak thread is safely stored in the object heap. Since this is the case + at the moment + that a check for interrupts is performed, that is when we return to the + browser if it is time + to do so. Interrupt checks happen quite frequently. */ /* If stacklimit is zero then the stack pages have not been initialized. */ - /* StackInterpreter>>#interpret */ + /* CoInterpreter>>#interpret */ sqInt interpret(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT @@ -2437,6 +2456,9 @@ interpret(void) initialEnterSmalltalkExecutive(); return null; } + if (!(GIV(CReturnAddress))) { + GIV(CReturnAddress) = ((usqIntptr_t) (getReturnAddress())); + } browserPluginInitialiseIfNeeded(); /* begin internalizeIPandSP */ assert(GIV(instructionPointer) != (ceReturnToInterpreterPC())); @@ -9972,7 +9994,6 @@ ceBaseFrameReturn(sqInt returnValue) # endif /* MULTIPLEBYTECODESETS */ longAtPointerput(GIV(stackPointer), returnValue); assert(checkIsStillMarriedContextcurrentFP(contextToReturnTo, GIV(framePointer))); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -10152,7 +10173,6 @@ ceEnterInterpreterOnReturnFromCogCode(void) # endif /* MULTIPLEBYTECODESETS */ GIV(instructionPointer) = longAt(GIV(framePointer) + FoxIFSavedIP); assertValidExecutionPointersimbarline(GIV(instructionPointer), GIV(framePointer), GIV(stackPointer), 1, __LINE__); - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -10917,7 +10937,6 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize ? 256 : 0); # endif /* MULTIPLEBYTECODESETS */ - /* begin invokeInterpreterFromMachineCode */ ceInvokeInterpret(); return null; } @@ -11710,6 +11729,13 @@ contextInstructionPointerframe(sqInt theIP, char *theFP) : theIP)) - (longAt(theFP + FoxMethod))) - BaseHeaderSize) + 2) << 1) | 1); } + /* CoInterpreter>>#cReturnAddressAddress */ +usqInt +cReturnAddressAddress(void) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + return ((usqInt)((&GIV(CReturnAddress)))); +} + /* CoInterpreter>>#createClosureNumArgs:numCopied:startpc: */ sqInt createClosureNumArgsnumCopiedstartpc(sqInt numArgs, sqInt numCopied, sqInt initialIP) @@ -40499,7 +40525,7 @@ instantiateClassindexableSize(sqInt classPointer, sqInt size) sqInt bm1; sqInt byteSize; sqInt byteSize1; - sqInt cClass; + usqInt cClass; sqInt classFormat; sqInt classOop; usqInt end; @@ -40508,7 +40534,7 @@ instantiateClassindexableSize(sqInt classPointer, sqInt size) sqInt format; usqInt hash; sqInt hdrSize; - sqInt header1; + usqInt header1; sqInt header3; usqInt i; sqInt minFree;