Parrot virtual machine

From Academic Kids

Parrot is a register-based virtual machine being developed using the C programming language and intended to run dynamic languages efficiently. It uses just-in-time compilation for speed because interpreters tend to be quite slow. Currently you can compile Parrot assembly language and PIR (an intermediate language) to Parrot bytecode and execute it.

It was started by the Perl community, and is developed with help from the open source and free software communities. As a result, it is focused on license compatibility (Artistic License and GNU GPL), platform compatibility (Unix, Microsoft Windows, Mac OS X and Classic, VMS, Crays, Windows CE, Palm OS, and others), processor architectures compatibility (x86, SPARC, Alpha, IA-64, ARM, Palms, old Macs), speed of execution, small size (around 700k depending on platform), and flexible enough to handle the varying demands of Perl, Python, Tcl, Ruby, Scheme, and other "dynamic" languages. It is also focusing on improving introspection, debugger capabilities, and compile-time semantic modulation.

Contents

Static and dynamic languages

The differing properties of statically and dynamically typed languages have motivated the design of Parrot. Current popular virtual machines such as the Java virtual machine and the Common Language Runtime have been designed for statically typed languages, while the languages targeted by Parrot are dynamically typed.

Virtual machines like the Java virtual machine and the current Perl 5 virtual machine are also stack based. The developers see it as an advantage of the Parrot machine that it has registers, and therefore more closely resembles an actual hardware design, allowing the vast literature on compiler optimization to be used generating code for the Parrot virtual machine so that it will run bytecode at speeds closer to compiled languages like C.

Besides a subset of the planned Perl 6, an increasing number of languages can be compiled to Parrot assembly language including BASIC, Befunge, Brainfuck, Cola, Forth, Jako, Lisp, m4, Miniperl, Ook, Parakeet, OpenComal, PHP, Plot, Python, Ruby, Scheme, Span, Tcl, URM, and YAL. Most of these other language implementations are currently still incomplete and experimental.

There is strong interest in parts of the Ruby community. The Python community is taking more of a wait-and-see attitude (for now), perhaps because they already have Psyco, a just-in-time Python-to-machine-code compiler, Jython, a Python-to-Java-bytecode compiler, and IronPython to compile to the .NET platform.

License

Parrot is a free software project, distributed under the same terms as Perl; that is, dual-licensed under both the GNU General Public License and the Artistic License.

History

The project started to implement Perl 6 and originally had the very dull name "The software we're writing to run Perl 6". The name Parrot came from an April Fool's joke in which a hypothetical language named Parrot was announced that would unify Python and Perl [1] (http://www.oreilly.com/news/parrotstory_0401.html). Later, the name was adopted by this project whose intent is to do just that. Several tiny languages are being developed along with it which target the parrot virtual machine.

The Parrot source code was first released to the world on September 10, 2001. Parrot 0.1.0 "Leaping Kakapo" was released on February 20, 2004. Parrot 0.1.1 "Poicephalus" was released on October 9, 2004. Parrot 0.1.2 "Phoenix" was released on 6 March, 2005. Parrot 0.2.0 "NLNet" was released on May 8, 2005.

Internals

Parrot code has three forms. Bytecode is natively interpreted by Parrot. Parrot Assembly Language (PASM) is the low level language that compiles down to bytecode. Parrot Intermediate Representation (PIR) is a slightly higher level language than PASM and the primary target of language implementations. PIR transparently manages Parrot's inter-routine calling conventions, provides improved syntax, register allocation, register spilling, and more.

IMCC is the Intermediate Code Compiler for Parrot and compiles PIR. It is also known as IMC and is usually stored in files with the suffix ".imc".

Examples

Registers

Unlike most virtual machines (which are stack-based), Parrot is register-based, just like most hardware CPUs. It provides four types of registers, typically with 32 registers of each type:

  • I0-I31: native integer type
  • N0-N31: floating point numbers
  • S0-S31: advanced string registers with Unicode support
  • P0-P31: PMC, or Parrot Magic Cookie — Parrot object type

It is possible to enable 64 registers, for enhanced speed in certain scenarios.

Arithmetic operations

   set I1, 10
   inc I1        # I1 is now 11
   add I1, 2     # I1 is now 13
   set N1, 42.0
   dec N1        # N1 is now 41.0
   sub N1, 2.0   # N1 is now 39.0
   print I1
   print ", "
   print N1
   print "\n"
   end


Culture

Tagline

The current tagline of the Parrot project is "one bytecode to rule them all," a reference to Tolkien's One Ring from The Hobbit and The Lord of the Rings.

See also

External links

Articles at parrotcode.org
Articles at sidhe.org

de:Parrot fr:Parrot pl:Parrot pt:Parrot

Navigation

Academic Kids Menu

  • Art and Cultures
    • Art (http://www.academickids.com/encyclopedia/index.php/Art)
    • Architecture (http://www.academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (http://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (http://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools