Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.2436
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eliotmiranda committed Aug 25, 2018
1 parent 217e917 commit e2fa2d1
Show file tree
Hide file tree
Showing 124 changed files with 13,677 additions and 4,212 deletions.
2 changes: 1 addition & 1 deletion image/BuildPharo6VMMakerImage.st
@@ -1 +1 @@
| manifest load |manifest := #( ('http://source.squeak.org/FFI' 1 ('FFI-Pools' 'FFI-Kernel')) ('http://source.squeak.org/VMMaker' 6 ('Balloon-Engine-Pools' 'BytecodeSets.spur' 'VMMaker.oscog' 'Cog' 'CogTools' 'ImageFormat')) ('http://source.squeak.org/VMMaker' 0 ('VMMakerCompatibilityForPharo6')) ('http://ss3.gemstone.com/ss/MethodMassage' 3 ('MethodMassage' 'MethodMassageCompatibility')) ('http://www.squeaksource.com/AioPlugin' 7 ('VMConstruction-Plugins-AioPlugin')) "('http://www.squeaksource.com/Alien' 0 ('Alien-Core' 'Alien-Tests-Core' 'Alien-Win32')) already in Pharo" "('http://www.squeaksource.com/FreeTypePlus' 5 ('FreeType')) can't load this. it is toxic to Squeak 4.5" "('http://www.squeaksource.com/FreetypePlugin' 8 ('Freetype-Plugin')) hence we can do without this" ('http://www.squeaksource.com/OSProcess' 4 ('OSProcess')) ('http://www.squeaksource.com/OSProcessPlugin' 9 ('VMConstruction-Plugins-OSProcessPlugin.oscog')) "('http://www.squeaksource.com/rb' 5 ('AST-Core' 'AST-Semantic' 'AST-Tests-Core' 'AST-Tests-Semantic' 'Refactoring-Changes' 'Refactoring-Core' 'Refactoring-Environment' 'Refactoring-Tests-Changes' 'Refactoring-Tests-Core' 'Refactoring-Tests-Environment' 'Refactoring-Squeak-Platform')) already in Pharo" "This for the Klatt speech synthesiser, but seems to be AWOL" ('http://www.squeaksource.com/Speech' 2 ('SharedPool-Speech' )) ('http://www.squeaksource.com/XDCP' 9 ('VMConstruction-Plugins-XDisplayControlPlugin' )) ('http://www.squeaksource.com/Balloon3D' 9 ('Balloon3D-Constants' 'Balloon3D-Plugins' )) ('http://www.squeaksource.com/Cryptography' 9 ('CryptographyPlugins' )) ('http://smalltalkhub.com/mc/Alistair/FileAttributesPlugin/main' 9 ('FileAttributesPlugin.oscog' )) ('http://ss3.gemstone.com/ss/AndreasSystemProfiler' 9 ('AndreasProfiler')) ('http://www.squeaksource.com/Printf' 5 ('Printf')) ).load := (manifest collect: [:tuple| [:path :order :packages| | repository | repository := MCHttpRepository location: path user: 'squeak' password: 'squeak'. MCRepositoryGroup default addRepository: repository. {repository. order. packages}] valueWithArguments: tuple]) sort: [:a :b| a second <= b second].#( "'FT2Constants.st'" 'Object-performwithwithwithwithwith.st' ) do: [:fileName| (FileLocator cwd / fileName) fileIn].load do: [:tuple| [:repository :order :packages| packages do: [:package | | packageVersions latestVersion | "We need to filter-out branches of unbranched packages, but can't assume the package list is (reverse) ordered." packageVersions := ((repository retrieveVersionsWithPackageNames: Set new) "e.g. Set with: #('Alien-Core' 'IgorStasenko' 71 'Alien-Core-IgorStasenko.71.mcz')" select: [ :v | v first = package and: [(v last at: package size + 1) = $-]]) asSortedCollection: [ :a :b | a third < b third ]. latestVersion := packageVersions last fourth. [| version | version := ((MCCacheRepository default includesVersionNamed: latestVersion) ifTrue: [MCCacheRepository default] ifFalse: [repository]) loadVersionFromFileNamed: latestVersion. version load. version workingCopy repositoryGroup addRepository: repository] on: Warning do: [:ex| ((ex messageText beginsWith: 'This package depends on the following classes') or: [ex messageText beginsWith: 'About to serialize an empty diffy version.']) ifFalse: [ex pass]. ex resume]]] valueWithArguments: tuple]. UIManager default edit: 'PharoWorkspace.text' asFileReference contents label: 'Overview'. #('VM Simulation' 'Source Generation' 'Slang Test' 'In-image Compilation') reverseDo: [ :nickname | GTPlayground openContents: (nickname , ' Workspace.text') asFileReference contents label: nickname, ' Playground'].#('Cog' 'CogTools' 'VMMaker') do: [ :pkg | (RPackageSet named: pkg) definedClasses do: [ :c | c organization sortCategories. c class organization sortCategories]]."Alas not. (Smalltalk classNamed: #StackInterpreter) withAllSubclasses do: [:sic| sic reorganizeAsISeeFit]."Smalltalk snapshot: true andQuit: true
| manifest load |manifest := #( "('http://source.squeak.org/FFI' 1 ('FFI-Pools' 'FFI-Kernel')) already in Pharo" ('http://source.squeak.org/VMMaker' 6 ('Balloon-Engine-Pools' 'BytecodeSets.spur' 'VMMaker.oscog' 'Cog' 'CogTools' 'ImageFormat')) ('http://source.squeak.org/VMMaker' 0 ('VMMakerCompatibilityForPharo6')) ('http://ss3.gemstone.com/ss/MethodMassage' 3 ('MethodMassage' 'MethodMassageCompatibility')) ('http://www.squeaksource.com/AioPlugin' 7 ('VMConstruction-Plugins-AioPlugin')) "('http://www.squeaksource.com/Alien' 0 ('Alien-Core' 'Alien-Tests-Core' 'Alien-Win32')) already in Pharo" "('http://www.squeaksource.com/FreeTypePlus' 5 ('FreeType')) can't load this. it is toxic to Squeak 4.5" "('http://www.squeaksource.com/FreetypePlugin' 8 ('Freetype-Plugin')) hence we can do without this" "('http://www.squeaksource.com/OSProcess' 4 ('OSProcess')) appears to conflict with OSSVMProcess" ('http://www.squeaksource.com/OSProcessPlugin' 9 ('VMConstruction-Plugins-OSProcessPlugin.oscog')) "('http://www.squeaksource.com/rb' 5 ('AST-Core' 'AST-Semantic' 'AST-Tests-Core' 'AST-Tests-Semantic' 'Refactoring-Changes' 'Refactoring-Core' 'Refactoring-Environment' 'Refactoring-Tests-Changes' 'Refactoring-Tests-Core' 'Refactoring-Tests-Environment' 'Refactoring-Squeak-Platform')) already in Pharo" "This for the Klatt speech synthesiser, but seems to be AWOL" ('http://www.squeaksource.com/Speech' 2 ('SharedPool-Speech' )) ('http://www.squeaksource.com/XDCP' 9 ('VMConstruction-Plugins-XDisplayControlPlugin' )) ('http://www.squeaksource.com/Balloon3D' 9 ('Balloon3D-Constants' 'Balloon3D-Plugins' )) ('http://www.squeaksource.com/Cryptography' 9 ('CryptographyPlugins' )) ('http://smalltalkhub.com/mc/Alistair/FileAttributesPlugin/main' 9 ('FileAttributesPlugin.oscog' )) ('http://ss3.gemstone.com/ss/AndreasSystemProfiler' 9 ('AndreasProfiler')) ('http://www.squeaksource.com/Printf' 5 ('Printf')) ).load := (manifest collect: [:tuple| [:path :order :packages| | repository | repository := MCHttpRepository location: path user: 'squeak' password: 'squeak'. MCRepositoryGroup default addRepository: repository. {repository. order. packages}] valueWithArguments: tuple]) sort: [:a :b| a second <= b second].#( "'FT2Constants.st'" ) do: [:fileName| (FileLocator cwd / fileName) fileIn].load do: [:tuple| [:repository :order :packages| packages do: [:package | | packageVersions latestVersion | "We need to filter-out branches of unbranched packages, but can't assume the package list is (reverse) ordered." packageVersions := ((repository retrieveVersionsWithPackageNames: Set new) "e.g. Set with: #('Alien-Core' 'IgorStasenko' 71 'Alien-Core-IgorStasenko.71.mcz')" select: [ :v | v first = package and: [(v last at: package size + 1) = $-]]) asSortedCollection: [ :a :b | a third < b third ]. latestVersion := packageVersions last fourth. [| version | version := ((MCCacheRepository default includesVersionNamed: latestVersion) ifTrue: [MCCacheRepository default] ifFalse: [repository]) loadVersionFromFileNamed: latestVersion. version load. version workingCopy repositoryGroup addRepository: repository] on: Warning do: [:ex| ((ex messageText beginsWith: 'This package depends on the following classes') or: [ex messageText beginsWith: 'About to serialize an empty diffy version.']) ifFalse: [ex pass]. ex resume]]] valueWithArguments: tuple]. UIManager default edit: 'PharoWorkspace.text' asFileReference contents label: 'Overview'. #('VM Simulation' 'Source Generation' 'Slang Test' 'In-image Compilation') reverseDo: [ :nickname | GTPlayground openContents: (nickname , ' Workspace.text') asFileReference contents label: nickname, ' Playground'].#('Cog' 'CogTools' 'VMMaker') do: [ :pkg | (RPackageSet named: pkg) definedClasses do: [ :c | c organization sortCategories. c class organization sortCategories]]."Alas not. (Smalltalk classNamed: #StackInterpreter) withAllSubclasses do: [:sic| sic reorganizeAsISeeFit]."Smalltalk snapshot: true andQuit: true
Expand Down
3 changes: 1 addition & 2 deletions image/BuildSqueakSpurTrunkVMMakerImage.st
Expand Up @@ -30,8 +30,7 @@ load := (manifest collect:
{repository. order. packages}] valueWithArguments: tuple])
sort: [:a :b| a second <= b second].

