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

commits at source.squeak.org commits at source.squeak.org
Sun Nov 21 23:35:55 UTC 2021


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

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

Name: Cog-eem.449
Author: eem
Time: 21 November 2021, 3:35:53.787163 pm
UUID: 832345bc-bd98-49ae-916d-5e283ea9548b
Ancestors: Cog-eem.448

CogProcessorAliens: fix several memory accesses missing the memoryOffset.  All four ISAs once again simulate Spur images correctly.

=============== Diff against Cog-eem.448 ===============

Item was changed:
  ----- Method: BochsIA32Alien>>abiMarshalArg0:arg1:in: (in category 'accessing-abstract') -----
  abiMarshalArg0: arg0 arg1: arg1 in: memory
  	"Marshal two integral arguments according to the ABI.
  	 Currently used only on processors that do ceFlushICache in machine code.
  	 CogICacheFlushingIA32Compiler does just this."
+ 	self pushWord: arg1 in: memory.
+ 	self pushWord: arg0 in: memory!
- 	self push: arg1.
- 	self push: arg0!

Item was changed:
  ----- Method: BochsIA32Alien>>handleExecutionPrimitiveFailureIn:minimumAddress: (in category 'error handling') -----
  handleExecutionPrimitiveFailureIn: memoryArray "<Bitmap|ByteArray>" minimumAddress: minimumAddress
  	"Handle an execution primitive failure.  Convert out-of-range call and absolute
  	 memory read into register instructions into ProcessorSimulationTrap signals."
  	"self printIntegerRegistersOn: Transcript"
  	"self printRegistersOn: Transcript"
