Eliot Miranda uploaded a new version of Cog to project VM Maker: http://source.squeak.org/VMMaker/Cog-eem.406.mcz ==================== Summary ==================== Name: Cog-eem.406 Author: eem Time: 6 September 2020, 2:21:17.20077 pm UUID: 907886af-dbe6-4d02-afb2-07c0b1e1754b Ancestors: Cog-eem.405 Modernize the CogProcessorAlien disassembly and error and log primitives. =============== Diff against Cog-eem.405 =============== Item was changed: ----- Method: ProcessorSimulatorPlugin>>primitiveDisassembleAt:InMemory: (in category 'primitives') ----- + "cpuAlien <CogProcessorAlien>" primitiveDisassembleAt: address "<Integer>" InMemory: memory "<Bitmap|ByteArray|WordArray|DoubleWordArray>" - "cpuAlien <BochsIA32|X86Alien>" primitiveDisassembleAt: address "<Integer>" InMemory: memory "<Bitmap|ByteArray|WordArray>" "Return an Array of the instruction length and its decompilation as a string for the instruction at address in memory." + | cpuAlien cpu instrLenOrErr resultObj log logLen logObj | - | cpuAlien cpu instrLenOrErr resultObj log logLen logObj logObjData | <var: #cpu type: #'void *'> <var: #log type: #'char *'> <var: #logLen type: #long> - <var: #logObjData type: #'char *'> cpuAlien := self primitive: #primitiveDisassembleAtInMemory parameters: #(SmallInteger WordsOrBytes) receiver: #Oop. (cpu := self cCoerceSimple: (self startOfData: cpuAlien) to: #'void *') = 0 ifTrue: [^interpreterProxy primitiveFailFor: PrimErrBadReceiver]. instrLenOrErr := self disassembleFor: cpu At: address In: memory Size: (interpreterProxy byteSizeOf: memory cPtrAsOop). instrLenOrErr < 0 ifTrue: [^interpreterProxy primitiveFailForOSError: instrLenOrErr negated]. + log := self getlog: (self addressOf: logLen put: [:v| logLen := v]). - log := self getlog: (self cCode: [self addressOf: logLen] inSmalltalk: [logLen := 0]). resultObj := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 2. + resultObj ifNil: - resultObj = 0 ifTrue: [^interpreterProxy primitiveFailFor: PrimErrNoMemory]. "Easier keeping the damn thing on the stack than using pushRemappableOop:/popRemappableOop. Where is topRemappableOop when you need it?" interpreterProxy pushRemappableOop: resultObj. logObj := interpreterProxy instantiateClass: interpreterProxy classString indexableSize: logLen. - interpreterProxy failed ifTrue: - [interpreterProxy popRemappableOop. - ^interpreterProxy primitiveFailFor: PrimErrNoMemory]. - logObjData := interpreterProxy arrayValueOf: logObj. - self mem: logObjData cp: log y: logLen. resultObj := interpreterProxy popRemappableOop. + logObj ifNil: + [^interpreterProxy primitiveFailFor: PrimErrNoMemory]. + self mem: (interpreterProxy firstIndexableField: logObj) cp: log y: logLen. interpreterProxy + storeInteger: 0 ofObject: resultObj withValue: instrLenOrErr; + storePointer: 1 ofObject: resultObj withValue: logObj. - storePointer: 0 - ofObject: resultObj - withValue: (interpreterProxy integerObjectOf: instrLenOrErr). - interpreterProxy storePointer: 1 ofObject: resultObj withValue: logObj. ^resultObj! Item was changed: ----- Method: ProcessorSimulatorPlugin>>primitiveErrorAndLog (in category 'primitives') ----- primitiveErrorAndLog + | log logLen resultObj logObj | - | log logLen resultObj logObj logObjData | <var: #log type: #'char *'> <var: #logLen type: #long> - <var: #logObjData type: #'char *'> self primitive: #primitiveErrorAndLog parameters: #(). + log := self getlog: (self addressOf: logLen put: [:v| logLen := v]). - log := self getlog: (self cCode: [self addressOf: logLen] inSmalltalk: [logLen := 0]). resultObj := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 2. + resultObj ifNil: - resultObj = 0 ifTrue: [^interpreterProxy primitiveFailFor: PrimErrNoMemory]. + interpreterProxy storeInteger: 0 ofObject: resultObj withValue: self errorAcorn. - interpreterProxy - storePointer: 0 - ofObject: resultObj - withValue: (interpreterProxy integerObjectOf: self errorAcorn). logLen > 0 ifTrue: [interpreterProxy pushRemappableOop: resultObj. logObj := interpreterProxy instantiateClass: interpreterProxy classString indexableSize: logLen. - interpreterProxy failed ifTrue: - [interpreterProxy popRemappableOop. - ^interpreterProxy primitiveFailFor: PrimErrNoMemory]. - resultObj := interpreterProxy popRemappableOop. + logObj ifNil: + [^interpreterProxy primitiveFailFor: PrimErrNoMemory]. + self mem: (interpreterProxy firstIndexableField: logObj) cp: log y: logLen. - logObjData := interpreterProxy arrayValueOf: logObj. - self mem: logObjData cp: log y: logLen. interpreterProxy storePointer: 1 ofObject: resultObj withValue: logObj]. + interpreterProxy methodReturnValue: resultObj! - interpreterProxy pop: 1 thenPush: resultObj! |
Free forum by Nabble | Edit this page |