Parrot Virtual Machine/Packfiles
Packfiles[edit | edit source]
Parrot bytecode files are called "packfiles" internally. Access routines to get information from and feed information to a packfile are stored in
Some things that can affect the way a file is stored are:
- Endianness. Some computers are called "little endian" and some computers are called "big endian". This has to do with the way that bits are ordered in a byte. Instead of picking one or the other to be the default.
- Value sizes. Things like pointers and INTVALs are going to be different sizes on different computers. Parrot must translate between 16 bit, 32 bit, and 64 bit values for these and other things. Also, FLOATVALS may be 32bit, 64bit, or 128bit, and need to be translated.
Serialization[edit | edit source]
HLL code is most often used on the computer where it is first compiled. To that end, Parrot is optimized to write packfiles using local settings. If a packfile is read which has been created on some other computer, Parrot must translate it internally so that it can be run on your computer. This translation process adds extra execution overhead, but it only needs to be run once on your computer to get things into the proper local format.
Freeze and Thaw[edit | edit source]
Serialization occurs through two interfaces: Freeze and thaw. Freezing is the process of converting a PMC or other type of data into a format ready for insertion into a packfile. Thawing is the process of reading data out of a packfile and recreate the PMC or other data object. PMCs have optional Freeze and Thaw vtable methods, although good defaults are available if the PMC does not use any additional storage. If you use additional storage, especially storage which has been allocated from the system using malloc, you must supply custom Freeze/Thaw methods to store and retrieve that.