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