<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Georgia">What if, instead of substituting a new literal
in the CM, you tried modifying the literal itself?</font> Maybe
COG would not object to that.<br>
<pre wrap=""> myDomainSubclass
compileSilently:
'writeBarrier
^ #(foo) first first'
classified: 'accessing'.
((myDomainSubclass methodDictionary at: #writeBarrier)
literalAt: 2) at: 1
put: (WeakArray with: theSession)
</pre>
<div class="moz-cite-prefix">On 12/26/12 12:09 PM, Chris Muller
wrote:<br>
</div>
<blockquote
cite="mid:CANzdToG=7wBfqMiuSB6y-vLpb4Jq+WtchSuh+tUENMs5KxnhWQ@mail.gmail.com"
type="cite">
<pre wrap="">With Eliot's latest Cog things are really rocking! But I am still
having one issue which seems to be related to a Cog code-generation /
timing issue.
It relates to a hack that dynamically creates a subclass of a domain
class to generate overrides of all of its methods that potentially
change the state of the object (e.g., a write-barrier).
In addition to the overriding methods, it also must generate one
accessor method which is used to refer to a Session object, so that
the overriding methods can notify it if, in fact, an inst-var changed.
When I generate the subclass, I _cannot_ add any new inst-vars to hold
the Session (because primChangeClassTo: requires the same physical
shape). So, to make the hack work at all, first I compile the
following method to establish slots for a couple of literals:
myDomainSubclass
compileSilently:
'writeBarrier
^ Object first'
classified: 'accessing'.
Then slap in the Session object I want into the second slot:
(myDomainSubclass methodDictionary at: #writeBarrier)
literalAt: 2
put: #Object -> (WeakArray with: theSession)
Voila! theSession has now been hacked into the CM at literal 2.
"Object" in the code now refers to the WeakArray holding my Session
rather than the Object class.
I wouldn't do this at all if it wasn't for the 3X improvement in
commit performance. However, about once or twice a day, I encounter a
debugger which indicates, by the accessing attempt, it thinks that
literal 2 is an Integer or a Character. Most of the time simply
printing "self writeBarrier" right there in the debugger produces the
correct answer (the Session object) -- as if Cog suddenly "caught up"
with it.
Any suggestions are greatly appreciated, thank you!
</pre>
</blockquote>
<br>
</body>
</html>