<div dir="ltr"><div>Hi David,<br></div>I wanted to say that COG depends on (self malloc: n) to be translated malloc(n); and not setMalloc(n); for example (you can have many others by browsing unimplemented calls), but maybe foo was not a generic ID in your case?<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-11 15:05 GMT+01:00 David T. Lewis <span dir="ltr"><<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class=""><br>
On Mon, Feb 10, 2014 at 10:12:32PM +0100, Nicolas Cellier wrote:<br>
><br>
> Hi David,<br>
> do you realize that Eliot is (ab)using this in COG in order to eliminate<br>
> some direct cCode: '...' inclusion?<br>
> So setFoo: is not an option (or i misunderstood something)<br>
><br>
<br>
</div>Hi Nicolas,<br>
<br>
Actually I am not sure what you are referring to here, so probably I am<br>
missing something. Can you explain why setFoo: would be a problem in Cog?<br>
I cannot check it myself right now but I am interested to know if I am<br>
missing something important.<br>
<br>
Thanks,<br>
Dave<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
><br>
> 2014-02-10 21:51 GMT+01:00 David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>>:<br>
><br>
> ><br>
> > I was looking at the trunk VMM yesterday and found that most of the issues<br>
> > were just caused by accessor methods, where #foo and #foo: generate<br>
> > conflicting foo(void) and foo(aParameter). In most cases, a convention of<br>
> > #setFoo: rather than #foo: takes care of the problem. There were a few<br>
> > other miscellaneous issues as well, but nothing that looked serious.<br>
> ><br>
> > The variable 'memory' is a challenge because it is used extensively both<br>
> > directly and through #memory and #memory:. I was considering changing the<br>
> > variable name to something like memoryBase, and leaving the accessors<br>
> > alone though I'm not sure that would be a very good idea.<br>
> ><br>
> > I ran out of time yesterday and did not pursue it beyond this.<br>
> ><br>
> > Dave<br>
> ><br>
> > ><br>
> > ><br>
> > > On 10-02-2014, at 11:53 AM, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>><br>
> > wrote:<br>
> > >><br>
> > >> I *think* the issue is the internal/external split brought abut by the<br>
> > >> introduction of the localFoo variables, such as localSP and localIP.<br>
> > ><br>
> > > It's really hard to be sure but I suspect that this isn't the (only)<br>
> > > issue. IIRC we used to be able to make non-inlined VMs at one point and<br>
> > > that was well after the internalFoo code was added.<br>
> > ><br>
> > > OK, some quick email searching reveals some work done in '03 by johnMcI,<br>
> > > Craig & me.<br>
> > > Craig found the following code helped -<br>
> > ><br>
> > > !'From Squeak3.6alpha of ''17 March 2003'' [latest update: #5325] on 21<br>
> > > July 2003 at 1:11:25 pm'!<br>
> > ><br>
> > > !Interpreter methodsFor: 'contexts' stamp: 'crl 7/19/2003 15:59'!<br>
> > > primitiveFindNextUnwindContext<br>
> > > "Primitive. Search up the context stack for the next method context<br>
> > > marked for unwind handling from the receiver up to but not including the<br>
> > > argument. Return nil if none found."<br>
> > > | thisCntx nilOop aContext isUnwindMarked header meth pIndex |<br>
> > > aContext _ self popStack.<br>
> > > thisCntx _ self fetchPointer: SenderIndex ofObject: self popStack.<br>
> > > nilOop _ nilObj.<br>
> > ><br>
> > > [(thisCntx = aContext) or: [thisCntx = nilOop]] whileFalse: [<br>
> > ><br>
> > > header _ self baseHeader: aContext.<br>
> > ><br>
> > > (self isMethodContextHeader: header)<br>
> > > ifTrue: [<br>
> > > meth _ self fetchPointer: MethodIndex ofObject:<br>
> > aContext.<br>
> > > pIndex _ self primitiveIndexOf: meth.<br>
> > > isUnwindMarked _ pIndex == 198]<br>
> > > ifFalse: [isUnwindMarked _ false].<br>
> > > isUnwindMarked ifTrue:[<br>
> > > self push: thisCntx.<br>
> > > ^nil].<br>
> > > thisCntx _ self fetchPointer: SenderIndex ofObject:<br>
> > thisCntx].<br>
> > ><br>
> > > ^self push: nilOop! !<br>
> > ><br>
> > > !Interpreter methodsFor: 'interpreter shell' stamp: 'crl 7/19/2003<br>
> > 15:33'!<br>
> > > interpret<br>
> > > "This is the main interpreter loop. It normally loops forever,<br>
> > fetching<br>
> > > and executing bytecodes. When running in the context of a browser plugin<br>
> > > VM, however, it must return control to the browser periodically. This<br>
> > > should done only when the state of the currently running Squeak thread is<br>
> > > safely stored in the object heap. Since this is the case at the moment<br>
> > > that a check for interrupts is performed, that is when we return to the<br>
> > > browser if it is time to do so. Interrupt checks happen quite<br>
> > > frequently."<br>
> > ><br>
> > > "record entry time when running as a browser plug-in"<br>
> > > "self browserPluginInitialiseIfNeeded"<br>
> > > self internalizeIPandSP.<br>
> > > self fetchNextBytecode.<br>
> > > [true] whileTrue: [self dispatchOn: currentBytecode in:<br>
> > BytecodeTable].<br>
> > > localIP _ localIP - 1. "undo the pre-increment of IP before<br>
> > returning"<br>
> > > self externalizeIPandSP.<br>
> > > ! !<br>
> > ><br>
> > > !Interpreter methodsFor: 'return bytecodes' stamp: 'crl 7/19/2003 16:05'!<br>
> > > returnValueTo<br>
> > > "Note: Assumed to be inlined into the dispatch loop."<br>
> > ><br>
> > > | nilOop thisCntx contextOfCaller localCntx localVal isUnwindMarked<br>
> > > header meth pIndex |<br>
> > > self inline: true.<br>
> > > self sharedCodeNamed: 'commonReturn' inCase: 120.<br>
> > ><br>
> > > nilOop _ nilObj. "keep in a register"<br>
> > > thisCntx _ activeContext.<br>
> > > localCntx _ cntx.<br>
> > > localVal _ val.<br>
> > ><br>
> > > "make sure we can return to the given context"<br>
> > > ((localCntx = nilOop) or:<br>
> > > [(self fetchPointer: InstructionPointerIndex ofObject: localCntx)<br>
> > =<br>
> > > nilOop]) ifTrue: [<br>
> > > "error: sender's instruction pointer or context is nil;<br>
> > cannot return"<br>
> > > ^self internalCannotReturn: localVal].<br>
> > ><br>
> > > "If this return is not to our immediate predecessor (i.e. from a<br>
> > method<br>
> > > to its sender, or from a block to its caller), scan the stack for the<br>
> > > first unwind marked context and inform this context and let it deal with<br>
> > > it. This provides a chance for ensure unwinding to occur."<br>
> > > thisCntx _ self fetchPointer: SenderIndex ofObject: activeContext.<br>
> > ><br>
> > > "Just possibly a faster test would be to compare the homeContext<br>
> > and<br>
> > > activeContext - they are of course different for blocks. Thus we might be<br>
> > > able to optimise a touch by having a different returnTo for the<br>
> > > blockreteurn (since we know that must return to caller) and then if<br>
> > > active ~= home we must be doing a non-local return. I think. Maybe."<br>
> > > [thisCntx = localCntx] whileFalse: [<br>
> > > thisCntx = nilObj ifTrue:[<br>
> > > "error: sender's instruction pointer or context is<br>
> > nil; cannot return"<br>
> > > ^self internalCannotReturn: localVal].<br>
> > > "Climb up stack towards localCntx. Break out to a send of<br>
> > > #aboutToReturn:through: if an unwind marked context is found"<br>
> > > header _ self baseHeader: thisCntx.<br>
> > ><br>
> > > (self isMethodContextHeader: header)<br>
> > > ifTrue: [<br>
> > > meth _ self fetchPointer: MethodIndex ofObject:<br>
> > thisCntx.<br>
> > > pIndex _ self primitiveIndexOf: meth.<br>
> > > isUnwindMarked _ pIndex == 198]<br>
> > > ifFalse: [isUnwindMarked _ false].<br>
> > ><br>
> > > isUnwindMarked ifTrue:[<br>
> > > "context is marked; break out"<br>
> > > ^self internalAboutToReturn: localVal through:<br>
> > thisCntx].<br>
> > > thisCntx _ self fetchPointer: SenderIndex ofObject:<br>
> > thisCntx.<br>
> > > ].<br>
> > ><br>
> > > "If we get here there is no unwind to worry about. Simply<br>
> > terminate the<br>
> > > stack up to the localCntx - often just the sender of the method"<br>
> > > thisCntx _ activeContext.<br>
> > > [thisCntx = localCntx]<br>
> > > whileFalse:<br>
> > > ["climb up stack to localCntx"<br>
> > > contextOfCaller _ self fetchPointer: SenderIndex ofObject:<br>
> > thisCntx.<br>
> > ><br>
> > > "zap exited contexts so any future attempted use will be<br>
> > caught"<br>
> > > self storePointerUnchecked: SenderIndex ofObject: thisCntx<br>
> > withValue:<br>
> > > nilOop.<br>
> > > self storePointerUnchecked: InstructionPointerIndex<br>
> > ofObject: thisCntx<br>
> > > withValue: nilOop.<br>
> > > reclaimableContextCount > 0 ifTrue:<br>
> > > ["try to recycle this context"<br>
> > > reclaimableContextCount _ reclaimableContextCount<br>
> > - 1.<br>
> > > self recycleContextIfPossible: thisCntx].<br>
> > > thisCntx _ contextOfCaller].<br>
> > ><br>
> > > activeContext _ thisCntx.<br>
> > > (thisCntx < youngStart) ifTrue: [ self beRootIfOld: thisCntx ].<br>
> > ><br>
> > > self internalFetchContextRegisters: thisCntx. "updates local IP<br>
> > and SP"<br>
> > > self fetchNextBytecode.<br>
> > > self internalPush: localVal.<br>
> > > ! !<br>
> > ><br>
> > > Shortly after that I released the VMMaker3.6 with a note that it couldn't<br>
> > > produce a completely non-inlined VM because of a problem in fetchByte if<br>
> > > globalstruct was enabled, and some odd problems in B2DPlugin. When<br>
> > > VMMaker3.7 was released a year late (march 04) I apparently thought it<br>
> > > could make the core vm non-inlined. Since this is all a bazillion years<br>
> > > ago I can't remember any context to help extend the history.<br>
> > ><br>
> > > tim<br>
> > > --<br>
> > > tim Rowledge; <a href="mailto:tim@rowledge.org">tim@rowledge.org</a>; <a href="http://www.rowledge.org/tim" target="_blank">http://www.rowledge.org/tim</a><br>
> > > Science is imagination equipped with grappling hooks.<br>
> > ><br>
> ><br>
> ><br>
> ><br>
<br>
</div></div></blockquote></div><br></div>