Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2325.mcz ==================== Summary ==================== Name: VMMaker.oscog-eem.2325 Author: eem Time: 25 January 2018, 1:30:51.009627 pm UUID: 48552a26-3c86-41d7-9b6f-75832766ff68 Ancestors: VMMaker.oscog-eem.2324 StackToRegisterMappingCogit: Fix ancient bug in voidReceiverResultRegContainsSelf. The computed index is the right argument for ssFlushTo:; it shouldn't be subtracted from simStackPtr! Make stackTopIsBoolean more robust. Better support for in-image compilation. Make sure to fill the code zone with stops (& provide better implementations of stopsFrom:to:). Extract creating an initialized Cogit instance to a method. Provide simStackPrintString. =============== Diff against VMMaker.oscog-eem.2324 =============== Item was changed: ----- Method: CogIA32Compiler>>stopsFrom:to: (in category 'generate machine code') ----- stopsFrom: startAddr to: endAddr + self + cCode: [self self me: startAddr ms: self stop et: endAddr - startAddr + 1] + inSmalltalk: + [| alignedEnd alignedStart stops | + stops := self stop << 8 + self stop. + stops := stops << 16 + stops. + alignedStart := startAddr + 3 // 4 * 4. + alignedEnd := endAddr - 1 // 4 * 4. + alignedEnd <= startAddr + ifTrue: + [startAddr to: endAddr do: + [:addr | objectMemory byteAt: addr put: self stop]] + ifFalse: + [startAddr to: alignedStart - 1 do: + [:addr | objectMemory byteAt: addr put: self stop]. + alignedStart to: alignedEnd by: 4 do: + [:addr | objectMemory long32At: addr put: stops]. + alignedEnd + 4 to: endAddr do: + [:addr | objectMemory byteAt: addr put: self stop]]]! - startAddr to: endAddr do: - [:addr | objectMemory byteAt: addr put: self stop]! Item was changed: ----- Method: CogMethodZone>>quickClearCogCompiledCode (in category 'jit - api') ----- quickClearCogCompiledCode "Quick, for in-image testing" <doNotGenerate> mzFreeStart := baseAddress. + self clearCogCompiledCode. + cogit backEnd stopsFrom: mzFreeStart to: limitAddress - 1! - self clearCogCompiledCode! Item was changed: ----- Method: CogX64Compiler>>stopsFrom:to: (in category 'generate machine code') ----- stopsFrom: startAddr to: endAddr + self + cCode: [self self me: startAddr ms: self stop et: endAddr - startAddr + 1] + inSmalltalk: + [| alignedEnd alignedStart stops | + stops := self stop << 8 + self stop. + stops := stops << 16 + stops. + stops := stops << 32 + stops. + alignedStart := startAddr + 7 // 8 * 8. + alignedEnd := endAddr - 1 // 8 * 8. + alignedEnd <= startAddr + ifTrue: + [startAddr to: endAddr do: + [:addr | objectMemory byteAt: addr put: self stop]] + ifFalse: + [startAddr to: alignedStart - 1 do: + [:addr | objectMemory byteAt: addr put: self stop]. + alignedStart to: alignedEnd by: 8 do: + [:addr | objectMemory long64At: addr put: stops]. + alignedEnd + 8 to: endAddr do: + [:addr | objectMemory byteAt: addr put: self stop]]]! - startAddr to: endAddr do: - [:addr | objectMemory byteAt: addr put: self stop]! Item was changed: ----- Method: Cogit class>>cog:selectorOrNumCopied:options: (in category 'in-image compilation') ----- cog: aCompiledMethod selectorOrNumCopied: selectorOrNumCopied options: optionsDictionaryOrArray "StackToRegisterMappingCogit cog: (Integer >> #benchFib) selector: #benchFib options: #(COGMTVM false)" | cogit coInterpreter | + cogit := self initializedInstanceForTests: optionsDictionaryOrArray. + coInterpreter := cogit coInterpreter. - cogit := self instanceForTests: optionsDictionaryOrArray. self attemptToComputeTempNamesFor: aCompiledMethod. self attemptToComputeInstVarNamesFor: aCompiledMethod. - coInterpreter := CurrentImageCoInterpreterFacade forCogit: cogit. - [cogit - setInterpreter: coInterpreter; - singleStep: true; - initializeCodeZoneFrom: 1024 upTo: coInterpreter memory size / 2. "leave space for rump C stack" - cogit methodZone freeStart: (cogit methodZone freeStart roundUpTo: 1024)] - on: Notification - do: [:ex| - (ex messageText beginsWith: 'cannot find receiver for') ifTrue: - [ex resume: coInterpreter]. - ex pass]. ^{ coInterpreter. cogit. selectorOrNumCopied isInteger ifTrue: [ cogit cogFullBlockMethod: (coInterpreter oopForObject: aCompiledMethod) numCopied: selectorOrNumCopied ] ifFalse: [ cogit cog: (coInterpreter oopForObject: aCompiledMethod) selector: (coInterpreter oopForObject: selectorOrNumCopied) ] }! Item was changed: ----- Method: Cogit class>>genAndDisPICoptions: (in category 'in-image compilation') ----- genAndDisPICoptions: optionsDictionaryOrArray + "StackToRegisterMappingCogit genAndDisPICoptions: #(ISA ARMv5 CogCompilerClass CogOutOfLineLiteralsARMCompiler)" + | cogit | + cogit := self initializedInstanceForTests: optionsDictionaryOrArray. - "StackToRegisterMappingCogit genAndDisPICoptions: #(ISA ARMv5 CogCompilerClass CogInLineLiteralsARMCompiler)" - | cogit coInterpreter | - cogit := self instanceForTests: optionsDictionaryOrArray. - coInterpreter := CurrentImageCoInterpreterFacade forCogit: cogit. - [cogit - setInterpreter: coInterpreter; - singleStep: true; - initializeCodeZoneFrom: 1024 upTo: coInterpreter memory size / 2. "leave space for rump C stack" - cogit methodZone freeStart: (cogit methodZone freeStart roundUpTo: 1024)] - on: Notification - do: [:ex| - (ex messageText beginsWith: 'cannot find receiver for') ifTrue: - [ex resume: coInterpreter]]. cogit disassembleFrom: cogit cPICPrototype + (cogit sizeof: CogMethod) to: cogit cPICPrototype + cogit closedPICSize! Item was added: + ----- Method: Cogit class>>initializedInstanceForTests: (in category 'in-image compilation support') ----- + initializedInstanceForTests: optionsDictionaryOrArray + "Answer an instance of a Cogit suitable for running tests that has initialized + its method zone (generated trampolines etc)" + | cogit coInterpreter | + cogit := self instanceForTests: optionsDictionaryOrArray. + coInterpreter := CurrentImageCoInterpreterFacade forCogit: cogit. + [cogit + setInterpreter: coInterpreter; + singleStep: true; + initializeCodeZoneFrom: 1024 upTo: coInterpreter memory size. + cogit methodZone freeStart: (cogit methodZone freeStart roundUpTo: 1024)] + on: Notification + do: [:ex| + (ex messageText beginsWith: 'cannot find receiver for') ifTrue: + [ex resume: coInterpreter]. + ex pass]. + ^cogit! Item was changed: ----- Method: Cogit class>>testPCMappingSelect:options: (in category 'tests') ----- testPCMappingSelect: aBlock options: optionsDictionaryOrArray "Test pc mapping both ways using a selection of the methods in the current image." + | cogit coInterpreter n | + cogit := self initializedInstanceForTests: optionsDictionaryOrArray. + coInterpreter := cogit coInterpreter. - | n cogit coInterpreter | - cogit := self instanceForTests: optionsDictionaryOrArray. - coInterpreter := CurrentImageCoInterpreterFacade forCogit: cogit. - [cogit - setInterpreter: coInterpreter; - singleStep: true; - initializeCodeZoneFrom: 1024 upTo: coInterpreter memory size] - on: Notification - do: [:ex| - (ex messageText beginsWith: 'cannot find receiver for') ifTrue: - [ex resume: coInterpreter]]. n := -1. SystemNavigation new allSelect: [:m| | cm | (m isQuick not and: [aBlock value: m]) ifTrue: [(n := n + 1) \\ 10 = 0 ifTrue: [Transcript nextPut: $.; flush]. cm := cogit cog: (coInterpreter oopForObject: m) selector: (coInterpreter oopForObject: m selector). cm ifNil: [cogit methodZone clearCogCompiledCode. coInterpreter initializeObjectMap. cm := cogit cog: (coInterpreter oopForObject: m) selector: (coInterpreter oopForObject: m selector). cm ifNil: [Transcript show: 'After 1 Cog compiled code compaction, still not able to generate the cog method...' ] ]. cm ifNotNil: [cogit testPCMappingForCompiledMethod: m cogMethod: cm]]. + false]! - false] ! Item was added: + ----- Method: CurrentImageCoInterpreterFacade>>long64At: (in category 'accessing') ----- + long64At: byteIndex + ^objectMemory long64At: byteIndex! Item was added: + ----- Method: CurrentImageCoInterpreterFacade>>long64At:put: (in category 'accessing') ----- + long64At: byteIndex put: aValue + ^objectMemory long64At: byteIndex put: aValue! Item was added: + ----- Method: CurrentImageCoInterpreterFacade>>mcprimFunctionForPrimitiveIndex: (in category 'accessing') ----- + mcprimFunctionForPrimitiveIndex: primIndex + ^self oopForObject: (coInterpreter mcprimFunctionForPrimitiveIndex: primIndex)! Item was added: + ----- Method: CurrentImageCoInterpreterFacadeForSpurObjectRepresentation>>maybeMethodClassOf:seemsToBeInstantiating: (in category 'accessing') ----- + maybeMethodClassOf: methodObj seemsToBeInstantiating: format + "Answers if the code is installed in a class instantiating objects with the format. Used in primitive + generation to make a quick path based on where the method is installed. This method cannot + be used as a guarantee as there can be false positive, it's just a heuristic. + Tries to interpret the last literal of the method as a behavior (more than 3 fields, 3rd field a Smi). + If it can be interpreted as a behavior, answers if instSpec matches the format, else answers false." + <api> + | maybeClassObj| + maybeClassObj := (self objectForOop: methodObj) methodClass. + ^maybeClassObj isBehavior + and: [maybeClassObj instSpec = format]! Item was changed: ----- Method: StackToRegisterMappingCogit>>printSimStack:toDepth:spillBase:on: (in category 'simulation only') ----- printSimStack: aSimStack toDepth: limit spillBase: spillBase on: aStream <doNotGenerate> | tempNames width tabWidth | aStream ensureCr. limit < 0 ifTrue: [^aStream nextPutAll: 'simStackEmpty'; cr; flush]. aSimStack ifNil: [^aStream nextPutAll: 'nil simStack'; cr; flush]. (self class initializationOptions at: #tempNames ifAbsent: nil) ifNotNil: [:tempNamesDictOrNil | | tab longest | tempNames := tempNamesDictOrNil at: (self class initializationOptions at: #startpc ifAbsent: [initialPC]) + 1. longest := tempNames inject: '' into: [:m :t| m size >= t size ifTrue: [m] ifFalse: [t]]. tabWidth := self widthInDefaultFontOf: (tab := String with: Character tab). width := self widthInDefaultFontOf: longest, tab. width <= ((self widthInDefaultFontOf: longest, (String with: Character space)) + 4) ifTrue: [width := width + tabWidth]]. 0 to: limit do: [:i| width ifNotNil: [self put: (tempNames at: i + 1 ifAbsent: ['']) paddedTo: width tabWidth: tabWidth on: aStream]. aStream print: i. + i = simStackPtr ifTrue: + [aStream nextPutAll: '<-' ]. + i = spillBase ifTrue: + [aStream nextPutAll: '(sb)']. + aStream tab: (i = spillBase ifTrue: [1] ifFalse: [2]). - i = spillBase - ifTrue: [aStream nextPutAll: ' sb'; tab] - ifFalse: [aStream tab; tab]. (aSimStack at: i) printStateOn: aStream. aStream cr; flush]! Item was added: + ----- Method: StackToRegisterMappingCogit>>simStackPrintString (in category 'simulation only') ----- + simStackPrintString + <doNotGenerate> + ^String streamContents: + [:s| + optStatus printStateOn: s. + self printSimStack: simStack toDepth: simStackPtr spillBase: simSpillBase on: s]! Item was changed: ----- Method: StackToRegisterMappingCogit>>stackTopIsBoolean (in category 'testing') ----- stackTopIsBoolean <inline: true> + ^simStackPtr >= methodOrBlockNumArgs and: [self stackEntryIsBoolean: self ssTop]! - ^simStackPtr > 0 and: [self stackEntryIsBoolean: self ssTop]! Item was changed: ----- Method: StackToRegisterMappingCogit>>voidReceiverResultRegContainsSelf (in category 'bytecode generator support') ----- voidReceiverResultRegContainsSelf "Used when ReceiverResultReg is allocated for other than simSelf, and there may be references to ReceiverResultReg which need to be spilled." | spillIndex | self voidReceiverOptStatus. spillIndex := -1. (methodOrBlockNumTemps max: simSpillBase) to: simStackPtr do: [:i| (self simStackAt: i) registerOrNone = ReceiverResultReg ifTrue: [spillIndex := i]]. spillIndex > 0 ifTrue: + [self ssFlushTo: spillIndex]! - [self ssFlushTo: simStackPtr - spillIndex]! |
Free forum by Nabble | Edit this page |