Branch: refs/heads/Cog
Home: https://github.com/OpenSmalltalk/opensmalltalk-vm
Commit: de918b2a4cf8f27eb7d1ec548477a7393dc8076c
https://github.com/OpenSmalltalk/opensmalltalk-vm/commit/de918b2a4cf8f27eb7…
Author: Eliot Miranda <eliot.miranda(a)gmail.com>
Date: 2018-08-24 (Fri, 24 Aug 2018)
Changed paths:
M nsspur64src/vm/cogit.h
M nsspur64src/vm/cointerp.c
M nsspur64src/vm/cointerp.h
M nsspur64src/vm/gcc3x-cointerp.c
M nsspursrc/vm/cogit.h
M nsspursrc/vm/cointerp.c
M nsspursrc/vm/cointerp.h
M nsspursrc/vm/gcc3x-cointerp.c
M nsspurstack64src/vm/gcc3x-interp.c
M nsspurstack64src/vm/interp.c
M nsspurstacksrc/vm/gcc3x-interp.c
M nsspurstacksrc/vm/interp.c
M spur64src/vm/cogit.h
M spur64src/vm/cointerp.c
M spur64src/vm/cointerp.h
M spur64src/vm/cointerpmt.c
M spur64src/vm/cointerpmt.h
M spur64src/vm/gcc3x-cointerp.c
M spur64src/vm/gcc3x-cointerpmt.c
M spurlowcode64src/vm/cogit.h
M spurlowcode64src/vm/cointerp.c
M spurlowcode64src/vm/cointerp.h
M spurlowcode64src/vm/gcc3x-cointerp.c
M spurlowcodesrc/vm/cogit.h
M spurlowcodesrc/vm/cointerp.c
M spurlowcodesrc/vm/cointerp.h
M spurlowcodesrc/vm/gcc3x-cointerp.c
M spurlowcodestack64src/vm/gcc3x-interp.c
M spurlowcodestack64src/vm/interp.c
M spurlowcodestacksrc/vm/gcc3x-interp.c
M spurlowcodestacksrc/vm/interp.c
M spursista64src/vm/cogit.h
M spursista64src/vm/cointerp.c
M spursista64src/vm/cointerp.h
M spursista64src/vm/gcc3x-cointerp.c
M spursistasrc/vm/cogit.h
M spursistasrc/vm/cointerp.c
M spursistasrc/vm/cointerp.h
M spursistasrc/vm/gcc3x-cointerp.c
M spursrc/vm/cogit.h
M spursrc/vm/cointerp.c
M spursrc/vm/cointerp.h
M spursrc/vm/cointerpmt.c
M spursrc/vm/cointerpmt.h
M spursrc/vm/gcc3x-cointerp.c
M spursrc/vm/gcc3x-cointerpmt.c
M spurstack64src/vm/gcc3x-interp.c
M spurstack64src/vm/interp.c
M spurstacksrc/vm/gcc3x-interp.c
M spurstacksrc/vm/interp.c
M src/plugins/FilePlugin/FilePlugin.c
M src/plugins/HostWindowPlugin/HostWindowPlugin.c
M src/plugins/Klatt/Klatt.c
M src/plugins/Mpeg3Plugin/Mpeg3Plugin.c
M src/plugins/RePlugin/RePlugin.c
M src/plugins/SoundPlugin/SoundPlugin.c
M src/plugins/SqueakFFIPrims/ARM32FFIPlugin.c
M src/plugins/SqueakFFIPrims/IA32FFIPlugin.c
M src/plugins/SqueakFFIPrims/X64SysVFFIPlugin.c
M src/plugins/SqueakFFIPrims/X64Win64FFIPlugin.c
M src/vm/cogit.h
M src/vm/cointerp.c
M src/vm/cointerp.h
M src/vm/cointerpmt.c
M src/vm/cointerpmt.h
M src/vm/gcc3x-cointerp.c
M src/vm/gcc3x-cointerpmt.c
M stacksrc/vm/gcc3x-interp.c
M stacksrc/vm/interp.c
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.2437
StackInterpreter:
Fix signature of reapAndResetErrorCodeTo:header: to leiminate warnings.
Generate the changed ThreadedFFIPlugin which somehow got forgot in the previous
commit.
Slang: Fix a slip in type inference. Named constants have types too.
**NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/
Functionality will be removed from GitHub.com on January 31st, 2019.
Branch: refs/heads/Cog
Home: https://github.com/OpenSmalltalk/opensmalltalk-vm
Commit: e2fa2d10b4e85f1fae03f4e759527eb8e1742385
https://github.com/OpenSmalltalk/opensmalltalk-vm/commit/e2fa2d10b4e85f1fae…
Author: Eliot Miranda <eliot.miranda(a)gmail.com>
Date: 2018-08-24 (Fri, 24 Aug 2018)
Changed paths:
M image/BuildPharo6VMMakerImage.st
M image/BuildSqueakSpurTrunkVMMakerImage.st
A image/LoadFFI.st
R image/Object-performwithwithwithwithwith.st
M image/Slang Test Workspace.text
M image/buildspurtrunkreader64image.sh
M image/buildspurtrunkreaderimage.sh
M image/getGoodSpur64VM.sh
M image/getGoodSpurVM.sh
M nsspur64src/vm/cogit.h
M nsspur64src/vm/cogitX64SysV.c
M nsspur64src/vm/cogitX64WIN64.c
M nsspur64src/vm/cointerp.c
M nsspur64src/vm/cointerp.h
M nsspur64src/vm/gcc3x-cointerp.c
M nsspur64src/vm/interp.h
M nsspursrc/vm/cogit.h
M nsspursrc/vm/cogitARMv5.c
M nsspursrc/vm/cogitIA32.c
M nsspursrc/vm/cogitMIPSEL.c
M nsspursrc/vm/cointerp.c
M nsspursrc/vm/cointerp.h
M nsspursrc/vm/gcc3x-cointerp.c
M nsspursrc/vm/interp.h
M nsspurstack64src/vm/gcc3x-interp.c
M nsspurstack64src/vm/interp.c
M nsspurstack64src/vm/interp.h
M nsspurstacksrc/vm/gcc3x-interp.c
M nsspurstacksrc/vm/interp.c
M nsspurstacksrc/vm/interp.h
M platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c
M platforms/Cross/vm/sqVirtualMachine.c
M platforms/Cross/vm/sqVirtualMachine.h
M platforms/iOS/vm/Common/Classes/sqSqueakMainApp.m
M platforms/iOS/vm/OSX/sqSqueakOSXApplication.m
A platforms/unix/vm/include_ucontext.h
M platforms/unix/vm/sqUnixMain.c
M platforms/unix/vm/sqUnixVMProfile.c
M platforms/win32/vm/sqPlatformSpecific.h
M platforms/win32/vm/sqWin32Main.c
M platforms/win32/vm/sqWin32VMProfile.c
M platforms/win32/vm/sqWin32Window.c
M spur64src/vm/cogit.h
M spur64src/vm/cogitX64SysV.c
M spur64src/vm/cogitX64WIN64.c
M spur64src/vm/cointerp.c
M spur64src/vm/cointerp.h
M spur64src/vm/cointerpmt.c
M spur64src/vm/cointerpmt.h
M spur64src/vm/gcc3x-cointerp.c
M spur64src/vm/gcc3x-cointerpmt.c
M spur64src/vm/interp.h
M spurlowcode64src/vm/cogit.h
M spurlowcode64src/vm/cogitX64SysV.c
M spurlowcode64src/vm/cogitX64WIN64.c
M spurlowcode64src/vm/cointerp.c
M spurlowcode64src/vm/cointerp.h
M spurlowcode64src/vm/gcc3x-cointerp.c
M spurlowcode64src/vm/interp.h
M spurlowcodesrc/vm/cogit.h
M spurlowcodesrc/vm/cogitARMv5.c
M spurlowcodesrc/vm/cogitIA32.c
M spurlowcodesrc/vm/cogitMIPSEL.c
M spurlowcodesrc/vm/cointerp.c
M spurlowcodesrc/vm/cointerp.h
M spurlowcodesrc/vm/gcc3x-cointerp.c
M spurlowcodesrc/vm/interp.h
M spurlowcodestack64src/vm/gcc3x-interp.c
M spurlowcodestack64src/vm/interp.c
M spurlowcodestack64src/vm/interp.h
M spurlowcodestacksrc/vm/gcc3x-interp.c
M spurlowcodestacksrc/vm/interp.c
M spurlowcodestacksrc/vm/interp.h
M spursista64src/vm/cogit.h
M spursista64src/vm/cogitX64SysV.c
M spursista64src/vm/cogitX64WIN64.c
M spursista64src/vm/cointerp.c
M spursista64src/vm/cointerp.h
M spursista64src/vm/gcc3x-cointerp.c
M spursista64src/vm/interp.h
M spursistasrc/vm/cogit.h
M spursistasrc/vm/cogitARMv5.c
M spursistasrc/vm/cogitIA32.c
M spursistasrc/vm/cogitMIPSEL.c
M spursistasrc/vm/cointerp.c
M spursistasrc/vm/cointerp.h
M spursistasrc/vm/gcc3x-cointerp.c
M spursistasrc/vm/interp.h
M spursrc/vm/cogit.h
M spursrc/vm/cogitARMv5.c
M spursrc/vm/cogitIA32.c
M spursrc/vm/cogitMIPSEL.c
M spursrc/vm/cointerp.c
M spursrc/vm/cointerp.h
M spursrc/vm/cointerpmt.c
M spursrc/vm/cointerpmt.h
M spursrc/vm/gcc3x-cointerp.c
M spursrc/vm/gcc3x-cointerpmt.c
M spursrc/vm/interp.h
M spurstack64src/vm/gcc3x-interp.c
M spurstack64src/vm/interp.c
M spurstack64src/vm/interp.h
M spurstacksrc/vm/gcc3x-interp.c
M spurstacksrc/vm/interp.c
M spurstacksrc/vm/interp.h
M src/plugins/FileAttributesPlugin/FileAttributesPlugin.c
M src/plugins/SqueakFFIPrims/ARM32FFIPlugin.c
M src/plugins/SqueakFFIPrims/IA32FFIPlugin.c
M src/plugins/SqueakFFIPrims/X64SysVFFIPlugin.c
M src/plugins/SqueakFFIPrims/X64Win64FFIPlugin.c
M src/vm/cogit.h
M src/vm/cogitARMv5.c
M src/vm/cogitIA32.c
M src/vm/cogitMIPSEL.c
M src/vm/cointerp.c
M src/vm/cointerp.h
M src/vm/cointerpmt.c
M src/vm/cointerpmt.h
M src/vm/gcc3x-cointerp.c
M src/vm/gcc3x-cointerpmt.c
M src/vm/interp.h
M stacksrc/vm/gcc3x-interp.c
M stacksrc/vm/interp.c
M stacksrc/vm/interp.h
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.2436
Core VM:
Support for failing FFI calls that raise exceptions. primitiveFailForFFIException:at:
is the entry point for the platform exception handlers (sigsegv,
squeakExceptionHandler, et al) to catch the signal and call to activate the
invoking method as a primitive failure.
Have the ThreadedFFIPlugin always call disownVM: and ownVM:, providing a flag
that states if this is a threaded callout or not, and another flag that states
that this is an FFI call.
Provide ffiExceptionResponse as a global variable the VM command line argument
processors can set. By default this is 0 and whether an FFI exception is caught
or not depends on there being an error code in the FFI callout. If there is one
any exception will be caught; if there isn't a crash will occur as always. If
ffiExceptionResponse is < 0 FFI exceptions will never be caught and never
delivered as primitive failures (which is selected by -nofailonffiexception).
If ffiExceptionResponse is > 0 then FFI exceptions will always be caught and
always delivered as primitive failures (which is selected by -failonffiexception).
primitiveFailForFFIException:at: now fails if
- in an FFI call as indicated by DisownVMForFFICall being set in inFFIFlags
- ffiExceptionResponse > 0 or ffiExceptionResponse = 0 and newMethod has an error code
So it should always be called from the platform exception handlers such as sigsegv on Unix platforms.
Refactoring:
Move reenterInterpreter up to StackInterpreter from CoInterpreter, along with
all relevant methods. Add mustBeInterpreterFrame agument to justActivateNewMethod:
to that the Cog VM can insist on activating the failing FFI invoking method in
the interpreter, which simplifies the machinery in activateFailingPrimitiveMethod,
which does the work of failing the primitive and long-jumping to the interpreter.
Fix a bug in CoInterpreter's justActivateNewMethod: which left the
instructionPointer one ahead if activating a failing primitive method.
Add primitiveFailForFFIException:at: as a setter for the exception state.
Add PrimErrFFIException. Update cloneOSErrorObj:numSlots: to deal with a three
slot subclass of PrimitiveError that adds a pc at which an exception took place
(exception can be represented by errorCode).
Misc:
Initializing extensions should occur before fetching a bytecode, in case the bytecode is itself extended.
FileAttributesPlugin:
274: Update primitiveFileStdioHandles error handling.
Previously validMask = -1 was considered an error. Now validMask < 0 is
considered an error and the value is returned to the image with
primitiveFailForOSError().
This is more robust against word length in the VM and provides a general
mechanism for the plugin to provide error information back to the image.
274: primitiveFileStdioHandles() fails to return nil if stdio file is not
available
Modify FilePlugin>>primitiveFileStdioHandles to treat validMask = 0 as
successfully determining that no stdio streams are available.
Previously validMask = 0 would result in the primitive failing with Unsupported.
However having no stdio streams available is normal on Windows, and so shouldn't
signal an error.
sqFileStdioHandlesInto() can either return -1 to signal an unspecified error or use primitiveFailFor() or primitiveFailForOSError() to specify an error.
Image Directory:
Add LoadFFI.st to ease creating spurreader images containing the FFI.
Fix the use of getGoodSpur[64]VM.sh so the buildspurtrunkreader[64]image.sh
commands can take both a -vm foo and an FFI argument.
Nuke Object-performwithwithwithwithwith.st. This is now in VMMaker.oscog.
**NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/
Functionality will be removed from GitHub.com on January 31st, 2019.
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2435.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.2435
Author: eem
Time: 24 August 2018, 4:52:23.139258 pm
UUID: b14b74e3-fc8b-4450-becf-350fc12c9ff1
Ancestors: VMMaker.oscog-eem.2434
Work around the hack use of (dis)ownVM: for storing the argumentCount of the current method on callback return in the non-threaded VM. The argument to disownVM: is either an immediate integer (callback) or flags which can't be immediate (FFI callout, plugin primitive callout). I regret this but it works, so keep it going for now.
=============== Diff against VMMaker.oscog-eem.2434 ===============
Item was changed:
----- Method: CoInterpreterMT class>>initializeMiscConstants (in category 'initialization') -----
initializeMiscConstants
super initializeMiscConstants.
"N.B. some of these DisownFlags are replicated in platforms/Cross/vm/sqVirtualMachine.h.
Hence they should always be initialized."
+ DisownVMForProcessorRelinquish := 64.
- DisownVMForProcessorRelinquish := 8.
(InitializationOptions at: #COGMTVM ifAbsent: [false]) == false ifTrue:
[^self].
COGMTVM := true.
ReturnToThreadSchedulingLoop := 2 "setjmp/longjmp code."!
Item was removed:
- ----- Method: SpurMemoryManager>>activateFailingPrimitiveMethod (in category 'simulation only') -----
- activateFailingPrimitiveMethod
- "hack around the CoInterpreter/ObjectMemory split refactoring"
- <doNotGenerate>
- ^coInterpreter activateFailingPrimitiveMethod!
Item was added:
+ ----- Method: SpurMemoryManager>>disownVM: (in category 'simulation only') -----
+ disownVM: flags
+ "hack around the CoInterpreter/ObjectMemory split refactoring"
+ <doNotGenerate>
+ ^coInterpreter disownVM: flags!
Item was added:
+ ----- Method: SpurMemoryManager>>ownVM: (in category 'simulation only') -----
+ ownVM: flags
+ "hack around the CoInterpreter/ObjectMemory split refactoring"
+ <doNotGenerate>
+ ^coInterpreter ownVM: flags!
Item was changed:
----- Method: StackInterpreter class>>initializeMiscConstants (in category 'initialization') -----
initializeMiscConstants
super initializeMiscConstants.
STACKVM := true.
"These flags function to identify a GC operation, or
to specify what operations the leak checker should be run for."
GCModeFull := 1. "stop-the-world global GC"
GCModeNewSpace := 2. "Spur's scavenge, or V3's incremental"
GCModeIncremental := 4. "incremental global gc (Dijkstra tri-colour marking); as yet unimplemented"
GCModeBecome := 8. "v3 post-become sweeping/Spur forwarding"
GCModeImageSegment := 16. "just a flag for leak checking image segments"
GCModeFreeSpace := 32. "just a flag for leak checking free space; Spur only"
GCCheckPrimCall := 64. "just a flag for leak checking external primitive calls"
StackPageTraceInvalid := -1.
StackPageUnreached := 0.
StackPageReachedButUntraced := 1.
StackPageTraced := 2.
DumpStackOnLowSpace := 0.
MillisecondClockMask := 16r1FFFFFFF.
"Note: The external primitive table should actually be dynamically sized but for the sake of inferior platforms (e.g., Mac :-) who cannot allocate memory in any reasonable way, we keep it static (and cross our fingers...)"
MaxExternalPrimitiveTableSize := 4096. "entries"
MaxJumpBuf := 32. "max. callback depth"
FailImbalancedPrimitives := InitializationOptions at: #FailImbalancedPrimitives ifAbsentPut: [true].
EnforceAccessControl := InitializationOptions at: #EnforceAccessControl ifAbsent: [true].
ReturnToInterpreter := 1. "setjmp/longjmp code."
"N.B. some of these DisownFlags are replicated in platforms/Cross/vm/sqVirtualMachine.h.
+ Hence they should always be initialized. Because of a hack with callbacks in the non-threaded
+ VM they must not conflct with the VM's tag bits."
+ DisownVMLockOutFullGC := 8.
+ DisownVMForFFICall := 16.
+ DisownVMForThreading := 32
- Hence they should always be initialized."
- DisownVMLockOutFullGC := 1.
- DisownVMForFFICall := 2.
- DisownVMForThreading := 4
!
Item was changed:
----- Method: StackInterpreter>>disownVM: (in category 'vm scheduling') -----
disownVM: flags
<api>
<inline: false>
"Release the VM to other threads and answer the current thread's index.
Currently valid flags for the non-threaded VM are:
DisownVMLockOutFullGC - prevent fullGCs while this thread disowns the VM
DisownVMForFFICall - informs the VM that it is entering an FFI call
This is the entry-point for plugins and primitives that wish to release the VM while
performing some operation that may potentially block, and for callbacks returning
back to some blocking operation. While this exists for the threaded FFI VM we use
it to reset newMethod and the argumentCount after a callback."
- self assert: ((objectMemory isIntegerObject: flags)
- and: [(objectMemory integerValueOf: flags)
- between: 0
- and: (self argumentCountOfMethodHeader: -1)]).
self assert: primFailCode = 0.
+ "Hack encodings of client state. We use non-immediates (bottom three bits clear)
+ for FFI/Plugin doing
+ save := self disownVM: FLAGS. ... callout ... self ownVM: save.
+ We use immediate integer (bottom bit 1) for callbacks doing
+ save := self ownVM: 0. ... callback ... self disownVM: save. return to C"
+ self assert: ((objectMemory isImmediate: flags)
+ ifFalse:
+ [flags = (flags bitAnd: DisownVMLockOutFullGC+DisownVMForFFICall+DisownVMForThreading)
+ and: [flags anyMask: DisownVMForFFICall]]
+ ifTrue:
+ [(objectMemory isIntegerObject: flags)
+ and: [(objectMemory integerValueOf: flags)
+ between: 0
+ and: (self argumentCountOfMethodHeader: -1)]]).
+
"If DisownVMForFFICall this is from the FFI plugin and we're making a callout; remember the fact."
+ (((objectMemory isImmediate: flags)) not
+ and: [flags anyMask: DisownVMForFFICall]) ifTrue:
- (flags anyMask: DisownVMForFFICall) ifTrue:
[self assert: ((objectMemory isOopCompiledMethod: newMethod)
and: [(self argumentCountOf: newMethod) = argumentCount]).
inFFIFlags := DisownVMForFFICall.
^flags].
+ self assert: ((objectMemory isIntegerObject: flags)
+ and: [(objectMemory integerValueOf: flags)
+ between: 0
+ and: (self argumentCountOfMethodHeader: -1)]).
+
"Otherwise this is a callback return; restore argumentCount and newMethod as per the ownVM: on callback."
argumentCount := objectMemory integerValueOf: flags.
newMethod := self popStack.
self assert: ((objectMemory isOopCompiledMethod: newMethod)
and: [(self argumentCountOf: newMethod) = argumentCount]).
^0!
Item was changed:
----- Method: StackInterpreter>>ownVM: (in category 'vm scheduling') -----
ownVM: threadIndexAndFlags
<api>
<inline: false>
"This is the entry-point for plugins and primitives that wish to reacquire the VM after having
released it via disownVM or callbacks that want to acquire it without knowing their ownership
status. While this exists for the threaded FFI VM we use it to reset newMethod and the
argumentCount after a callback.
Answer -1 if the current thread is unknown to the VM and fails to take ownership."
<var: 'amInVMThread' declareC: 'extern sqInt amInVMThread(void)'>
+ self cppIf: COGMTVM
+ ifTrue:
+ [self amInVMThread ifFalse:
+ [^-1]].
+
- self amInVMThread ifFalse:
- [^-1].
- self assert: primFailCode = 0.
self assert: ((objectMemory isOopCompiledMethod: newMethod)
and: [(self argumentCountOf: newMethod) = argumentCount]).
+ "Hack encodings of client state. We use non-immediates (bottom three bits clear)
+ for FFI/Plugin doing
+ save := self disownVM: FLAGS. ... callout ... self ownVM: save.
+ We use immediate integer (bottom bit 1) for callbacks doing
+ save := self ownVM: 0. ... callback ... self disownVM: save. return to C"
+
"If DisownVMForFFICall this is from the FFI plugin and we're returning from a callout."
(threadIndexAndFlags anyMask: DisownVMForFFICall) ifTrue:
[inFFIFlags := 0.
+ ^threadIndexAndFlags].
- ^0].
+ "Otherwise this is a callback; stash newMethod on the stack and encode
+ argumentCount in the flags retrieved when the calback calls disownVM:."
+ self assert: primFailCode = 0.
- "Otherwise this is a callback; stash newMethod on the stack and argumentCount in the flags
- we'll get back when the calback calls disownVM:."
self push: newMethod.
^objectMemory integerObjectOf: argumentCount!