[Vm-dev] VM Maker: VMMaker.oscog-eem.1685.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Feb 20 01:08:54 UTC 2016


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1685.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.1685
Author: eem
Time: 19 February 2016, 5:07:14.475113 pm
UUID: 59633283-8843-4826-a68a-b23ea22d1fa8
Ancestors: VMMaker.oscog-eem.1684

Slang:
Emit constants before types to allow constant names to be used when defining types, e.g. for array extents.

Threaded FFI plugin:
Use above facility for neater declarations.
Enable generation of the ThreadedX64Win64FFIPlugin.  Declare its number of int and float reg args correctly.

=============== Diff against VMMaker.oscog-eem.1684 ===============

Item was changed:
  ----- Method: CCodeGenerator>>emitCCodeOn:doInlining:doAssertions: (in category 'C code generator') -----
  emitCCodeOn: aStream doInlining: inlineFlag doAssertions: assertionFlag
  	"Emit C code for all methods in the code base onto the given stream. All inlined method calls should already have been expanded."
  
  	| verbose methodList |
  	"method preparation"
  	verbose := false.
  	self prepareMethods.
  	verbose ifTrue: [
  		self printUnboundCallWarnings.
  		self printUnboundVariableReferenceWarnings.
  		logger cr.
  	].
  	assertionFlag ifFalse: [ self removeAssertions ].
  	self doInlining: inlineFlag.
  
  	"code generation"
  	"If we're outputting the VM put the main interpreter loop first for two reasons.
  	 1, so that the dispdbg.h header included at the bytecode dispatch can define
  	 macros that affect all C code in the interpreter,  and 2, so that all primitive
  	 functions will come after and have relatively high addresses.  This provides safety
  	 in the use of primitiveFunctionPointer as a function pointer and an index by trying
  	 to ensure that primitives have addresses much higher than any indices."
  	methodList := self sortMethods: methods.
  	(methods includesKey: #interpret) ifTrue:
  		[methodList := { methods at: #interpret }, (methodList copyWithout: (methods at: #interpret))].
  	"clean out no longer valid variable names and then
  	 handle any global variable usage in each method"
  	methodList do: [:m | self checkForGlobalUsage: (m removeUnusedTempsAndNilIfRequiredIn: self) in: m].
  	self localizeGlobalVariables.
  
  	self emitCHeaderOn: aStream.
- 	self emitCTypesOn: aStream.
  	self emitCConstantsOn: aStream.
+ 	self emitCTypesOn: aStream. "Emitting types after constants allows use of constant names, e.g. in declaring arrays."
  	self emitCFunctionPrototypes: methodList on: aStream.
  	self emitCVariablesOn: aStream.
  	self emitCMacros: methodList on: aStream.
  	self emitCMethods: methodList on: aStream.
  	self emitExportsOn: aStream.
  !

Item was changed:
  ----- Method: ThreadedFFICalloutState class>>instVarNamesAndTypesForTranslationDo: (in category 'translation') -----
  instVarNamesAndTypesForTranslationDo: aBinaryBlock
  	"enumerate aBinaryBlock with the names and C type strings for the inst vars to include in a ThreadedFFICalloutState struct."
  
  	self instVarNames do:
  		[:ivn|
  		aBinaryBlock
  			value: ivn
  			value: (ivn caseOf: {
  						['argVector']	-> [#'char *'].
  						['currentArg']	-> [#'char *'].
+ 						['limit']			-> [#'char *'].
- 						['limit']	-> [#'char *'].
  						['ffiArgSpec']	-> [#'void *'].
+ 						['stringArgs']	-> [{#'char *'. '[MaxNumArgs]'}] }
- 						['stringArgs']	-> [{#'char *'. '[', ThreadedFFIPlugin maxNumArgs printString, ']'}] }
  					otherwise:
  						[#sqInt])]!

Item was changed:
  ----- Method: ThreadedFFICalloutStateForARM class>>instVarNamesAndTypesForTranslationDo: (in category 'translation') -----
  instVarNamesAndTypesForTranslationDo: aBinaryBlock
+ 	"enumerate aBinaryBlock with the names and C type strings for the inst vars to include in a ThreadedFFICalloutState struct."
- 	"enumerate aBinaryBlock with the names and C type strings for the inst vars to include in a ReentrantFFICalloutState struct."
  
  	superclass instVarNamesAndTypesForTranslationDo: aBinaryBlock.
  	self instVarNames do:
  		[:ivn|
  		aBinaryBlock
  			value: ivn
  			value: (ivn caseOf: {
+ 						['integerRegisters']	-> [{#sqInt. '[NumIntRegArgs]'}].
+ 						['floatRegisters']	-> [{#float. '[NumFloatRegArgs]'}] }
- 						['integerRegisters']	-> [{#sqInt. '[', ThreadedARMFFIPlugin numIntRegArgs printString, ']'}].
- 						['floatRegisters']	-> [{#float. '[', ThreadedARMFFIPlugin numFloatRegArgs printString, ']'}] }
  					otherwise:
  						[#sqInt])]!

Item was changed:
  ----- Method: ThreadedFFICalloutStateForPPC class>>instVarNamesAndTypesForTranslationDo: (in category 'translation') -----
  instVarNamesAndTypesForTranslationDo: aBinaryBlock
+ 	"enumerate aBinaryBlock with the names and C type strings for the inst vars to include in a ThreadedFFICalloutState struct."
- 	"enumerate aBinaryBlock with the names and C type strings for the inst vars to include in a ReentrantFFICalloutState struct."
  
  	superclass instVarNamesAndTypesForTranslationDo: aBinaryBlock.
  	self instVarNames do:
  		[:ivn|
  		aBinaryBlock
  			value: ivn
  			value: (ivn caseOf: {
+ 						['integerRegisters']	-> [{#sqInt. '[NumIntRegArgs]'}].
+ 						['floatRegisters']	-> [{#float. '[NumFloatRegArgs]'}] }
- 						['integerRegisters']	-> [{#sqInt. '[', ThreadedPPCBEFFIPlugin numRegArgs printString, ']'}].
- 						['floatRegisters']		-> [{#double. '[', ThreadedPPCBEFFIPlugin numRegArgs printString, ']'}] }
  					otherwise:
  						[#sqInt])]!

Item was changed:
  ----- Method: ThreadedFFICalloutStateForX64 class>>instVarNamesAndTypesForTranslationDo: (in category 'translation') -----
  instVarNamesAndTypesForTranslationDo: aBinaryBlock
  	"enumerate aBinaryBlock with the names and C type strings for the inst vars to include in a ThreadedFFICalloutState struct."
  
  	ThreadedFFICalloutState instVarNamesAndTypesForTranslationDo: aBinaryBlock.
+ 	ThreadedFFICalloutStateForX64 instVarNames do:
- 	self instVarNames do:
  		[:ivn|
  		aBinaryBlock
  			value: ivn
  			value: (ivn caseOf: {
+ 						['integerRegisters']	-> [{#sqInt. '[NumIntRegArgs]'}].
+ 						['floatRegisters']	-> [{#double. '[NumFloatRegArgs]'}] }
- 						['integerRegisters']	-> [{#sqInt. '[', self pluginClass numRegArgs printString, ']'}].
- 						['floatRegisters']	-> [{#double. '[', self pluginClass numFloatRegArgs printString, ']'}] }
  					otherwise:
  						[#sqInt])]!

Item was changed:
  ----- Method: ThreadedFFIPlugin class>>generateCodeStringForPrimitives (in category 'translation') -----
  generateCodeStringForPrimitives
  	"Output a skeletal SqueakFFIPrims.c that includes the relevant FooFFIPlugin.c for
  	 each subclass based on the identifyingPredefinedMacros the subclass defines."
  	 
  	^String streamContents:
  		[:s|
  		 s nextPutAll: '/* Automatically generated by\	' withCRs.
  		 s nextPutAll: (CCodeGenerator monticelloDescriptionFor: self).
  		 s cr; nextPutAll: ' */'.
  		 s cr; cr; nextPut: $#.
+ 		 (self allSubclasses sort: [:a :b| a name < b name]) do:
- 		 (self subclasses sort: [:a :b| a name < b name]) do:
  			[:class |
  			class identifyingPredefinedMacros ifNotNil:
  				[:predefinedMacros|
  				 s nextPutAll: 'if '.
  				class includingPredefinedMacros ifNotNil:
  					[:includingMacros|
  					 includingMacros do:
  						[:predefinedMacro| s nextPutAll: 'defined('; nextPutAll: predefinedMacro; nextPutAll: ') && '].
  					 s nextPut: $(].
  				class excludingPredefinedMacros ifNotNil:
  					[:excludingMacros|
  					 excludingMacros do:
  						[:predefinedMacro| s nextPutAll: '!!defined('; nextPutAll: predefinedMacro; nextPutAll: ') && '].
  					 s nextPut: $(].
  				 predefinedMacros
  					do: [:predefinedMacro| s nextPutAll: 'defined('; nextPutAll: predefinedMacro; nextPut: $)]
  					separatedBy: [s nextPutAll: ' || '].
  				class excludingPredefinedMacros ifNotNil:
  					[s nextPut: $)].
  				class includingPredefinedMacros ifNotNil:
  					[s nextPut: $)].
  				 s cr; cr; nextPutAll: '#	include "'; nextPutAll: class moduleName; nextPutAll: '.c"'.
  				 s cr; cr; nextPutAll: '#el']].
  		 s nextPutAll: 'se'.
  		 #(	'As yet no FFI implementation appears to exist for your platform.'
  			'Consider implementing it, starting by adding a subclass of ThreadedFFIPlugin.') do:
  			[:msg| s cr; nextPutAll: '#	error '; nextPutAll: msg].
  		 s cr; nextPutAll: '#endif'; cr]!

Item was changed:
  ----- Method: ThreadedX64FFIPlugin class>>calloutStateClass (in category 'translation') -----
  calloutStateClass
+ 	^ThreadedFFICalloutStateForX64!
- 	^ThreadedFFICalloutStateForX64SysV!

Item was changed:
  ----- Method: ThreadedX64FFIPlugin class>>identifyingPredefinedMacros (in category 'translation') -----
  identifyingPredefinedMacros
  	"Answer the predefined macros that identify the platforms a subclass handles, if any.
+ 	 If the subclass isn't yet ready for production (a work in progress) simply answer nil.
+ 	 Override to filter-out this abstract class."
+ 	^nil!
- 	 If the subclass isn't yet ready for production (a work in progress) simply answer nil."
- 	^#('x86_64' '__amd64' '__x86_64' '__amd64__' '__x86_64__')!

Item was removed:
- ----- Method: ThreadedX64SysVFFIPlugin class>>calloutStateClass (in category 'translation') -----
- calloutStateClass
- 	^ThreadedFFICalloutStateForX64SysV!

Item was removed:
- ----- Method: ThreadedX64Win64FFIPlugin class>>calloutStateClass (in category 'translation') -----
- calloutStateClass
- 	^ThreadedFFICalloutStateForX64SysV!

Item was changed:
  ----- Method: ThreadedX64Win64FFIPlugin class>>initialize (in category 'class initialization') -----
  initialize
  	WordSize := 8.
+ 	NumIntRegArgs := 4.
+ 	NumFloatRegArgs := 4!
- 	NumIntRegArgs := 6.
- 	NumFloatRegArgs := 8!



More information about the Vm-dev mailing list