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

commits at source.squeak.org commits at source.squeak.org
Sat Jun 25 20:31:34 UTC 2022


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

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

Name: VMMaker.oscog-eem.3200
Author: eem
Time: 25 June 2022, 1:31:19.003777 pm
UUID: dcd3d040-95e7-43b9-a0e7-4ad384662520
Ancestors: VMMaker.oscog-eem.3199

Add a scheme to report the traceFlags in usage() on the command-line. traceFlagsMeanings is a null-terminated array of strings as per argv.

Redefine the flags so that the newspeak-only & simulation-only ones come at the end so avoid reporting unused entries.

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

Item was added:
+ ----- Method: CogVMSimulator>>primitivePropertyFlagsForSpur:numArgs: (in category 'multi-threading simulation switch') -----
+ primitivePropertyFlagsForSpur: primIndex numArgs: numArgs
+ 	"This method includes or excludes CoInterpreterMT methods as required.
+ 	 Auto-generated by CogVMSimulator>>ensureMultiThreadingOverridesAreUpToDate"
+ 
+ 	^self perform: #primitivePropertyFlagsForSpur:numArgs:
+ 		withArguments: {primIndex. numArgs}
+ 		inSuperclass: (cogThreadManager ifNil: [CoInterpreterPrimitives] ifNotNil: [CoInterpreterMT])!

