LargePositiveInteger indexIfCompact isZero (inconsistency)
Hi, I found this comment in TBehavior>>indexIfCompact : "Verify if the compactClassesArray and indexIfCompact are coheren Smalltalk compactClassesArray doWithIndex: [:c :i | c == nil ifFalse: [c indexIfCompact = i ifFalse: [self halt]]] " Since it *does* halt, I rewrote to: | inconsistencies | inconsistencies := OrderedCollection new. Smalltalk compactClassesArray doWithIndex: [ :class :index | class ifNotNil: [ class indexIfCompact = index ifFalse: [ inconsistencies add: { class. index. class indexIfCompact } ]]]. inconsistencies."---> an OrderedCollection({LargeNegativeInteger. 4. 0} {LargePositiveInteger. 5. 0})" I checked that in Pharo 2 they are consistent, so I guess this should be fixed. I ignore deep vm internals so... how would you fix this? I tried to #becomeUncompact to then #becomeCompact again, but it didn't work out-of-the-box. Cheers, MartÃn
Hello, Try : Smalltalk compactClassesArray at: 5 put: nil. LargePositiveInteger becomeUncompact. LargePositiveInteger becomeCompactSimplyAt: 5. then: LargePositiveInteger indexIfCompact. is correct. Same script is needed for LargeNegativeInteger. I think this bug is due to the introduction of LargeInteger class in Pharo 3 (common superclass of LargePositiveInteger and LargeNegativeInteger). Now this is strange that the script I gave you worked because if you look at TBehavior>>checkCanBeUncompact "Certain classes cannot be uncompacted in CogVM. If you download VMMaker and see the VM code, these are as defined by StackInterpreter>>#checkAssumedCompactClasses and the ones that can't be uncompacted are the following: " ({ Array. LargeNegativeInteger. LargePositiveInteger. Float. MethodContext } includes: self) ifTrue: [ self error: 'Class ', self name, ' cannot be uncompact. ' ] However it seems that it worked with #becomeCompactSimplyAt 2014-02-24 11:33 GMT+01:00 Martin Dias <tinchodias@gmail.com>:
Hi,
I found this comment in TBehavior>>indexIfCompact :
"Verify if the compactClassesArray and indexIfCompact are coheren Smalltalk compactClassesArray doWithIndex: [:c :i | c == nil ifFalse: [c indexIfCompact = i ifFalse: [self halt]]] "
Since it *does* halt, I rewrote to:
| inconsistencies | inconsistencies := OrderedCollection new.
Smalltalk compactClassesArray doWithIndex: [ :class :index | class ifNotNil: [ class indexIfCompact = index ifFalse: [ inconsistencies add: { class. index. class indexIfCompact } ]]].
inconsistencies."---> an OrderedCollection({LargeNegativeInteger. 4. 0} {LargePositiveInteger. 5. 0})"
I checked that in Pharo 2 they are consistent, so I guess this should be fixed.
I ignore deep vm internals so... how would you fix this?
I tried to #becomeUncompact to then #becomeCompact again, but it didn't work out-of-the-box.
Cheers, MartÃn
On Mon, Feb 24, 2014 at 12:21 PM, Clément Bera <bera.clement@gmail.com>wrote:
Hello,
Try :
Smalltalk compactClassesArray at: 5 put: nil. LargePositiveInteger becomeUncompact. LargePositiveInteger becomeCompactSimplyAt: 5.
then:
LargePositiveInteger indexIfCompact.
is correct.
Same script is needed for LargeNegativeInteger.
Good!
I think this bug is due to the introduction of LargeInteger class in Pharo 3 (common superclass of LargePositiveInteger and LargeNegativeInteger).
Ok
Now this is strange that the script I gave you worked because if you look at TBehavior>>checkCanBeUncompact "Certain classes cannot be uncompacted in CogVM. If you download VMMaker and see the VM code, these are as defined by StackInterpreter>>#checkAssumedCompactClasses and the ones that can't be uncompacted are the following: " ({ Array. LargeNegativeInteger. LargePositiveInteger. Float. MethodContext } includes: self) ifTrue: [ self error: 'Class ', self name, ' cannot be uncompact. ' ]
I debugged "LargePositiveInteger becomeUncompact": it returns before sending #checkCanBeUncompact since #indexIfCompact is zero. So, it'd be enough with just: Smalltalk compactClassesArray at: 4 put: nil. LargeNegativeInteger becomeCompactSimplyAt: 4. Smalltalk compactClassesArray at: 5 put: nil. LargePositiveInteger becomeCompactSimplyAt: 5.
However it seems that it worked with #becomeCompactSimplyAt
So we should add a test for compact classes consistency. Maybe in Slot's class builder. --- PS: I've found this method in Integer metaclass: initialize "Integer initialize" "Ensure we have the right compact class index" "LPI has been a compact class forever - just ensure basic correctness" (LargePositiveInteger indexIfCompact = 5) ifFalse:[ (Smalltalk compactClassesArray at: 5) ifNil:[LargePositiveInteger becomeCompactSimplyAt: 5] ifNotNil:[self error: 'Unexpected compact class setup']]. (LargeNegativeInteger indexIfCompact = 4) ifFalse:[ (Smalltalk compactClassesArray at: 4) ifNil:[LargeNegativeInteger becomeCompactSimplyAt: 4] ifNotNil:[self error: 'Unexpected compact class setup']]. (2 years old) the only senders in the image of #becomeCompactSimplyAt: --- MartÃn
participants (2)
-
Clément Bera -
Martin Dias