Nicolas Cellier uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2713.mcz ==================== Summary ==================== Name: VMMaker.oscog-nice.2713 Author: nice Time: 18 February 2020, 8:50:42.039483 am UUID: 140e2584-0181-4190-af0f-6d808961d58f Ancestors: VMMaker.oscog-nice.2712 Fix bug in LargeInteger division: instantiation of quotient (quo) may fail and thus require a proper guard. It may happen: I did report some crash when testing huge integer division at http://smallissimo.blogspot.com/2019/05/tuning-large-arithmetic-thresholds.html Fix a copy/paste glitch JumpCarry/JumpNoCarry in #setsConditionCodesFor: We only ever use JumpZero so far, so it's benign. =============== Diff against VMMaker.oscog-nice.2712 =============== Item was changed: ----- Method: CogIA32Compiler>>setsConditionCodesFor: (in category 'testing') ----- setsConditionCodesFor: aConditionalJumpOpcode <inline: false> "to save Slang from having to be a real compiler (it can't inline switches that return)" "Answer if the receiver's opcode sets the condition codes correctly for the given conditional jump opcode." ^opcode caseOf: { [ArithmeticShiftRightCqR] -> [self shiftSetsConditionCodesFor: aConditionalJumpOpcode]. [ArithmeticShiftRightRR] -> [self shiftSetsConditionCodesFor: aConditionalJumpOpcode]. [LogicalShiftLeftCqR] -> [self shiftSetsConditionCodesFor: aConditionalJumpOpcode]. [LogicalShiftLeftRR] -> [self shiftSetsConditionCodesFor: aConditionalJumpOpcode]. [XorRR] -> [true]. + [ClzRR] -> [aConditionalJumpOpcode = JumpZero or: [aConditionalJumpOpcode = JumpNonZero or: [aConditionalJumpOpcode = JumpCarry or: [aConditionalJumpOpcode = JumpNoCarry "carry flag is set if input is zero"]]]] - [ClzRR] -> [aConditionalJumpOpcode = JumpZero or: [aConditionalJumpOpcode = JumpNonZero or: [aConditionalJumpOpcode = JumpNoCarry or: [aConditionalJumpOpcode = JumpNoCarry "carry flag is set if input is zero"]]]] } otherwise: [self halt: 'unhandled opcode in setsConditionCodesFor:'. false]! Item was changed: ----- Method: CogX64Compiler>>setsConditionCodesFor: (in category 'testing') ----- setsConditionCodesFor: aConditionalJumpOpcode <inline: false> "to save Slang from having to be a real compiler (it can't inline switches that return)" "Answer if the receiver's opcode sets the condition codes correctly for the given conditional jump opcode." ^opcode caseOf: { [ArithmeticShiftRightCqR] -> [self shiftSetsConditionCodesFor: aConditionalJumpOpcode]. [ArithmeticShiftRightRR] -> [self shiftSetsConditionCodesFor: aConditionalJumpOpcode]. [LogicalShiftLeftCqR] -> [self shiftSetsConditionCodesFor: aConditionalJumpOpcode]. [LogicalShiftLeftRR] -> [self shiftSetsConditionCodesFor: aConditionalJumpOpcode]. [LogicalShiftRightCqR] -> [false]. [XorRR] -> [true]. + [ClzRR] -> [aConditionalJumpOpcode = JumpZero or: [aConditionalJumpOpcode = JumpNonZero or: [aConditionalJumpOpcode = JumpCarry or: [aConditionalJumpOpcode = JumpNoCarry "carry flag is set if input is zero"]]]] - [ClzRR] -> [aConditionalJumpOpcode = JumpZero or: [aConditionalJumpOpcode = JumpNonZero or: [aConditionalJumpOpcode = JumpNoCarry or: [aConditionalJumpOpcode = JumpNoCarry "carry flag is set if input is zero"]]]] } otherwise: [self halt: 'unhandled opcode in setsConditionCodesFor:'. false]! Item was changed: ----- Method: LargeIntegersPlugin>>digitDivLarge:with:negative: (in category 'oop functions') ----- digitDivLarge: firstInteger with: secondInteger negative: neg "Does not normalize." "Division by zero has to be checked in caller." | firstDigitLen secondDigitLen quoDigitLen d div rem quo result | firstDigitLen := self digitSizeOfLargeInt: firstInteger. secondDigitLen := self digitSizeOfLargeInt: secondInteger. quoDigitLen := firstDigitLen - secondDigitLen + 1. quoDigitLen <= 0 ifTrue: [self remapOop: firstInteger in: [result := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 2]. result ifNotNil: [interpreterProxy stObject: result at: 1 put: (0 asOop: SmallInteger). interpreterProxy stObject: result at: 2 put: firstInteger]. ^ result]. "set rem and div to copies of firstInteger and secondInteger, respectively. However, to facilitate use of Knuth's algorithm, multiply rem and div by 2 (that is, shift) until the high word of div is >=16r80000000" d := 32 - (self cHighBit32: (self unsafeDigitOfLargeInt: secondInteger at: secondDigitLen)). self remapOop: firstInteger in: [div := self digit: secondInteger Lshift: d. div ifNotNil: [div := self largeInt: div growTo: (self digitSizeOfLargeInt: div) + 1 * 4]. div ifNil: [^div]]. self remapOop: div in: [rem := self digit: firstInteger Lshift: d. rem ifNotNil: [(self digitSizeOfLargeInt: rem) = firstDigitLen ifTrue: [rem := self largeInt: rem growTo: firstDigitLen + 1 * 4]]. rem ifNil: [^rem]]. self remapOop: #(div rem) + in: [quo := self createLargeIntegerNeg: neg digitLength: quoDigitLen. + quo ifNil: + [interpreterProxy primitiveFailFor: PrimErrNoMemory. ^quo]]. - in: [quo := self createLargeIntegerNeg: neg digitLength: quoDigitLen]. self cDigitDiv: (self pointerToFirstDigitOfLargeInt: div) len: (self digitSizeOfLargeInt: div) rem: (self pointerToFirstDigitOfLargeInt: rem) len: (self digitSizeOfLargeInt: rem) quo: (self pointerToFirstDigitOfLargeInt: quo) len: (self digitSizeOfLargeInt: quo). self remapOop: quo in: [rem := self digit: rem Rshift: d lookfirst: (self digitSizeOfLargeInt: div) - 1]. "^ Array with: quo with: rem" self remapOop: #(quo rem) in: [result := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 2]. result ifNotNil: [interpreterProxy stObject: result at: 1 put: quo. interpreterProxy stObject: result at: 2 put: rem]. ^result! |
Free forum by Nabble | Edit this page |