help-smalltalk
[Top][All Lists]
Advanced

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

Re: [Help-smalltalk] _gst_invalidate_method_cache and _gst_reset_inline_


From: Gwenaël Casaccio
Subject: Re: [Help-smalltalk] _gst_invalidate_method_cache and _gst_reset_inline_caches
Date: Sun, 22 Dec 2013 15:32:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 22/12/2013 10:48, Holger Hans Peter Freyther wrote:
On Sat, Dec 21, 2013 at 09:38:26PM +0100, Paolo Bonzini wrote:

I think the species of MethodDictionary should be LookupTable?
It is more complicated than this. E.g. with the >>#remove:


  remove: anAssociation [
        ...
            copy := self copy.
            result := copy dangerouslyRemove: anAssociation.
            self become: copy.
            Behavior flushCache].
        ...
     ]


So >>#copy should return a MethodDictionary. I considered just
changing >>#copyEmpty: but >>#shallowCopy is already using this.

What about introducing a >>#fastSelect: inside VisualGST to
avoid the flush? In the case of Doit/DoIt in VisualGST and Behavior..
what if we introduce a method that just creates a CompiledMethod
but does not add it to a method dictionary?
Why not doing:

--- a/kernel/MethodDictionary.st
+++ b/kernel/MethodDictionary.st
@@ -119,6 +119,32 @@ interpreter.'>
        self mutex critical: [ self growBy: 0 ]
     ]

+    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."
+
+    <category: 'dictionary enumerating'>
+    | newDict |
+    newDict := self copyEmpty: self capacity.
+    self
+ associationsDo: [:assoc | (aBlock value: assoc value) ifTrue: [newDict dangerouslyAt: assoc key put: assoc value]].
+    ^newDict
+    ]
+
+    dangerouslyAt: aKey put: aValue [
+    <category: 'private methods'>
+
+        | index |
+        index := self findIndex: aKey.
+        (self primAt: index) isNil ifTrue: [
+ self incrementTally ifTrue: [ index := self findIndex: aKey ].
+                                             self primAt: index put: aKey
+                                           ]
+ ifFalse: [ (self valueAt: index) discardTranslation ].
+        self valueAt: index put: aValue.
+       ^ aValue
+    ]
+

holger



Example issue while running the test code:

Swazoo.SwazooCompilerTest>>#testEvaluate did not understand 
#dangerouslyRemoveKey:
TestVerboseLog>>logError: (SUnit.star#VFS.ZipFile/SUnit.st:609)
Swazoo.SwazooCompilerTest(TestCase)>>logError: 
(SUnit.star#VFS.ZipFile/SUnit.st:877)
[] in TestResult>>runCase: (SUnit.star#VFS.ZipFile/SUnit.st:443)
MessageNotUnderstood(Exception)>>activateHandler: (ExcHandling.st:515)
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
LookupTable(Object)>>doesNotUnderstand: #dangerouslyRemoveKey: 
(SysExcept.st:1408)
[] in MethodDictionary>>removeKey:ifAbsent: (MethodDict.st:108)
[] in Semaphore>>critical: (Semaphore.st:80)
BlockClosure>>ensure: (BlkClosure.st:271)
Semaphore>>critical: (Semaphore.st:60)
MethodDictionary>>removeKey:ifAbsent: (MethodDict.st:111)
Metaclass(Behavior)>>removeSelector:ifAbsent: (Behavior.st:261)
Behavior class(Behavior)>>evalString:to: (Behavior.st:432)
Behavior class(Behavior)>>evaluate:to: (Behavior.st:503)
SpEnvironment class>>evaluate:receiver:in: (Sport.star#VFS.ZipFile/sport.st:385)


_______________________________________________
help-smalltalk mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-smalltalk




reply via email to

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