Feeds:
Posts
Comments

Archive for the ‘cog’ Category

Here are the command line commands I used to get CogSpur running with a VMMaker image and the CMakeVMakerSqueak package starting from scratch.

#Do an svn checkout

svn co http://www.squeakvm.org/svn/squeak/branches/Cog

#run Eliot’s bash script to get the VMMaker image up and configured.

cd Cog/image
cat README
./ buildspurtrunkvmmakerimage.sh
./ cogspurlinuxht/squeak  SpurVMMaker.image  &

#Install the CMakeVMMakerSqueak package and see the documentation
Monticello browser
Repository http://source.squeak.org/VMMaker
CMakeVMMaker (latest) load
CMakeVMMakerSqueak (latest) load
HelpBrowser topic CMakeVMMakerSqueak

save and quit

#set up my personal working environment

#put the executable cog/spur in my PATH

mv cogspurlinuxht /home/tty/usr/bin/

#set up a development area independent of the Cog svn source tree
cd ../../
mkdir cogspurVMMaker
mv Cog/image/SpurVMMaker.* cogspurVMMaker/
mv Cog/image/SqueakV50.sources cogspurVMMaker/

#the tools are installed. now we need to put the Cog source tree
#in a subdirectory of the .image file. The directory is named ‘oscogvm’

cd cogspurVMMaker
mkdir oscogvm
rsync -Carv  –exclude=”image*”  ../Cog/ cogspurVMMaker/

#the resulting work environment directory tree looks like this

tree -d -L 2  cogspurVMMaker/
cogspurVMMaker/
`– oscogvm
|– build.linux32ARM
|– build.linux32x86
|– build.linux64x64
|– build.macos32x86
|– build.macos64x64
|– build.win32x86
|– history
|– nsspursrc
|– nsspurstack64src
|– nsspurstacksrc
|– nssrc
|– platforms
|– processors
|– products
|– scripts
|– sources
|– spur64src
|– spursistasrc
|– spursrc
|– spurstack64src
|– spurstacksrc
|– src
`– stacksrc

 

Advertisements

Read Full Post »

The pharo team is going through a “wish list” phase. I have my own, so I figured I would post it.
It is not a rigorous “think through” this is just brainstorms:

* Squeak Stuff I Want To Do
+ [ ] multi-processor squeak ala roarvm
+ [ ] Kernel space squeak
+ [ ] Squeak As Dia with zoom/pan capability
+ [ ] Seaside Desktop with RenderOn: idiom
+ [ ] REPL
+ [ ] REPL with Emacs
+ [ ] FFI's or Plugins to GL
+ [ ] Tweak/Croquet stuff
+ [ ] Squeak as X server/client, like WindowMaker or E or twm. i.e. an X desktop and not just an application
+ [ ] Squeak Image File System for linux. i.e mkfs.squeak

Read Full Post »

Architecture, not OS

Bert brings up an important point that I will endeavor to follow in the future.

It would be more accurate to classify VMs by the image types they support, and architecture they run on (leaving out the issue of OS). E.g. it is inaccurate to say “Cog supports 32 bit images on a 32 bit machine” because it does not support pre-closure interpreter images even though they are 32 bits, and it only works on the x86 architecture, soon ARM 32 bits, but not e.g. PowerPC or MIPS 32 bits, which are supported by the interpreter VMs.

– Bert –

Bert’s point effects previous posts where I write like the entire world runs Linux on AMD.

Read Full Post »

Building SqueakSSL compiles just fine, but fails at the libtool stage when compiled as an internal plugin.

My hunch is that when compiled as an external plugin, the linking is deferred until the module is loaded by the VM. If that is the case, then it explains the primitive fail.

My approach was to compile it as an internal plugin as (by just giving it a try) I found what I thought was an #include error. It took me a while (too long really–I have a bad habit of not closely reading things) find the problem, but it happens after a successful compilation when a thing called “libtool” is run.

Here is the output of the error at that stage:

