Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.879.mcz ==================== Summary ==================== Name: Kernel-eem.879 Author: eem Time: 9 October 2014, 1:35:55.93 pm UUID: fbc8b106-b977-4d3b-8df9-4f4836beff40 Ancestors: Kernel-eem.878 Add a usable unusedBytecode hook that allows InstructionClients to define unusedBytecode and act appropriately. Remove the obsolete interpretExtension:in:for: =============== Diff against Kernel-eem.878 =============== Item was removed: - ----- Method: InstructionStream>>interpretExtension:in:for: (in category 'private') ----- - interpretExtension: offset in: method for: client - | type offset2 byte2 byte3 byte4 | - offset <= 6 ifTrue: - ["Extended op codes 128-134" - byte2 := method at: pc. pc := pc + 1. - offset <= 2 ifTrue: - ["128-130: extended pushes and pops" - type := byte2 // 64. - offset2 := byte2 \\ 64. - offset = 0 ifTrue: - [type = 0 ifTrue: [^client pushReceiverVariable: offset2]. - type = 1 ifTrue: [^client pushTemporaryVariable: offset2]. - type = 2 ifTrue: [^client pushConstant: (method literalAt: offset2 + 1)]. - type = 3 ifTrue: [^client pushLiteralVariable: (method literalAt: offset2 + 1)]]. - offset = 1 ifTrue: - [type = 0 ifTrue: [^client storeIntoReceiverVariable: offset2]. - type = 1 ifTrue: [^client storeIntoTemporaryVariable: offset2]. - type = 2 ifTrue: [self error: 'illegalStore']. - type = 3 ifTrue: [^client storeIntoLiteralVariable: (method literalAt: offset2 + 1)]]. - offset = 2 ifTrue: - [type = 0 ifTrue: [^client popIntoReceiverVariable: offset2]. - type = 1 ifTrue: [^client popIntoTemporaryVariable: offset2]. - type = 2 ifTrue: [self error: 'illegalStore']. - type = 3 ifTrue: [^client popIntoLiteralVariable: (method literalAt: offset2 + 1)]]]. - "131-134: extended sends" - offset = 3 ifTrue: "Single extended send" - [^client send: (method literalAt: byte2 \\ 32 + 1) - super: false numArgs: byte2 // 32]. - offset = 4 ifTrue: "Double extended do-anything" - [byte3 := method at: pc. pc := pc + 1. - type := byte2 // 32. - type = 0 ifTrue: [^client send: (method literalAt: byte3 + 1) - super: false numArgs: byte2 \\ 32]. - type = 1 ifTrue: [^client send: (method literalAt: byte3 + 1) - super: true numArgs: byte2 \\ 32]. - type = 2 ifTrue: [^client pushReceiverVariable: byte3]. - type = 3 ifTrue: [^client pushConstant: (method literalAt: byte3 + 1)]. - type = 4 ifTrue: [^client pushLiteralVariable: (method literalAt: byte3 + 1)]. - type = 5 ifTrue: [^client storeIntoReceiverVariable: byte3]. - type = 6 ifTrue: [^client popIntoReceiverVariable: byte3]. - type = 7 ifTrue: [^client storeIntoLiteralVariable: (method literalAt: byte3 + 1)]]. - offset = 5 ifTrue: "Single extended send to super" - [^client send: (method literalAt: byte2 \\ 32 + 1) - super: true numArgs: byte2 // 32]. - offset = 6 ifTrue: "Second extended send" - [^client send: (method literalAt: byte2 \\ 64 + 1) - super: false numArgs: byte2 // 64]]. - offset = 7 ifTrue: [^client doPop]. - offset = 8 ifTrue: [^client doDup]. - offset = 9 ifTrue: [^client pushActiveContext]. - byte2 := method at: pc. pc := pc + 1. - offset = 10 ifTrue: - [^byte2 < 128 - ifTrue: [client pushNewArrayOfSize: byte2] - ifFalse: [client pushConsArrayWithElements: byte2 - 128]]. - offset = 11 ifTrue: [^self error: 'unusedBytecode']. - byte3 := method at: pc. pc := pc + 1. - offset = 12 ifTrue: [^client pushRemoteTemp: byte2 inVectorAt: byte3]. - offset = 13 ifTrue: [^client storeIntoRemoteTemp: byte2 inVectorAt: byte3]. - offset = 14 ifTrue: [^client popIntoRemoteTemp: byte2 inVectorAt: byte3]. - "offset = 15" - byte4 := method at: pc. pc := pc + 1. - ^client - pushClosureCopyNumCopiedValues: (byte2 bitShift: -4) - numArgs: (byte2 bitAnd: 16rF) - blockSize: (byte3 * 256) + byte4! 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 pushConstant: (SpecialConstants at: offset)]. offset = 8 ifTrue: [^ client methodReturnReceiver]. 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" - offset > 13 ifTrue: [^ self error: 'unusedBytecode']]. 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 send: (Smalltalk specialSelectorAt: offset + 1) super: false numArgs: (Smalltalk specialNargsAt: offset + 1)]. type = 12 ifTrue: "non-arithmetic special selector sends" [^ client send: (Smalltalk specialSelectorAt: offset + 17) super: false 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 pushConstant: (SpecialConstants at: offset)]. offset = 8 ifTrue: [^ client methodReturnReceiver]. 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" - ^ self error: 'unusedBytecode']. "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 send: (Smalltalk specialSelectorAt: offset + 1) super: false numArgs: (Smalltalk specialNargsAt: offset + 1)]. type = 12 ifTrue: "non-arithmetic special selector sends" [^ client send: (Smalltalk specialSelectorAt: offset + 17) super: false 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>>interpretV3ClosuresExtension:in:for: (in category 'decoding - private - v3 plus closures') ----- interpretV3ClosuresExtension: offset in: method for: client | type offset2 byte2 byte3 byte4 | offset <= 6 ifTrue: ["Extended op codes 128-134" byte2 := method at: pc. pc := pc + 1. offset <= 2 ifTrue: ["128-130: extended pushes and pops" type := byte2 // 64. offset2 := byte2 \\ 64. offset = 0 ifTrue: [type = 0 ifTrue: [^client pushReceiverVariable: offset2]. type = 1 ifTrue: [^client pushTemporaryVariable: offset2]. type = 2 ifTrue: [^client pushConstant: (method literalAt: offset2 + 1)]. type = 3 ifTrue: [^client pushLiteralVariable: (method literalAt: offset2 + 1)]]. offset = 1 ifTrue: [type = 0 ifTrue: [^client storeIntoReceiverVariable: offset2]. type = 1 ifTrue: [^client storeIntoTemporaryVariable: offset2]. type = 2 ifTrue: [self error: 'illegalStore']. type = 3 ifTrue: [^client storeIntoLiteralVariable: (method literalAt: offset2 + 1)]]. offset = 2 ifTrue: [type = 0 ifTrue: [^client popIntoReceiverVariable: offset2]. type = 1 ifTrue: [^client popIntoTemporaryVariable: offset2]. type = 2 ifTrue: [self error: 'illegalStore']. type = 3 ifTrue: [^client popIntoLiteralVariable: (method literalAt: offset2 + 1)]]]. "131-134: extended sends" offset = 3 ifTrue: "Single extended send" [^client send: (method literalAt: byte2 \\ 32 + 1) super: false numArgs: byte2 // 32]. offset = 4 ifTrue: "Double extended do-anything" [byte3 := method at: pc. pc := pc + 1. type := byte2 // 32. type = 0 ifTrue: [^client send: (method literalAt: byte3 + 1) super: false numArgs: byte2 \\ 32]. type = 1 ifTrue: [^client send: (method literalAt: byte3 + 1) super: true numArgs: byte2 \\ 32]. type = 2 ifTrue: [^client pushReceiverVariable: byte3]. type = 3 ifTrue: [^client pushConstant: (method literalAt: byte3 + 1)]. type = 4 ifTrue: [^client pushLiteralVariable: (method literalAt: byte3 + 1)]. type = 5 ifTrue: [^client storeIntoReceiverVariable: byte3]. type = 6 ifTrue: [^client popIntoReceiverVariable: byte3]. type = 7 ifTrue: [^client storeIntoLiteralVariable: (method literalAt: byte3 + 1)]]. offset = 5 ifTrue: "Single extended send to super" [^client send: (method literalAt: byte2 \\ 32 + 1) super: true numArgs: byte2 // 32]. offset = 6 ifTrue: "Second extended send" [^client send: (method literalAt: byte2 \\ 64 + 1) super: false numArgs: byte2 // 64]]. offset = 7 ifTrue: [^client doPop]. offset = 8 ifTrue: [^client doDup]. offset = 9 ifTrue: [^client pushActiveContext]. byte2 := method at: pc. pc := pc + 1. offset = 10 ifTrue: [^byte2 < 128 ifTrue: [client pushNewArrayOfSize: byte2] ifFalse: [client pushConsArrayWithElements: byte2 - 128]]. + offset = 11 ifTrue: [^self unusedBytecode: client at: pc - 1]. - offset = 11 ifTrue: [^self error: 'unusedBytecode']. byte3 := method at: pc. pc := pc + 1. offset = 12 ifTrue: [^client pushRemoteTemp: byte2 inVectorAt: byte3]. offset = 13 ifTrue: [^client storeIntoRemoteTemp: byte2 inVectorAt: byte3]. offset = 14 ifTrue: [^client popIntoRemoteTemp: byte2 inVectorAt: byte3]. "offset = 15" byte4 := method at: pc. pc := pc + 1. ^client pushClosureCopyNumCopiedValues: (byte2 bitShift: -4) numArgs: (byte2 bitAnd: 16rF) blockSize: (byte3 * 256) + byte4! Item was changed: ----- Method: InstructionStream>>interpretV3Extension:in:for: (in category 'decoding - private - v3 plus closures') ----- interpretV3Extension: offset in: method for: client | type offset2 byte2 byte3 | offset <= 6 ifTrue: ["Extended op codes 128-134" byte2 := method at: pc. pc := pc + 1. offset <= 2 ifTrue: ["128-130: extended pushes and pops" type := byte2 // 64. offset2 := byte2 \\ 64. offset = 0 ifTrue: [type = 0 ifTrue: [^client pushReceiverVariable: offset2]. type = 1 ifTrue: [^client pushTemporaryVariable: offset2]. type = 2 ifTrue: [^client pushConstant: (method literalAt: offset2 + 1)]. type = 3 ifTrue: [^client pushLiteralVariable: (method literalAt: offset2 + 1)]]. offset = 1 ifTrue: [type = 0 ifTrue: [^client storeIntoReceiverVariable: offset2]. type = 1 ifTrue: [^client storeIntoTemporaryVariable: offset2]. type = 2 ifTrue: [self error: 'illegalStore']. type = 3 ifTrue: [^client storeIntoLiteralVariable: (method literalAt: offset2 + 1)]]. offset = 2 ifTrue: [type = 0 ifTrue: [^client popIntoReceiverVariable: offset2]. type = 1 ifTrue: [^client popIntoTemporaryVariable: offset2]. type = 2 ifTrue: [self error: 'illegalStore']. type = 3 ifTrue: [^client popIntoLiteralVariable: (method literalAt: offset2 + 1)]]]. "131-134: extended sends" offset = 3 ifTrue: "Single extended send" [^client send: (method literalAt: byte2 \\ 32 + 1) super: false numArgs: byte2 // 32]. offset = 4 ifTrue: "Double extended do-anything" [byte3 := method at: pc. pc := pc + 1. type := byte2 // 32. type = 0 ifTrue: [^client send: (method literalAt: byte3 + 1) super: false numArgs: byte2 \\ 32]. type = 1 ifTrue: [^client send: (method literalAt: byte3 + 1) super: true numArgs: byte2 \\ 32]. type = 2 ifTrue: [^client pushReceiverVariable: byte3]. type = 3 ifTrue: [^client pushConstant: (method literalAt: byte3 + 1)]. type = 4 ifTrue: [^client pushLiteralVariable: (method literalAt: byte3 + 1)]. type = 5 ifTrue: [^client storeIntoReceiverVariable: byte3]. type = 6 ifTrue: [^client popIntoReceiverVariable: byte3]. type = 7 ifTrue: [^client storeIntoLiteralVariable: (method literalAt: byte3 + 1)]]. offset = 5 ifTrue: "Single extended send to super" [^client send: (method literalAt: byte2 \\ 32 + 1) super: true numArgs: byte2 // 32]. offset = 6 ifTrue: "Second extended send" [^client send: (method literalAt: byte2 \\ 64 + 1) super: false numArgs: byte2 // 64]]. offset = 7 ifTrue: [^client doPop]. offset = 8 ifTrue: [^client doDup]. offset = 9 ifTrue: [^client pushActiveContext]. + ^self unusedBytecode: client at: pc! - ^self error: 'unusedBytecode'! Item was added: + ----- Method: InstructionStream>>unusedBytecode:at: (in category 'private') ----- + unusedBytecode: client at: targetPC + [client unusedBytecode] + on: MessageNotUnderstood + do: [:ex| + (ex receiver == client + and: [ex message selector == #unusedBytecode]) + ifTrue: [self error: 'unusedBytecode'] + ifFalse: [ex pass]]! |
Free forum by Nabble | Edit this page |