#( "'FT2Constants.st'"
'Object-performwithwithwithwithwith.st' ) do:
#( "'FT2Constants.st'" ) do:
[:fileName| (FileDirectory default fileNamed: fileName) fileIn].

load do:
Expand Down
1 change: 1 addition & 0 deletions image/LoadFFI.st
@@ -0,0 +1 @@
| manifest load |manifest := #( ('http://source.squeak.org/FFI' 1 ('FFI-Pools' 'FFI-Kernel' 'FFI-MacOS' 'FFI-Unix' 'FFI-Win32' 'FFI-Tests')) ('http://www.squeaksource.com/Alien' 0 ('Alien-Core' 'Alien-Tests-Core' 'Alien-Win32')) ).load := (manifest collect: [:tuple| [:path :order :packages| | repository | repository := MCHttpRepository location: path user: 'squeak' password: 'squeak'. MCRepositoryGroup default addRepository: repository. {repository. order. packages}] valueWithArguments: tuple]) sort: [:a :b| a second <= b second].load do: [:tuple| [:repository :order :packages| packages do: [:package | | packageVersions latestVersion | "We need to filter-out branches of unbranched packages, but can't assume the package list is (reverse) ordered." packageVersions := ((repository versionNamesForPackageNamed: package) select: [:versionName| (versionName at: package size + 1) = $-]) asSortedCollection: [ :a :b | a versionNumber < b versionNumber ]. latestVersion := packageVersions last. [| version | version := ((MCCacheRepository default includesVersionNamed: latestVersion) ifTrue: [MCCacheRepository default] ifFalse: [repository]) versionNamed: latestVersion. version load. version workingCopy repositoryGroup addRepository: repository] on: Warning do: [:ex| ((ex messageText beginsWith: 'This package depends on the following classes') or: [ex messageText beginsWith: 'About to serialize an empty diffy version.']) ifFalse: [ex pass]. ex resume]]] valueWithArguments: tuple].Smalltalk snapshot: true andQuit: true
Expand Down
1 change: 0 additions & 1 deletion image/Object-performwithwithwithwithwith.st

This file was deleted.

0 comments on commit e2fa2d1

Please sign in to comment.