/bin/sh
[......]/debugCogSqueakSSL/unixbuild/bld/libtool --mode=link gcc -m32 -g -Og -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG -DITIMER_HEARTBEAT=1 -DCOGMTVM=0 -DDEBUGVM=0 -DLSB_FIRST=1 -Wl,-z,now -export-dynamic -o squeak vm/vm.a AsynchFilePlugin/AsynchFilePlugin.a B2DPlugin/B2DPlugin.a BitBltPlugin/BitBltPlugin.a FilePlugin/FilePlugin.a SocketPlugin/SocketPlugin.a SqueakSSL/SqueakSSL.a MiscPrimitivePlugin/MiscPrimitivePlugin.a disabledPlugins.o version.o -lutil -ldl -lpthread -lm -lnsl -lpthread vm/vm.a

gcc -m32 -g -Og -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DNDEBUG -DITIMER_HEARTBEAT=1 -DCOGMTVM=0 -DDEBUGVM=0 -DLSB_FIRST=1 -Wl,-z -Wl,now -o squeak disabledPlugins.o version.o -Wl,--export-dynamic vm/vm.a AsynchFilePlugin/AsynchFilePlugin.a B2DPlugin/B2DPlugin.a BitBltPlugin/BitBltPlugin.a FilePlugin/FilePlugin.a SocketPlugin/SocketPlugin.a SqueakSSL/SqueakSSL.a MiscPrimitivePlugin/MiscPrimitivePlugin.a -lutil -ldl -lpthread -lm -lnsl -lpthread vm/vm.a

SqueakSSL/SqueakSSL.a(sqUnixOpenSSL.o): In function `sqCopyBioSSL':
[......]/debugCogSqueakSSL/platforms/unix/plugins/SqueakSSL/sqUnixOpenSSL.c:37: undefined reference to `BIO_ctrl_pending'

(more errors omitted for brevity. all of them are unresolved references to stuff in /usr/include/openssl/ssl.h . these errors do not happen at compile time, only linking stage )

Since discovering this, I have tried two things

