***"Source" Integer class>> printOn: aStream base: b "Append a representation of this number in base b on aStream. In order to reduce cost of LargePositiveInteger ops, split the number in approximately two equal parts in number of digits." | halfDigits halfPower head tail nDigitsUnderestimate | "Don't engage any arithmetic if not normalized" (self digitLength = 0 or: [(self digitAt: self digitLength) = 0]) ifTrue: [^self normalize printOn: aStream base: b]. nDigitsUnderestimate := b = 10 ifTrue: [((self highBit - 1) * 1233 >> 12) + 1. "This is because (2 log)/(10 log)*4096 is slightly greater than 1233"] ifFalse: [self highBit quo: b highBit]. "splitting digits with a whole power of two is more efficient" halfDigits := 1 bitShift: nDigitsUnderestimate highBit - 2. halfDigits <= 1 ifTrue: ["Hmmm, this could happen only in case of a huge base b... Let lower level fail" ^self printOn: aStream base: b nDigits: (self numberOfDigitsInBase: b)]. "Separate in two halves, head and tail" halfPower := b raisedToInteger: halfDigits. head := self quo: halfPower. tail := self - (head * halfPower). "print head" head printOn: aStream base: b. "print tail without the overhead to count the digits" tail printOn: aStream base: b nDigits: halfDigits ***"Decompiled" Integer class>> printOn: arg1 base: arg2 | temp3 temp4 temp5 temp6 temp7 | (self digitLength = 0 or: [ (self digitAt: self digitLength) = 0 ]) ifTrue: [ ^ self normalize printOn: arg1 base: arg2 ]. temp7 _ arg2 = 10 ifTrue: [ self highBit - 1 * 1233 >> 12 + 1 ] ifFalse: [ self highBit quo: arg2 highBit ]. temp3 _ 1 bitShift: temp7 highBit - 2. temp3 <= 1 ifTrue: [ ^ self printOn: arg1 base: arg2 nDigits: (self numberOfDigitsInBase: arg2) ]. temp4 _ arg2 raisedToInteger: temp3. temp5 _ self quo: temp4. temp6 _ self - (temp5 * temp4). temp5 printOn: arg1 base: arg2. temp6 printOn: arg1 base: arg2 nDigits: temp3. ***"ByteCodes" 153 <70> self 154 send: digitLength 155 <75> pushConstant: 0 156 send: = 157 <99> jumpFalse: 160 158 <71> pushConstant: true 159 <95> jumpTo: 166 160 <70> self 161 <70> self 162 send: digitLength 163 send: digitAt: 164 <75> pushConstant: 0 165 send: = 166 <9D> jumpFalse: 173 167 <70> self 168 send: normalize 169 <10> pushTemp: 0 170 <11> pushTemp: 1 171 send: printOn:base: 172 <7C> returnTop 173 <11> pushTemp: 1 174 <29> pushConstant: 10 175 send: = 176 jumpFalse: 189 178 <70> self 179 send: highBit 180 <76> pushConstant: 1 181 send: - 182 <27> pushConstant: 1233 183 send: * 184 <28> pushConstant: 12 185 send: >> 186 <76> pushConstant: 1 187 send: + 188 <94> jumpTo: 194 189 <70> self 190 send: highBit 191 <11> pushTemp: 1 192 send: highBit 193 send: quo: 194 <6E> popIntoTemp: 6 195 <76> pushConstant: 1 196 <16> pushTemp: 6 197 send: highBit 198 <77> pushConstant: 2 199 send: - 200 send: bitShift: 201 <6A> popIntoTemp: 2 202 <12> pushTemp: 2 203 <76> pushConstant: 1 204 send: <= 205 jumpFalse: 216 207 <70> self 208 <10> pushTemp: 0 209 <11> pushTemp: 1 210 <70> self 211 <11> pushTemp: 1 212 send: numberOfDigitsInBase: 213 <83 6A> send: printOn:base:nDigits: 215 <7C> returnTop 216 <11> pushTemp: 1 217 <12> pushTemp: 2 218 send: raisedToInteger: 219 <6B> popIntoTemp: 3 220 <70> self 221 <13> pushTemp: 3 222 send: quo: 223 <6C> popIntoTemp: 4 224 <70> self 225 <14> pushTemp: 4 226 <13> pushTemp: 3 227 send: * 228 send: - 229 <6D> popIntoTemp: 5 230 <14> pushTemp: 4 231 <10> pushTemp: 0 232 <11> pushTemp: 1 233 send: printOn:base: 234 <87> pop 235 <15> pushTemp: 5 236 <10> pushTemp: 0 237 <11> pushTemp: 1 238 <12> pushTemp: 2 239 <83 6A> send: printOn:base:nDigits: 241 <87> pop 242 <78> returnSelf ***"Details, details" Manjaro:RPi4:~/OpenSmalltalk/Bavision/products/sqcogspur64ARMv8linuxht/lib/squeak/5.0-202103220146 >>> ./squeak --version 5.0-202103220146 Sun May 2 10:59:52 PDT 2021 gcc 10.2.0 [Production Spur 64-bit VM] CoInterpreter VMMaker.oscog-eem.2948 uuid: 935d1ee7-0e61-47a5-92e2-953224c7ffcf May 2 2021 StackToRegisterMappingCogit VMMaker.oscog-eem.2946 uuid: 461911e1-d450-4f05-8a40-7b0470487041 May 2 2021 VM: 202103220146 kend@RPi4Manjaro:OpenSmalltalk/Bavision Date: Sun Mar 21 21:46:24 2021 CommitHash: d494240 Plugins: 202103220146 kend@RPi4Manjaro:OpenSmalltalk/Bavision Linux RPi4Manjaro 5.10.31-1-MANJARO-ARM #1 SMP PREEMPT Mon Apr 19 13:28:29 UTC 2021 aarch64 GNU/Linux plugin path: /home/kend/OpenSmalltalk/Bavision/products/sqcogspur64ARMv8linuxht/lib/squeak/5.0-202103220146/ [default: /home/kend/OpenSmalltalk/Bavision/products/sqcogspur64ARMv8linuxht/lib/squeak/5.0-202103220146/] Manjaro:RPi4:~/OpenSmalltalk/Bavision/products/sqcogspur64ARMv8linuxht/lib/squeak/5.0-202103220146 >>> uname -a Linux RPi4Manjaro 5.10.43-1-MANJARO-ARM #1 SMP PREEMPT Mon Jun 14 14:31:41 UTC 2021 aarch64 GNU/Linux Manjaro:RPi4:~/OpenSmalltalk/Bavision/products/sqcogspur64ARMv8linuxht/lib/squeak/5.0-202103220146 >>> lscpu Architecture: aarch64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Vendor ID: ARM Model name: Cortex-A72 Model: 3 Thread(s) per core: 1 Core(s) per cluster: 4 Socket(s): - Cluster(s): 1 Stepping: r0p3 CPU max MHz: 1500.0000 CPU min MHz: 600.0000 BogoMIPS: 108.00 Flags: fp asimd evtstrm crc32 cpuid Vulnerabilities: Itlb multihit: Not affected L1tf: Not affected Mds: Not affected Meltdown: Not affected Spec store bypass: Vulnerable Spectre v1: Mitigation; __user pointer sanitization Spectre v2: Vulnerable Srbds: Not affected Tsx async abort: Not affected Manjaro:RPi4:~/OpenSmalltalk/Bavision/products/sqcogspur64ARMv8linuxht/lib/squeak/5.0-202103220146 >>> --- E O F ---