help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] [PATCH] Fix spurious failure in floatmath.st


From: Paolo Bonzini
Subject: [Help-smalltalk] [PATCH] Fix spurious failure in floatmath.st
Date: Fri, 25 May 2007 11:03:11 +0200
User-agent: Thunderbird 2.0.0.0 (Macintosh/20070326)

The testcase of this failure is actually weird:

Try this:

st> LookupTable new capacity
6
st> LookupTable new copy capacity
12
st> LookupTable new copy copy capacity
24
st> LookupTable new copy copy copy capacity
48

In the case of floatmath.st, repeated usage of Behavior>>#evaluate: causes a method to be removed repeatedly from a MethodDictionary. To ensure atomicity, the operation is done on a *copy* of the MethodDictionary. And this causes the MethodDictionary's size to blow up.

This should be the last failure on MacOS X/i386. So, we're close to 2.3.4 now. I'll send a call for testing separately.

Paolo
2007-05-24  Paolo Bonzini  <address@hidden>

        * kernel/Collection.st: Don't use #basicSize in #copyWith:.
        * kernel/Dictionary.st: Replace #primSize with #capacity.
        * kernel/HashedColl.st: Replace #primSize with #capacity.
        * kernel/LookupTable.st: Replace #primSize with #capacity.

--- orig/kernel/Collection.st
+++ mod/kernel/Collection.st
@@ -445,8 +445,7 @@ copyReplacing: targetObject withObject: 
 copyWith: newElement
     "Answer a copy of the receiver to which newElement is added"
 
-    ^(self copyEmpty: self basicSize + 1)
-       addAll: self;
+    ^self copy
        add: newElement;
        yourself
 !


--- orig/kernel/Dictionary.st
+++ mod/kernel/Dictionary.st
@@ -327,7 +327,7 @@ collect: aBlock
     "Answer a new dictionary where the keys are the same and the values are
      obtained by passing each value to aBlock and collecting the return values"
     | aDictionary |
-    aDictionary := self copyEmpty: self primSize.
+    aDictionary := self copyEmpty: self capacity.
     self keysAndValuesDo: [ :key :value |
        aDictionary at: key put: (aBlock value: value) ].
     ^aDictionary
@@ -337,7 +337,7 @@ select: aBlock
     "Answer a new dictionary containing the key/value pairs for which aBlock
      returns true. aBlock only receives the value part of the pairs."
     | newDict |
-    newDict := self copyEmpty: self primSize.
+    newDict := self copyEmpty: self capacity.
     self associationsDo:
        [ :assoc | (aBlock value: assoc value)
                     ifTrue: [ newDict add: assoc ] ].
@@ -348,7 +348,7 @@ reject: aBlock
     "Answer a new dictionary containing the key/value pairs for which aBlock
      returns false. aBlock only receives the value part of the pairs."
     | newDict |
-    newDict := self copyEmpty: self primSize.
+    newDict := self copyEmpty: self capacity.
     self associationsDo:
        [ :assoc | (aBlock value: assoc value)
                     ifFalse: [ newDict add: assoc ] ].


--- orig/kernel/HashedColl.st
+++ mod/kernel/HashedColl.st
@@ -122,7 +122,7 @@ remove: oldObject ifAbsent: anExceptionB
 shallowCopy
     "Returns a shallow copy of the receiver (the instance variables are
      not copied)"
-    ^(self copyEmpty: self primSize)
+    ^(self copyEmpty: self capacity)
         copyAllFrom: self;
         yourself
 !
@@ -131,7 +131,7 @@ deepCopy
     "Returns a deep copy of the receiver (the instance variables are
      copies of the receiver's instance variables)"
     | newHashedCollection |
-    newHashedCollection := self copyEmpty: self primSize.
+    newHashedCollection := self copyEmpty: self capacity.
     self do: [ :each | newHashedCollection addWhileGrowing: each copy ].
     ^newHashedCollection
 ! !
@@ -264,7 +264,7 @@ incrementTally
     "Answer whether the collection's size varied"
     | grown |
     (grown := tally >= (self primSize * 3 // 4))
-        ifTrue: [ self growBy: self primSize ].
+        ifTrue: [ self growBy: self capacity ].
 
     tally := tally + 1.
     ^grown
@@ -288,7 +288,7 @@ addWhileGrowing: value
 
 copyEmpty
     "Answer an empty copy of the receiver"
-    ^self copyEmpty: self primSize
+    ^self copyEmpty: self capacity
 !
 
 copyAllFrom: aHashedCollection
@@ -355,7 +355,7 @@ findIndexOrNil: anObject
 !
 
 grow
-    ^self growBy: self primSize
+    ^self growBy: self capacity
 !
 
 growBy: delta
@@ -363,7 +363,7 @@ growBy: delta
 
     | newSize newHashedCollection |
     newSize := self primSize + delta.
-    newHashedCollection := self copyEmpty: self primSize + delta.
+    newHashedCollection := self copyEmpty: self capacity + delta.
     newHashedCollection copyAllFrom: self.
     ^self become: newHashedCollection
 ! !


--- orig/kernel/LookupTable.st
+++ mod/kernel/LookupTable.st
@@ -116,7 +116,7 @@ deepCopy
     "Returns a deep copy of the receiver (the instance variables are
      copies of the receiver's instance variables)"
     | key newDict |
-    newDict := self copyEmpty: self primSize.
+    newDict := self copyEmpty: self capacity.
     1 to: self primSize do: [ :index |
        key := self primAt: index.
        key isNil


--- orig/tests/testsuite.at
+++ mod/tests/testsuite.at
@@ -31,7 +31,7 @@ AT_DIFF_TEST([sets.st])
 AT_DIFF_TEST([processes.st])
 AT_DIFF_TEST([exceptions.st])
 AT_DIFF_TEST([intmath.st])
-AT_DIFF_TEST([floatmath.st], [AT_XFAIL_IF(:)])
+AT_DIFF_TEST([floatmath.st])
 AT_DIFF_TEST([dates.st])
 AT_DIFF_TEST([objects.st])
 AT_DIFF_TEST([strings.st])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]