Marcel Taeumel uploaded a new version of Kernel to project The Trunk: http://source.squeak.org/trunk/Kernel-mt.1543.mcz
==================== Summary ====================
Name: Kernel-mt.1543 Author: mt Time: 20 December 2023, 1:32:47.777692 pm UUID: 82030861-6f6f-b54c-ace9-9439ab79382f Ancestors: Kernel-mt.1542
Fixes implicit-literal enumeration for ^true, ^false, ^nil etc. constants.
=============== Diff against Kernel-mt.1542 ===============
Item was added: + ----- Method: Context>>methodReturnSpecialConstant: (in category 'instruction decoding implicit literals') ----- + methodReturnSpecialConstant: value + "Simulate the action of a 'return constant' bytecode whose value is the + argument, value. This corresponds to a source expression like '^0'." + + ^self return: value from: self methodReturnContext!
Item was added: + ----- Method: ImplicitLiteralFinder>>methodReturnSpecialConstant: (in category 'instruction decoding - implicit literals') ----- + methodReturnSpecialConstant: value + ^value!
Item was added: + ----- Method: ImplicitLiteralInstructionClientHook>>methodReturnSpecialConstant: (in category 'instruction decoding - implicit literals') ----- + methodReturnSpecialConstant: value + "This is a hook to allow clients to intercept implicit literal bytecodes" + ^self methodReturnConstant: value!
Item was changed: ----- Method: InstructionStream>>interpretNextSistaV1InstructionFor: (in category 'decoding - private - sista v1') ----- interpretNextSistaV1InstructionFor: client "Send to the argument, client, a message that specifies the next instruction."
| byte div16 offset method extA extB savedPC | method := self method. "For a table of the bytecode set, see EncoderForSistaV1's class comment." "consume and compute any extensions first." extA := extB := 0. savedPC := pc. [byte := self method at: pc. pc := pc + 1. byte >= 16rE0 and: [byte <= 16rE1]] whileTrue: [| extByte | extByte := self method at: pc. pc := pc + 1. byte = 16rE0 ifTrue: [extA := (extA bitShift: 8) + extByte] ifFalse: [extB := (extB = 0 and: [extByte > 127]) ifTrue: [extByte - 256] ifFalse: [(extB bitShift: 8) + extByte]]]. div16 := byte // 16. offset := byte \ 16. "We do an inline quasi-binary search on each of the possible 16 values of div16" div16 < 11 ifTrue: [div16 < 6 ifTrue: [div16 < 4 ifTrue: [div16 < 2 ifTrue: [div16 = 0 ifTrue: [^client pushReceiverVariable: offset]. ^client pushLiteralVariable: (method literalAt: offset + 1)]. "div16 = 1" ^client pushConstant: (method literalAt: byte \ 32 + 1)]. div16 = 4 ifTrue: [offset < 12 ifTrue: [^client pushTemporaryVariable: offset]. offset = 12 ifTrue: [^client pushReceiver]. offset = 13 ifTrue: [^client pushSpecialConstant: true]. offset = 14 ifTrue: [^client pushSpecialConstant: false]. offset = 15 ifTrue: [^client pushSpecialConstant: nil]]. "div16 = 5" offset < 2 ifTrue: [^client pushSpecialConstant: offset]. offset = 2 ifTrue: [^self interpretSistaV1ExtendedPush: extB for: client]. offset = 3 ifTrue: [^client doDup]. offset = 8 ifTrue: [^client methodReturnReceiver]. offset = 9 ifTrue: + [^client methodReturnSpecialConstant: true]. - [^client methodReturnConstant: true]. offset = 10 ifTrue: + [^client methodReturnSpecialConstant: false]. - [^client methodReturnConstant: false]. offset = 11 ifTrue: + [^client methodReturnSpecialConstant: nil]. - [^client methodReturnConstant: nil]. offset = 12 ifTrue: [^client methodReturnTop]. offset = 13 ifTrue: [^client blockReturnConstant: nil]. offset = 14 ifTrue: [^client blockReturnTop]. offset = 15 ifTrue: [^client doNop]. ^self unusedBytecode: client at: savedPC]. "short sends" div16 = 6 ifTrue: [^client sendSpecial: (Smalltalk specialSelectorAt: offset + 1) numArgs: (Smalltalk specialNargsAt: offset + 1)]. div16 = 7 ifTrue: [^client sendSpecial: (Smalltalk specialSelectorAt: offset + 17) numArgs: (Smalltalk specialNargsAt: offset + 17)]. ^client send: (method literalAt: offset + 1) super: false numArgs: div16 - 8]. "div16 >= 11; bytecode >= 176" div16 < 14 ifTrue: [div16 = 11 ifTrue: [offset < 8 ifTrue: [^client jump: offset + 1]. ^client jump: offset - 7 if: true]. div16 = 12 ifTrue: [offset < 8 ifTrue: [^client jump: offset + 1 if: false]. ^client popIntoReceiverVariable: offset - 8]. "div16 = 13" offset < 8 ifTrue: [^client popIntoTemporaryVariable: offset]. offset = 8 ifTrue: [^client doPop]. offset = 9 ifTrue: [^client trap]. ^self unusedBytecode: client at: savedPC]. "2 byte and 3 byte codes" byte < 248 ifTrue: [^self interpretNext2ByteSistaV1Instruction: byte for: client extA: extA extB: extB startPC: savedPC]. ^self interpretNext3ByteSistaV1Instruction: byte for: client extA: extA extB: extB startPC: savedPC!
Item was changed: ----- Method: InstructionStream>>interpretNextV3ClosuresInstructionFor: (in category 'decoding - private - v3 plus closures') ----- interpretNextV3ClosuresInstructionFor: client "Send to the argument, client, a message that specifies the type of the next instruction."
| byte type offset method | method := self method. byte := method at: pc. type := byte // 16. offset := byte \ 16. pc := pc+1. "We do an inline binary search on each of the possible 16 values of type." type < 8 ifTrue: [type < 4 ifTrue: [type < 2 ifTrue: [type = 0 ifTrue: [^ client pushReceiverVariable: offset]. ^ client pushTemporaryVariable: offset]. "type = 1" type = 2 ifTrue: [^ client pushConstant: (method literalAt: offset + 1)]. ^ client pushConstant: (method literalAt: offset + 17)]. "type = 3" type < 6 ifTrue: [type = 4 ifTrue: [^ client pushLiteralVariable: (method literalAt: offset + 1)]. ^ client pushLiteralVariable: (method literalAt: offset + 17)]."type = 5" type = 6 ifTrue: [offset < 8 ifTrue: [^ client popIntoReceiverVariable: offset]. ^ client popIntoTemporaryVariable: offset - 8]. "type = 7" offset = 0 ifTrue: [^ client pushReceiver]. offset < 8 ifTrue: [^ client pushSpecialConstant: (SpecialConstants at: offset)]. offset = 8 ifTrue: [^ client methodReturnReceiver]. + offset < 12 ifTrue: [^ client methodReturnSpecialConstant: (SpecialConstants at: offset - 8)]. - offset < 12 ifTrue: [^ client methodReturnConstant: (SpecialConstants at: offset - 8)]. offset = 12 ifTrue: [^ client methodReturnTop]. offset = 13 ifTrue: [^ client blockReturnTop]. ^ self unusedBytecode: client at: pc - 1]. "offset = 14 & offset = 15, 126 & 127" type < 12 ifTrue: [type < 10 ifTrue: [type = 8 ifTrue: [^ self interpretV3ClosuresExtension: offset in: method for: client]. "type = 9 (short jumps)" offset < 8 ifTrue: [^ client jump: offset + 1]. ^ client jump: offset - 8 + 1 if: false]. type = 10 ifTrue: "(long jumps)" [byte := method at: pc. pc := pc + 1. offset < 8 ifTrue: [^ client jump: offset - 4 * 256 + byte]. ^ client jump: (offset bitAnd: 3) * 256 + byte if: offset < 12]. "type = 11; arithmetic special selector sends" ^ client sendSpecial: (Smalltalk specialSelectorAt: offset + 1) numArgs: (Smalltalk specialNargsAt: offset + 1)]. type = 12 ifTrue: "non-arithmetic special selector sends" [^ client sendSpecial: (Smalltalk specialSelectorAt: offset + 17) numArgs: (Smalltalk specialNargsAt: offset + 17)]. "type = 13, 14 or 15" ^ client send: (method literalAt: offset + 1) super: false numArgs: type - 13 "0, 1 & 2"!
Item was changed: ----- Method: InstructionStream>>interpretNextV3InstructionFor: (in category 'decoding - private - v3 plus closures') ----- interpretNextV3InstructionFor: client "Send to the argument, client, a message that specifies the type of the next instruction."
| byte type offset method | method := self method. byte := method at: pc. type := byte // 16. offset := byte \ 16. pc := pc+1. "We do an inline binary search on each of the possible 16 values of type." type < 8 ifTrue: [type < 4 ifTrue: [type < 2 ifTrue: [type = 0 ifTrue: [^ client pushReceiverVariable: offset]. ^ client pushTemporaryVariable: offset]. "type = 1" type = 2 ifTrue: [^ client pushConstant: (method literalAt: offset + 1)]. ^ client pushConstant: (method literalAt: offset + 17)]. "type = 3" type < 6 ifTrue: [type = 4 ifTrue: [^ client pushLiteralVariable: (method literalAt: offset + 1)]. ^ client pushLiteralVariable: (method literalAt: offset + 17)]."type = 5" type = 6 ifTrue: [offset < 8 ifTrue: [^ client popIntoReceiverVariable: offset]. ^ client popIntoTemporaryVariable: offset - 8]. "type = 7" offset = 0 ifTrue: [^ client pushReceiver]. offset < 8 ifTrue: [^ client pushSpecialConstant: (SpecialConstants at: offset)]. offset = 8 ifTrue: [^ client methodReturnReceiver]. + offset < 12 ifTrue: [^ client methodReturnSpecialConstant: (SpecialConstants at: offset - 8)]. - offset < 12 ifTrue: [^ client methodReturnConstant: (SpecialConstants at: offset - 8)]. offset = 12 ifTrue: [^ client methodReturnTop]. offset = 13 ifTrue: [^ client blockReturnTop]. ^ self unusedBytecode: client at: pc - 1]. "offset = 14 & offset = 15, 126 & 127" type < 12 ifTrue: [type < 10 ifTrue: [type = 8 ifTrue: [^ self interpretV3Extension: offset in: method for: client]. "type = 9 (short jumps)" offset < 8 ifTrue: [^ client jump: offset + 1]. ^ client jump: offset - 8 + 1 if: false]. type = 10 ifTrue: "(long jumps)" [byte := method at: pc. pc := pc + 1. offset < 8 ifTrue: [^ client jump: offset - 4 * 256 + byte]. ^ client jump: (offset bitAnd: 3) * 256 + byte if: offset < 12]. "type = 11; arithmetic special selector sends" ^ client sendSpecial: (Smalltalk specialSelectorAt: offset + 1) numArgs: (Smalltalk specialNargsAt: offset + 1)]. type = 12 ifTrue: "non-arithmetic special selector sends" [^ client sendSpecial: (Smalltalk specialSelectorAt: offset + 17) numArgs: (Smalltalk specialNargsAt: offset + 17)]. "type = 13, 14 or 15" ^ client send: (method literalAt: offset + 1) super: false numArgs: type - 13 "0, 1 & 2"!
packages@lists.squeakfoundation.org