Eliot Miranda uploaded a new version of Cog to project VM Maker: http://source.squeak.org/VMMaker/Cog-eem.415.mcz ==================== Summary ==================== Name: Cog-eem.415 Author: eem Time: 28 October 2020, 10:55:45.197107 am UUID: 27a88b2a-20d1-48c2-b467-f3d84eb216f2 Ancestors: Cog-eem.414 Add the offset version of the run/step primitives which allow simulation of the simulator. Add the metacircular simulation methods for them. Recategorise the old more-arguments run/step primitives as legacy. =============== Diff against Cog-eem.414 =============== Item was changed: + ----- Method: ProcessorSimulatorPlugin>>primitiveRunInMemory:minimumAddress:maximumAddress:readOnlyBelow: (in category 'primitives-legacy') ----- - ----- Method: ProcessorSimulatorPlugin>>primitiveRunInMemory:minimumAddress:maximumAddress:readOnlyBelow: (in category 'primitives') ----- "cpuAlien <BochsIA32|X86Alien>" primitiveRunInMemory: memory "<Bitmap|ByteArray|WordArray>" minimumAddress: minAddress "<Integer>" maximumAddress: maxAddress "<Integer>" readOnlyBelow: minWriteMaxExecAddress "<Integer>" "Run the cpu using the first argument as the memory and the following arguments defining valid addresses, running until it halts or hits an exception." + <legacy> | cpuAlien cpu memorySize maybeErr | <var: #cpu type: #'void *'> cpuAlien := self primitive: #primitiveRunInMemoryMinAddressMaxAddressReadWrite parameters: #(WordsOrBytes SmallInteger SmallInteger SmallInteger) receiver: #Oop. (cpu := self cCoerceSimple: (self startOfData: cpuAlien) to: #'void *') = 0 ifTrue: [^interpreterProxy primitiveFailFor: PrimErrBadReceiver]. (minAddress < 0 or: [maxAddress < 0 or: [minWriteMaxExecAddress < 0]]) ifTrue: [^self primitiveFailFor: PrimErrBadArgument]. "Add forceStopOnInterrupt to the interrupt check chain. It is our responsibility to chain calls, hence we remember any previous client in prevInterruptCheckChain." + prevInterruptCheckChain := interpreterProxy setInterruptCheckChain: #forceStopOnInterrupt. + prevInterruptCheckChain = #forceStopOnInterrupt ifTrue: - prevInterruptCheckChain := interpreterProxy setInterruptCheckChain: #forceStopOnInterrupt asSymbol. - prevInterruptCheckChain = #forceStopOnInterrupt asSymbol ifTrue: [prevInterruptCheckChain := 0]. memorySize := interpreterProxy byteSizeOf: memory cPtrAsOop. maybeErr := self runCPU: cpu In: memory Size: (memorySize min: maxAddress) MinAddressRead: minAddress Write: minWriteMaxExecAddress. interpreterProxy setInterruptCheckChain: prevInterruptCheckChain. maybeErr ~= 0 ifTrue: [^interpreterProxy primitiveFailForOSError: maybeErr]. ^cpuAlien! Item was changed: ----- Method: ProcessorSimulatorPlugin>>primitiveRunInMemory:minimumAddress:readOnlyBelow: (in category 'primitives') ----- "cpuAlien <BochsIA32|X86Alien>" primitiveRunInMemory: memory "<Bitmap|ByteArray|WordArray>" minimumAddress: minAddress "<Integer>" readOnlyBelow: minWriteMaxExecAddress "<Integer>" "Run the cpu using the first argument as the memory and the following arguments defining valid addresses, running until it halts or hits an exception." | cpuAlien cpu maybeErr | <var: #cpu type: #'void *'> cpuAlien := self primitive: #primitiveRunInMemoryMinimumAddressReadWrite parameters: #(WordsOrBytes SmallInteger SmallInteger) receiver: #Oop. (cpu := self cCoerceSimple: (self startOfData: cpuAlien) to: #'void *') = 0 ifTrue: [^interpreterProxy primitiveFailFor: PrimErrBadReceiver]. (minAddress < 0 or: [minWriteMaxExecAddress < 0]) ifTrue: [^self primitiveFailFor: PrimErrBadArgument]. + prevInterruptCheckChain := interpreterProxy setInterruptCheckChain: #forceStopOnInterrupt. + prevInterruptCheckChain = #forceStopOnInterrupt ifTrue: - prevInterruptCheckChain := interpreterProxy setInterruptCheckChain: #forceStopOnInterrupt asSymbol. - prevInterruptCheckChain = #forceStopOnInterrupt asSymbol ifTrue: [prevInterruptCheckChain := 0]. maybeErr := self runCPU: cpu In: memory Size: (interpreterProxy byteSizeOf: memory cPtrAsOop) MinAddressRead: minAddress Write: minWriteMaxExecAddress. interpreterProxy setInterruptCheckChain: prevInterruptCheckChain. maybeErr ~= 0 ifTrue: [^interpreterProxy primitiveFailForOSError: maybeErr]. ^cpuAlien! Item was added: + ----- Method: ProcessorSimulatorPlugin>>primitiveRunInMemory:offsetBy:minimumAddress:readOnlyBelow: (in category 'primitives') ----- + "cpuAlien <ProcessorSimulatorAlien>" primitiveRunInMemory: memory "<BitsObject>" offsetBy: offset "<Integer>" minimumAddress: minAddress "<Integer>" readOnlyBelow: minWriteMaxExecAddress "<Integer>" + "Run the cpu using the first argument as the memory and the following arguments defining valid addresses, running until it halts or hits an exception." + | cpuAlien cpu maybeErr | + <var: #cpu type: #'void *'> + cpuAlien := self primitive: #primitiveRunInMemoryMinimumAddressReadWrite + parameters: #(WordsOrBytes SmallInteger SmallInteger SmallInteger) + receiver: #Oop. + (cpu := self cCoerceSimple: (self startOfData: cpuAlien) to: #'void *') = 0 ifTrue: + [^interpreterProxy primitiveFailFor: PrimErrBadReceiver]. + (minAddress < 0 + or: [minWriteMaxExecAddress < 0]) ifTrue: + [^self primitiveFailFor: PrimErrBadArgument]. + prevInterruptCheckChain := interpreterProxy setInterruptCheckChain: #forceStopOnInterrupt. + prevInterruptCheckChain = #forceStopOnInterrupt ifTrue: + [prevInterruptCheckChain := 0]. + maybeErr := self runCPU: cpu + In: (self cCoerceSimple: memory to: #'char *') + offset + Size: (interpreterProxy byteSizeOf: memory cPtrAsOop) + MinAddressRead: minAddress + Write: minWriteMaxExecAddress. + interpreterProxy setInterruptCheckChain: prevInterruptCheckChain. + maybeErr ~= 0 ifTrue: + [^interpreterProxy primitiveFailForOSError: maybeErr]. + ^cpuAlien! Item was changed: + ----- Method: ProcessorSimulatorPlugin>>primitiveSingleStepInMemory:minimumAddress:maximumAddress:readOnlyBelow: (in category 'primitives-legacy') ----- - ----- Method: ProcessorSimulatorPlugin>>primitiveSingleStepInMemory:minimumAddress:maximumAddress:readOnlyBelow: (in category 'primitives') ----- "cpuAlien <BochsIA32|X86Alien>" primitiveSingleStepInMemory: memory "<Bitmap|ByteArray|WordArray>" minimumAddress: minAddress "<Integer>" maximumAddress: maxAddress "<Integer>" readOnlyBelow: minWriteMaxExecAddress "<Integer>" "Single-step the cpu using the first argument as the memory and the following arguments defining valid addresses." + <legacy> | cpuAlien cpu memorySize maybeErr | <var: #cpu type: #'void *'> cpuAlien := self primitive: #primitiveSingleStepInMemoryMinAddressMaxAddressReadWrite parameters: #(WordsOrBytes SmallInteger SmallInteger SmallInteger) receiver: #Oop. (cpu := self cCoerceSimple: (self startOfData: cpuAlien) to: #'void *') = 0 ifTrue: [^interpreterProxy primitiveFailFor: PrimErrBadReceiver]. (minAddress < 0 or: [maxAddress < 0 or: [minWriteMaxExecAddress < 0]]) ifTrue: [^self primitiveFailFor: PrimErrBadArgument]. memorySize := interpreterProxy byteSizeOf: memory cPtrAsOop. maybeErr := self singleStepCPU: cpu In: memory Size: (memorySize min: maxAddress) MinAddressRead: minAddress Write: minWriteMaxExecAddress. maybeErr ~= 0 ifTrue: [^interpreterProxy primitiveFailForOSError: maybeErr]. ^cpuAlien! Item was added: + ----- Method: ProcessorSimulatorPlugin>>primitiveSingleStepInMemory:offsetBy:minimumAddress:readOnlyBelow: (in category 'primitives') ----- + "cpuAlien <BochsIA32|X86Alien>" primitiveSingleStepInMemory: memory "<Bitmap|ByteArray|WordArray>" offsetBy: offset "<Integer>" minimumAddress: minAddress "<Integer>" readOnlyBelow: minWriteMaxExecAddress "<Integer>" + "Single-step the cpu using the first argument as the memory and the following arguments defining valid addresses." + | cpuAlien cpu maybeErr | + <var: #cpu type: #'void *'> + cpuAlien := self primitive: #primitiveSingleStepInMemoryMinimumAddressReadWrite + parameters: #(WordsOrBytes SmallInteger SmallInteger SmallInteger) + receiver: #Oop. + (cpu := self cCoerceSimple: (self startOfData: cpuAlien) to: #'void *') = 0 ifTrue: + [^interpreterProxy primitiveFailFor: PrimErrBadReceiver]. + (minAddress < 0 + or: [minWriteMaxExecAddress < 0]) ifTrue: + [^self primitiveFailFor: PrimErrBadArgument]. + maybeErr := self singleStepCPU: cpu + In: (self cCoerceSimple: memory to: #'char *') + offset + Size: (interpreterProxy byteSizeOf: memory cPtrAsOop) + MinAddressRead: minAddress + Write: minWriteMaxExecAddress. + maybeErr ~= 0 ifTrue: + [^interpreterProxy primitiveFailForOSError: maybeErr]. + ^cpuAlien! Item was added: + ----- Method: ProcessorSimulatorPlugin>>runCPU:In:Size:MinAddressRead:Write: (in category 'simulation') ----- + runCPU: cpu In: memoryCArray Size: memorySize MinAddressRead: minAddress Write: minWriteMaxExecAddress + "*now* we need derived pointers. Ho hum... + But all we need is one more level of indirection..." + ^mySimulatorAlien + primitiveRunInMemory: interpreterProxy memory + offsetBy: memoryCArray ptrAddress + minimumAddress: minAddress + readOnlyBelow: minWriteMaxExecAddress! Item was added: + ----- Method: ProcessorSimulatorPlugin>>singleStepCPU:In:Size:MinAddressRead:Write: (in category 'simulation') ----- + singleStepCPU: cpu In: memoryCArray Size: memorySize MinAddressRead: minAddress Write: minWriteMaxExecAddress + "*now* we need derived pointers. Ho hum... + But all we need is one more level of indirection..." + ^mySimulatorAlien + primitiveSingleStepInMemory: interpreterProxy memory + offsetBy: memoryCArray ptrAddress + minimumAddress: minAddress + readOnlyBelow: minWriteMaxExecAddress! Item was changed: + ----- Method: ProcessorSimulatorPlugin>>storeIntegerRegisterStateOf:into: (in category 'simulation') ----- + storeIntegerRegisterStateOf: alien into: aCArray - ----- Method: ProcessorSimulatorPlugin>>storeIntegerRegisterStateOf:into: (in category 'simulation support') ----- - storeIntegerRegisterStateOf: objOop into: aCArray | state | state := mySimulatorAlien integerRegisterState. 1 to: state size do: + [:i| aCArray at: i - 1 put: (state at: i)]! - [:i| aCArray at: i - 1 put: (objOop at: i)]! |
Free forum by Nabble | Edit this page |