Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.375.mcz ==================== Summary ==================== Name: Compiler-eem.375 Author: eem Time: 13 March 2018, 4:26:34.000538 pm UUID: ac95b0ba-0013-4121-8cf5-70e85161add0 Ancestors: Compiler-eem.374 Provide a comprehensive literal-in-bytecode scanning scheme that works for SistaV1's Integer and Character encodings, not just the special selectors and the special pushes. =============== Diff against Compiler-eem.374 =============== Item was added: + ----- Method: BytecodeEncoder class>>scanBlockOrNilForLiteral: (in category 'scanning') ----- + scanBlockOrNilForLiteral: aLiteral + "Answer a block argument for CompiledMethod>>#scanFor: that answers + if the method refers to the literal implicitly via a special bytecode. + If the literal is not accessible via a special bytecode, answer nil. + Subclasses override as appropriate" + ^nil! Item was added: + ----- Method: EncoderForSistaV1 class>>scanBlockOrNilForLiteral: (in category 'scanning') ----- + scanBlockOrNilForLiteral: aLiteral + "Answer a block argument for CompiledMethod>>#scanFor: that answers + if the method refers to the literal implicitly via a special bytecode. + If the literal is not accessible via a special bytecode, answer nil." + | value hi lo | + "96-111 0110 iiii Send Arithmetic Message #iiii (+ - < > <= >= = ~= * / \\ @ bitShift: // bitAnd: bitOr:) + 112-119 01110 iii Send Special Message #iii + 0 (at: at:put: size next nextPut: atEnd == class)" + aLiteral isSymbol ifTrue: + [value := 96 + ((Smalltalk specialSelectors indexOf: aLiteral ifAbsent: [^nil]) // 2). + ^[:byte| byte = value]]. + "232 11101000 iiiiiiii Push Integer #iiiiiiii (+ Extend B * 256, where bbbbbbbb = sddddddd, e.g. -32768 = i=0, d=0, s=1)" + aLiteral isInteger ifTrue: + [(aLiteral between: -32768 and: 32767) ifFalse: [^nil]. + (aLiteral between: 0 and: 255) ifTrue: + [^[:b1 :b2| b1 = 232 and: [b2 = aLiteral]]]. + lo := aLiteral bitAnd: 255. + hi := (aLiteral bitShift: -8) bitAnd: 255. + ^[:b1 :b2 :b3 :b4| b1 = 16rE1 and: [b2 = hi and: [b3 = 232 and: [b4 = lo]]]]]. + "233 11101001 iiiiiiii Push Character #iiiiiiii (+ Extend B * 256)" + aLiteral isCharacter ifTrue: + [((value := aLiteral asInteger) > 65535) ifTrue: [^nil]. + (aLiteral between: 0 and: 255) ifTrue: + [^[:b1 :b2| b1 = 233 and: [b2 = value]]]. + lo := value bitAnd: 255. + hi := (value bitShift: -8) bitAnd: 255. + ^[:b1 :b2 :b3 :b4| b1 = 16rE1 and: [b2 = hi and: [b3 = 233 and: [b4 = lo]]]]]. + + "77 01001101 Push true + 78 01001110 Push false + 79 01001111 Push nil + 88-91 010110 ii Return Receiver/true/false/nil + 93 01011101 BlockReturn nil" + aLiteral == true ifTrue: + [^[:byte| byte = 77 or: [byte = 89]]]. + aLiteral == false ifTrue: + [^[:byte| byte = 78 or: [byte = 90]]]. + aLiteral == nil ifTrue: + [^[:byte| byte = 79 or: [byte = 91 or: [byte = 93]]]]. + ^nil! Item was added: + ----- Method: EncoderForV3 class>>scanBlockOrNilForLiteral: (in category 'scanning') ----- + scanBlockOrNilForLiteral: aLiteral + "Answer a block argument for CompiledMethod>>#scanFor: that answers + if the method refers to the literal implicitly via a special bytecode. + If the literal is not accessible via a special bytecode, answer nil." + | value | + "176-191 1011iiii Send Arithmetic Message #iiii + 192-207 1100iiii Send Special Message #iiii" + (aLiteral isSymbol or: [aLiteral isInteger]) ifTrue: + [value := aLiteral isSymbol + ifTrue: [176 + ((Smalltalk specialSelectors indexOf: aLiteral ifAbsent: [^nil]) // 2)] + ifFalse: [(aLiteral between: -1 and: 2) ifFalse: [^nil]. + aLiteral + 117]. + ^[:byte| byte = value]]. + "112-119 01110iii Push (receiver, true, false, nil, -1, 0, 1, 2) [iii] + 120-123 011110ii Return (receiver, true, false, nil) [ii] From Message" + aLiteral == nil ifTrue: + [^[:byte| byte = 115 or: [byte = 123]]]. + aLiteral == true ifTrue: + [^[:byte| byte = 116 or: [byte = 124]]]. + aLiteral == false ifTrue: + [^[:byte| byte = 117 or: [byte = 125]]]. + ^nil! |
Free forum by Nabble | Edit this page |