After waiting more than a week, and seeing no further<br>feedback, here&#39;s the 64-bit FAQ as it currently stands.<br>I&#39;d be grateful if someone (Ian?) could park it safely on<br><a href="http://squeakvm.org">squeakvm.org
</a>.<br><br>Thanks,<br>Andrew.<br><br>1. What is a 32-bit image?<br><br>2. What is a 64-bit image?<br><br>3. Can I run a 32-bit image on my 64-bit computer?<br><br>4. Can I run a 64-bit image on my 32-bit computer?<br><br>
5. Can a single VM run both 32-bit and 64-bit images?<br><br>6. What is a 64-bit VM?<br><br>7. Can I run a 32- or 64-bit VM on my computer?<br><br>8. For which hardware/OS combinations is there a 64-bit VM?<br><br>9. Does this VM run both 32-bit and 64-bit images?
<br><br>10. I have a 64-bit computer;&nbsp; should I use a 64-bit VM to run my 32-bit Squeak<br>images?<br><br>11. What are the advantages of using 64-bits?<br><br>12. What are the disadvantages of using 64-bits?<br>&nbsp; <br>13. My OS allows a single process to grow to 
3.75GB;&nbsp; if I need a lot of objects<br>can I use a 32-bit image / VM, or must I use a 64-bit one?<br>&nbsp; <br>14. Where can I find a 64-bit image?<br>&nbsp; <br>15. Why isn&#39;t there an officially-released 64-bit image?<br>&nbsp; <br>
16. How can I make a 64-bit image from a 32-bit image?<br>&nbsp; <br>17. How does a 32-bit VM manage to run a 64-bit image if pointers are only<br>32-bits wide?<br>&nbsp; <br>18. What sizes and alignment does the new 64-bit image format use for pointers
<br>and integers?<br><br>19. How do I tell if a given image file is 32-bit or 64-bit?<br><br><br>1/<br>What is a 32-bit image?<br>- A 32-bit image is an image in which the object memory uses a 32-bit word size<br>&nbsp; for object pointers,&nbsp; limiting its total size to a maximum amount of 4GB of
<br>&nbsp; memory.&nbsp; The formats of object memory and object pointers are defined in class<br>&nbsp; ObjectMemory (see the class comment for a basic explanation).&nbsp; As of this<br>&nbsp; writing,&nbsp; all Squeak images of practical interest are 32-bit images.
<br><br>2/<br>What is a 64-bit image?<br>- A 64-bit image is an image in which the object memory uses a 64-bit word size<br>&nbsp; for object pointers,&nbsp; allowing the size of the image to grow beyond 4GB of<br>&nbsp; memory.&nbsp; Squeak now supports a 64-bit image format that is sufficient to
<br>&nbsp; produce a working system, but which is intentionally simple.&nbsp; It is expected<br>&nbsp; to be modified and extended to take advantage of additional 64-bit<br>&nbsp; capabilities in the future.<br><br>3/<br>Can I run a 32-bit image on my 64-bit computer?
<br>- Yes.&nbsp; A 32-bit image can be run on either a 32-bit VM or a 64-bit VM. Some<br>&nbsp; computer platforms (e.g. 64-bit Linux) can run both the 32-bit VM and 64-bit<br>&nbsp; VM on the same system.<br><br>4/<br>Can I run a 64-bit image on my 32-bit computer?
<br>- Yes. If you build a VM with the &quot;64-bit VM?&quot; check box selected, you will<br>&nbsp; create a VM that runs 64-bit images.&nbsp; This will work on 32-bit host systems<br>&nbsp; as well as on 64-bit host systems.<br><br>5/<br>
Can a single VM run both 32-bit and 64-bit images?<br>- No.&nbsp; For any given computer platform,&nbsp; two different VMs are required to run<br>&nbsp; 32-bit and 64-bit images.&nbsp; The type of VM that you build is governed by the<br>&nbsp; &quot;64-bit VM?&quot; check box in VMMaker,&nbsp; and is independent of the word size of
<br>&nbsp; your computer.&nbsp; While it would be possible to create a VM that is<br>&nbsp; &quot;smart&quot; enough to run both 32-bit and 64-bit images,&nbsp; this is currently of<br>&nbsp; little practical value due to Squeak&#39;s reliance on plugins that are linked to
<br>&nbsp; 32-bit or 64 external library code.<br><br>&nbsp; Any combination of 32/64 bit VM and 32/64-bit image is possible, but note<br>&nbsp; that all currently available Squeak images are still in 32-bit format, and<br>&nbsp; most (perhaps all) pre-built VMs are 32-bit applications.
<br><br>6/<br>What is a 64-bit VM?<br>- A 64-bit VM is one which is compiled with the LP64 or ILP64 data model.&nbsp; This<br>&nbsp; means, in C terms, that pointers and longs are 64-bits wide.<br><br>7/<br>Can I run a 32- or 64-bit VM on my computer?
<br>- It depends.&nbsp; Some current architectures,&nbsp; such as the x86-64 and the<br>&nbsp; UltraSPARC,&nbsp; can run 32-bit as well as 64-bit applications;&nbsp; these are known<br>&nbsp; as &quot;bi-arch&quot; systems.&nbsp; However,&nbsp; some systems,&nbsp; such as the Alpha,&nbsp; can only
<br>&nbsp; run 64-bit applications.&nbsp; For bi-arch systems,&nbsp; you can choose whether to run<br>&nbsp; a 32-bit or 64-bit VM.&nbsp; For 64-bit-only systems,&nbsp; you don&#39;t have that choice;<br>&nbsp; you can only run a 64-bit VM,&nbsp; since there&#39;s no way of compiling a 32-bit
<br>&nbsp; application.<br><br>8/<br>For which hardware/OS combinations is there a 64-bit VM?<br>- Linux on 64-bit architectures: x86-64, SPARC64, Alpha, Power64, etc.<br>- Solaris on x86-64 and SPARC64<br>- MacOS on Power64<br>
- Windows on x86-64<br><br>9/<br>Does my 64-bit VM run both 32-bit and 64-bit images?<br>- No. Any VM will run either 32-bit or 64-bit images, but not both. You can<br>&nbsp; select one or the other when you generate sources with VMMaker, and you can
<br>&nbsp; install both flavors of VM on your system (one each for 32-bit images and<br>&nbsp; 64-bit images).<br><br>&nbsp; If try to run a 64-bit image with a VM built for 32-bit images, you will get<br>&nbsp; an error message such as this:
<br><br>&nbsp;&nbsp;&nbsp; This interpreter (vers. 6502) cannot read image file (vers. 68000).<br><br>&nbsp; If you try to run a 32-bit image using a VM built for 64-bit images, you will<br>&nbsp; get an error message such as this:<br><br>&nbsp;&nbsp;&nbsp; This interpreter (vers. 68000) cannot read image file (vers. 6502).
<br><br><br>10/<br>I have a 64-bit computer; should I use a 64-bit VM to run my 32-bit Squeak images?<br>- It depends.&nbsp; Either one will work,&nbsp; but if your image depends on plugins that<br>&nbsp; are only available for 32-bit systems,&nbsp; use the 32-bit VM.&nbsp; Otherwise,&nbsp; if
<br>&nbsp; you are building your own VM,&nbsp; go ahead and use the 64-bit version.<br><br>11/<br>What are the advantages of using 64-bits?<br>- The first advantage is that your image size can be enormous.&nbsp; If you need the<br>&nbsp; size of your VM code plus in-memory image to exceed 4 GB, then a 64-bit image
<br>&nbsp; running on a 64-bit VM is for you.&nbsp; Note that it will take ages to write out<br>&nbsp; an image that&#39;s this big to disk.&nbsp; The sort of applications that need this<br>&nbsp; are those which load a small(ish) image, and run code that creates millions
<br>&nbsp; of objects, but don&#39;t save them back to disk in the image.&nbsp; Keep in mind that<br>&nbsp; the garbage collector is probably not up to the task of collecting multiple<br>&nbsp; gigabytes.<br>- Another advantage is that certain architectures (
e.g. the Alpha) don&#39;t offer<br>&nbsp; a 32-bit mode; they are 64-bit only.&nbsp; For such machines, a 64-bit VM is<br>&nbsp; required;&nbsp; the image may be 32- or 64-bit.<br>- Another advantage is that when the 64-bit-VM is built, the C compiler knows
<br>&nbsp; the ABI is different from the 32-bit ABI.&nbsp; The x86-64 case is an interesting<br>&nbsp; example: the old i386 ABI offered few registers, used i387 floating-point,<br>&nbsp; and passed parameters on the stack (remember, memory writes are slower than
<br>&nbsp; register moves).&nbsp; The x86-64 ABI and architecture, on the other hand, has<br>&nbsp; many more registers, has SSE, SSE2, etc.&nbsp; for FP, and passes parameters in<br>&nbsp; registers where possible.&nbsp; It also has additional instructions (MMX et al).
<br>&nbsp; All of these CPU and ABI features may make for a VM that runs faster, but<br>&nbsp; only if (a) the compiler is able to make use of them and (b) is told to do so<br>&nbsp; at compile-time.&nbsp; However, the gains are unlikely to be much, and will also
<br>&nbsp; be offset by the cost of large pointers (see below).&nbsp; If you&#39;re looking for<br>&nbsp; performance, it&#39;s important to measure a 32-bit VM with a 32-bit image versus<br>&nbsp; a 64-bit VM with a 64-bit image before assuming anything.
<br><br>12/<br>What are the disadvantages to using 64-bits?<br>- A disadvantage to 64-bit code is that pointers are 8 bytes instead of 4;<br>&nbsp; they are also aligned on 8-byte boundaries, meaning that some space around<br>
&nbsp; them, known as `padding&#39;,&nbsp; is wasted.&nbsp; This means that (a) pointers take more<br>&nbsp; space in RAM,&nbsp; (b) take more memory bandwidth when the CPU loads and stores<br>&nbsp; them,&nbsp; (c) take up valuable space in on-chip caches,&nbsp; and (d) will have
<br>&nbsp; greater wastage due to padding compared to 32-bit pointers aligned on 4-byte<br>&nbsp; boundaries.&nbsp; For most users,&nbsp; the upper 32-bits of each pointer will always<br>&nbsp; be zero,&nbsp; so it makes little sense to load,&nbsp; process and store pointers that
<br>&nbsp; are double the size but only half-used.&nbsp; So for these users,&nbsp; a 32-bit VM and<br>&nbsp; image is a good choice.<br>- Another disadvantage is that most users use the 32-bit VM and a 32-bit image.<br>&nbsp; This combination is therefore the most tested,&nbsp; and therefore most stable,
<br>&nbsp; combination.<br>- A third disadvantage is that code for many of the plugins is not yet ported<br>&nbsp; to a 64-bit VM.<br><br>13/<br>My OS allows a single process to grow to 3.75GB;&nbsp; if I need a lot of objects<br>can I use a 32-bit image / VM, or must I use a 64-bit one?
<br>- There have in the past been problems related to the so-called &quot;2-GB limit&quot;.<br>&nbsp; This is due to conversion to and from signed 32-bit integers to 32-bit<br>&nbsp; pointers in the VM code.&nbsp; These problems appeared when the operating system
<br>&nbsp; loaded the image into memory at addresses above the 2GB mark, and could occur<br>&nbsp; with normal-sized images,&nbsp; not only images larger than 2GB.&nbsp; These issues<br>&nbsp; should be a thing of the past.&nbsp; Use the most recently-released VM for your
<br>&nbsp; platform, and report any problems that you see.&nbsp; You should only *need* a<br>&nbsp; 64-bit VM and 64-bit image if your image size will exceed 4GB.<br><br>14/<br>Where can I find a 64-bit image?<br>- These are scarce. The original 64-bit port project (from Ian and Dan)
<br>&nbsp; includes a 64-bit image that worked with the VM distributed at that time. A<br>&nbsp; current VM cannot execute the original 64-bit image due to changes in the<br>&nbsp; interpreter since that time.&nbsp; It is possible to update that original image
<br>&nbsp; using a modified VM, and the resulting image is executable using a current<br>&nbsp; unmodified VM.&nbsp; However, there are no official or supported releases of 64-bit<br>&nbsp; images at this time.<br><br>15/<br>Why isn&#39;t there an officially-released 64-bit image?
<br>- Lack of interest:&nbsp; most people don&#39;t need a 64-bit image.<br>- There may yet be some changes to the 64-bit image format to take advantage of<br>&nbsp; features of 64-bit CPUs.&nbsp; For instance,&nbsp; 63-bit tagged integers might be
<br>&nbsp; possible.<br><br>16/<br>How can I make a 64-bit image from a 32-bit image?<br>- Use the SystemTracer (SystemTracerV2 on SqueakMap).&nbsp; The original 64-bit<br>&nbsp; Squeak image was created using this tool,&nbsp; and a sufficiently motivated
<br>&nbsp; person should be able to reproduce the job.&nbsp; However,&nbsp; the SystemTracer does<br>&nbsp; not currently work on little-endian computers (including Intel),&nbsp; so some<br>&nbsp; work should be expected in order to enhance SystemTracer before a successful
<br>&nbsp; conversion will be possible.<br><br>17/<br>How does a 32-bit VM manage to run a 64-bit image if pointers are 32-bits?<br>- The short answer:&nbsp; It relies on the image size being smaller than 4GB.<br>- The long answer:&nbsp; Object pointers within the object memory are not pointers in
<br>&nbsp; the C sense of the word.&nbsp; The VM needs to be able to convert the object<br>&nbsp; pointers into C pointers,&nbsp; and this can be done on either a 32-bit host or a<br>&nbsp; 64 bit host.&nbsp; The only caveat would be that if a 64-bit image grew to a size
<br>&nbsp; large enough to use object pointers larger than the 32-bit limit (i.e. an<br>&nbsp; image approaching 4GB in size),&nbsp; then a 64-bit VM would be required.<br><br>18/<br>What sizes and alignment does the new 64-bit image format use for
<br>pointers and integers?<br>- Object pointers are 64-bits wide,&nbsp; allowing for memory up to 2^64 bytes to be<br>&nbsp; directly addressable.&nbsp; They are aligned on 8-byte boundaries.&nbsp; Integers are<br>&nbsp; still implemented as tagged 31-bit values, but are sign-extended to use the
<br>&nbsp; full 64-bit object word size and therefore are aligned on 8-byte boundaries.<br>&nbsp; Future enhancements to 64-bit Squeak will probably make use of the larger<br>&nbsp; word size to increase the range of SmallInteger values, which will require
<br>&nbsp; further changes to both the VM and the image in order to be effective.&nbsp; These<br>&nbsp; alignments were chosen as most 64-bit CPUs require them.<br><br>- The object header and pointer formats for both 32-bit and 64-bit images are
<br>&nbsp; documented in the class comment of ObjectMemory (in the VMMaker package).<br>&nbsp; The conversions to and from host data types are done in<br>&nbsp; platforms/Cross/vm/sqMemoryAccess.h using either macros or inline functions.
<br>&nbsp; The actual conversions vary from host to host,&nbsp; and are controlled by macros<br>&nbsp; such as SQ_HOST64 and SQ_IMAGE32 which must be set for that host.&nbsp; In the<br>&nbsp; case of a Unix VM,&nbsp; the configure utility is used to specify the
<br>&nbsp; characteristics of the host platform.<br><br>- The word size to be used in the object memory is specified by the<br>&nbsp; SQ_VI_BYTES_PER_WORD macro on src/vm/interp.h.&nbsp; This file is created in the<br>&nbsp; VMMaker code generation process,&nbsp; and the value of SQ_VI_BYTES_PER_WORD is
<br>&nbsp; determined by the &quot;64-bit VM?&quot; check box in the VMMaker tool.<br><br>- In summary,&nbsp; the object word format is described in class ObjectMemory,&nbsp; the<br>&nbsp; host data type conversions are specified in sqMemoryAccess.h
,&nbsp; and the image<br>&nbsp; word size is specified in interp.h.<br><br>19/<br>How do I tell if a given image file is 32-bit or 64-bit?<br>- The first four bytes in the image file are a &quot;magic&quot; value that indicates the
<br>&nbsp; image word size.&nbsp; This is specified in Interpreter&gt;&gt;imageFormatVersion.&nbsp; For<br>&nbsp; most images,&nbsp; this will be the first four bytes of the image file,&nbsp; although<br>&nbsp; in some cases the image data may be offset by 512 bytes in order to permit an
<br>&nbsp; image file to be treated as an executable program on Unix platforms (see<br>&nbsp; <a href="http://en.wikipedia.org/wiki/Shebang_(Unix)">http://en.wikipedia.org/wiki/Shebang_(Unix)</a>).<br><br>&nbsp; For instance, if I load 
VMMaker-3.8b6 into a stock Squeak3.9a-7024.image<br>&nbsp; file,&nbsp; I see this:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imageFormatVersion<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;Return a magic constant that changes when the image format<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; changes. Since the image reading code uses this to detect byte
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ordering, one must avoid version numbers that are invariant<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; under byte reversal.&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BytesPerWord == 4<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ifTrue: [^6502]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ifFalse: [^68000]
<br><br>&nbsp; Examining the file itself gives this:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; apg@breakfast: ~/squeak xxd Squeak3.9a-7024.image | head -1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0000000: 0000 1966 0000 0040 011c 7ee0 0427 b000&nbsp; ...f...@..~..&#39;..<br><br>&nbsp; Looking at the first four bytes gives this:
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; apg@breakfast: ~/squeak perl -e &#39;print 0x1966&#39;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6502<br><br>&nbsp; (or do &quot;16r1966 &lt;Alt-P&gt;&quot; in a workspace; it also returns 6502.)<br><br>&nbsp; So Squeak3.9a-7024.image is a 32-bit image file (since BytesPerWord == 4).
<br><br><br>