[Vm-dev] VM Maker: Cog-eem.269.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Jun 18 21:51:53 UTC 2015


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

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

Name: Cog-eem.269
Author: eem
Time: 18 June 2015, 2:51:40.083 pm
UUID: 475665c8-2268-4d08-b35b-a0bd752253d0
Ancestors: Cog-eem.268

Better disassebly decoration for out-of-line literls.

=============== Diff against Cog-eem.268 ===============

Item was changed:
  ----- Method: CogProcessorAlien>>disassembleFrom:to:in:for:labels:on: (in category 'disassembly') -----
  disassembleFrom: startAddress to: endAddress in: memory for: aSymbolManager "<Cogit>" labels: labelDictionary on: aStream
  	| address |
  	address := startAddress.
  	[address <= endAddress] whileTrue:
+ 		[[:sizeArg :stringArg| | size string index offset |
- 		[[:sizeArg :stringArg| | size string |
  		size := sizeArg.
  		string := stringArg.
  		(aSymbolManager labelForPC: address) ifNotNil:
  			[:label| aStream nextPutAll: label; nextPut: $:; cr].
  		(labelDictionary at: address ifAbsent: []) ifNotNil:
  			[:label|
  			label isArray
+ 				ifTrue: [label first == #literal
+ 							ifTrue:
+ 								[aStream
+ 									nextPutAll: (address printStringBase: 16 length: 8 padded: true) asLowercase;
+ 									nextPut: $:; space;
+ 									nextPutAll: (aSymbolManager lookupAddress: (aSymbolManager objectMemory longAt: address))]
+ 							ifFalse:
+ 								[aStream
+ 									nextPutAll: label first;
+ 									nextPut: $:; cr;
+ 									nextPutAll: (address printStringBase: 16 length: 8 padded: true) asLowercase;
+ 									nextPut: $:; space;
+ 									nextPutAll: (aSymbolManager perform: label second with: address) asString].
- 				ifTrue: [aStream
- 							nextPutAll: label first;
- 							nextPut: $:; cr;
- 							nextPutAll: (address printStringBase: 16 length: 8 padded: true) asLowercase;
- 							nextPut: $:; space;
- 							nextPutAll: (aSymbolManager perform: label second with: address) asString.
  						string := nil.
  						size := label third]
  				ifFalse: [aStream nextPutAll: label; nextPut: $:; cr]].
  		string ifNotNil:
+ 			[aStream nextPutAll: (self decorateDisassembly: string for: aSymbolManager fromAddress: address).
+ 			 ((string includesSubString: ': ldr ')
+ 			  and: [(index := string indexOfSubCollection: ' [pc, #' startingAt: 1) > 0]) ifTrue:
+ 				[offset := Integer readFrom: (ReadStream on: string from: index + 6 to: string size).
+ 				 offset := address + 8 + offset.
+ 				 labelDictionary
+ 					at: offset
+ 					ifAbsentPut: []]].
- 			[aStream nextPutAll: (self decorateDisassembly: string for: aSymbolManager fromAddress: address)].
  		aStream cr; flush.
  		address := address + size]
  			valueWithArguments: (self
  									primitiveDisassembleAt: address
  									inMemory: memory)]!

Item was changed:
  ----- Method: GdbARMAlien>>decorateDisassembly:for:fromAddress: (in category 'disassembly') -----
  decorateDisassembly: anInstructionString for: aSymbolManager fromAddress: address
  "Decode what we can of the instruction and decorate it with useful stuff"
  	| word opcode rotate mode operand memory addressinatorBlock|
  	addressinatorBlock :=
  		[:value| | string |
  		(value notNil
  		 and: [(string := aSymbolManager lookupAddress: value) notNil])
  			ifTrue: [ ' = ', value hex, ' = ', string]
  			ifFalse: ['']].
  	
  	word := (memory:= aSymbolManager objectMemory) longAt: address.
  	(self instructionIsAnyB: word)
  		ifTrue:
  			[((self instructionIsB: word) or: [self instructionIsBL: word]) ifTrue:
  				["We can extract the offset from a plain B/BL instruction"
  				 operand := self extractOffsetFromBL: word..
  				 operand := operand + address + 8 bitAnd: aSymbolManager addressSpaceMask].
  			"We can't extract the offset from a  BX/BLX instructions register, unless we're at the current pc,
  			 because otherwise its current value has nothing to do with the value when this instruction is executed."
  			(self pc = address
  			 and: [(self instructionIsBX: word) or: [self instructionIsBLX: word]]) ifTrue:
  					[operand := (self perform: (self registerStateGetters at: (word bitAnd: 15) + 1))]]
  		ifFalse:
  			[(self instructionIsAnyLoadStore: word)
+ 				ifTrue:
+ 					[|baseR lit|
- 				ifTrue: [|baseR|
  					"first see if this is a load via the varBase register - quick access globals. We'll trust
  					that nobody makes a nasty instruction that uses this reg in a mean way" 
  					operand := (baseR := (word >> 16 bitAnd: 15)) = CogARMCompiler VarBaseReg
  									ifTrue: [aSymbolManager varBaseAddress + (word bitAnd: 1 << 12 - 1)]
  									ifFalse: [self pc = address ifTrue:
  												[(self register: baseR) + (self extractOffsetFromLoadStore: word)]].
+ 					"See if this is a pc-relative literal load"
+ 					baseR = CogARMCompiler PCReg ifTrue:
+ 						[lit := memory longAt: (aSymbolManager backEnd pcRelativeAddressAt: address).
+ 						 ^(aSymbolManager lookupAddress: lit)
+ 							ifNotNil: [:label| anInstructionString, ' ', label]
+ 							ifNil: [anInstructionString, ' ', lit hex]].
- 
  					"look for SP operations -pop/push"
  					 (self instructionIsPush: word) ifTrue: "push - "
  						[|srcR|
  						srcR := word >>12 bitAnd: 16rF.
  						^ (anInstructionString readStream upTo: $}), '}', (self pc = address ifTrue: ['  (', (self register: srcR) hex, ') to ',  (self sp - 4) hex] ifFalse: [''])].
  					(self instructionIsPop: word) ifTrue: "pop - " 
  						[^ (anInstructionString readStream upTo: $}), '}', (self pc = address ifTrue: ['  (', (memory longAt: self sp) hex, ') ' , ' from ' , self sp hex] ifFalse: [''])].
  
  					"look for a ld/st of the sp"
  					(self instructionIsLDRSP: word) ifTrue:
  						[^anInstructionString, '; Load SP from ', (addressinatorBlock value: operand)].
  					(self instructionIsSTRSP: word) ifTrue:
  						[^anInstructionString, '; Save SP to ', (addressinatorBlock value: operand)]]
  				ifFalse:
  					["check for SP changers not relating to read/writing data"
+ 					 (self instructionIsAlignSP: word) ifTrue:
- 					(self instructionIsAlignSP: word) ifTrue:
  						[^anInstructionString, ' ALIGN SP ', (self pc = address ifTrue: [self sp hex] ifFalse: [''])].
+ 					 (self instructionIsAddSP: word) ifTrue:
- 					(self instructionIsAddSP: word) ifTrue:
  						[^anInstructionString, ' ADD ', (word bitAnd: 16rFF) asString,' to SP ', (self pc = address ifTrue: ['= ' , self sp hex] ifFalse: [''])].
  
+ 					 "check for the end of a mov/orr/orr/orr set filling a reg with a const"
+ 					 opcode := word >> 21 bitAnd: 16rF.
+ 					 (opcode ~= CogARMCompiler orOpcode
+ 					  or: [aSymbolManager cogit backEnd literalLoadInstructionBytes = 4]) ifTrue:
- 					"check for the end of a mov/orr/orr/orr set filling a reg with a const"
- 					opcode := word >> 21 bitAnd: 16rF.
- 					 opcode ~= CogARMCompiler orOpcode ifTrue:
  						[^anInstructionString].
  					 rotate := word >> 8 bitAnd: 16rF.
  					 mode := word >> 25 bitAnd: 7.
  					 "CogARMCompiler always uses a 0 rotate in the last operand of the final ORR when building long constants."
  					 (mode = 1 and: [rotate ~= 0]) ifTrue:
  						[^anInstructionString].
  					 operand := aSymbolManager backEnd literalBeforeFollowingAddress: address + 4]].
  	"is there an interesting address with this?"
  	^anInstructionString, (addressinatorBlock value: operand)!

Item was added:
+ ----- Method: GdbARMAlien>>disassembleFrom:to:in:for:labels:on: (in category 'disassembly') -----
+ disassembleFrom: startAddress to: endAddress in: memory for: aSymbolManager "<Cogit>" labels: labelDictionary on: aStream
+ 	| address |
+ 	address := startAddress.
+ 	[address <= endAddress] whileTrue:
+ 		[[:sizeArg :stringArg| | size string index offset |
+ 		size := sizeArg.
+ 		string := stringArg.
+ 		(aSymbolManager labelForPC: address) ifNotNil:
+ 			[:label| aStream nextPutAll: label; nextPut: $:; cr].
+ 		(labelDictionary at: address ifAbsent: []) ifNotNil:
+ 			[:label|
+ 			label isArray
+ 				ifTrue: [label first == #literal
+ 							ifTrue:
+ 								[label size = 4 ifTrue:
+ 									[aStream nextPutAll: label last; nextPut: $:; cr].
+ 								 aStream
+ 									nextPutAll: (address printStringBase: 16 length: 8 padded: true) asLowercase;
+ 									nextPut: $:; space;
+ 									nextPutAll: ((aSymbolManager objectMemory longAt: address) printStringBase: 16 length: 8 padded: true) asLowercase.
+ 								 (aSymbolManager lookupAddress: (aSymbolManager objectMemory longAt: address)) ifNotNil:
+ 									[:name| aStream space; nextPutAll: name]]
+ 							ifFalse:
+ 								[aStream
+ 									nextPutAll: label first;
+ 									nextPut: $:; cr;
+ 									nextPutAll: (address printStringBase: 16 length: 8 padded: true) asLowercase;
+ 									nextPut: $:; space;
+ 									nextPutAll: (aSymbolManager perform: label second with: address) asString].
+ 						string := nil.
+ 						size := label third]
+ 				ifFalse: [aStream nextPutAll: label; nextPut: $:; cr]].
+ 		string ifNotNil:
+ 			[aStream nextPutAll: (self decorateDisassembly: string for: aSymbolManager fromAddress: address).
+ 			 (string includesSubString: ': ldr	') ifTrue:"i.e. colon space 'ldr' tab" 
+ 				[(index := string indexOfSubCollection: ' [pc, #' startingAt: 1) > 0
+ 					ifTrue:
+ 						[offset := Integer readFrom: (ReadStream on: string from: index + 7 to: (string indexOf: $] startingAt: index + 7) - 1)]
+ 					ifFalse:
+ 						[(string indexOfSubCollection: ' [pc]' startingAt: 1) > 0 ifTrue:
+ 							[offset := 0]].
+ 				 offset ifNotNil:
+ 					[offset := address + 8 + offset.
+ 					 labelDictionary
+ 						at: offset
+ 						ifPresent:
+ 							[:entry|
+ 							entry isString
+ 								ifTrue: [labelDictionary at: offset put: {#literal. offset. 4. entry}]
+ 								ifFalse: [self assert: (entry isArray and: [entry first == #literal])]]
+ 						ifAbsentPut: [{#literal. offset. 4}]]]].
+ 		aStream cr; flush.
+ 		address := address + size]
+ 			valueWithArguments: (self
+ 									primitiveDisassembleAt: address
+ 									inMemory: memory)]!



More information about the Vm-dev mailing list