David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker-dtl.343.mcz ==================== Summary ==================== Name: VMMaker-dtl.343 Author: dtl Time: 2 March 2014, 10:42:12.883 am UUID: 7749056b-e9ad-442f-ba10-457f2eb8c0f4 Ancestors: VMMaker-dtl.342 VMMaker 4.13.3 Fix an obscure bug in generating type declarations caused by unreferenced type declarations remaining after their associated variables have been inlined away. See TMethod>>removeUnreferencedDeclarations. Document the bug in SlangTest>>testRemoveTypeDeclartionForRemovedIntermediate. Fix SlangTest>>testSetInstanceVariableWithAnAccessorMethod which contained an error that was masked because the test is an expected failure. Fix code generator initialization for MemoryAccess. Note - there is no change to generated C code unless MemoryAccess methods are added to the code generator, therefore regeneration of sources for SVN is not required. =============== Diff against VMMaker-dtl.342 =============== Item was changed: ----- Method: Interpreter class>>initializeCodeGenerator: (in category 'translation') ----- initializeCodeGenerator: cg "Load a code generator with classes in a manner suitable for generating code for this class." super initializeCodeGenerator: cg. + self initializeClassicObjectMemoryInCodeGenerator: cg. + VMMaker addMemoryAccessTo: cg. + ^cg - ^ self initializeClassicObjectMemoryInCodeGenerator: cg "^ self initializeNewObjectMemoryInCodeGenerator: cg" ! Item was added: + ----- Method: InterpreterPlugin class>>initializeCodeGenerator: (in category 'translation') ----- + initializeCodeGenerator: cg + "Load a code generator with classes in a manner suitable for generating + code for this class." + + super initializeCodeGenerator: cg. + VMMaker addMemoryAccessTo: cg. + ^cg + ! Item was added: + ----- Method: SlangTest>>testRemoveTypeDeclarationForRemovedIntermediate (in category 'testing var decl requires memoryaccess') ----- + testRemoveTypeDeclarationForRemovedIntermediate + "Document a bug in variable declaration. This is hard to reproduce, so the test uses + the actual failure. Necessary conditions are to use MemoryAccess (requires deep + inlining), then generate the entire interpreter. The error condition appears in the + reverseDisplayFrom:to: method. Generating that method alone is not sufficient to + reproduce the bug, the entire interpreter must first be generated, after which the + method may be individually generated to inspect for the error condition. Symptoms + are that #ptr, which is used as a sqInt, is incorrectly declared as (char *) due to a + left over unreferenced declaration in one of the inlined methods. + The bug exists as of VMMaker-dtl.342 and is corrected in VMMaker-dtl.343." + + | ma maState | + ma := Smalltalk classNamed: #MemoryAccess. + ma ifNil: [^ self + "requires these accessors in combination with object memory / interpreter refactoring in order to reproduce bug"]. + maState := ma isEnabled. + [ | s cg strm meth | + ma enable. + cg := CCodeGenerator new initialize. + cg declareMethodsStatic: false. + Interpreter initializeCodeGenerator: cg. + cg vmClass: Interpreter. + strm := ReadWriteStream on: ''. + cg emitCCodeOn: strm doInlining: true doAssertions: false. + meth := cg methodNamed: 'reverseDisplayFrom:to:' . + strm := ReadWriteStream on: ''. + meth emitCCodeOn: strm generator: cg. + s := strm contents. + self shouldnt: ('*char #ptr;*' match: s). + self should: ('*sqInt ptr;*' match: s) + ] ensure: [maState + ifTrue: [ma enable] + ifFalse: [ma disable]] + ! Item was changed: ----- Method: SlangTest>>testSetInstanceVariableWithAnAccessorMethod (in category 'testing intermediate variable removal') ----- testSetInstanceVariableWithAnAccessorMethod "Intermediate variable from parameter of accessor method should be removed. This is an existing limitation of the inliner, and could be improved for better code generation. It is not a bug." | stssi s | + stssi := SlangTestSupportInterpreter inline: true. + s := (stssi asCString: #setInstanceVariableWithAnAccessorMethod) - stssi := SlangTestSupportInterpreter inline: false. - s := (stssi asInlinedCString: #setInstanceVariableWithAnAccessorMethod) copyReplaceAll: 'setInstanceVariableWithAnAccessorMethod' with: 'methodName'. + self deny: (s includesSubString: 'sqInt oop'). + self assert: (s includesSubString: 'aVariable = remap('). - self assert: (s includesSubString: 'aVariable = remap(objectMemory, nilObj);'). + "Should be translated to something similar to this: - "Should be translated like this: aVariable = remap(objectMemory, nilObj); Not like this: oop = remap(objectMemory, nilObj); aVariable = oop;" ! Item was added: + ----- Method: TMethod>>removeUnreferencedDeclarations (in category 'inlining') ----- + removeUnreferencedDeclarations + "Variables may have been eliminated during inlining. Remove declarations for those variables." + declarations keys copy + do: [:key | (args , locals includes: key) + ifFalse: [declarations removeKey: key]]! Item was changed: ----- Method: TMethod>>tryToInlineMethodsIn: (in category 'inlining') ----- tryToInlineMethodsIn: aCodeGen "Expand any (complete) inline methods called by this method. Set the complete bit when all inlining has been done. Return true if something was inlined." | stmtLists didSomething newStatements sendsToInline | self definedAsMacro ifTrue: [complete := true. ^false]. didSomething := false. sendsToInline := Dictionary new: 100. parseTree nodesDo: [:node| (self inlineableFunctionCall: node in: aCodeGen) ifTrue: [sendsToInline at: node put: (self inlineFunctionCall: node in: aCodeGen)]] unless: "Don't inline the arguments to asserts to keep the asserts readable" [:node| node isSend and: [node selector == #cCode:inSmalltalk: or: [aCodeGen isAssertSelector: node selector]]]. sendsToInline isEmpty ifFalse: [didSomething := true. + self removeUnreferencedDeclarations. parseTree := parseTree replaceNodesIn: sendsToInline]. didSomething ifTrue: [writtenToGlobalVarsCache := nil. ^didSomething]. stmtLists := self statementsListsForInliningIn: aCodeGen. stmtLists do: [:stmtList| newStatements := OrderedCollection new: 100. stmtList statements do: [:stmt| (self inlineCodeOrNilForStatement: stmt in: aCodeGen) ifNil: [newStatements addLast: stmt] ifNotNil: [:inlinedStmts| didSomething := true. newStatements addAllLast: inlinedStmts]]. stmtList setStatements: newStatements asArray]. didSomething ifTrue: [writtenToGlobalVarsCache := nil. ^didSomething]. complete ifFalse: [self checkForCompleteness: stmtLists in: aCodeGen. complete ifTrue: [ didSomething := true ]]. "marking a method complete is progress" ^didSomething! Item was removed: - ----- Method: VMClass class>>initializeCodeGenerator: (in category 'translation') ----- - initializeCodeGenerator: cg - "Load a code generator with classes in a manner suitable for generating - code for this class." - - super initializeCodeGenerator: cg. - VMMaker addMemoryAccessTo: cg. - ^cg - ! |
Free forum by Nabble | Edit this page |