Hi guys!
In the past few days i tried to get InterpreterSimulator running without success. First of all, a little context about my goal: I'm digging into the VM because i would like to be able to delegate to some class (that I'll develop) the responsibility for, say, the method lookup algorithm. With that in mind, here's what i've been doing: Using the Pharo 1.2 image Mariano Peck's prepared in his exellent article (http://marianopeck.wordpress.com/2011/04/23/how-to-debug-the-vm/), loaded the VMMaker package with the following script: Deprecation raiseWarning: false. Gofer new squeaksource: 'MetacelloRepository'; package: 'ConfigurationOfCog'; load. (Smalltalk at: #ConfigurationOfCog) project latestVersion load. Once it finishes (without errors) I "Save As" the current image as "demo.image", close it and open the original Pharo 1.2 image that Mariano provided. When, for example, I run: (CogVMSimulator new openOn: 'demo.image') test or (InterpreterSimulatorLSB new openOn: 'demo.image') test I get the following error: "Error: basicNew: failed" (see attached images at the end). When I tried to load VMMaker in the Pharo 1.3 OneClick release, I got another error (see attached images at the end). Am I doing something wrong? Are those the right simulators to use? I can tell the difference between all that are available in VMMaker package. Thanks in advance! Nick |
On Fri, Sep 23, 2011 at 6:40 AM, Nick. <[hidden email]> wrote: Hi guys! Weird. Something I remember about the simulator is that you need to run it with a VM that has the BochsIA32Plugin. Try Eliot's VM that will have it for sure. But anywya, I doesn't look related to your particula problem. When I tried to load VMMaker in the Pharo 1.3 OneClick release, I got Yes, because you need some changes in order to make it work. I have attached those changes in the post. But those changes should be already integrated in latests Pharo 1.3. You don't have that error in the image I put of 1.2 because that image comes already with such changes. Am I doing something wrong? Well...it depends on what you want. FOr example, if you build a stack VM then you should use instead StackInterpreterSimulator. So..for the Cog VM I guess it is CogVMSimulator. If you go to here: http://www.squeakvm.org/svn/squeak/branches/Cog/image/ you can see http://www.squeakvm.org/svn/squeak/branches/Cog/image/VM%20Simulation%20Workspace.text It might be outdated, but it can be a start point. cheers Thanks in advance! -- Mariano http://marianopeck.wordpress.com _______________________________________________ VM-beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners |
Hi Mariano!
Thanks for the directions you gave me. I',m definitely giving them a try and let you know. About my approach to reifying the method lookup algorithm: do you think that simulating a VM will work as a development strategy, or i will need to compile the whole VM? My idea was to modify the Interpreter class and just simulate the modified VM to do some tests. What do you think? Cheers! (from Argentina :)) |
On Fri, Sep 23, 2011 at 5:53 PM, Nick. <[hidden email]> wrote: Hi Mariano! :) About my approach to reifying the method lookup algorithm: do you think that From my own experience, it was always easier to compile the VM than using the simulator. But maybe you have luck with the simulator.
Yes, it make sense. You can start with the simulator and once it seems to work you move to the real VM. But don't get stuck. If you cannot make it work (the simulator) try directly with the real VM.
-- Mariano http://marianopeck.wordpress.com _______________________________________________ VM-beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners |
Hi Guys,
Im attaching the PharoDebug.log (PharoDebug.log.tar.gz) that was generated when the error came up. Those are the steps I used to reproduce the problem. The environment used is Ubuntu 11.04: - From Jetkins, I downloaded the sources and vm for the "StackVM-Unix" job: https://ci.lille.inria.fr/pharo/view/Cog/job/StackVM-Unix/6/ - Unzipped the files and loaded [sources dir]/build/generator.image with StackVM. - Finally, evaluated (StackInterpreterSimulator new openOn: Smalltalk imageName) test Also, I tried evaluating the same but running the image from a compiled stack vm (from StackUnixDebugConfig). In this case, the error that came up was different: a MNU on ByteStrinng >> asDisplayText. The log, named CompiledVM-PharoDebug.log is also attached: CompiledVM-PharoDebug-.log.tar.gz I'd appreciate any directions on how resolve this one :) Cheers! |
Hi Nick. Unfortunatly, few people use the interpreter. Even less (if none) do it in Pharo. The only ones I know that use the simulator right now is Eliot in Squeak and Graig in Spoon.
So...as you can see, the simulator is implemented in image side. Since Eliot uses Squeak for his development, is more likely the simulator will work easier in Squeak than Pharo. Of course that for the Pharo community it would be AWESOME to be able to run the simulator. So if you can help with that, excellent. As an example, in Pharo you have the error. But in Squeak you have: String asDisplayText "Answer a DisplayText whose text string is the receiver." ^DisplayText text: self asText :) So... my suggestion? start with squeak. Once you make it work, please, update it in order to make it work in Pharo :) In your case, I would try with 3 squeak images: 4.2, 4.3 and the one eliot uses in: http://www.squeakvm.org/svn/squeak/branches/Cog/image/ (VMMaker-Squeak4.1.image) cheers On Mon, Oct 3, 2011 at 4:32 AM, Nick. <[hidden email]> wrote: Hi Guys, -- Mariano http://marianopeck.wordpress.com _______________________________________________ VM-beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners |
Hi Mariano,
Thanks for the advice. I want to update this post with the results of some tests I've been doing, so it's useful to anyone trying to run the simulator. I got stuck with an error I describe in the "About running StackInterpreterSimulator in Pharo" section. Hope someone could give me a clue on fixing that one :) Simulator in Squeak 2.6/2.7 is working First of all, if all you need is a simulator for learning/experimenting purposes grab a Squeak 2.6 or 2.7 release (yes, that old). The simulator works right out of the box in those ones. See http://wiki.squeak.org/squeak/2465 for instructions on how to archieve that. About running StackInterpreterSimulator in Pharo Taking Mariano's image as base (grab it here: https://gforge.inria.fr/frs/download.php/28513/Pharo-1.2.1.cog.zip) I found the following issues and fixed them: To begin, I saved a copy of the image to a new file named "simulated.image". Closed the image and reopened the first one. 1) First problem: "Error: basicNew: failed" Then, I evaluated the following from the original: (StackInterpreterSimulator new openOn: 'source.image') test. The error I've got is the one I described in my first post: "Error: basicNew: failled" for "ArrayClass>>new". Inspecting the stack trace I found that RootTableSize was an instance of UndefinedObject in ObjectMemory>>initialize. Taking a deeper look, it seemed that RootTableSize was setted in ObjectMemory>>initializeWithOptions, wich wasn't called from StackInterpreterSimulator>>initialize. Instead, ObjectMemory>>initialize was called, but that message didn't initialize RootTableSize. So, I replaced the call form objectMemoryClass initialize to objectMemoryClass initializeWithOptions: Dictionary new. to get RootTableSize initialized properly. 2) Second problem: same situation with MethodCacheSize Proceeding with StackInterpreterSimulator's execution, I came across a similar situation with MethodCacheSize in ArrayClass>>basicNew:. Following the same procedure as before, I found MethodCacheSize uninitialized, and setted it property replacing, in StackInterpreterSimulator>>initialize, the call from StackInterpreter initialize. to StackInterpreter initializeWithOptions: Dictionary new. 3) Third problem: missing method from UtilityClass Proceeding again, I came across an MNU saying that UtilityClass does not understands "informUser:during:" message. After a message selector search, I replaced the call (that was being done in StackInterpreterSimulator>>openOn:extraMemory:) with UIManager default informUser: (...) during: (...) 4) Fourth problem: "the receiver of / is nil" Originated from InterpreterStackPage>>headFP:. The cause was that LargeContextBytes was an instance of UndefinedObject. Once again, using the Method Finder (great tool!) I fixed the problem evaluating: InterpreterStackPage initialize. as said in that method's comment. 5) Fifth problem: Two MNUs in StackInterpreter Those came up: isContextNonInt:, generated from commonVariable:at:chacheIndex: and commonVaraible:at:put:cacheIndex:. I fixed those issues by replacing calls from self isContextNonInt: to self objectMemory isContextNonInt:. 6) Sixth problem: MNU in StackInterpreter The selector was isContextHeader: and it was used in StackInterpreter>>stObject:at:. I replaced calls from self isContextHeader: to self objectMemory isContextHeader:. 7) Seventh problem: primitive clone failed in CArrayAccesor. I fixes that by adding the clone message in CArrayAccessor as follows: clone <primitive: 148> ^ self primitiveFailed 8) Lastly, restarting the simulation again I found that the desktop from the simulation image was beign rendered (Pharo logo, some Workpaces that were saved, etc.) and then this error came up: "primitive failed: setGCBiasToGrowGCLimit:". The thing is that the VM that hosts the simulated one didn't open the debugger on that halt, it was like the simulated image was frozen (I suppose, because that error was in the call stack of snapshot:andQuit:embedded:). And here is when I wanted to ask you for some help guys, as I couldn't debug the host machine to invesitgate the cause and fix the problem. Do you have any clue/idea to detect the cause/fix this issue? FileOut of the changes described ChangesSoFarToMakeSimulatorWorkInPharo-1.2.1.zip Cheers and thanks in advance! Nick |
On Thu, Oct 13, 2011 at 5:26 AM, Nick. <[hidden email]> wrote: Hi Mariano, Wow Nick. Your experience is really really helpful. *Simulator in Squeak 2.6/2.7 is working* Can you put the exact code to initialize all this points of 1) 2) and 4) ? I mean, can you provide the final script you had to use before being able to do the (StackInterpreterSimulator new openOn: 'source.image') test. 5) Fifth problem: Two MNUs in StackInterpreter for 5) and 6) .. which version of VMMaker are you using? because maybe this was already fixed in new versions?
No, I have no idea :( but maybe someone does. *FileOut of the changes described* Excellent! At the end you can also provide an image (that mine) with those changes + a workspace with all the needed initialize code and the snippet to start the simulator. Cheers Cheers and thanks in advance! -- Mariano http://marianopeck.wordpress.com _______________________________________________ VM-beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners |
Hi Mariano!
Sure, here it goes: Deprecation raiseWarning: false. Gofer new squeaksource: 'MetacelloRepository'; package: 'ConfigurationOfCog'; load. ((Smalltalk at: #ConfigurationOfCog) project latestVersion) load. The version of ConfigurationOfCog loaded was 3.3. I'm using VMMaker-oscog-IgorStasenko.123. I've checked updating to the latest version, VMMaker-oscog-dtl.125, and those two seems to be fixed. Done! :) I've shared a file, http://dl.dropbox.com/u/45558068/Pharo-1.2.1.cog-ChangesSoFarToMakeSimulatorWork-images.7z, containing two images: - Pharo-1.2.1.cog.image: this is your original image, with all the changes I commented, and a workspace with all the needed code to initialize and run the simulator. - simulated.image: a snapshot Pharo-1.2.1.cog.image to be simulated Also, I managed to get the PharoDebug.log from simulated.image (I think) and not from Pharo-1.2.1.cog.image describing the "Error: setGCBiasToGrowGCLimit: failed" error. That file, named PharoDebug - setGCBiasToGrowGCLimit - failed.log, can also be found on the .7z file. Cheers! Nick |
In reply to this post by Mariano Martinez Peck
Hi Guys,
Just wanted to give you an update. I managed to fix this one: Here´s how I fixed it: The first thing I tried to do was to put a halt on the VM implementetion of #setGCBiasToGrowGCLimit: to see what's going on. That didn't work because the primitive wasn't called at all, it was failing for another reason. So, the next thing I did was to halt the interpreter when the selector matched #primitiveFailed. That allowed me to inspect the call stack, and finally determine that this bug was caused by StackInterpreterSimulator >> #loadNewPlugin:. How did I found that? First of all, I noticed that the primitive pragma in #setGCBiasToGrowGCLimit: didn't include the "module" parameter: <primitive: 'primitiveSetGCBiasToGrowGCLimit'> . For primitives implemented inside plugins class, the module is assumed to be the plugin's class name if it's missing (more on that at: http://marianopeck.wordpress.com/2011/07/06/named-primitives/). The thing is that this primitive is implemented in the interpreter itself, so this case wasn't taken into account in #loadNewPlugin: So, to fix this bug (after doing some research) I borrowed the implementation from CogVMSimulator >> #loadNewPlugin: and replaced the one in StackInterpreterSimulator with it: turned out to be the same, except for this little fragment of code (that did just what I needed!): pluginString isEmpty ifTrue: [plugin := self] After that, the simulator started the image correctly (even the Pharo logo was rendered!) , but now presenting me a new issue to be solve: mouse clicks doesn't do anything on the simulated machine. The funny thing is that, when I exit from it by pressing CMD+"." all those clicks are executed on the host VM. Somehow they're not passed to the simulated VM, and are "remembered" in the host VM. That's all (for the moment). Cheers, Nick |
Free forum by Nabble | Edit this page |