+ 	| memoryOffset pc opcode |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	((pc := self eip) between: minimumAddress and: memoryArray byteSize + memoryOffset - 1) ifTrue:
+ 		[opcode := memoryArray byteAt: pc + 1 - memoryOffset.
- 	| pc opcode |
- 	((pc := self eip) between: minimumAddress and: memoryArray byteSize - 1) ifTrue:
- 		[opcode := memoryArray byteAt: pc + 1 - self primitiveMemoryOffset.
  		 opcode ~= 16r0f ifTrue:
  			[^self
  				perform: (OpcodeExceptionMap at: opcode + 1)
  				with: pc
  				with: memoryArray].
+ 		 opcode := memoryArray byteAt: pc + 2 - memoryOffset.
- 		 opcode := memoryArray byteAt: pc + 2 - self primitiveMemoryOffset.
  		 ^self
  				perform: (ExtendedOpcodeExceptionMap at: opcode + 1)
  				with: pc
  				with: memoryArray].
  	^self reportPrimitiveFailure!

Item was changed:
  ----- Method: BochsIA32Alien>>handleMovEbGbFailureAt:in: (in category 'error handling') -----
  handleMovEbGbFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>"
  	"Convert an execution primitive failure for a byte register write into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte address |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	modrmByte := memoryArray byteAt: pc + 2 - memoryOffset.
- 	| modrmByte address |
- 	modrmByte := memoryArray byteAt: pc + 2.
  	(modrmByte bitAnd: 7) ~= 4 ifTrue: "MoveRMbr with r = ESP requires an SIB byte"
  		[address := (modrmByte bitAnd: 16rC0)
  					caseOf: {
  						[0 "ModRegInd"]
+ 						->	[memoryArray unsignedLongAt: pc + 3 - memoryOffset].
- 						->	[memoryArray unsignedLongAt: pc + 3 - self primitiveMemoryOffset].
  						[16r80 "ModRegRegDisp32"]
  						->	[(self perform: (#(eax ecx edx ebx esp ebp esi edi) at: (modrmByte bitAnd: 7) + 1))
+ 								+ (memoryArray unsignedLongAt: pc + 3 - memoryOffset)
- 								+ (memoryArray unsignedLongAt: pc + 3 - self primitiveMemoryOffset)
  								bitAnd: 16rFFFFFFFF] }
  					otherwise: [^self reportPrimitiveFailure].
  		^(ProcessorSimulationTrap
  				pc: pc
  				nextpc: pc + 6
  				address: address
  				type: #write
  				accessor: (#(al cl dl bl ah ch dh bh) at: ((modrmByte >> 3 bitAnd: 7) + 1)))
  			signal].
  	^self reportPrimitiveFailure!

Item was changed:
  ----- Method: BochsIA32Alien>>handleMovEvGvFailureAt:in: (in category 'error handling') -----
  handleMovEvGvFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>"
  	"Convert an execution primitive failure for a register write into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	^((modrmByte := memoryArray byteAt: pc + 2 - memoryOffset) bitAnd: 16rC7) = 16r5 "ModRegInd & disp32"
- 	| modrmByte |
- 	^((modrmByte := memoryArray byteAt: pc + 2 - self primitiveMemoryOffset) bitAnd: 16rC7) = 16r5 "ModRegInd & disp32"
  		ifTrue:
  			[(ProcessorSimulationTrap
  					pc: pc
  					nextpc: pc + 6
+ 					address: (memoryArray unsignedLongAt: pc + 3 - memoryOffset)
- 					address: (memoryArray unsignedLongAt: pc + 3 - self primitiveMemoryOffset)
  					type: #write
  					accessor: (#(eax ecx edx ebx esp ebp esi edi) at: ((modrmByte >> 3 bitAnd: 7) + 1)))
  				signal]
  		ifFalse:
  			[self reportPrimitiveFailure]!

Item was changed:
  ----- Method: BochsIA32Alien>>handleMovGbEbFailureAt:in: (in category 'error handling') -----
  handleMovGbEbFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>"
  	"Convert an execution primitive failure for a byte register load into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte address |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	modrmByte := memoryArray byteAt: pc + 2 - memoryOffset.
- 	| modrmByte address |
- 	modrmByte := memoryArray byteAt: pc + 2.
  	address := (modrmByte bitAnd: 16rC0)
  					caseOf: {
  						[0 "ModRegInd"]
+ 						->	[memoryArray unsignedLongAt: pc + 3 - memoryOffset].
- 						->	[memoryArray unsignedLongAt: pc + 3 - self primitiveMemoryOffset].
  						[16r80 "ModRegRegDisp32"]
  						->	[(self perform: (#(eax ecx edx ebx esp ebp esi edi) at: (modrmByte bitAnd: 7) + 1))
+ 								+ (memoryArray unsignedLongAt: pc + 3 - memoryOffset)
- 								+ (memoryArray unsignedLongAt: pc + 3 - self primitiveMemoryOffset)
  								bitAnd: 16rFFFFFFFF] }
  					otherwise: [^self reportPrimitiveFailure].
  	^(ProcessorSimulationTrap
  			pc: pc
  			nextpc: pc + 6
  			address: address
  			type: #read
  			accessor: (#(al: cl: dl: bl: ah: ch: dh: bh:) at: ((modrmByte >> 3 bitAnd: 7) + 1)))
  		signal!

Item was changed:
  ----- Method: BochsIA32Alien>>handleMovGvEbFailureAt:in: (in category 'error handling') -----
  handleMovGvEbFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>"
  	"Convert an execution primitive failure for a register load into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte mode srcIsSP srcVal dst offset |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	modrmByte := memoryArray byteAt: pc + 3 - memoryOffset.
- 	| modrmByte mode srcIsSP srcVal dst offset |
- 	modrmByte := memoryArray byteAt: pc + 3.
  	mode := modrmByte >> 6 bitAnd: 3.
  	dst := #(eax: ecx: edx: ebx: esp: ebp: esi: edi:) at: ((modrmByte >> 3 bitAnd: 7) + 1).
  	mode = 0 ifTrue: "ModRegInd"
+ 		[offset := memoryArray unsignedLongAt: pc + 4 - memoryOffset. "1-relative"
- 		[offset := memoryArray unsignedLongAt: pc + 4 - self primitiveMemoryOffset. "1-relative"
  		 ^(ProcessorSimulationTrap
  					pc: pc
  					nextpc: pc + 7
  					address: offset
  					type: #read
  					accessor: dst)
  				signal].
  	srcIsSP := (modrmByte bitAnd: 7) = 4.
  	srcVal := self perform: (#(eax ecx edx ebx esp ebp esi edi) at: (modrmByte bitAnd: 7) + 1).
  	mode = 1 ifTrue: "ModRegRegDisp8"
+ 		[offset := memoryArray byteAt: pc + ((srcIsSP ifTrue: [5] ifFalse: [4] "1-relative") - memoryOffset).
- 		[offset := memoryArray byteAt: pc + ((srcIsSP ifTrue: [5] ifFalse: [4] "1-relative") - self primitiveMemoryOffset).
  		 offset > 127 ifTrue: [offset := offset - 256].
  		 ^(ProcessorSimulationTrap
  					pc: pc
  					nextpc: pc + (srcIsSP ifTrue: [5] ifFalse: [4])
  					address: (srcVal + offset bitAnd: 16rFFFFFFFF)
  					type: #read
  					accessor: dst)
  				signal].
  	mode = 2 ifTrue: "ModRegRegDisp32"
+ 		[offset := memoryArray unsignedLongAt: pc + ((srcIsSP ifTrue: [5] ifFalse: [4] "1-relative") - memoryOffset).
- 		[offset := memoryArray unsignedLongAt: pc + ((srcIsSP ifTrue: [5] ifFalse: [4] "1-relative") - self primitiveMemoryOffset).
  		 ^(ProcessorSimulationTrap
  					pc: pc
  					nextpc: pc + (srcIsSP ifTrue: [8] ifFalse: [7])
  					address: (srcVal + offset bitAnd: 16rFFFFFFFF)
  					type: #read
  					accessor: dst)
  				signal].
  	^self reportPrimitiveFailure!

Item was changed:
  ----- Method: BochsIA32Alien>>handleMovGvEvFailureAt:in: (in category 'error handling') -----
  handleMovGvEvFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>"
  	"Convert an execution primitive failure for a register load into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	^(((modrmByte := memoryArray byteAt: pc + 2 - memoryOffset) bitAnd: 16rC7) = 16r5) "ModRegInd & disp32"
- 	| modrmByte |
- 	^(((modrmByte := memoryArray byteAt: pc + 2 - self primitiveMemoryOffset) bitAnd: 16rC7) = 16r5) "ModRegInd & disp32"
  		ifTrue:
  			[(ProcessorSimulationTrap
  					pc: pc
  					nextpc: pc + 6
+ 					address: (memoryArray unsignedLongAt: pc + 3 - memoryOffset)
- 					address: (memoryArray unsignedLongAt: pc + 3 - self primitiveMemoryOffset)
  					type: #read
  					accessor: (#(eax: ecx: edx: ebx: esp: ebp: esi: edi:) at: ((modrmByte >> 3 bitAnd: 7) + 1)))
  				signal]
  		ifFalse:
  			[self reportPrimitiveFailure]!

Item was changed:
  ----- Method: BochsIA32Alien>>postCallArgumentsNumArgs:in: (in category 'execution') -----
  postCallArgumentsNumArgs: numArgs "<Integer>" in: memory "<ByteArray|Bitmap>"
  	"Answer an argument vector of the requested size after a vanilla
  	 ABI call.  On IA32 this typically means accessing stacked arguments
  	 beyond the pushed return address and saved frame pointer.
  	 For compatibility with Cog/Slang we answer unsigned values."
+ 	| memoryOffset |
+ 	memoryOffset := self ebp - self primitiveMemoryOffset.
  	^(9 to: numArgs * 4 + 5 by: 4) collect:
  		[:i|
+ 		memory unsignedLongAt: memoryOffset + i]!
- 		memory unsignedLongAt: self ebp + i bigEndian: false]!

Item was changed:
  ----- Method: BochsX64Alien>>handleExecutionPrimitiveFailureIn:minimumAddress: (in category 'error handling') -----
  handleExecutionPrimitiveFailureIn: memoryArray "<Bitmap|ByteArray>" minimumAddress: minimumAddress
  	"Handle an execution primitive failure.  Convert out-of-range call and absolute
  	 memory read into register instructions into ProcessorSimulationTrap signals."
  	"self printIntegerRegistersOn: Transcript"
  	"self printRegistersOn: Transcript"
+ 	| memoryOffset pc opcode rexByteOrNil |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	((pc := self rip) between: minimumAddress and: memoryArray byteSize + memoryOffset - 1) ifTrue:
+ 		[opcode := memoryArray byteAt: pc + 1 - memoryOffset.
- 	| pc opcode rexByteOrNil |
- 	((pc := self rip) between: minimumAddress and: memoryArray byteSize - 1) ifTrue:
- 		[opcode := memoryArray byteAt: pc + 1 - self primitiveMemoryOffset.
  		 (opcode bitAnd: 16rF8) = self rexPrefix ifTrue: "skip rex prefix if present"
  			[rexByteOrNil := opcode.
+ 			 opcode := memoryArray byteAt: pc + 2 - memoryOffset].
- 			 opcode := memoryArray byteAt: pc + 2 - self primitiveMemoryOffset].
  		 ^self
  			perform: (OpcodeExceptionMap at: opcode + 1)
  			with: pc
  			with: memoryArray
  			with: rexByteOrNil].
  	^self reportPrimitiveFailure!

Item was changed:
  ----- Method: BochsX64Alien>>handleGroup6through10FailureAt:in:rex: (in category 'error handling') -----
  handleGroup6through10FailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>" rex: rexByteOrNil "<Integer|nil>"
  	"Convert an execution primitive failure for a group 6 instruction into the relevant ProcessorSimulationTrap signal."
+ 	| memoryOffset rexByte modrmByte baseReg srcReg |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	(((rexByte := memoryArray byteAt: pc + 2 - memoryOffset) bitAnd: 16rF8) = self rexPrefix
+ 	and: [(memoryArray byteAt: pc + 3 - memoryOffset) = 16r0F
+ 	and: [(memoryArray byteAt: pc + 4 - memoryOffset) = 16rB1]]) ifTrue:
+ 		[modrmByte := memoryArray byteAt: pc + 5 - memoryOffset.
- 	| rexByte modrmByte baseReg srcReg |
- 	(((rexByte := memoryArray byteAt: pc + 2 - self primitiveMemoryOffset) bitAnd: 16rF8) = self rexPrefix
- 	and: [(memoryArray byteAt: pc + 3 - self primitiveMemoryOffset) = 16r0F
- 	and: [(memoryArray byteAt: pc + 4 - self primitiveMemoryOffset) = 16rB1]]) ifTrue:
- 		[modrmByte := memoryArray byteAt: pc + 5 - self primitiveMemoryOffset.
  		 modrmByte >> 6 = 0 ifTrue: "ModRegInd"
  			[srcReg := (modrmByte >> 3 bitAnd: 7) + ((rexByte bitAnd: 4) bitShift: 1).
  			 baseReg := (modrmByte bitAnd: 7) + ((rexByte bitAnd: 1) bitShift: 3).
  			^(CompareAndSwapSimulationTrap
  						pc: pc
  						nextpc: pc + 5
  						address: (self perform: (self registerStateGetters at: baseReg + 1))
  						type: #write
  						accessor: (self registerStateSetters at: srcReg + 1))
  					failedComparisonRegisterAccessor: #rax:;
  					expectedValue: self rax;
  					storedValue: (self perform: (self registerStateGetters at: srcReg + 1));
  					signal]].
  	self reportPrimitiveFailure!

Item was changed:
  ----- Method: BochsX64Alien>>handleMovEbGbFailureAt:in:rex: (in category 'error handling') -----
  handleMovEbGbFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>" rex: rexByteOrNil "<Integer|nil>"
  	"Convert an execution primitive failure for a byte register write into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte offset size baseReg srcReg |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	modrmByte := memoryArray byteAt: pc + 3 - memoryOffset.
- 	| modrmByte offset size baseReg srcReg |
- 	modrmByte := memoryArray byteAt: pc + 3.
  	(modrmByte bitAnd: 16rC0) caseOf: {
+ 		[16r80 "ModRegRegDisp32"] -> [offset := memoryArray unsignedLongAt: pc + 4 - memoryOffset.
- 		[16r80 "ModRegRegDisp32"] -> [offset := memoryArray unsignedLongAt: pc + 4 - self primitiveMemoryOffset.
  										 size := 7].
+ 		[16r40 "ModRegRegDisp8"] -> [offset := memoryArray byteAt: pc + 4 - memoryOffset.
- 		[16r40 "ModRegRegDisp8"] -> [offset := memoryArray byteAt: pc + 4 - self primitiveMemoryOffset.
  										offset > 127 ifTrue: [offset := offset - 256].
  										 size := 4].
  		[16r0 "ModRegInd"] -> [offset := 0.
  								size := 3]}
  		otherwise: [self reportPrimitiveFailure].
  	srcReg := (modrmByte >> 3 bitAnd: 7) + ((rexByteOrNil bitAnd: 4) bitShift: 1).
  	baseReg := (modrmByte bitAnd: 7) + ((rexByteOrNil bitAnd: 1) bitShift: 3).
  	^(ProcessorSimulationTrap
  			pc: pc
  			nextpc: pc + size
  			address: (((self perform: (self registerStateGetters at: baseReg + 1))
  					+ offset)
  						bitAnd: 16rFFFFFFFFFFFFFFFF)
  			type: #write
  			accessor: (#(al cl dl bl spl bpl sil dil r8l r9l r10l r11l r12l r13l r14l r15l) at: srcReg + 1))
  		signal!

Item was changed:
  ----- Method: BochsX64Alien>>handleMovEvGvFailureAt:in:rex: (in category 'error handling') -----
  handleMovEvGvFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>" rex: rexByteOrNil "<Integer|nil>"
  	"Convert an execution primitive failure for a register write into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte getter base offset |
+ 	memoryOffset := self primitiveMemoryOffset.
- 	| modrmByte getter base offset |
  	self assert: rexByteOrNil notNil.
+ 	modrmByte := memoryArray byteAt: pc + 3 - memoryOffset.
- 	modrmByte := memoryArray byteAt: pc + 3 - self primitiveMemoryOffset.
  	getter := self registerStateGetters at: (modrmByte >> 3 bitAnd: 7) + ((rexByteOrNil bitAnd: 4) << 1) + 1.
  	(modrmByte bitAnd: 16rC7) = 16r5 ifTrue: "ModRegInd & disp32"
  		[^(ProcessorSimulationTrap
  				pc: pc
  				nextpc: pc + 7
+ 				address: (memoryArray unsignedLongAt: pc + 4 - memoryOffset)
- 				address: (memoryArray unsignedLongAt: pc + 4 - self primitiveMemoryOffset)
  				type: #write
  				accessor: getter)
  			signal].
  	(modrmByte bitAnd: 16rC0) = 0 ifTrue: "ModRegInd"
  		[base := self registerStateGetters at: (modrmByte bitAnd: 7) + ((rexByteOrNil bitAnd: 1) << 3) + 1.
  		 ^(ProcessorSimulationTrap
  				pc: pc
  				nextpc: pc + 3
  				address: (self perform: base)
  				type: #write
  				accessor: getter)
  			signal].
  	(modrmByte bitAnd: 16rC0) = 16r80 ifTrue: "ModRegRegDisp32"
+ 		[offset := memoryArray longAt: pc + 4 - memoryOffset.
- 		[offset := memoryArray longAt: pc + 4 - self primitiveMemoryOffset.
  		 base := self registerStateGetters at: (modrmByte bitAnd: 7) + ((rexByteOrNil bitAnd: 1) << 3) + 1.
  		 ^(ProcessorSimulationTrap
  				pc: pc
  				nextpc: pc + 7
  				address: (self perform: base) + offset
  				type: #write
  				accessor: getter)
  			signal].
  	(modrmByte bitAnd: 16rC0) = 16r40 ifTrue: "ModRegRegDisp8"
+ 		[offset := memoryArray unsignedByteAt: pc + 4 - memoryOffset.
- 		[offset := memoryArray unsignedByteAt: pc + 4 - self primitiveMemoryOffset.
  		 offset > 127 ifTrue: [offset := offset - 256].
  		 base := self registerStateGetters at: (modrmByte bitAnd: 7) + ((rexByteOrNil bitAnd: 1) << 3) + 1.
  		 ^(ProcessorSimulationTrap
  				pc: pc
  				nextpc: pc + 4
  				address: (self perform: base) + offset
  				type: #write
  				accessor: getter)
  			signal].
  	^self reportPrimitiveFailure!

Item was changed:
  ----- Method: BochsX64Alien>>handleMovGbEbFailureAt:in:rex: (in category 'error handling') -----
  handleMovGbEbFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>" rex: rexByteOrNil "<Integer|nil>"
  	"Convert an execution primitive failure for a byte register load into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte offset size |
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	modrmByte := memoryArray byteAt: pc + 3 - memoryOffset.
- 	| modrmByte offset size |
- 	modrmByte := memoryArray byteAt: pc + 3 - self primitiveMemoryOffset.
  	(modrmByte bitAnd: 16rC0) caseOf: {
+ 		[16r80 "ModRegRegDisp32"] -> [offset := memoryArray unsignedLongAt: pc + 4 - memoryOffset.
- 		[16r80 "ModRegRegDisp32"] -> [offset := memoryArray unsignedLongAt: pc + 4 - self primitiveMemoryOffset.
  										 size := 7].
+ 		[16r40 "ModRegRegDisp8"] -> [offset := memoryArray byteAt: pc + 4 - memoryOffset.
- 		[16r40 "ModRegRegDisp8"] -> [offset := memoryArray byteAt: pc + 4.
  										offset > 127 ifTrue: [offset := offset - 256].
  										 size := 4] }
  		otherwise: [self reportPrimitiveFailure].
  	^(ProcessorSimulationTrap
  			pc: pc
  			nextpc: pc + size
  			address: (((self perform: (self registerStateGetters at: (modrmByte bitAnd: 7) + ((rexByteOrNil bitAnd: 1) bitShift: 3) + 1))
  					+ offset)
  						bitAnd: 16rFFFFFFFFFFFFFFFF)
  			type: #read
  			accessor: (#(al: cl: dl: bl: spl: bpl: sil: dil: r8l: r9l: r10l: r11l: r12l: r13l: r14l: r15l:) at: ((modrmByte >> 3 bitAnd: 7) + ((rexByteOrNil bitAnd: 4) bitShift: 1) + 1)))
  		signal!

Item was changed:
  ----- Method: BochsX64Alien>>handleMovGvEbFailureAt:in:rex: (in category 'error handling') -----
  handleMovGvEbFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>" rex: rexByteOrNil "<Integer|nil>"
  	"Convert an execution primitive failure for a register load into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte mode srcIsSP srcVal dst offset |
- 	| modrmByte mode srcIsSP srcVal dst offset |
  	self shouldBeImplemented.
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	modrmByte := memoryArray byteAt: pc + 3 - memoryOffset.
- 	modrmByte := memoryArray byteAt: pc + 3.
  	mode := modrmByte >> 6 bitAnd: 3.
  	srcIsSP := (modrmByte bitAnd: 7) = 4.
  	srcVal := self perform: (#(eax ecx edx ebx esp ebp esi edi) at: (modrmByte bitAnd: 7) + 1).
  	dst := #(eax: ecx: edx: ebx: esp: ebp: esi: edi:) at: ((modrmByte >> 3 bitAnd: 7) + 1).
  	mode = 1 ifTrue: "ModRegRegDisp8"
+ 		[offset := memoryArray byteAt: pc + ((srcIsSP ifTrue: [5] ifFalse: [4] "1-relative") - memoryOffset). 
- 		[offset := memoryArray byteAt: pc + ((srcIsSP ifTrue: [5] ifFalse: [4] "1-relative") - self primitiveMemoryOffset). 
  		 offset > 127 ifTrue: [offset := offset - 256].
  		 ^(ProcessorSimulationTrap
  					pc: pc
  					nextpc: pc + (srcIsSP ifTrue: [5] ifFalse: [4])
  					address: ((srcVal + offset) bitAnd: 16rFFFFFFFF)
  					type: #read
  					accessor: dst)
  				signal].
  	mode = 2 ifTrue: "ModRegRegDisp32"
+ 		[offset := memoryArray unsignedLongAt: pc + ((srcIsSP ifTrue: [5] ifFalse: [4] "1-relative") - memoryOffset). 
- 		[offset := memoryArray unsignedLongAt: pc + ((srcIsSP ifTrue: [5] ifFalse: [4] "1-relative") - self primitiveMemoryOffset). 
  		 ^(ProcessorSimulationTrap
  					pc: pc
  					nextpc: pc + (srcIsSP ifTrue: [8] ifFalse: [7])
  					address: ((srcVal + offset) bitAnd: 16rFFFFFFFF)
  					type: #read
  					accessor: dst)
  				signal].
  	^self reportPrimitiveFailure!

Item was changed:
  ----- Method: BochsX64Alien>>handleMovGvEvFailureAt:in:rex: (in category 'error handling') -----
  handleMovGvEvFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>" rex: rexByteOrNil "<Integer|nil>"
  	"Convert an execution primitive failure for a register load into a ProcessorSimulationTrap signal."
+ 	| memoryOffset modrmByte getter setter offset |
- 	| modrmByte getter setter offset |
  	self assert: rexByteOrNil notNil.
+ 	memoryOffset := self primitiveMemoryOffset.
+ 	modrmByte := memoryArray byteAt: pc + 3 - memoryOffset.
- 	modrmByte := memoryArray byteAt: pc + 3 - self primitiveMemoryOffset.
  	setter := self registerStateSetters at: ((modrmByte >> 3 bitAnd: 7) + ((rexByteOrNil bitAnd: 4) << 1) + 1).
  	(modrmByte bitAnd: 16rC7) = 16r5 ifTrue: "ModRegInd & disp32"
  		[^(ProcessorSimulationTrap
  				pc: pc
  				nextpc: pc + 7
+ 				address: (memoryArray unsignedLongAt: pc + 4 - memoryOffset)
- 				address: (memoryArray unsignedLongAt: pc + 4 - self primitiveMemoryOffset)
  				type: #read
  				accessor: setter)
  			signal].
  	getter := self registerStateGetters at: ((modrmByte bitAnd: 7) + ((rexByteOrNil bitAnd: 1) << 3) + 1).
  	(modrmByte bitAnd: 16rC0) = 16r80 ifTrue: "ModRegRegDisp32"
+ 		[offset := memoryArray longAt: pc + 4 - memoryOffset.
- 		[offset := memoryArray longAt: pc + 4 - self primitiveMemoryOffset.
  		 ^(ProcessorSimulationTrap
  				pc: pc
  				nextpc: pc + 7
  				address: (self perform: getter) + offset
  				type: #read
  				accessor: setter)
  			signal].
  	(modrmByte bitAnd: 16rC0) = 16r40 ifTrue: "ModRegRegDisp8"
+ 		[offset := memoryArray byteAt: pc + 4 - memoryOffset.
- 		[offset := memoryArray byteAt: pc + 4 - self primitiveMemoryOffset.
  		 offset > 16r7F ifTrue:
  			[offset := offset - 16r100].
  		 ^(ProcessorSimulationTrap
  				pc: pc
  				nextpc: pc + 4
  				address: (self perform: getter) + offset
  				type: #read
  				accessor: setter)
  			signal].
  	(modrmByte bitAnd: 16rC0) = 16r00 ifTrue: "ModRegInd"
  		[^(ProcessorSimulationTrap
  				pc: pc
  				nextpc: pc + 3
  				address: (self perform: getter)
  				type: #read
  				accessor: setter)
  			signal].
  	^self reportPrimitiveFailure!

Item was changed:
  ----- Method: GdbARMAlien>>handleExecutionPrimitiveFailureIn:minimumAddress: (in category 'error handling') -----
  handleExecutionPrimitiveFailureIn: memoryArray "<Bitmap|ByteArray>" minimumAddress: minimumAddress "<Integer>"
  	"Handle an execution primitive failure.  Convert out-of-range call and absolute
  	 memory read into register instructions into ProcessorSimulationTrap signals."
  	"self printRegistersOn: Transcript"
+ 	| pcOnEntry pc memoryOffset instr |
- 	| pcOnEntry pc instr |
  	pc := pcOnEntry := self pc.
  	self endCondition = InstructionPrefetchError ifTrue:
  		[pc := self pc: self priorPc].
  
+ 	memoryOffset := self primitiveMemoryOffset.
- 	(pc between: minimumAddress and: memoryArray byteSize - 1) ifTrue:
- 		[instr := memoryArray unsignedLongAt:  pc + 1 - self primitiveMemoryOffset.
  
+ 	(pc between: minimumAddress and: memoryArray byteSize + memoryOffset - 1) ifTrue:
+ 		[instr := memoryArray unsignedLongAt:  pc + 1 - memoryOffset.
+ 
  		 (self endCondition = InstructionPrefetchError) ifTrue:
  			[^self handleFailingBranch: instr to: pcOnEntry at: pc].
  
  		 (self instructionIsAnyLoadStore: instr) ifTrue:
  			[^self handleFailingLoadStore: instr at: pc].
  
  		 (self instructionIsAnyFPArithmetic: instr) ifTrue:
  			[^self handleFailingFPArithmetic: instr at: pc].
  
  		 ^self handleExecutionPrimitiveFailureAt: pc in: memoryArray].
  
  	^self reportPrimitiveFailure!

Item was changed:
  ----- Method: GdbARMAlien>>handleExecutionPrimitiveFailureIn:minimumAddress:code: (in category 'error handling') -----
  handleExecutionPrimitiveFailureIn: memoryArray "<Bitmap|ByteArray>" minimumAddress: minimumAddress "<Integer>"code: errorCode "<Integer>"
  	"Handle an execution primitive failure.  Convert out-of-range call and absolute
  	 memory read into register instructions into ProcessorSimulationTrap signals."
  	"self printRegistersOn: Transcript"
+ 	| pcOnEntry pc memoryOffset instr |
- 	| pcOnEntry pc instr |
  	pc := pcOnEntry := self pc.
  	errorCode = InstructionPrefetchError ifTrue:
  		[pc := self pc: self priorPc].
  
+ 	memoryOffset := self primitiveMemoryOffset.
- 	(pc between: minimumAddress and: memoryArray byteSize - 1) ifTrue:
- 		[instr := memoryArray unsignedLongAt: pc + 1 - self primitiveMemoryOffset.
  
+ 	(pc between: minimumAddress and: memoryArray byteSize + memoryOffset - 1) ifTrue:
+ 		[instr := memoryArray unsignedLongAt: pc + 1 - memoryOffset.
+ 
  		 errorCode = InstructionPrefetchError ifTrue:
  			[^self handleFailingBranch: instr to: pcOnEntry at: pc].
  
  		 (self instructionIsAnyLoadStore: instr) ifTrue:
  			[^self handleFailingLoadStore: instr at: pc].
  
  		 (self instructionIsAnyFPArithmetic: instr) ifTrue:
  			[^self handleFailingFPArithmetic: instr at: pc]].
  
  	^self reportPrimitiveFailure!



More information about the Vm-dev mailing list