Item was changed:
  ----- Method: Cogit class>>declareCVarsIn: (in category 'translation') -----
  declareCVarsIn: aCCodeGenerator
  	| backEnd |
  	backEnd := CogCompilerClass basicNew.
  	#(	'coInterpreter' 'objectMemory' 'methodZone' 'objectRepresentation'
  		'cogBlockMethodSurrogateClass' 'cogMethodSurrogateClass' 'nsSendCacheSurrogateClass'
  		'threadManager' 'processor' 'lastNInstructions' 'simulatedAddresses' 'ioHighResClock'
  		'simulatedTrampolines' 'simulatedVariableGetters' 'simulatedVariableSetters'
  		'processorFrameValid' 'printRegisters' 'printInstructions' 'clickConfirm' 'clickStepping' 'singleStep'
  		'codeZoneIsExecutableNotWritable' 'debugAPISelector' 'shortCutTrampolineBlocks'
  		'perMethodProfile' 'instructionProfile') do:
  			[:simulationVariableUnusedByRealVM|
  			aCCodeGenerator removeVariable: simulationVariableUnusedByRealVM].
  	NewspeakVM ifFalse:
  		[#(	'selfSendTrampolines' 'dynamicSuperSendTrampolines'
  			'implicitReceiverSendTrampolines' 'outerSendTrampolines'
  			'ceEnclosingObjectTrampoline' 'numIRCs' 'indexOfIRC' 'theIRCs') do:
  				[:variableNotNeededInNormalVM|
  				aCCodeGenerator removeVariable: variableNotNeededInNormalVM]].
  	aCCodeGenerator removeConstant: #COGMTVM. "this should be defined at compile time"
  	"N.B. We *do not* include sq.h; it pulls in conflicting definitions now that sqVirtualMachine.h
  	 declares cointerp's functions, and declares some of them inaccurately for histrical reasons.
  	 We pull in CoInterpreter's api via cointerp.h which is accurate."
  	aCCodeGenerator
  		addHeaderFile:'"sqConfig.h"'; "config.h must be first on linux"
  		addHeaderFile:'<stddef.h>'; "for e.g. offsetof"
  		addHeaderFile:'<stdio.h>';
  		addHeaderFile:'<stdlib.h>';
  		addHeaderFile:'<string.h>';
  		addHeaderFile:'"sqPlatformSpecific.h"'; "e.g. solaris overrides things for sqCogStackAlignment.h"
  		addHeaderFile:'"sqMemoryAccess.h"';
  		addHeaderFile:'"sqCogStackAlignment.h"';
  		addHeaderFile:'"dispdbg.h"'; "must precede cointerp.h & cogit.h otherwise NoDbgRegParms gets screwed up"
  		addHeaderFile:'"cogmethod.h"'.
  	NewspeakVM ifTrue:
  		[aCCodeGenerator addHeaderFile:'"nssendcache.h"'].
  	aCCodeGenerator
  		addHeaderFile:'#if COGMTVM';
  		addHeaderFile:'"cointerpmt.h"';
  		addHeaderFile:'#else';
  		addHeaderFile:'"cointerp.h"';
  		addHeaderFile:'#endif';
  		addHeaderFile:'"cogit.h"'.
  	aCCodeGenerator
  		var: #ceGetFP
  			declareC: 'usqIntptr_t (*ceGetFP)(void)';
  		var: #ceGetSP
  			declareC: 'usqIntptr_t (*ceGetSP)(void)';
  		var: #ceCaptureCStackPointers
  			declareC: 'void (*ceCaptureCStackPointers)(void)';
  		var: #ceInvokeInterpret
  			declareC: 'void (*ceInvokeInterpret)(void)';
  		var: #ceEnterCogCodePopReceiverReg
  			declareC: 'void (*ceEnterCogCodePopReceiverReg)(void)';
  		var: #realCEEnterCogCodePopReceiverReg
  			declareC: 'void (*realCEEnterCogCodePopReceiverReg)(void)';
  		var: #ceCallCogCodePopReceiverReg
  			declareC: 'void (*ceCallCogCodePopReceiverReg)(void)';
  		var: #realCECallCogCodePopReceiverReg
  			declareC: 'void (*realCECallCogCodePopReceiverReg)(void)';
  		var: #ceCallCogCodePopReceiverAndClassRegs
  			declareC: 'void (*ceCallCogCodePopReceiverAndClassRegs)(void)';
  		var: #realCECallCogCodePopReceiverAndClassRegs
  			declareC: 'void (*realCECallCogCodePopReceiverAndClassRegs)(void)';
  		var: #postCompileHook
  			declareC: 'void (*postCompileHook)(CogMethod *)';
  		var: #openPICList declareC: 'CogMethod *openPICList = 0';
  		var: #maxMethodBefore type: #'CogBlockMethod *';
  		var: 'enumeratingCogMethod' type: #'CogMethod *'.
  	
  	aCCodeGenerator
  		var: #ceTryLockVMOwner
  		declareC: '#if COGMTVM\usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t)\#endif'.
  
  	backEnd numICacheFlushOpcodes > 0 ifTrue:
  		[aCCodeGenerator
  			var: #ceFlushICache
  				declareC: 'static void (*ceFlushICache)(usqIntptr_t from, usqIntptr_t to)'].
  	aCCodeGenerator
  		var: #ceFlushDCache
  			declareC: '#if DUAL_MAPPED_CODE_ZONE\static void (*ceFlushDCache)(usqIntptr_t from, usqIntptr_t to)\#endif';
  		var: #codeToDataDelta
  			declareC: '#if DUAL_MAPPED_CODE_ZONE\static sqInt codeToDataDelta\#else\# define codeToDataDelta 0\#endif';
  		var: #cFramePointerInUse
  			declareC: '#if !!defined(cFramePointerInUse)\sqInt cFramePointerInUse\#endif'.
  
  	aCCodeGenerator
  		declareVar: 'aMethodLabel' type: #'AbstractInstruction'; "Has to come lexicographically before backEnd & methodLabel"
  		var: #backEnd declareC: 'AbstractInstruction * const backEnd = &aMethodLabel';
  		var: #methodLabel declareC: 'AbstractInstruction * const methodLabel = &aMethodLabel'.
  	self declareC: #(abstractOpcodes stackCheckLabel
  					blockEntryLabel blockEntryNoContextSwitch
  					stackOverflowCall sendMiss
  					entry noCheckEntry selfSendEntry dynSuperEntry
  					fullBlockNoContextSwitchEntry fullBlockEntry
  					picMNUAbort picInterpretAbort  endCPICCase0 endCPICCase1 cPICEndOfCodeLabel)
  			as: #'AbstractInstruction *'
  				in: aCCodeGenerator.
  	aCCodeGenerator
  		declareVar: #cPICPrototype type: #'CogMethod *';
  		declareVar: #blockStarts type: #'BlockStart *';
  		declareVar: #fixups type: #'BytecodeFixup *';
  		declareVar: #methodZoneBase type: #usqInt.
  	aCCodeGenerator
  		var: #ordinarySendTrampolines
  			declareC: 'sqInt ordinarySendTrampolines[NumSendTrampolines]';
  		var: #superSendTrampolines
  			declareC: 'sqInt superSendTrampolines[NumSendTrampolines]'.
  	BytecodeSetHasDirectedSuperSend ifTrue:
  		[aCCodeGenerator
  			var: #directedSuperSendTrampolines
  				declareC: 'sqInt directedSuperSendTrampolines[NumSendTrampolines]';
  			var: #directedSuperBindingSendTrampolines
  				declareC: 'sqInt directedSuperBindingSendTrampolines[NumSendTrampolines]'].
  	NewspeakVM ifTrue:
  		[aCCodeGenerator
  			var: #selfSendTrampolines
  				declareC: 'sqInt selfSendTrampolines[NumSendTrampolines]';
  			var: #dynamicSuperSendTrampolines
  				declareC: 'sqInt dynamicSuperSendTrampolines[NumSendTrampolines]';
  			var: #implicitReceiverSendTrampolines
  				declareC: 'sqInt implicitReceiverSendTrampolines[NumSendTrampolines]';
  			var: #outerSendTrampolines
  				declareC: 'sqInt outerSendTrampolines[NumSendTrampolines]'].
  	aCCodeGenerator
  		addConstantForBinding: self bindingForNumTrampolines;
  		var: #trampolineAddresses
  			declareC: 'static char *trampolineAddresses[NumTrampolines*2]';
  		var: #objectReferencesInRuntime
  			declareC: 'static usqInt objectReferencesInRuntime[NumObjRefsInRuntime+1]';
  		var: #labelCounter
  			type: #int;
  		var: #traceFlags
  			declareC: 'int traceFlags = 8 /* prim trace log on by default */';