1. compile on my pure 64 bit partition…this failed –we don’t have 64 bit Cog yet (: but hey…a guy can hope!

2. I installed openssl compat32 libs alongside the 64 bit versions…as shown below.
2.a I made some changes that I kinda-sorta-hoped would work in some strings in the script that had the substring “/lib64 ” but that did not work.

bash-4.2$ ls lib/*ssl*
lib/libssl.so.0 lib/libssl.so.0.9.8 lib/libssl.so.1 lib/libssl.so.1.0.0
bash-4.2$ ls lib64/*ssl*
lib64/libssl.so.0 lib64/libssl.so.0.9.8 lib64/libssl.so.1 lib64/libssl.so.1.0.0

I posted the above to the vm-dev mailing list and will see if anybody picks up on it. I will hit this again tomorrow!

Read Full Post »

I just completed this tutorial:

http://stephane.ducasse.free.fr/FreeBooks/CollectiveNBlueBook/greenberg.pdf

I have written my first plugin! Woot!

Okey-dokey…now on to fixing the SqueakSSL plugin.

Read Full Post »

VMClass

I stumbled upon VMClass a few days ago and spent several days mapping it out with Dia. While not encapsulating the whole of the Squeak Object Engine, it is the superclass of quite a bit: Interpreter, Plugins, StackPages, Primitives, ObjectMemory, CogClass and VMStructType. Each of these have significant hierarchies as well.

For the VM Neophyte, its worth looking at for getting a sense of the forest for the trees.

Read Full Post »

Eliot Miranda at Cog:Blog offers three examples of BlockContexts as a preliminary to introducing BlockClosures.

This post focuses on what happens in Eliot’s second example where
he presents an intermediate step towards solving the reentrancy problem by using copy to create a new BlockContext.

From Eliot’s post, his example reads:

OK, let’s deal with the reentrancy problem. Simply evaluating a copy of the block instead of the original produces a fresh activation record for each activation of the block. This is what Allen Wirfs-Brock’s team did in the Tektronix implementation on the 4404 back in the ’80′s. They modified the BlockContext>>value[:value:…] primitives to activate a copy of the receiver. Let’s try modifying the example with explicit copies:

| factorial |
factorial := [:n| n = 1 ifTrue: [1] ifFalse: [(factorial copy value: n – 1) * n]].
(1 to: 10) collect: factorial copy #(1 1 1 1 1 1 1 1 1 1)

which answers… #(1 1 1 1 1 1 1 1 1 1) ?!?!

Being a newbie to this, what happens above was not obvious to me. This “tutorial” shows my line of thinking.

I present this in 2 stages.
Stage 1 starts with tracing the output of a modified version of Eliot’s code. This trace is followed by a discussion of what I see in the trace.
A screenshot of Stage 1 is provided for cross-reference as well.

Stage 2 looks at the problem of the sender of the first MethodContext when the code is run. This point will be made clear to the reader by the end
of Stage 1.

Let’s start with stage 1.

I “newbie-fied” Eliot’s code like this:

| factorial fc |
“Transcript clear.”
factorial := [:n |
n = 1
ifTrue:[
Transcript show: ‘ n=’, (n asString),’ ‘, (thisContext class name), ‘(‘, (thisContext identityHash asString),’)’ .
Transcript show: ‘–sender–>’, (thisContext sender) class name, ‘(‘, (thisContext sender) identityHash asString,’)’.
Transcript show: ‘–home–>’, (thisContext home) class name, ‘(‘, (thisContext home) identityHash asString,’)’; cr.
Transcript show: ‘++++++++++++++++++++++++++++++++++++++++’;cr.
“thisContext explore. ”
1
]
ifFalse:[ Transcript show: ‘———————————————–‘;cr.
Transcript show: ‘ n=’, (n asString),’ ‘, (thisContext class name), ‘(‘, (thisContext identityHash asString),’)’ .
Transcript show: ‘–sender–>’, (thisContext sender) class name, ‘(‘, (thisContext sender) identityHash asString,’)’.
Transcript show: ‘–home–>’, (thisContext home) class name, ‘(‘, (thisContext home) identityHash asString,’)’; cr.
(factorial copy value: n-1) * n
]].
Transcript show: ‘*************************************************’;cr.
Transcript show:’ thisContext = ‘ , (thisContext class name),'(‘,thisContext identityHash asString,’)’.
Transcript show: ‘–sender–>’, (thisContext sender) class name, ‘(‘, (thisContext sender) identityHash asString,’)’.
Transcript show: ‘–home–>’, (thisContext home) class name, ‘(‘, (thisContext home) identityHash asString,’)’; cr.
Transcript show: ‘*************************************************’;cr;cr.

Transcript show:’ factorial = ‘ , (factorial class name),'(‘,factorial identityHash asString,’)’.
Transcript show: ‘–sender–>’, (factorial sender) class name, ‘(‘, (factorial sender) identityHash asString,’)’.
Transcript show: ‘–home–>’, (factorial home) class name, ‘(‘, (factorial home) identityHash asString,’)’; cr.
Transcript show: ‘^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^’;cr;cr.
fc := factorial copy .

Transcript show:’ fc = ‘ , (fc class name),'(‘,fc identityHash asString,’)’.
Transcript show: ‘–sender–>’, (fc sender) class name, ‘(‘, (fc sender) identityHash asString,’)’.
Transcript show: ‘–home–>’, (fc home) class name, ‘(‘, (fc home) identityHash asString,’)’; cr.
Transcript show: ‘^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^’;cr;cr.
thisContext inspect.
thisContext sender explore.
factorial inspect.
fc inspect.
(1 to: 3) collect: fc.

The output in the transcript after DoIt is:

*************************************************
thisContext = MethodContext(2154)–sender–>MethodContext(376)–home–>MethodContext(2154)
*************************************************

factorial = BlockContext(2468)–sender–>UndefinedObject(3840)–home–>MethodContext(2154)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

fc = BlockContext(3452)–sender–>UndefinedObject(3840)–home–>MethodContext(2154)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

n=1 BlockContext(3452)–sender–>MethodContext(337)–home–>MethodContext(2154)
++++++++++++++++++++++++++++++++++++++++
———————————————–
n=2 BlockContext(3452)–sender–>MethodContext(337)–home–>MethodContext(2154)
n=1 BlockContext(1676)–sender–>BlockContext(3452)–home–>MethodContext(2154)
++++++++++++++++++++++++++++++++++++++++
———————————————–
n=3 BlockContext(3452)–sender–>MethodContext(337)–home–>MethodContext(2154)
———————————————–
n=2 BlockContext(1496)–sender–>BlockContext(3452)–home–>MethodContext(2154)
n=1 BlockContext(752)–sender–>BlockContext(1496)–home–>MethodContext(2154)
++++++++++++++++++++++++++++++++++++++++

In my running commentary to myself as I studied the output above, I ran self identityHash on the various inspectors that opened
while running the above code. I then modified the title bar of each inspector and added this identityHash to the title bar. In the following screenshot you can see those inspectors and correlate them to the trace above.

BlockContextReentrantAttemptWithCopy

Here is my running commentary to myself for Stage 1:

1 We see our initial context at the line:
thisContext = MethodContext(2154)–sender–>MethodContext(376)–home–>MethodContext(2154)

MethodContext(2154)’s method is CompiledMethod(3991). This is the code that initially runs.

1. At bytecode 127 of CompiledMethod(3991) the “send: blockCopy” tells the Interpreter to create and activate the initial BlockContext(2468) and it becomes the active record.. Its home is the now the suspended MethodContext(2154). Per the BlueBook, the BlockContext(2154) shares much if its state with the active context that creates it. The receiver, arguments, temporary variables, CompiledMethod and sender are all the same.

You can see this in the line that begins with “factorial=” on the Transcript at the left.

2. sending copy to “factorial” creates BlockContext(3452).

3 at n = 1 The sender of BlockContext(3452) is MethodContext(337). MethodContext(337) was created by sending the message ‘collect’ to the Interval (1 to: 3). Remember, from the BlueBook, a A MethodContext … Represents the execution of a CompiledMethod in response to a message. Notice that this MethodContext(337). Note that it is the first sender at n=2 and n=3 as well.

4. Looking at n=3 will tell us everthing we need to know about n=2 so let’s move to the line that starts with
n=3.

5 At n=3 collect sends the value:3 to BlockContext(3452) activating MethodContext(337)
As the recursion call progresses to n=1, we can see chain of senders. The active BlockContext is at the far right of the following chain.

MethodContext(337) <<<–sender-BlockContext3452()<<<-sender-BlockContext(1496)<<>allocateOrRecycleContext:

7. That’s the chain of our code, but look again at the line near the top that reads:
thisContext = MethodContext(2154)–sender–>MethodContext(376)–home–>MethodContext(2154)

Where did its sender come from?

We are now at Stage2 and need to answer the question, where did that initial sender MethodContext(376) come from?

Here is screenshot and my running commentary notes from that investigation:

BlockContextReentrantAttemptWithCopyDoItTracingIncluded

7. That’s the chain of our code, but look again at the line that reads:
thisContext = MethodContext(2154)–sender–>MethodContext(376)–home–>MethodContext(2154)

Where did its sender MethodContext(376) come from?

To see this, I added tracer code in the following methods:

ParagraphEditor>>doIt
ParagraphEditory>>evaluateSelection
Compiler>>evaluate: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: logFlag

I have scrolled the Transcript to include the output from that tracing. Lets follow it.

1. When we DoIt on the example, The message doIt is sent to #ParagraphEditor. We see that tracing
at the lines
This Class->TextMorphEditor
thisContext = MethodContext(3259)–sender–>BlockContext(3126)–home–>MethodContext(3259)
I believe that (but do not know) that since the ParagraphEditor is embeded in a TextMorphEditor, that that is why the class shows as TextMorphEditor.

2. This invokes ParagraphEditor >>evaluateSelection

3 ParagraphEditor >>evaluateSelection does some error checking and marshalling and then invokes
Compiler >> evaluate: textOrStream in: aContext to: receiver notifying: aRequestor ifFail: failBlock logged: logFlag

4 The Compiler then compiles the workspace code into the CompiledMethod(3991) and “invokes it”. Where we see it as Compiler(376)>>evaluate:in:to:notifyi…etc…
It is this initial MethodContext(376) that the Compiler creates that serves as the sender to our MethodContext(2154)

5. At this point our code runs as described above.

And that’s it. I will be working Eliot’s third example next, before returning to his first example.

Read Full Post »

Older Posts »