[Vm-dev] VM Maker: SlangBrowser-dtl.12.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue Mar 19 23:59:23 UTC 2013


2013/3/20  <commits at source.squeak.org>:
>
> David T. Lewis uploaded a new version of SlangBrowser to project VM Maker:
> http://source.squeak.org/VMMaker/SlangBrowser-dtl.12.mcz
>
> ==================== Summary ====================
>
> Name: SlangBrowser-dtl.12
> Author: dtl
> Time: 19 March 2013, 7:34:57.17 pm
> UUID: 65db3519-14eb-42c7-a7f6-6eb3a215b8ba
> Ancestors: SlangBrowser-dtl.11
>
> Use ReadWriteStream on: String new in various methods.

I did not look usage into code, but simple question: do we need a
ReadWriteStream at all here?
Otherwise using a String new writeStream would be a good thing to do.
If we ever want to clean our Stream hierarchy, we must think of
cleaning the client first...

Nicolas

> Use VMMaker class>>buildCodeGenerator:inlined: to deobfuscate the generated code caching.
>
> =============== Diff against SlangBrowser-dtl.11 ===============
>
> Item was changed:
>   ----- Method: InterpreterPlugin class>>asCString: (in category '*SlangBrowser-translation') -----
>   asCString: aSelector
>         "Answer the translated C source for a method."
>
>         | cg stream method vmm |
>         (Smalltalk hasClassNamed: 'VMMaker')
>                 ifTrue: [vmm := Smalltalk at: #VMMaker]
>                 ifFalse: [^ self notify: 'VMMaker not in this image' translated].
>         cg := vmm codeGenerator: #cCode forClass: self.
>         cg isString ifTrue:
>                 [^ '/* ', self name, ' can not be translated. */',
>                         String cr, '/* ', cg, ' */'].
>         method := cg methodNamed: aSelector.
>         method ifNil: [^ ObjectMemory methodNotTranslatedMessage: aSelector].
> +       stream := ReadWriteStream on: String new.
> -       stream := ReadWriteStream on: ''.
>         method emitCCodeOn: stream generator: cg.
>         ^ stream contents
>   !
>
> Item was changed:
>   ----- Method: InterpreterPlugin class>>asInlinedCString: (in category '*SlangBrowser-translation') -----
>   asInlinedCString: aSelector
>         "Answer the translated inlined C source for a method."
>
>         | cg stream method vmm |
>         (Smalltalk hasClassNamed: 'VMMaker')
>                 ifTrue: [vmm := Smalltalk at: #VMMaker]
>                 ifFalse: [^ self notify: 'VMMaker not in this image' translated].
>         cg := vmm codeGenerator: #inlinedCCode forClass: self.
>         cg isString ifTrue:
>                 [^ '/* ', self name, ' can not be translated. */',
>                         String cr, '/* ', cg, ' */'].
>         method := cg methodNamed: aSelector.
>         method ifNil: [^ ObjectMemory methodNotTranslatedMessage: aSelector].
> +       stream := ReadWriteStream on: String new.
> -       stream := ReadWriteStream on: ''.
>         method emitCCodeOn: stream generator: cg.
>         ^ stream contents
>   !
>
> Item was changed:
>   ----- Method: Object class>>asCString (in category '*SlangBrowser-VMMaker-Translation to C') -----
>   asCString
>         "Answer the translated C source for this class."
>
>         "Interpreter asCString"
>         "ObjectMemory asCString"
>         "FilePlugin asCString"
>
>         | vmm cg stream |
>         (Smalltalk hasClassNamed: 'VMMaker')
>                 ifTrue: [vmm := Smalltalk at: #VMMaker]
>                 ifFalse: [^ self notify: 'VMMaker not in this image'].
>         cg := vmm codeGenerator: #cCode forClass: self.
> +       stream := ReadWriteStream on: String new.
> -       stream := ReadWriteStream on: ''.
>         cg emitCCodeOn: stream doAssertions: true.
>         ^ stream contents
>   !
>
> Item was changed:
>   ----- Method: Object class>>asCString: (in category '*SlangBrowser-VMMaker-Translation to C') -----
>   asCString: aSelector
>         "Answer the translated C source for a method."
>
>         "Interpreter asCString: #bytecodePrimBlockCopy"
>         "ObjectMemory asCString: #lastPointerOf:"
>
>         | vmm cg method stream |
>         (Smalltalk hasClassNamed: 'VMMaker')
>                 ifTrue: [vmm := Smalltalk at: #VMMaker]
>                 ifFalse: [^ self notify: 'VMMaker not in this image'].
>         cg := vmm codeGenerator: #cCode forClass: self.
>         cg isString ifTrue:
>                 [^ '/* ', self name, ' can not be translated. */',
>                         String cr, '/* ', cg, ' */'].
>         method := cg methodNamed: aSelector.
>         method ifNil: [^ self methodNotTranslatedMessage: aSelector].
> +       stream := ReadWriteStream on: String new.
> -       stream := ReadWriteStream on: ''.
>         method emitCCodeOn: stream generator: cg.
>         ^ stream contents
>   !
>
> Item was changed:
>   ----- Method: Object class>>asInlinedCString (in category '*SlangBrowser-VMMaker-Translation to C') -----
>   asInlinedCString
>         "Answer the translated C source for this class."
>
>         "Interpreter asInlinedCString"
>         "ObjectMemory asInlinedCString"
>         "FilePlugin asInlinedCString"
>
>         | vmm cg stream |
>         (Smalltalk hasClassNamed: 'VMMaker')
>                 ifTrue: [vmm := Smalltalk at: #VMMaker]
>                 ifFalse: [^ self notify: 'VMMaker not in this image'].
>         cg := vmm codeGenerator: #inlinedCCode forClass: self.
> +       stream := ReadWriteStream on: String new.
> -       stream := ReadWriteStream on: ''.
>         cg emitCCodeOn: stream doAssertions: true.
>         ^ stream contents
>   !
>
> Item was changed:
>   ----- Method: Object class>>asInlinedCString: (in category '*SlangBrowser-VMMaker-Translation to C') -----
>   asInlinedCString: aSelector
>         "Answer the translated Inlined C source for a method."
>
>         "Interpreter asCString: #bytecodePrimBlockCopy"
>         "ObjectMemory asCString: #lastPointerOf:"
>
>         | vmm cg method stream |
>         (Smalltalk hasClassNamed: 'VMMaker')
>                 ifTrue: [vmm := Smalltalk at: #VMMaker]
>                 ifFalse: [^ self notify: 'VMMaker not in this image'].
>         cg := vmm codeGenerator: #inlinedCCode forClass: self.
>         cg isString ifTrue:
>                 [^ '/* ', self name, ' can not be translated. */',
>                         String cr, '/* ', cg, ' */'].
>         method := cg methodNamed: aSelector.
>         method ifNil: [^ ObjectMemory methodNotTranslatedMessage: aSelector].
> +       stream := ReadWriteStream on: String new.
> -       stream := ReadWriteStream on: ''.
>         method emitCCodeOn: stream generator: cg.
>         ^ stream contents
>   !
>
> Item was added:
> + ----- Method: VMMaker class>>buildCodeGenerator:inlined: (in category '*SlangBrowser-browser support') -----
> + buildCodeGenerator: aClass inlined: doInlining
> +       "Answer a new C code generator for aClass"
> +
> +       | cg |
> +       ObjectMemory initialize; initializeConstants.
> +       cg := aClass buildCodeGeneratorInlined: doInlining.
> +       cg prepareMethodsInlined: doInlining doAssertions: true.
> +       ^ cg
> + !
>
> Item was changed:
>   ----- Method: VMMaker class>>cCodeGenerator:inCache:inlined: (in category '*SlangBrowser-browser support') -----
>   cCodeGenerator: aClass inCache: cache inlined: doInlining
>         "Answer a C code generator, or a string explaining why a code generator is not available"
>
>         | cg |
>         cg := cache
>                 at: aClass name asSymbol
> +               ifAbsentPut: [self buildCodeGenerator: aClass inlined: doInlining].
> -               ifAbsentPut:
> -                       [ObjectMemory initialize.
> -                       ObjectMemory initializeConstants.
> -                       cg := aClass buildCodeGeneratorInlined: doInlining.
> -                       cg prepareMethodsInlined: doInlining doAssertions: true.
> -                       cg].
>         ^ cg
>   !
>


More information about the Vm-dev mailing list