+ 		declareVar: #traceFlagsMeanings type: #'const char *';
+ 		var: #traceFlagsMeanings
+ 			declareC: (CCodeGenerator new arrayInitializerCalled: #traceFlagsMeanings for: ((Cogit basicNew sendTrace: -1)) sizeString: nil type: #'const char *');
  		var: #cStackAlignment
  			declareC: 'const int cStackAlignment = STACK_ALIGN_BYTES'.
  	aCCodeGenerator
  		declareVar: #minValidCallAddress type: #'usqIntptr_t'.
  	aCCodeGenerator vmClass generatorTable ifNotNil:
  		[:bytecodeGenTable|
  		aCCodeGenerator
  			var: #generatorTable
  				declareC: 'static BytecodeDescriptor generatorTable[', bytecodeGenTable size printString, ']',
  							(self tableInitializerFor: bytecodeGenTable
  								in: aCCodeGenerator)].
  	"In C the abstract opcode names clash with the Smalltalk generator syntactic sugar.
  	 Most of the syntactic sugar is inlined, but alas some remains.  Rename the syntactic
  	 sugar to avoid the clash."
  	(self organization listAtCategoryNamed: #'abstract instructions') do:
  		[:s|
  		aCCodeGenerator addSelectorTranslation: s to: 'g', (aCCodeGenerator cFunctionNameFor: s)].
  	aCCodeGenerator addSelectorTranslation: #halt: to: 'haltmsg'.
  	self declareFlagVarsAsByteIn: aCCodeGenerator!

Item was changed:
  ----- Method: Cogit class>>mustBeGlobal: (in category 'translation') -----
  mustBeGlobal: var
  	"Answer if a variable must be global and exported.  Used for inst vars that are
  	 accessed from VM support code, or that need visibility at the gdb/lldb level."
  	^(#('ceBaseFrameReturnTrampoline' ceCaptureCStackPointers 'ceCheckForInterruptTrampoline'
  		ceEnterCogCodePopReceiverReg realCEEnterCogCodePopReceiverReg
  		ceCallCogCodePopReceiverReg realCECallCogCodePopReceiverReg
  		ceCallCogCodePopReceiverAndClassRegs realCECallCogCodePopReceiverAndClassRegs
  		ceInvokeInterpret 'ceReturnToInterpreterTrampoline' 'ceCannotResumeTrampoline'
  		ceTryLockVMOwner
  		'cmEntryOffset' 'cmNoCheckEntryOffset' 'cmDynSuperEntryOffset' 'cmSelfSendEntryOffset'
  		'missOffset' 'cbEntryOffset' 'cbNoSwitchEntryOffset' 'blockNoContextSwitchOffset' breakPC
  		ceGetFP ceGetSP cFramePointerInUse
  		methodZoneBase
+ 		traceFlags traceFlagsMeanings traceStores)
- 		traceFlags traceStores)
  			includes: var)
  			or: [self activeCompilerClass mustBeGlobal: var]!

