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

commits at source.squeak.org commits at source.squeak.org
Wed Dec 22 00:23:08 UTC 2021

Eliot Miranda uploaded a new version of VMMaker to project VM Maker:

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

Name: VMMaker.oscog-eem.3122
Author: eem
Time: 21 December 2021, 4:22:53.449826 pm
UUID: 0b780ccb-785e-4780-b94f-9f0b2d685031
Ancestors: VMMaker.oscog-eem.3121

Add the full block entry label to full block disassembly.

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

Item was changed:
  ----- Method: Cogit>>disassembleMethod:on: (in category 'disassembly') -----
  disassembleMethod: surrogateOrAddress on: aStream
  	| cogMethod mapEntries codeRanges |
  	cogMethod := surrogateOrAddress isInteger
  								ifTrue: [self cogMethodSurrogateAt: surrogateOrAddress]
  								ifFalse: [surrogateOrAddress].
  	cogMethod cmType = CMBlock ifTrue:
  		[^self disassembleMethod: cogMethod cmHomeMethod on: aStream].
  	disassemblingMethod ifNil:
  		[^[disassemblingMethod := cogMethod.
  		     self disassembleMethod: surrogateOrAddress on: aStream] ensure:
  			[disassemblingMethod := nil]].
  	self printMethodHeader: cogMethod on: aStream.
  	mapEntries := Dictionary new.
- 	(cogMethod cmType = CMMethod and: [cogMethod cmIsFullBlock]) ifFalse:
- 		[mapEntries at: cogMethod asInteger + cmEntryOffset put: 'entry'].
  	cogMethod cmType = CMMethod ifTrue:
  		[cogMethod cmIsFullBlock
+ 			ifTrue:
+ 				[mapEntries
+ 					at: cogMethod asInteger + cbNoSwitchEntryOffset put: 'noSwitchEntry';
+ 					at: cogMethod asInteger + cbEntryOffset put: 'entry']
+ 			ifFalse:
+ 				[mapEntries
+ 					at: cogMethod asInteger + cmNoCheckEntryOffset put: 'noCheckEntry';
+ 					at: cogMethod asInteger + cmEntryOffset put: 'entry']].
- 			ifTrue: [mapEntries at: cogMethod asInteger + cbNoSwitchEntryOffset put: 'noSwitchEntry']
- 			ifFalse: [mapEntries at: cogMethod asInteger + cmNoCheckEntryOffset put: 'noCheckEntry']].
  	cogMethod cmType = CMClosedPIC
  		ifTrue: "Since Tim R's lovely work on Closed PICs, PIC cases go backwards..."
  			[mapEntries at: cogMethod asInteger + firstCPICCaseOffset put: 'ClosedPICCase', MaxCPICCases printString.
  			 1 to: MaxCPICCases - 1 do:
  					at: cogMethod asInteger + firstCPICCaseOffset + (i * cPICCaseSize)
  					put: 'ClosedPICCase', (MaxCPICCases - i) printString]]
  			[self mapFor: cogMethod
  				performUntil: #collectMapEntry:address:into:
  				arg: mapEntries].
  	NewspeakVM ifTrue:
  		[objectRepresentation canPinObjects ifFalse:
  			[mapEntries keys do:
  				(mapEntries at: a) = #IsNSSendCall ifTrue:
  						at: a + backEnd jumpShortByteSize
  							put: {'Class'. #disassembleCachedOop:. (objectMemory wordSize)};
  						at: a + backEnd jumpShortByteSize + objectMemory bytesPerOop
  							put: {'ImplicitReceiver'. #disassembleCachedOop:. (objectMemory wordSize)}]]]].
  	"This would all be far more elegant and simple if we used blocks.
  	 But there are no blocks in C and the basic enumerators here need
  	 to be used in the real VM.  Apologies."
  	(codeRanges := self codeRangesFor: cogMethod) do:
  		(cogMethod cmType = CMMethod) ifTrue:
  			[mapEntries keysAndValuesDo:
  				[:mcpc :label| | bcpc selectorOrNone |
  				(((range includes: mcpc) or: [range last + 1 = mcpc])
  				 and: [(AnnotationsWithBytecodePCs includes: label)
  				 and: [range cogMethod stackCheckOffset > 0]]) ifTrue:
  					[bcpc := self bytecodePCFor: mcpc startBcpc: range startpc in: range cogMethod.
  					 bcpc ~= 0 ifTrue:
  						[label = #IsSendCall
  								[selectorOrNone := (self selectorForSendAt: mcpc annotation: IsSendCall in: cogMethod methodObject).
  								 (selectorOrNone isInteger and: [objectMemory addressCouldBeOop: selectorOrNone]) ifTrue:
  									[selectorOrNone := objectMemory stringOf: selectorOrNone].
  								selectorOrNone := ' ', selectorOrNone]
  							ifFalse: [selectorOrNone := ''].
  							at: mcpc
  							put: label, selectorOrNone, ' bc ', bcpc printString, '/', (bcpc + 1) printString]]]].
  		(cogMethod blockEntryOffset ~= 0
  		 and: [range first = (cogMethod blockEntryOffset + cogMethod asInteger)])
  				[aStream nextPutAll: 'blockEntry:'; cr.
  				 self blockDispatchFor: cogMethod
  					perform: #disassemble:from:to:arg:
  					arg: aStream]
  				[range first > (cogMethod address + cmNoCheckEntryOffset) ifTrue:
  					[self printMethodHeader: range cogMethod
  						on: aStream].
  				self maybeNoteStartpcFor: range.
  				self disassembleFrom: range first to: range last labels: mapEntries on: aStream]].
  	aStream nextPutAll: 'startpc: '; print: codeRanges first startpc; cr.
  	(cogMethod cmType = CMMethod
  	 or: [cogMethod cmType = CMOpenPIC]) ifTrue:
  		[[self mapFor: cogMethod
  			performUntil: #printMapEntry:mcpc:args:
  			arg: { aStream. codeRanges. cogMethod }]
  			on: AssertionFailure
  			do: [:ex|
  				ex primitiveChangeClassTo: ResumableVMError basicNew. ":) :) :)"
  				ex resume: nil]].

More information about the Vm-dev mailing list