Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2697.mcz ==================== Summary ==================== Name: VMMaker.oscog-eem.2697 Author: eem Time: 2 February 2020, 6:37:09.700472 pm UUID: 981e806f-061b-4a48-8c03-ae9740125a88 Ancestors: VMMaker.oscog-eem.2696 Slang/Simulation: Allow the CoInterpreter to specify the clustering of variables so that those variables accessed via VarVaseReg can be placed in a convenient order starting at VarBaseReg. =============== Diff against VMMaker.oscog-eem.2696 =============== Item was changed: ----- Method: CCodeGeneratorGlobalStructure>>buildSortedVariablesCollection (in category 'C code generator') ----- buildSortedVariablesCollection "Build sorted vars, end result will be sorted collection based on static usage, perhaps cache lines will like this!!" | globalNames | globalNames := Bag new: globalVariableUsage size. globalVariableUsage keysAndValuesDo: [:k :v | | count | count := 0. v do: [:methodName| (methods at: methodName ifAbsent: []) ifNotNil: [:method| method parseTree nodesDo: [:n| (n isVariable and: [n name hasEqualElements: k]) ifTrue: [count := count + 1]]]]. globalNames add: k "move arrays (e.g. methodCache) to end of struct" withOccurrences: (((variableDeclarations at: k ifAbsent: ['']) includes: $[) ifTrue: [count] ifFalse: [count + 1000])]. variableDeclarations keysDo: [:e | globalNames add: e withOccurrences: 0]. variables do: [:e | globalNames add: e withOccurrences: 0]. + "Allow vmClass to specify some number of names that should be emitted first in a specific order. + This is for the Cogit's use of VarBaseRegister." + ([vmClass clusteredVariableNames] + on: MessageNotUnderstood + do: [:ex| nil]) ifNotNil: + [:clusteredVariableNames| + clusteredVariableNames with: (clusteredVariableNames size - 1 * 10000 + 1000000 to: 1000000 by: -10000) do: + [:variable :occurrences| + (globalNames includes: variable) ifTrue: + [globalNames + remove: variable; + add: variable withOccurrences: occurrences]]]. ^(globalNames sortedElements asSortedCollection: [:a1 :a2| a1 value > a2 value or: [a1 value = a2 value and: [a1 key <= a2 key]]]) collect: [:ea| ea key]! Item was added: + ----- Method: CoInterpreter class>>clusteredVariableNames (in category 'translation') ----- + clusteredVariableNames + "Insist that these variables are present early in the list of variables, and in this order, + so that e.g. they are conveniently accessed via the VarBaseReg if it is available." + ^#(stackPointer framePointer CStackPointer CFramePointer + primFailCode newMethod instructionPointer argumentCount nextProfileTick + nativeSP nativeStackPointer shadowCallStackPointer)! Item was removed: - ----- Method: CoInterpreter>>varBaseAddress (in category 'cog jit support') ----- - varBaseAddress - <api> - <returnTypeC: #usqInt> - ^self cCode: [(self addressOf: stackPointer) asUnsignedInteger - 16r40] - inSmalltalk: [cogit fakeVarBaseAddress]! Item was changed: ----- Method: Cogit>>fakeAddressFor:index: (in category 'initialization') ----- fakeAddressFor: anObject index: index "Answer a fake address for some variable based on some index. The index will usually be the size of simulatedAddresses, but in determining the varBaseAddress we take a guess at the final size of simulatedAddresses." <doNotGenerate> + ^index * objectMemory wordSize + + ((backEnd notNil + and: [backEnd wantsNearAddressFor: anObject]) + ifTrue: [self addressSpaceMask - (1024 * 1024)] + ifFalse: [self allButTopBitOfAddressSpaceMask])! - ^(index + 101 * objectMemory wordSize) negated - bitAnd: ((backEnd notNil - and: [backEnd wantsNearAddressFor: anObject]) - ifTrue: [self addressSpaceMask] - ifFalse: [self allButTopBitOfAddressSpaceMask])! Item was changed: ----- Method: Cogit>>fakeVarBaseAddress (in category 'accessing') ----- fakeVarBaseAddress - "We expect simulatedAddresses to have around 40 entries. 48 is hopefully a good maximum." <doNotGenerate> + ^simulatedAddresses at: #stackPointer! - ^self fakeAddressFor: nil index: 48! Item was changed: ----- Method: Cogit>>setInterpreter: (in category 'initialization') ----- setInterpreter: aCoInterpreter "Initialization of the code generator in the simulator. These objects already exist in the generated C VM or are used only in the simulation." <doNotGenerate> coInterpreter := aCoInterpreter. objectMemory := aCoInterpreter objectMemory. threadManager := aCoInterpreter threadManager. "N.B. may be nil" methodZone := self class methodZoneClass new. objectRepresentation := objectMemory objectRepresentationClass forCogit: self methodZone: methodZone. methodZone setInterpreter: aCoInterpreter objectRepresentation: objectRepresentation cogit: self. generatorTable := self class generatorTable. processor := ProcessorClass new. simulatedAddresses := Dictionary new. + coInterpreter class clusteredVariableNames do: + [:cvn| self simulatedAddressFor: (cvn first = $C ifTrue: ['get', cvn] ifFalse: [cvn]) asSymbol]. simulatedTrampolines := Dictionary new. simulatedVariableGetters := Dictionary new. simulatedVariableSetters := Dictionary new. traceStores := 0. traceFlags := (self class initializationOptions at: #recordPrimTrace ifAbsent: [true]) ifTrue: [8] "record prim trace on by default (see Cogit class>>decareCVarsIn:)" ifFalse: [0]. debugPrimCallStackOffset := 0. singleStep := printRegisters := printInstructions := clickConfirm := false. backEnd := CogCompilerClass for: self. methodLabel := CogCompilerClass for: self. (literalsManager := backEnd class literalsManagerClass new) cogit: self. ordinarySendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines). superSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines). BytecodeSetHasDirectedSuperSend ifTrue: [directedSuperSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines). directedSuperBindingSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines). directedSendUsesBinding := false]. NewspeakVM ifTrue: [selfSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines). dynamicSuperSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines). implicitReceiverSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines). outerSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines)]. "debug metadata" objectReferencesInRuntime := CArrayAccessor on: (Array new: NumObjRefsInRuntime). runtimeObjectRefIndex := 0. "debug metadata" trampolineAddresses := CArrayAccessor on: (Array new: NumTrampolines * 2). trampolineTableIndex := 0. extA := numExtB := extB := 0. compilationTrace ifNil: [compilationTrace := self class initializationOptions at: #compilationTrace ifAbsent: [0]]. debugOpcodeIndices := self class initializationOptions at: #debugOpcodeIndices ifAbsent: [Set new]. debugBytecodePointers := self class initializationOptions at: #debugBytecodePointers ifAbsent: [Set new]. self class initializationOptions at: #breakPC ifPresent: [:pc| breakPC := pc]! Item was changed: ----- Method: Cogit>>varBaseAddress (in category 'accessing') ----- varBaseAddress + ^coInterpreter stackPointerAddress! - "This is for disassembly decoration by the processor aliens. they don't know aboud objectMemory hence forward..." - <doNotGenerate> - ^coInterpreter varBaseAddress! Item was removed: - ----- Method: CurrentImageCoInterpreterFacade>>varBaseAddress (in category 'accessing') ----- - varBaseAddress - "This value is chosen for ARM, which has the ability to do 12-bit relative addresses from the var base register." - ^(variables at: 'stackLimit') - (1 << 11)! |
Free forum by Nabble | Edit this page |