Item was changed:
  ----- Method: Cogit>>breakOnImplicitReceiver (in category 'debugging') -----
  breakOnImplicitReceiver
  	<api>
+ 	<cmacro: '() (traceFlags & 256)'>
+ 	^(traceFlags bitAnd: 256) ~= 0!
- 	<cmacro: '() (traceFlags & 64)'>
- 	^(traceFlags bitAnd: 64) ~= 0!

Item was changed:
  ----- Method: Cogit>>checkStackDepthOnSend (in category 'debugging') -----
  checkStackDepthOnSend
  	<doNotGenerate>
+ 	^(traceFlags bitAnd: 512) ~= 0!
- 	^(traceFlags bitAnd: 128) ~= 0!

Item was changed:
  ----- Method: Cogit>>compileSendTrace (in category 'debugging') -----
  compileSendTrace
+ 	"2 is trace sends; 64 is traceLinkedSends"
- 	"2 is trace sends; 256 is traceLinkedSends"
  	<inline: #always>
+ 	^traceFlags allMask: 64!
- 	^traceFlags allMask: 256!

Item was changed:
  ----- Method: Cogit>>recordFastCCallPrimTrace (in category 'debugging') -----
  recordFastCCallPrimTrace
  	<api>
+ 	<cmacro: '() (traceFlags & 128)'>
+ 	^(traceFlags bitAnd: 128) ~= 0!
- 	<cmacro: '() (traceFlags & 512)'>
- 	^(traceFlags bitAnd: 512) ~= 0!

Item was changed:
  ----- Method: Cogit>>sendTrace: (in category 'debugging') -----
  sendTrace: aBooleanOrInteger
  	<doNotGenerate>
+ 	"traceFlags is a set of flags. Answer an Array of strings describing them for command-line usage info via Cogit class>>#declareCVarsIn:.
- 	"traceFlags is a set of flags.
  	 1 => print trace (if something below is selected)
  	 2 => trace sends
  	 4 => trace block activations
  	 8 => trace interpreter primitives (on by default; see Cogit class>>#declareCVarsIn:)
  	 16 => trace events (context switches, GCs, etc)
  	 32 => trace stack overflow
+ 	 64 => trace linked sends
+ 	128 => trace fast C call interpreter primitives (off by default)
+ 	256 => send breakpoint on implicit receiver (Newspeak VM only)
+ 	512 => check stack depth on send (simulation only)"
- 	 64 => send breakpoint on implicit receiver (Newspeak VM only)
- 	128 => check stack depth on send (simulation only)
- 	256 => trace linked sends
- 	512 => trace fast C call interpreter primitives (off by default)"
  	traceFlags := aBooleanOrInteger isInteger
  						ifTrue: [aBooleanOrInteger]
+ 						ifFalse: [aBooleanOrInteger ifTrue: [traceFlags bitOr: 6] ifFalse: [traceFlags bitClear: 6]].
+ 	^#('1: print trace'
+ 		 '2: trace sends'
+ 		 '4: trace block activations'
+ 		 '8: trace interpreter primitives'
+ 		'16: trace events (context switches, GCs, etc)'
+ 		'32: trace stack overflow (poll for events hook)'
+ 		'64: trace linked sends'
+ 		'128: trace fast C call interpreter primitives'),
+ 	   (NewspeakVM
+ 			ifTrue: [#('256: send breakpoint on implicit receiver' nil)]
+ 			ifFalse: [#(nil)])!
- 						ifFalse: [aBooleanOrInteger ifTrue: [traceFlags bitOr: 6] ifFalse: [traceFlags bitClear: 6]]!



More information about the Vm-dev mailing list