[squeak-dev] Review Request: fix-directedSuperSend-frameSize.1.cs

christoph.thiede at student.hpi.uni-potsdam.de christoph.thiede at student.hpi.uni-potsdam.de
Wed Sep 14 14:46:08 UTC 2022


This was a funny one! Please review. :-)

Best,
Christoph

=============== Summary ===============

Change Set:        fix-directedSuperSend-frameSize
Date:            14 September 2022
Author:            Christoph Thiede

Fixes omission fault in encoder that caused an insufficient frame size for compiled blocks with a directed super send. While the Cog VM was able to execute these methods anyway (probably performing invalid mem accesses?), the debugger aka image simulator failed to do so.

=============== Diff ===============

CompilerTest>>testDirectedSuperSendStackSize {tests - syntax} · ct 9/14/2022 16:35
+ testDirectedSuperSendStackSize
+ 
+     {13. CompiledCode smallFrameSize.
+     14. CompiledCode fullFrameSize}
+         pairsDo: [:numTemps :expectedBlockFrame |
+         | temps compiledMethod methodNode compiledBlock |
+         temps := (Character alphabet first: numTemps) asArray.
+         methodNode := Compiler new
+             compile: 'griffle
+ |' , (temps joinSeparatedBy: $ ) , '|
+ ' , (temps withIndexCollect: [:t :i | '' , t , ':=' , i , '. ']) join , '
+ [' , (temps joinSeparatedBy: $+) , '.
+ super someDirectedSend: a] value.'
+             in: nil class
+             environment: nil environment
+             notifying: nil
+             ifFail: [^ self fail].
+         compiledMethod := methodNode generateWithTempNames.
+         
+         self
+             assert: compiledMethod equals: compiledMethod codeLiterals first;
+             assert: 2 equals: compiledMethod codeLiterals size.
+         self assert: CompiledCode fullFrameSize equals: compiledMethod frameSize.
+         compiledBlock := compiledMethod codeLiterals second.
+         self
+             assert: compiledBlock isCompiledBlock;
+             assert: expectedBlockFrame equals: compiledBlock frameSize].

SelectorNode>>emitCode:args:encoder:super: {code generation} · ct 9/14/2022 16:19 (changed)
emitCode: stack args: nArgs encoder: encoder super: supered
    code < Send ifTrue:
        [self internalEncodingError].
-     stack pop: nArgs.
    supered
        ifTrue:
            [(encoder supportsFullBlocks
              and: [encoder generatingFullBlock])
                ifTrue:
-                     [encoder genPushLiteral: (encoder sharableLitIndex: encoder classEncoding).
+                     [stack push: 1. "superclass"
+                      encoder genPushLiteral: (encoder sharableLitIndex: encoder classEncoding).
+                      stack pop: 1 "superclass".
+                      stack pop: nArgs. 
                     encoder genSendDirectedSuper: index numArgs: nArgs]
-                 ifFalse: [encoder genSendSuper: index numArgs: nArgs]]
+                 ifFalse:
+                     [stack pop: nArgs.
+                      encoder genSendSuper: index numArgs: nArgs]]
        ifFalse:
-             [encoder genSend: index numArgs: nArgs]
+             [stack pop: nArgs.
+              encoder genSend: index numArgs: nArgs]

["fix-directedSuperSend-frameSize.1.cs"]

---
Sent from Squeak Inbox Talk
["fix-directedSuperSend-frameSize.1.cs"]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220914/c3821689/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-directedSuperSend-frameSize.1.cs
Type: application/octet-stream
Size: 2257 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220914/c3821689/attachment.obj>


More information about the Squeak-dev mailing list