Slashdot Mirror


Virtual Machine Design and Implementation in C/C++

wackybrit writes: "The concept of the virtual machine is one of the most important concepts in computer science today. Emulators use virtual machines, operating systems use virtual machines (Microsoft's .NET), and programming languages use virtual machines (Perl, Java)". Read on for his review of Virtual Machine Design and Implementation in C/C++, an attempt to examine and explain virtual machines and the concepts which allow them to exist. Virtual Machine Design and Implementation in C/C++ author Bill Blunden pages 670 publisher Wordware Publishing rating 9 reviewer Peter Cooper ISBN 1-55622-903-8 summary An in-depth look at virtual machines, assemblers, debuggers, and system architecture in general.

Virtual machines are, in effect, a software model of a whole system architecture and processor. They take in bytecode (formed of opcodes, operands, and other data) and execute it, much in the same way a real system executes code. Running these operations in software, however, gives you more security, and total control over how the system works.

Virtual machines are popular for a number of reasons. The first is that they give programmers a third compiler option. You don't have to either go the dynamic interpreted route or the static compiled route, you can compile for a virtual machine instead. Another is that virtual machines aid portability. If you compile your code for a virtual machine, you can run that binary on any system to which the virtual machine has been ported.

Few books have been written on virtual machines, with only a few Java Virtual Machine titles available. Virtual Machine Design and Implementation by Bill Blunden is therefore a landmark book for anyone with an interest in virtual machines, or even system and processor architecture as a whole.

What's to Like?

Blunden makes sure to cover every topic related to virtual machines in extreme depth. The beauty of this is that you're not left in the dark, but that experts can simply skip sections. The book is well divided up, and off topic rants or notes are clearly marked with dividers. This is an easy book to read, even though it runs to some 650 pages.

To lead the reader through the entire production of a virtual machine, Blunden showcases the development of his own 'HEC' virtual machine (HEC being one of the fictional companies in 'CPU Wars'). Initially he starts slowly, and introduces the reader to how CPUs work, how memory works, how paging works, and how almost any other system process you can imagine works. Nothing is missed out. Multitasking, threads, processes, porting.. he covers it all. This is excellent for those new to some of these topics, and makes this an advanced book that's actually quite readable by someone with a modicum of computer science experience.

After laying down the foundations for the design of the virtual machine, the actual development starts in Chapter 3. All of the code in this book is in C or C++, and nearly all of the code is talks about is actually printed on the right pages in the book. No more flipping between code on your computer and the book, it's all just where it should be!

Further on in the book, a number of extremely advanced concepts are introduced, but even these need not be out of the reach of an intermediate programmer. Blunden presents the most vivid insight into how assemblers and debuggers are created, and the book is worth it for this information alone.

Another important thing about this book is that it looks at creating a register based virtual machine. Stack based virtual machines are covered, but the author makes a compelling argument for using registers. This makes a refreshing change from the Java Virtual Machine books that ram stack based theory down your throat. It's also useful if you're interested in the Perl 6 'Parrot' project, which is also an in-development register based virtual machine, and bound to become rather important over the next few years.

What's to Consider?

Virtual machines aren't for everyone. If you're a high level programmer working with database apps, this isn't really for you. This book is primarily for system engineers, low level programmers, and hobbyists with an interest in compilation, assembler, and virtual machine theory.

This is not a book for beginners. You need to have a reasonable knowledge of C to understand the plentiful examples and source code in the book. C++ is also useful, although OOP is clearly explained, so even a standard C programmer could follow it. That said, this is an excellent book for intermediate programmers or computer science students, as a number of advanced topics (garbage collection, memory management, assembler construction, paging, token parsing) are dealt with in a very easy to understand way.

The Summary

Released in March 2002, this book is extremely up to date. This is good news, as virtual machines are clearly going to take up a good part of future compiler and operating system technology, and this makes it important to learn about their construction and operation now. These technologies are already in the marketplace; Microsoft's .NET, and JVM, for example. Perl 6's 'Parrot' is also going to become a big player, with languages like Ruby, Python, and Scheme being able to run on it in the future.

Whether you want to learn about system architecture, assembler construction, or just have a reasonably fun programming-related read, this book is great.

Table of Contents
  1. History and Goals
  2. Basic Execution Environment
  3. Virtual Machine Implementation
  4. The HEC Debugger
  5. Assembler Implementation
  6. Virtual Machine Interrupts
  7. HEC Assembly Language
  8. Advanced Topics

You can purchase Virtual Machine Design and Implementation in C/C++ from bn.com. Slashdot welcomes readers' book reviews -- to submit yours, read the book review guidelines, then visit the submission page.

239 comments

  1. Wouldn't this lead us to... by dmarien · · Score: 1

    Mainstream operating systems which drop support for the virtual machines?

    --
    dmarien
    1. Re:Wouldn't this lead us to... by Anonymous Coward · · Score: 0

      This post was neither off-topic, nor anti-MS.

  2. Virtual Machine by JohnHegarty · · Score: 2, Interesting

    Can anyone give me a substantial difference between a virtual machine, and an emulator...

    because I can't see whats different between my mame and java virutal machine...

    1. Re:Virtual Machine by Anonymous Coward · · Score: 1, Informative

      a vm passes appropriate instructions directly to the CPU, while an emulator simulates each and every instruction.

      this is why (in Java, and VMWare) it's a VM, not an emulator.

    2. Re:Virtual Machine by Wolfier · · Score: 3, Informative

      An emulator is a virtual machine with a pre-existing non-virtual counterpart.

    3. Re:Virtual Machine by Anonymous Coward · · Score: 4, Interesting

      An emulator is a specific type of virtual machine. VMs don't necessarily reproduce a real machine, while emulators do. Also, many emulators reproduce the original machine down to the timing of instructions.

      For example, some of the nuclear power plants here in Canada are using or switching over to an emulator to run the plants because they are running out of spare parts for their 1972 control machines. Without the use of an emulator, they'd each have to rewrite shelves and shelves of assembler code.

      You can imagine that some of the code is timing critical, so the emulator must be exact down to the timing.

    4. Re:Virtual Machine by boltar · · Score: 0, Informative

      An emulator simulates an entire machine in that it displays the virtual screen in a window, does the I/O etc. A VM merely simulates a ficticious architecture just enough to be able to get a
      program running on the host system.

    5. Re:Virtual Machine by ranulf · · Score: 5, Informative
      Yeah, they're basically the same, but the distinction is fundamentally on the original intention.

      A virtual machine is designed specifically to be general and run in different environments, whereas an emulator is designed to emulate the environment of some existing hardware or software to trick software into beleiving that it genuinely is running on the original device.

      So, whereas a virtual machine will have a fairly abstract policy towards doing things (compare Java's AWT - I'd like to open a window, I'd like a button here, I'd like a menu there) and an emulator will get really bogged down emualting details, e.g. memory address $DFF180 changes the background colour.

      Both can be easily emulated by a state machine (hence why they come up in this book), however virtual machines can be made more efficient as they are intentionally abstract. e.g. in the JVM, you know what is code and what isn't, so you can translate blocks of code into native machine code and run that directly instead of interpreting every instruction. If you try that with an emulator, you'll come unstuck when you come across self-modifying code, or things that access memory mapped registers (e.g. on a 68000 the instruction mov d0,4(a0) offers no clue as to whether the write is to hardware or memory.

      Generally, you'll find that most virtual machine designs aim to reduce the instruction set down to a bare minimum. This allows a virtual machine (if it chooses) to effectively re-build the original parse tree and generate native code. However, emulators are generally trying to emulate CISC processors where as much is squashed into an instruction set as possible. Similarly, most virtual machines are heavily stack based, so as not to make any assumptions about register availability.

    6. Re:Virtual Machine by JCCyC · · Score: 2

      (...) virtual machines can be made more efficient as they are intentionally abstract. e.g. in the JVM, you know what is code and what isn't, so you can translate blocks of code into native machine code and run that directly instead of interpreting every instruction.

      Isn't that called JIT? Also, if I remember correctly, didn't the first version of Java come without this? (and were therefore unspeakably slow?)

    7. Re:Virtual Machine by Java+Pimp · · Score: 2, Informative
      Sort of...

      A Just in Time compiler will compile all the byte code to native code before it is executed and run it on the hardware. Performance hit at the start of each execution but ultimately faster than interpreting byte code. Note that the JIT is probably not the best optimizer so it still won't be as efficient as platform specific binaries. (among other reasons...)

      An optimized VM will recognize instructions or code sequences within the bytecode that can be directly mapped to native code and execute it directly on the hardware. Not as fast as JIT but faster than interpreting everything.

      Both are still slower than platform specific binaries but that's just the nature of the beast.

      --
      Ascalante: Your bride is over 3,000 years old.
      Kull: She told me she was 19!
    8. Re:Virtual Machine by p3d0 · · Score: 3
      A VM is basically nothing but a simulator for a machine that doesn't exist. This is qualitatively different from an emulator. While a simulator mostly pretends to do something, an emulator mostly just does it.

      For instance, if you were to make a Pentium emulator to run on a 486, then many of the instructions could be executed as-is by the hardware. Most register values could be stored in actual registers. And so on.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    9. Re:Virtual Machine by Zeinfeld · · Score: 2
      Can anyone give me a substantial difference between a virtual machine, and an emulator...

      Yes, an emulator simulates a piece of hardware that once existed, a Virtual Machine is an idealised machine.

      The difference is significant because many Virtual Machines have features that either cannot be supported in hardware or would be prohibitively expensive. This is the principle design difference between the original Java VM and the Microsoft .NET CLI. The original Java VM was designed so that it could be implemented as silicon gates, the .NET CLI could be implemented in Silicon if you really tried really hard and were a complete masochist but that was never a design goal.

      I don't know about the second Java VM, my interest in Java VM kinda died after it was clear Sun wanted no external inputs they did not control absolutely. I would guess that the redesign would be towards a more abstract representation that would allow for better JIT compilation.

      Strictly speaking .NET does not use a VM, it uses an intermediate compiler representation, however any turing complete representation could be called a VM. The distinction matters because you can compile .NET code down to the Java VM if you choose but going the other way would not be a great idea...

      --
      Looking for an Information Security student project suggestion?
      Try http://dotcrimeManifesto.com/
    10. Re:Virtual Machine by RevAaron · · Score: 2

      Not always. That is, there have existed virtual machines for which there was no pre-existing non-virtual counterpart. However, emulators emulate something that was designed to be non-virtual, regardless of whether anyone bothered to fab one. :)

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    11. Re:Virtual Machine by Hard_Code · · Score: 2

      The JIT has since been folded into (well, at least Sun's VM) the HotSpot VM architecture, which can identify and natively compile bottlenecks ("hot spots") at run time. This is the same idea that the Crusoe chip/software uses, as well as HP's venture into dynamic interpretation/compilation where they showed that running a program in interpreted mode actually turned out *faster* because they had the benefit of dynamically profiling and optimizing it at runtime (e.g. dynamically unrolling loops and frequently followed branch paths).

      --

      It's 10 PM. Do you know if you're un-American?
    12. Re:Virtual Machine by nusuth · · Score: 2
      If you try that with an emulator, you'll come unstuck when you come across self-modifying code, or things that access memory mapped registers (e.g. on a 68000 the instruction mov d0,4(a0) offers no clue as to whether the write is to hardware or memory.

      Perhaps you should check uae-jit patch (which has been ported to basillisk and integrated into win series of uae) before concluding jit based 68s emulation is not practical.

      --

      Gentlemen, you can't fight in here, this is the War Room!

    13. Re:Virtual Machine by Anonymous Coward · · Score: 0

      Others already made the distinction so I'll just nitpick. MAME is not an emulator (neither is wine btw) it is a meta-emulator. Each module MAME loads emulates a specific hardware piece and a collection of such modules emulates a complete hardware (such as original capcom hardware.) MAME knows what modules to load for a given ROM image and how to establish communication between modules, and between IO modules and your underlying OS.

    14. Re:Virtual Machine by Anonymous Coward · · Score: 0

      ...an emulator will get really bogged down emualting details, e.g. memory address $DFF180 changes the background colour.

      $DFF180? Ah, a (former?) Amiga user ;-)

    15. Re:Virtual Machine by tgrigsby · · Score: 1

      ...some of the nuclear power plants here in Canada are using or switching over to an emulator to run the plants because they are running out of spare parts for their 1972 control machines...

      Scratch my plans to move to Canada...

      --
      *** *** You're just jealous 'cause the voices talk to me... ***
    16. Re:Virtual Machine by Bytenik · · Score: 1

      I'd put Canada's nuclear safety record up against the United States' any day.

      --

      "Scientists prove we were never here."
      -- Devo

  3. thank you! by jeffy124 · · Score: 2, Interesting

    I must say I'm pleased to hear about this book. I actually would like to do something with VMs in my upcoming academic life (read: grad school), but am having trouble getting started, nor am sure if this is what i want to study. Every search engine out there returns everything Java for the phrase "virtual machine," which is not exactly what I'm looking for.

    --
    The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
    1. Re:thank you! by the_great_cornholio · · Score: 1

      Have you thought about asking one of your professors about a good resource, or are you no longer in school?

    2. Re:thank you! by jeffy124 · · Score: 1

      I'll be an undergraduate senior this fall, and yes, I've thought about asking. I dont know if I'm that serious about it yet, VMs are just one of the few topics running around in my head. If I stay at my current school (Drexel) for grad school, i dont think VMs would make a good topic, whereas parallel systems or reverse engineering would. Though VMs could come integrate themselves into RE. hmmm.....

      but anyways, thanks for the suggestion.

      --
      The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
    3. Re:thank you! by MAXOMENOS · · Score: 2
      Check out Intermediate Machines in the iServer or AS/400 context. It's the same type deal, and they've been in existance for almost 20 years now.

      Hope this helps.

  4. I want to run a virtual Machine by TheDick · · Score: 2, Funny

    Inside my virtual machine, where then I can run some sort of virtual reality program where I can interface with Eliza.

    --

  5. Alternate titles by eyepeepackets · · Score: 3, Funny

    Some alternate titles for this tome might be:

    1. Reversi: C64 Speed on a Pentium IV
    2. Double Your Code, Halve Your Speed
    3. Real Men Don't Use Real Computers
    4. VM:Very Macho or Verily laMe
    5. Atari ST Rebirth: a 20 Year Reversal

    etc., etc.

    Ack, I'm turning into a crank! Oy.

    --
    Everything in the Universe sucks: It's the law!
    1. Re:Alternate titles by Anonymous Coward · · Score: 1, Insightful

      You forgot:

      Maintainable code
      Faster time to market
      Minimum breakage during enhancements
      Ability to easily port to other platforms


      If you owned a software business would these things be important to you? I don't think performance would be the primary concern.

    2. Re:Alternate titles by IndependentVik · · Score: 1

      Why should he be marked as a troll? I don't necessarily agree with him, but I certainly thought his post was funny. Just b/c you have a VM fetish is no reason penalize the guy.

      --
      I'd suggest you don't use Slashdot as your only news source, or you will suffer permanent brain damage.
    3. Re:Alternate titles by Anonymous Coward · · Score: 0

      Look, I know that Sun and Microsoft's marketing departments have destroyed your brain, but PLEASE try to learn the difference between a langauge and an execution environment.

      a VM has nothing to do with "Maintainable Code" "Faster time to market" or "Minimum breakage during enhancements."

      BOCHS is a VM for x86. Does it instantly make my gcc compiled C++ app more maintainable?

  6. weee by TweeKinDaBahx · · Score: 0

    virtual machines are leet because you can test your virus code without actually damaging your own system. Unless you're clueless, in which case you'll probably infect yourself and the rest of the internet and get ass raped in prison.

  7. Why *virtual* machines? by Anonymous Coward · · Score: 3, Interesting

    One of the things that has surprised me about virtual machines ever since Java became a buzzword was that no one had ever thought to eliminate the relative performance penalty by implementing the VM as hardware on a PCI card (or a licensed chipset to put on the mobo. I can understand the portability implications of using VM's, and I'm glad that much work is being developed in this area.

    My question to anyone qualified to comment: Is there a reason why these virtual machines aren't taken as a blueprint for real hardware and implemented as such? I can imagine real performance benefits happening with such an idea...

    1. Re:Why *virtual* machines? by JohnnyCannuk · · Score: 3, Informative

      Zuccotto and a few other companies have done just that...the JVM is an actual hardware chip. There were at least 5 companies doing the same at Java One

      --
      Never by hatred has hatred been appeased, only by kindness - the Buddha
    2. Re:Why *virtual* machines? by Anonymous Coward · · Score: 0

      Hardware based VMs? Transmeta makes them (you know, Linus's employer).

    3. Re:Why *virtual* machines? by stackdump · · Score: 1

      Hardware virtual machine, doesnt that defeat the purpose. I mean wasn't the whole concept developed so that the sofware could be MACHINE INDEPENDANT.

      It seems to me that the only application of such a piece of hardware was when you want to use code written in a certain language exclusively , like that semi-new Sharp pda with a linux based Java VM.

    4. Re:Why *virtual* machines? by timeOday · · Score: 1
      Oh, certainly.

      X86 was originally just a vertual machine, but as slow as Bochs is, you can imagine that on a VAX. So eventually they broke down and came out with the 8088.

    5. Re:Why *virtual* machines? by kinga · · Score: 3, Insightful

      Sun license the picoJava core, which is the JVM on a chip, to a number of companies, including IBM and Fujitsu.

    6. Re:Why *virtual* machines? by Anonymous Coward · · Score: 0

      There are several very small start ups making Java Chips nowadays. Historically one of the big failures of virtual machine designed around a specific language includes the so called lisp machines that were supposed to be all the rage in the early 80s with the AI folks ("ok now we will be able to produce intelligent machines since the software will run so fast on hardware designed for it..."). It never took off. An UltraSPARC III is much more useful than a JavaChip by the way. With the SPARC you are not limited to one programming language.

    7. Re:Why *virtual* machines? by tshak · · Score: 2

      Running a few tests with C# proves that in some cases C# is faster then C++. This is, however, the exception and not the rule. If we use "unsafe" C# with "pointers" (not _quite_ the same as a pointer in C), even graphics processing is a reasonably good speed. This is a speculative statement, but I theorize that for most applications it would cost more for a specific "VM as hardware" PCI card then it would be to upgrade from a 1Ghz Athlon to a 1.2Ghz Athlon because in many cases C++ is only 15-20% faster on average. Search the newsgroups and MSDN for some early performance comparisons.

      One final point: I've found that some graphics applications, even with "unsafe code", perform a lot slower then it's C++ counterpart. This may be due to a general lack of experience with graphics programming (the technical barrier of entry is lower), and the relative immaturity of the CLR. Remember, the JVM is a lot faster then it was in the late 90's.

      --

      There is no longer anything that can be done with computers that is nontrivial and clearly legal. -- Paul Phillips
    8. Re:Why *virtual* machines? by RevAaron · · Score: 2

      Actually, it has been attempted. Sun created a java chip, called picoJava. There also is an ARM chip with a hardware interpreter for JVM bytecodes, Jazelle. There are plenty of other examples of this.

      Nothing that sits on the mobo to supplement a 'real' CPU tho.

      Is there a reason why these virtual machines aren't taken as a blueprint for real hardware and implemented as such?

      I'm no hardware guy. But I have a wee bit of experience hacking on the Smalltalk virtual machine. I imagine that this is so because VMs are designed as VMs, not as a blueprint for hardware. To support an entire computer, I wouldn't be surprised if you had to add a lot more instructions than most VMs provide.

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    9. Re:Why *virtual* machines? by RevAaron · · Score: 2

      There's no reason that it can't be both machine independent and have an accelorator chip. You can get SSL accelorators, yet, I can still run SSL on this machine, which hasn't one.

      It would be useful for certain applications for the computer to have a (or multiple!) hardware Java chips to speed up execution of Java code. Java servlets, for example. Sun is hyping Java on the server side awfully hard. But they can be slow, especially when you have thousands going at a time.

      You could have this *and* a cross-platform VM. They're not mutually exclusive. Schmucks in Windows can still run Limewire with a setup like this on some machines.

      The Zaurus doesn't use Java exclusively. From my playing with them, Java (like elsewhere) is still very much as second-class citizen in Qtopia. PocketLinux, which is now defunct (no doubt because Java sucks- sorry, couldn't help it) was a PDA operating environment that ran on top of Linux that used Java exclusively.

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    10. Re:Why *virtual* machines? by Doomdark · · Score: 2
      One of the things that has surprised me about virtual machines ever since Java became a buzzword was that no one had ever thought to eliminate the relative performance penalty by implementing the VM as hardware
      ...
      Is there a reason why these virtual machines aren't taken as a blueprint for real hardware and implemented as such?

      Ok here are some potential problems with the idea that I can think of:

      • [Specifically for Java:] VM is stack-based, and stack-based designs were tried couple of decades ago, and eventually were obsoleted by register-based CPUs. Memory-to-memory just isn't efficient way to do it, even with caches.
      • Do-it-on-software philosophy. "Native" CPUs are seen as CISC, in "too specific" sense, not necessarily size or complexity of instruction set itself.
      • [Java] General design of bytecode. Java bytecode probably wasn't really designed to be implemented in hardware (I think making it stack-based makes this obvious by itself but...), and as such there may be implementation problems regarding performance.
      • Too specific; market for these CPUs would be more limited than the market for generic CPUs. I'm not aware of a complete fully Java-based desk top system, so desk top systems would need to be hybrid ones, which leads to:
      • Complexity (and specificity) of h/w design, to support multiple non-symmetric CPUs. Which, in turn leads to:
      • Complexity of the OS that would make use of the add-on special CPU.

      However, there are niches where h/w implementation might well make sense; tiny mobile devices where performance is not so much the key but simplicity, and where ease of development is another strong selling point (for companies that develop s/w for such products). Being able to omit advanced JVMs is a plus, and performance may still be decent, if not stellar.

      --
      I like paying taxes. With them I buy civilization -- Oliver Wendell Holmes
    11. Re:Why *virtual* machines? by William+Tanksley · · Score: 2

      [Specifically for Java:] VM is stack-based, and stack-based designs were tried couple of decades ago, and eventually were obsoleted by register-based CPUs. Memory-to-memory just isn't efficient way to do it, even with caches.

      That's not true -- stack-based chips were dropped for other reasons. The modern stack-based chips are very fast indeed -- consider the X25, shBOOM, or P21.

      But I think you're confusing "stack based" with "memory to memory". Not all stacks are implemented in memory; an on-chip stack is very fast, and allows the CPU to operate at almost the full ALU clock, since there's no register access delay.

      Your other reasons are, of course, sufficient and correct.

      -Billy

    12. Re:Why *virtual* machines? by heh2k · · Score: 1
      But I think you're confusing "stack based" with "memory to memory". Not all stacks are implemented in memory; an on-chip stack is very fast, and allows the CPU to operate at almost the full ALU clock, since there's no register access delay.

      how is that? does it have multiple stacks? how can it execute more than one instruction at a time, if only the top element on the stack can be addressed?

    13. Re:Why *virtual* machines? by Anonymous Coward · · Score: 0

      I am a hardware guy who has spent quite a few years putting Self and Smalltalk virtual machines into silicon.

      Java and Smalltalk VMs are far too complex already, so the best results would be obtained by eliminating instructions instead of adding them. See the great work Chuck Moore has done in implementing the ColorForth VM in 27 instructions, for example. Some interesting Smalltalk efforts were SOAR and Mushroom which also went in the direction of reduced instructions.

    14. Re:Why *virtual* machines? by HiThere · · Score: 2

      There have been Forth chips, there have been Java chips. I think that there have even been Basic chips. CDC once thought about using APL as the assembler language on one of their fancy machines (the Star), but as I recall they decided against it. (It might have made sense if the machine had been more designed for array processing, but it was instead a pipelined vector computer.)

      There have been lots of virtual machines that turned real. And the converse, of course. Just consider VMWare for one example.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    15. Re:Why *virtual* machines? by William+Tanksley · · Score: 2

      how is that? does it have multiple stacks? how can it execute more than one instruction at a time, if only the top element on the stack can be addressed?

      Great question! There's a little bit of a false assumption in there; I believe you're assuming that only superscalar chips can be fast. Not true; superscalar has a LOT of advantages, but a lot of disadvantages as well. The worst disadvantage is complexity; the superscalar chips eat a LOT more energy.

      The fastest stack chips don't execute multiple instructions at the same time. (They do have multiple stacks, but that's a different issue.)

      The trick is that although they can't execute 5 instructions at the same time, they can and do execute 5 instructions in the time it takes other processors to execute one, for two reasons: first, their cycle length is that much shorter; second, their instruction encodings are that much shorter.

      The cycle length is shorter because the top two registers of the stack are gated directly to all the chip's functional units. As soon as the stack stabilizes from the last instruction, the functional units begin computing correct results for the next instruction. By the time the next instruction's decoded, all it has to do is MUX the correct result onto the stack, and possibly pop the stack.

      The encoding is shorter because there are no operands: instructions always apply to the top of the stack (well, except the LITERAL instruction). This means that (for the fastest chip) 4 instructions fit into one machine word -- so one can fairly consistently get 4 instructions per RAM cycle.

      The chip speed is so much faster than the 18-bit 4ns cache chip being used as RAM for this that the multiprocessor version of this chip, the X25, uses one of its processors to drive each of its logic pins, thereby making its logical interface essentially software-driven. 250MHz isn't impressive (that's the effective speed of the cache RAM, if my calculations are correct), but having enough spare MHz to implement the access protocol in software IS impressive. Doing all this at 500 mW @ 1.8 V (this assumes all 25 computers running at full bore, which isn't needed; at minimum draw, 100mAh battery life is 1 year, with 1 computer running throttled (I'm quoting from the specs, I haven't bothered to do the conversions needed to compare wattage directly).

      But I don't want to get caught in the trap of claiming stack chips are faster than superscalar chips. Not true -- but you have to use a LOT of power and a LOT of transistors to beat a stack chip.

      -Billy

    16. Re:Why *virtual* machines? by Anonymous Coward · · Score: 0

      "
      Hardware virtual machine, doesnt that defeat the purpose. I mean wasn't the whole concept developed so that the sofware could be MACHINE INDEPENDANT.
      "

      You're making a mistake. Virtual Machines are not and are not made to be machine independant. The operating enviroment they provide is made to be machine independant. There is a big difference. Go to java.sun.com for instance, to the jvm download page. The binary for solaris won't work under windows, the binary for windows won't work under solaris. However, a java app will work under the solaris jvm and the windows jvm.
      A virtual machine is not an abstraction in itself, it _provides_ a level of abstraction.

    17. Re:Why *virtual* machines? by jilles · · Score: 2

      Server performance has more to do with IO overhead than with execution speed. BTW. part of the coolness of java on the serverside is being able to use stuff like loadbalancing, caching, etc. in a more or less transparent way.

      Hardware acceleration makes sense on embedded platforms where there are not enough resources to properly do on the fly compilation and optization (basically a non issue on servers).

      As for your comments regarding pocketlinux, I suspect they were simply outcompeted by other pda oses who managed to produce a more usable os & apps. Users don't care about kernels, they do care about whether they can do stuff on a PDA: read mail, edit word documents, read pdf, manage agenda's, synchronize with popular pc applicatins, etc.

      --

      Jilles
    18. Re:Why *virtual* machines? by RevAaron · · Score: 2

      Is this Jecel? :)

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    19. Re:Why *virtual* machines? by RevAaron · · Score: 2

      If you wish, then toss out the server example. There are times when better Java performance is desired. Including small devices and on the desktop. It's for those applications, regardless of where, such a co-processor would be nice. There are a fair amount of companies who are investing a lot into creating Java desktop apps, and many of them have suboptimal performance on today's machines. Sure, CPUs will get faster.

      There are also a few people doing math-based research using Java. It would be amazing to be able to use RMI and a shared class pool to do distributed processing. Who needs entire computers to farm out computations to, when you have a 4 Java CPUs on a PCI card?

      No, this kind of technology isn't required. We're getting along, using Java, without it today. But it could be nice for some applications.

      PocketLinux wasn't so much out-competed as it was abandoned. They weren't poised to compete. Like a lot of open source companies, they expected the community to really take interest and start churning out apps for them. A lot of the Linux-nerd-world isn't into Java, they're still using C. That's all good, but you can't write (GUI) apps for PocketLinux in C. They're market, initially, wasn't end-users. It was the same group of people who read Slashdot and now own Zaurus and Agendas.

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    20. Re:Why *virtual* machines? by turnidge · · Score: 1

      Virtual machines which employ dynamic compilation of bytecodes to some host system have the potential to perform optimizations that are not possible in hardware. It is a simple matter to remove an unneeded null check during compilation or to unroll some loop that runtime profiling determines to be "hot".

      Also, virtual machines like the HotSpot java virtual machine from Sun can actually inline virtual methods -- and un-inline them later when the class hierarchy changes. In a programming model where short small methods are encouraged, this can bunch the meaty stuff together and open up some good opportunities for optimization. Try that in hardware -- you'd have to pay the virtual call overhead every time.

      And who wants to implement the more bulky runtime code in hardware -- garbage collection, etc. Some stuff is tricky, bug-prone, and belongs in software anyway. There's more to the virtual machine than the bytecodes. Much more. There's a whole context in which the bytecodes are executed that can be very rich.

      Oh, and another thing. Intel (and friends) have gazillions of minions working round the clock to make their hardware fast, but how many engineers would be working on your special little chip? Precious few. General purpose hardware is a fine thing.

    21. Re:Why *virtual* machines? by cpeterso · · Score: 2


      Does Sun own the exclusive rights to create native Java CPUs? I know other companies have paid Sun to license picoJava designs, but what if someone else made a Java-compatible CPU but just did not call it "Java(tm)"?

    22. Re:Why *virtual* machines? by Doomdark · · Score: 2
      The modern stack-based chips are very fast indeed -- consider the X25, shBOOM, or P21.

      Interesting. I probably should read something about those... I'm not a h/w specialist, but it's good to have basic knowledge and try to keep that up-to-date.

      And yes, I thought that caches generally were (always) implemented using main memory, so I did confuse the issues.

      By the way, where are the chips you mention usually used? For signal-processing? (I'm sure Google can answer that one)

      --
      I like paying taxes. With them I buy civilization -- Oliver Wendell Holmes
    23. Re:Why *virtual* machines? by William+Tanksley · · Score: 2

      P21 was used in a settop box for Internet access, RIP (too many settop boxes, too little demand). It's not exclusively for that, but I'm not aware of any other use.

      The shBOOM is now being marketed as a Java accelerator (it's called the PSC1000, by Patriot); another variant of it is rad-hardened and used in orbit.

      The 25x (sorry, I mispelled it originally), described at http://www.colorforth.com/25x.html, is a new development from the guy who designed both the above chips, and isn't funded.

      I found a list of similar chips at http://www.ultratechnology.com/chips.htm. Interesting stuff.

      -Billy

    24. Re:Why *virtual* machines? by ClosedSource · · Score: 1

      And yet I think that is exactly what Sun had intended all along. Sucker everyone into using Java for the "write-once-run-anywhere" dream, and then suddenly come up with hardware that had better performance. I wonder if there was a clause in Java licenses that prevented the licensee from developing Java hardware accelerators without Sun's permission. It's just speculation on my part but I wouldn't be surprised.

    25. Re:Why *virtual* machines? by be-fan · · Score: 2

      The problem is that C# is a fully-VM language, and neither is Java. Both (C# more so than most Java VMs) compile to native code as the program runs and caches the native code. After awhile, all the performance critical paths (ie. the ones that are called more than once) are running directly on the hardware. The speedup you see with C++ is not so much the performance hit of running on the VM, but the hit due to less mature optimizers in the C# compilers and the overhead of various saftey features in C$. These fancy-smancy new languages are nice, but I think the real reason they're so popular is the great class libraries supporting them. If C++ had nearly as nice and unified a set of class libraries, it would have a significant advantage over Java and C#. C++ is a far more powerful language. It doesn't force the programmer to a particular way of doing things. As I was learning Java, I kept coming across statements that to the effect of "feature X could be misused by the programmer, so we chose to leave it out." I'm not five years old, and don't like being treated like one.

      --
      A deep unwavering belief is a sure sign you're missing something...
    26. Re:Why *virtual* machines? by Anonymous Coward · · Score: 0

      >My question to anyone qualified to comment: Is >there a reason why these virtual machines aren't >taken as a blueprint for real hardware and >implemented as such? I can imagine real performance >benefits happening with such an idea...

      the problem with hardware is the rate at which it's outdated. your cool shiny new high performance java Vm chip will be high performance for a couple of months until software VM's running on faster hardware catch up. If you are in the java vm chip business, you probably aren't selling that many that you can compete with intel or amd on that ... thus your only compelling argument for implementing VMs in hardware, performance, doesn't work that well in practice.

    27. Re:Why *virtual* machines? by Anonymous Coward · · Score: 0

      Is this Jecel? :)

      Yes, but I have forgotten my slashdot password and don't have time to look it up today...

      I guess I am the only one doing Self hardware right now, but I hope more people will try it in the near future.

    28. Re:Why *virtual* machines? by RevAaron · · Score: 2

      Well, I'd still love to get a Self machine. :)

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
  8. Re:A replacement for C by smagoun · · Score: 2

    Dear sir, That was one of the most informative posts I have seen on Slashdot in a long time, perhaps since the days of TheGloriousMeept! It truly captures the spirit of discussion. Thank you again kind sir, me

  9. Re:OT: Perl Virtual Machine? by Anonymous Coward · · Score: 0

    C/C++ (for use in enterprise apps) is already being outdated because of Java. .NET (and it's oss clones) is really just a mocking of Java and the J2EE.

    also, perl is a VM. It compiles into bytecode, then executes the bytecode. Perl 6 is actually supposed to be able to compile Java .class files, allowing you to throw the .class files into a JVM like it were a Java program, and allowing easy interfacing with a Java program.

  10. How to use Google by Anonymous Coward · · Score: 1, Informative

    So you want more info on searching on virtual machines on Google, not using Java ?

    Search on : "virtual machine -java"

    It's simple & off topic.

    Cheers,
    T.

    1. Re:How to use Google by jeffy124 · · Score: 1

      yes, I'm aware of how to exclude certain tokens from a google search. Unfortunately, one mention of the word "java" in a document (like the review above, or the book's webpage), and the page is eliminated from the result set, leaving behind very little to work with.

      --
      The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
  11. The downside of virtual machines by PhysicsGenius · · Score: 1
    At the lab, we do simulations of nuclear bomb explosions, particle interactions, etc all the time. The "virtual events" are critical in making sure our equations are accurate and save a lot of resources and money vs actually exploding a bomb. However, keep in mind that the simulation is only as accurate as our knowledge of it. We don't actually gain new information from the simulation (new insight, yes, new information no).

    The same is true of virtual machines. Simulating how a computer might react to certain error codes and so forth is all right in small doses, but the only way to get real data is go out there and buy some actual hardware.

    Just my $.02.

    1. Re:The downside of virtual machines by proj_2501 · · Score: 2
      I think you may have missed the point a little. Virtual machines are not necessarily used to simulate hardware. (Although they can be used for that. The N64 dev kit was an SGI Onyx running an emulator, IIRC)



      Plus, digital circuits are a little less complicated and better understood than nuclear explosions and particle interactions.

    2. Re:The downside of virtual machines by Anonymous Coward · · Score: 0

      Please to be sir, where am I for to getting the nuclear bombs?

      Thank you verily,

      Mustafa Al Achmed Bing Goatfucker

    3. Re:The downside of virtual machines by Vagary · · Score: 1

      Dirty physicist, don't you know that Computer Scientists have no interest in this "reality" you speak of. VMs are better than the real thing, because then you don't have to worry about things like quality of service and storage space. If I wanted to know how a computer would react to certain inputs, I'd read the manual -- it's not some natural phenomenon that we need to gather empirical data on.

  12. Re:Operating Systems by queh · · Score: 2, Interesting

    Define operating system. Don't mix it up with boot loaders or kernels. Now explain how Microsoft's .NET isn't an operating system.

  13. Re:OT: Perl Virtual Machine? by Anonymous Coward · · Score: 0
    Slightly more on topic, the idea of a vm for C/C++ is great, but isn't this going to become outdated once (if) .NET and its open source counterparts catch on?

    Um, no. It is an implementation written in c/c++ (as opposed to Fortran for instance...) not a VM for c/c++.

  14. Re:Operating Systems by TweeKinDaBahx · · Score: 0

    Well, not yet at least.

    Lets remember, XP is kinda like ME in the sense that it's just an interface update. The actual OS behind XP is essentially just Win2k. 'Whistler' AKA .NET is still in the works.

    I'm actually interested in seeing what it's like, in all seriousness, I've heard M$ programmers refer to it as MS UNIX. I can only imagine what that means...

  15. Implementation of the Icon Programming Language by Anonymous Coward · · Score: 2, Informative


    The Implementation of the Icon Programming Language
    [cover]

    This book describes the implementation of Icon in detail. Highlights include:

    * Icon's virtual machine
    * the interpreter for the virtual machine
    * generators and goal-directed evaluation
    * data representation
    * string manipulation
    * structures
    * memory management

    http://www.cs.arizona.edu/icon/ibsale.htm

    Information on the Icon programming language itself can be found at

    http://www.cs.arizona.edu/icon

  16. umm by selderrr · · Score: 2

    All of the code in this book is in C or C++, and nearly all of the code is talks about is actually printed on the right pages in the book. No more flipping between code on your computer and the book, it's all just where it should be!


    Practically all coding books do this, and I mostly find it a cheap way to poop out thick books and massive volumes... Not a measure of quality in any way.

    1. Re:umm by TweeKinDaBahx · · Score: 0

      Unless you're trying to learn how to code, in which case a lot of well documented code in a book such as this one can make all the difference.

      Not like my CS text, which promptly introduced such concepts as templates before anyone in the class could even use a class in C++...

      Ah well, I like code in books, that way I can compare my code to someone elses without having to use another terminal (ALT+F* baby)

  17. Re:OT: Perl Virtual Machine? by TweeKinDaBahx · · Score: 0

    Isn't perl technically an interperted language like basic?

    I'm not trying to troll, but I guess I should have stayed awake in my CS class because i was under the impression the 'scripting' languages were not compiled.

    I guess that would be why it runs on a virtual machine, if I'm right (and I think i may be way outta whack).

    Someone throw me a bone here.

  18. Re:OT: Perl Virtual Machine? by Anonymous Coward · · Score: 0

    Perl 6 is supposed to be compiled to Parrot instead of machine code.

  19. .NET is a code interface for M$'s new runtime by Anonymous Coward · · Score: 0

    M$'s new runtime being CLR (Common Language Runtime, or something like that)

    .NET is NOT an Operating System.

  20. Take a Further look at this! by idfrsr · · Score: 4, Interesting

    I program in Java mostly right now, and so when people begin the usual 'vm is slow' crank I am curious about what they exactly mean.

    Programs written to run on vm's can be significantly slower due to the extra layer. Yet, if the design of the vm is done well enough (by perhaps reading this tome?) then the vm should be comparable. Certainly C is faster generally than an interpreted language. But there are native compilers out there than provide very comparable results, and the advantage of a language that forces careful programing. Here is the slashdot link

    If adding layers to programs automatically makes them slower, and so slow that they are useless, we all would code in assembly.

    Good design is important. A badly written C program of which there are thousands, will be just as slow (read bad) as a badly written vm program.

    --
    "The large print giveth, and the small print taketh away" -Tom Waits
    1. Re:Take a Further look at this! by shadow303 · · Score: 1

      Although bad C can be as bad as bad vm programs, good C is better than good vm programs. Sure native compilation helps, but that is moving away from a true vm. As far as languages that force careful programming, that isn't relevant to since there is nothing stopping you from making a such a language that gets compiled to native code.
      That said, I think that vm's are becoming more and more viable now that computers are becoming so blazing fast. It is getting so the overhead doesn't matter so much for things like office apps or simpler games (of course the games will likely always lag behind the cutting edge of the time). There was a time when many things were written in assembler since it was faster than C, but as machines grew more powerful, and compilers improved, the added speed just wasn't worth the effort any more.

      --
      I've got a mind like a steel trap - it's got an animal's foot stuck in it.
    2. Re:Take a Further look at this! by RevAaron · · Score: 2

      It's also a little easy to write shitty C programs than it is to write shitty Java programs. It's quite easy to make massive memory leaks in C from not knowing how to handle pointers and such.

      What it comes down to is how I want to use my time. For my use, Smalltalk and Lisp are fast enough. They are compiled languages, compiled to bytecode which is then JITed. I can get a lot more done with their benefits and only loose a little speed, speed that isn't missed for the kind of stuff I work on.

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    3. Re:Take a Further look at this! by scrytch · · Score: 2

      Actually, C with all its aliasing problems (read: ponters), defeats all sorts of static analysis and other optimizations that could otherwise be done. e.g. you could do copy-on-write at the struct level, or you could rearrange memory for better locality. You just plain can't do that in C, because it enforces a very rigid ABI -- which may be dandy for some programs, like OS's, but makes you otherwise do all that nifty stuff by hand. No one does, ergo the C program is slower. And even then, one technique that optimizes well on one machine is likely to fail miserably on another.

      It's not so much the language as it is the runtime. CPU's don't really like to be micromanaged anymore, except by experts (again, like OS's). With a properly tuned runtime (like a good VM -- not saying Java is one), every program gains its benefit. C pretty much completely lacks a runtime layer completely, and the mismatch is starting to show.

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    4. Re:Take a Further look at this! by Anonymous Coward · · Score: 0

      Current JIT VM's are good, and indeed can be comparable to C. What most people miss in their Java vs. C speed comparisons is that the real-life speed difference is not because of the use of VM per se, but because of the higher level nature of the Java language, garbage collection, and heavy use of complex multi-level OO libraries. And the worst of all, a higher level language makes it a lot easier for a not-so-hot programmer to make stupid inefficient code, as compared to using a lower level language like C where the culture of micro-optimization is all over the language community.

    5. Re:Take a Further look at this! by pong · · Score: 2

      Some compilers have introduced certain #pragmas to compensate for the aliasing problem. The SGI MipsPro 7.3 compiler, for instance. The programmer can simply declare whether a pointer is aliased. Of course, if you lie, the compiler will generate incorrect code.

    6. Re:Take a Further look at this! by randombit · · Score: 1

      Actually, C with all its aliasing problems (read: ponters), defeats all sorts of static analysis and other optimizations that could otherwise be done.

      Using the restrict keyword, or various compiler options, can often help this, by assuring the compiler that certain methods of aliasing are not used. Compilers still don't support it very well (GCC ignores it most of the time right now), but it can be useful.

      C pretty much completely lacks a runtime layer completely, and the mismatch is starting to show.

      I don't disagree with you here (completely, anyway). There are times when you really don't want a big runtime, however (embedded systems, OS, etc). And of course there is the problem of: what if the runtime isn't there, or it's the wrong version? I've had some 'interesting' problems with that (which is why one machine I admin has not 1, not 2, but 3 Java VMs installed).

    7. Re:Take a Further look at this! by Anonymous Coward · · Score: 0
      If adding layers to programs automatically makes them slower, and so slow that they are useless, we all would code in assembly.

      Which is usually an option even when using high level natively compiled languages. I have written quite a bit of asm for the very tight loops - and still kept the OO-goodness in the rest of the code.

      That option is just not available with VM languages. This is where they lose, IMO.

    8. Re:Take a Further look at this! by horza · · Score: 2

      If adding layers to programs automatically makes them slower, and so slow that they are useless, we all would code in assembly.

      Useless depends on the performance needed by the implementation. For example a sort routine in C may be fine for a database application, but in sorting visible polygons in an arcade game it may be too slow in which case there may be no choice except to implement that particular routine in assembly and interface it to the C program.

      Java may use a VM and be slower than C but it has taken hold in server-side programming where the network connection is the bottleneck rather than the application. Even if the server becomes heavily loaded it's cheaper to throw more hardware at it than rewrite it in something faster.

      It's all about how far you can get away with moving up the speed vs maintainability curve. It's for this reason we don't see any arcade games coming out written in Java, and why web designers will knock up a web site in PHP rather than write optimised C CGI/ISAPI/etc.

      Phillip.

    9. Re:Take a Further look at this! by ralphbecket · · Score: 1
      Some fundamental performance problems for Java are caused by the language design and have nothing to do with going via an intermediate VM language (jitted or not.)
      1. Java's weak type system does not support parametric polymorphism (or "generics" to everybody in OO-land) hence your code has to be sprinkled with downcasts from `object' (e.g. when looking up a value in a general purpose hash table); these are not cheap and their ubiquity costs big-time.
      2. There is no sensible, safe, efficient way to implement algebraic data types.
      3. It is almost impossible to have structured values with a small memory footprint.
      4. The lack of support for closures is a pain; inner classes are something of a poor-man's solution to the problem.

      - Ralph
    10. Re:Take a Further look at this! by pyrrho · · Score: 2

      relative speed will always matter...

      the person that doesn't think so will be running their office apps on their 100 Ghz machine and say, "look, fast enough", the person that does think so will be running a complete simulation of a galaxy at 1,000,000 yrs/s.

      "Fast enough" is subjective opinion, a feeling, an intuition, biased by expectation. All that matters is relative speed and relative efficiency and the stability of the code in the end, and of course the ease of development. C and C++ increase flexibility without reducing ability. This means you are still able to seg fault, but it also means you are free to anything-else too. And I like Java, but the VM will always be compiled, remember that! (well, always... until it's put on a chip and made into a ubiquitous coprocessor )

      --

      -pyrrho

  21. Re:Operating Systems by Anonymous Coward · · Score: 0

    Yessir it is. .NET is a blanket term for everything MS is coming out with these days, including the upcoming successor to Win2k, the .NET Server range.

  22. Why are current VMs preoccupied with GC? by Anonymous Coward · · Score: 1, Interesting

    It seems that everyone assumes that VMs these days (JVM, CLR, Mono, Parrot) must include garbage collection and not use pointer-based ops. Why is that? Knuth's MMIX VM is modelled after a traditional RISC CPU which modern compilers like GCC can target. C, C++, FORTH, Objective C can be targetted toward it out of the box.
    I think that VMs these days are getting bloated with everything including the kitchen sink. This makes them harder to port and test. Performance suffers. What ever happened to keep it simple stupid?

    1. Re:Why are current VMs preoccupied with GC? by Tune · · Score: 1

      Good point. ' Guess that answers the question about the subtle difference between an emulator and a VM. VMs tend to include more high level concepts than emulators.

      Still, as much as (software) emulators emulate existing hardware there have also been several attempts to create "virtual" machines in hardware. (For example: P-code interpreters (low-level Pascal) and Sun's attempts to hard wire a Java VM.)

    2. Re:Why are current VMs preoccupied with GC? by Anonymous Coward · · Score: 0

      It seems that everyone assumes that VMs these days (JVM, CLR, Mono, Parrot) must include garbage collection and not use pointer-based ops.

      What ? Both CLR and Mono allow you to use pointers, how do you think C++ could be run on CLR if it didn't support raw pointers ?

    3. Re:Why are current VMs preoccupied with GC? by spitzak · · Score: 2
      If the GC is considered part of the VM then it can be implemented in low-level code and be fast. If it is not part of the VM then most likely programs will have to implement GC (or at least C malloc/free) in the VM language, which would never be as fast and would be just a bug-prone as doing it now, and would also probably make assumptions about whatever memory allocation is provided by the VM that would prevent it from taking advantage of new system designs. It also allows services provided by the VM to create objects that can be manipulated like any other objects.

      Even the earliest VMs did garbage collection (take a look at Lisp which for some reason nobody has mentioned here yet).

      However it is true that this argument could be made for any feature added to the VM, but it does seem that using the VM design to get away from numerically-addressed memory is a natural division that most designers go for.

    4. Re:Why are current VMs preoccupied with GC? by Anonymous Coward · · Score: 0

      Would it not be more useful to have truly cross platform software (a la Microsoft Office) that runs on any machine with the *exact* same distribution? Please show me a decent cross-platform Java Office Suite - it does not exist. I say garbage collection is a noose around software's neck. We should be pushing for Architecturally Neutral Distribution Formats (ANDF) instead of bloated GC-based VMs. Somewhere along the line the industry took a hard left and forgot about what makes software useful to most people.

    5. Re:Why are current VMs preoccupied with GC? by Anonymous Coward · · Score: 0

      Which part do you want to keep simple, stupid? The design of the language, or the implementation of the machine? Either answer is fine, but there's no getting around the fact that there's a decision to be made.

      You can design a language that's very easy to use and which frees the programmer from having to worry about the most common and troublesome mistakes, such as memory management, and then build a machine which has enough features to support that language. This is a good idea if you think that a lot of people might actually use your language, and if you think that the resulting ease of use and the raw speed of underlying hardware will offset the performance penalty of those features.

      You can design a machine that's extremely simple, fast, and efficient, and then come up with a language that runs on that machine. This is a good idea if performance is a top priority, and if you don't mind shifting some of the burden of managing low-level details to the programmer, or to a higher layer of software.

      There is no one correct answer, as evidenced by the large number of machines (virtual or otherwise) and languages out there. Assembly, C, C++, Java, Scheme, Objective C, SML, and all the others each have their place.

      Design the right tool for the job.
      Use the right tool for the job.

    6. Re:Why are current VMs preoccupied with GC? by RevAaron · · Score: 2

      There are many virtual machines are aren't bloated. How large is the JVM? Just the JVM, not the library (jars, class files). I imagine it's pretty large. Just because Java is poorly done it doesn't mean all languages with VMs are as bloated. Smalltalk, which is by all measures a language with a huge library, can have a VM as small as 100k, but still get to all the standard libraries. Sure, you could target it to hardware, but if the language is well designed (like Smalltalk, not like Java) it's not as much of an issue.

      Not even the JVM includes anything near the kitchen sink. The libraries do. They're not terribly hard to port when all they do is interpret bytecodes.

      It's sad to see people with these kind of attitudes. In their minds, all virtual machine-based languages equals Java. Anything that's not compiled directly to native code equals QBasic. That's not the case.

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    7. Re:Why are current VMs preoccupied with GC? by William+Tanksley · · Score: 2

      Partially true. For example, Forth's VM avoids all that, and is VERY fast -- as a bonus, its VM is extremely easy to produce native code for (native code compilers are entirely compatible with others).

      Others have discussed why GC isn't as bad as you say; I agree with them, although they're a little extreme (it's NOT true that you always need GC).

      I'm working on a VM which can handle both GC'ed and non-GC'ed stuff at the same time, for a substantial speed advantage. Unfortunately, my VM has a language tiedown; I'm not sure how to add the type support I need to most languages.

      -Billy

    8. Re:Why are current VMs preoccupied with GC? by Anonymous Coward · · Score: 0

      It is not a question of GC being "bad" or "good", per se. The point was that the term "VM" should not be synonymous with GC (as your Forth example clearly shows).

    9. Re:Why are current VMs preoccupied with GC? by Anonymous Coward · · Score: 0

      It's sad to see people with these kind of attitudes.

      Look in the mirror. You have the same attitude; only a different opinion. Other people have opinions that are equally valid.

    10. Re:Why are current VMs preoccupied with GC? by RevAaron · · Score: 2

      /me looks in the mirror

      Sorry, don't follow you. I don't have the same attitude, having practical experience in the "real world" designing and developing, I've found that some VM-based languages can be slow, even if code is designed well. Usually, performances depends on the code itself.

      Sure, having an opinion based on ignorance is valid. However, it's still rooted in ignorance. One of the purposes of discussion is to share information, and that's what I do.

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
  23. Another use by Erbo · · Score: 5, Interesting
    Another thing virtual machines have historically been used for is to assist in the development of new computers, by creating a perfect model of the new computer's hardware in software, so the microcode authors (and maybe the OS authors, too) can get their code working before the hardware's completely debugged. In this guise they're called "simulators," and there was mention of them in Tracy Kidder's seminal work The Soul of A New Machine. As the book says, "A simulator makes a slow computer, but a fast tool."

    Also, don't forget the UCSD P-System, which used a virtual machine to run code compiled in that environment. I know of at least one commercial product that used the P-System; I believe there were many.

    Virtual machines have been around awhile; they're an interesting field, made newly relevant by the ascendancy of environments such as Java and the MS CLR. I just wish I had a good excuse to drop $50 on this book...:-)

    Eric

    --
    Be who you are...and be it in style!
    1. Re:Another use by dgym · · Score: 2, Insightful

      History isn't just in the past. AMD's next processor, codenamed the Hammer, will be the first x86-64 instruction set CPU. To kick start projects wishing to make good use of this 64bit extension to x86, AMD developed and made freely (beer) available virtual machine called SimNow over a year before the chip is due to launch.

      What I found particularly interesting was that this seemingly hopefull project was taken up so well that Simics thought it prudent to add x86-64 support to thier existing commercial multi-architecture simulator.

      The good news in all of this is that Linux and a fair few of the GNU tools are x86-64 ready now, well in advance of any x86-64 chips' release.

  24. Low-resolution thread concurrency? by magi · · Score: 4, Interesting
    Are there any VMs currently, for Java, Python or some other language, that can execute each thread one VM instruction at a time?

    It would also be nice to have language-level support for parallel processing, like in Occam.

    For example, in a Python implementation, the following code would execute the two for-statements in the "par"-block in parallel:

    par:
    for a in range (0, 3):
    print "a = %d" % (a)
    for b in range (0, 3):
    print "b = %d" % (b)

    As the two threads would be executed exactly at the same speed, the output would be:

    a = 0
    b = 0
    a = 1
    b = 1
    a = 2
    b = 2
    1. Re:Low-resolution thread concurrency? by Anonymous Coward · · Score: 2, Interesting

      You're assuming print is atomic.
      The output would more likely be:

      a =b 0
      a= 0
      b= =1
      a1
      b =
      = 2
      2

      Occam is an interesting language, but I think it has a too restrictive view. No global variables, no mutexes, everything uses channels - even shutting down a multithreaded Occam program is a major pain in the ass - message passing nightmare.

    2. Re:Low-resolution thread concurrency? by Anonymous Coward · · Score: 2, Informative

      While I'm sure someone could write a VM that did that, I don't think anyone would want to use it. On an x86, a context switch costs enough that one instruction per context switch would give you a bit more than 95% overhead lost on context switching. This means your programs would run at 1/20th speed at best.

    3. Re:Low-resolution thread concurrency? by jeremy_a · · Score: 1

      Let's assume for a moment that a VM could provide the behavior you describe. (As another poster mentioned, this would be quite slow as you end up with lots of task switching overhead.)

      Now what if you run on a system with two processors? Ideally, you would want each of your two threads to run on a separate processor so you get maximum concurrency. But if they are running concurrently, two operations could be executed simultaneously. So now you might get a mix of a's and b's, instead of strict alternation:

      a = 0
      b = 0
      b = 1
      a = 1
      b = 2
      a = 2

      This of course assumes that both processors would stay exactly in sync with each other -- probably not the case.

      Now what if there were three threads running on two processors? Now there is no way to keep the three threads running in parallel while keeping both processors busy and achieving the output you suggest.

      And this is ignoring the fact that in nearly all cases your program isn't the only thing running on the system -- there are usually some number of operating system processes/threads and other programs running.

      So in summary, even if the behavior you described is possible, it isn't going to be practical -- you would end up loosing the ability to run on multiple processors, which eliminates much of the use of your parallel algorithm.

    4. Re:Low-resolution thread concurrency? by magi · · Score: 2

      While I'm sure someone could write a VM that did that, I don't think anyone would want to use it. On an x86, a context switch costs enough that one instruction per context switch would give you a bit more than 95% overhead lost on context switching.

      You're right, assuming that the VM uses native threads. I was thinking of having the threading implemented in the VM; I guess it would be kind of trivial and it would have very little (if any) overhead because of context switching, although there might be some other costs.

      But of course, without native threads, we would lose the possibility to use multiple processors easily, which wouldn't be very nice.

      Then why have this low resolution? A friend of mine has a home-brewn VM for an ad-hoc language for embedded programming that handles concurrent execution one instruction at a time. He says it's very important for his embedded application. I don't know his specific reasons, but I'd imagine it has something to do with controlling multiple embedded devices and interfaces.

      Anyhow, low-resolution concurrency just sounds cool. ;-)

    5. Re:Low-resolution thread concurrency? by magi · · Score: 2

      You're assuming print is atomic.

      Well, yes, I think it's a rather safe assumption if the threading is implemented in the VM; formatting and printing a buffer would probably be implemented with an efficient native function, which would be atomic.

      But, yes, if we use native threading, the context switch could occur anywhere, and the output would be a mess, just as you describe. As noted in other messages in this thread (ummm...this discussion thread), using native threading would probably be the wisest choise.

      I don't know Occam really at all, but I don't quite like the normal Java or Posix ways of threading either. The PAR statement in Occam might make threading so much easier.

    6. Re:Low-resolution thread concurrency? by laxrox · · Score: 1

      I am not sure about a VM, but I remember reading about an extension to C someone wrote to do this for FPGA programming.

    7. Re:Low-resolution thread concurrency? by kinga · · Score: 2, Informative

      You're right, assuming that the VM uses native threads. I was thinking of having the threading implemented in the VM

      IBM's Jalapeno, now known as the Jikes Virtual Machine for Research, does its own thread scheduling instead of using native threads. The compiler generates yield points in method prologues and the back-edges of loops where the VM can preempt the thread. I suppose if you really wanted to you could have it generate a yield point for every instruction...

    8. Re:Low-resolution thread concurrency? by r · · Score: 3, Informative

      Are there any VMs currently, for Java, Python or some other language, that can execute each thread one VM instruction at a time?

      if you have a language that optimizes tail-calls, you could have the front-end of the language convert the separate threads of execution into continuation-passing style, and then execute the code one continuation at a time, simulating threading on a VM level. if i remember correctly, the scheme48 VM could do that kind of threading, though on a coarse level.

      in CPS a function decomposes into a sequence of more primitive functions, each returning a continuation, ie. a handler for computation yet to come. for a simplified example, the evaluation of (+ (* 2 3) (* 4 5)) would evaluate (* 2 3) into 6 and return a continuation that evaluates (+ 6 (* 4 5)), which in turn would evaluate (* 4 5) into 20 and return a continuation that evaluates (+ 6 20), and that would finally evaluate to 26.

      but the point here is that one could explicitly halt the evaluation after receiving the first continuation, store it on the queue, and go off and compute something else. after a while you can come back, pop the continuation off the queue, and pick up the computation where you left off.

      the problem with such a setup is that it makes optimization difficult. i'd suggest looking at the CPS for more details...

      --

      My other car is a cons.

    9. Re:Low-resolution thread concurrency? by magi · · Score: 2
      Below is a VM with a "reduced instruction set", illustrating what I meant with low-resolution threads. The VM has full threading capability. (The code actually works.)
      #include <magic/mapplic.h>
      #include <magic/mobject.h>
      #include <magic/mpackarray.h>
      #include <magic/mlist.h>

      enum vm_bytecodes {VMBC_BRK=000, VMBC_NOP=001, VMBC_FORK=002, VMBC_JOIN=003};

      class Thread {
      public:
      static int smThreadCounter;
      int mThreadId;
      int mInstruction;
      int mChildCount;
      Thread* mpParent;

      Thread (Thread* pParent=NULL, int position=0) {mpParent=pParent; mInstruction = position; mChildCount=0; mThreadId=smThreadCounter++;
      printf ("Thread %d created\n", mThreadId);}

      bool execute (PackArray<int>& code, List<Thread*>& threads) {
      printf ("Thread %d, instruction %05d: %03d\n", mThreadId, mInstruction, code[mInstruction]);
      switch (code[mInstruction]) {
      case VMBC_BRK: // Break; exit the thread.
      if (mpParent)
      mpParent->mChildCount--;
      return true;
      case VMBC_NOP: // Do nothing
      mInstruction++;
      break;
      case VMBC_FORK: // Create a thread
      threads.add (new Thread (this, code[mInstruction+1]));
      mInstruction += 2;
      break;
      case VMBC_JOIN: // Join all child threads
      if (mChildCount == 0)
      mInstruction++;
      break;
      }
      return false; // Do not exit the thread.
      }
      };
      int Thread::smThreadCounter = 0;

      Main ()
      {
      PackArray<int> instructions (20);
      instructions[0] = VMBC_FORK; // Fork to instruction 5
      instructions[1] = 5;
      instructions[2] = VMBC_FORK; // Fork to instruction 8
      instructions[3] = 8;
      instructions[4] = VMBC_JOIN; // Wait for the threads to exit.
      instructions[5] = VMBC_NOP; // Thread 1; do nothing.
      instructions[6] = VMBC_NOP; // Thread 1; do nothing.
      instructions[7] = VMBC_BRK; // Thread 1; exit thread.
      instructions[8] = VMBC_NOP; // Thread 2; do nothing.
      instructions[9] = VMBC_BRK; // Thread 2; exit thread.

      // Add the main thread.
      List<Thread*> threadpool;
      threadpool.add (new Thread ());

      // Run VM
      int threadCount;
      do {
      threadCount = 0;
      for (ListIter<Thread*> i (threadpool); !i.exhausted (); i.next (), threadCount++)
      if (i.get()->execute (instructions, threadpool))
      i.deleteCurrent (); // The thread exited
      } while (threadCount > 0);
      }
      (Implemented with my MagiC++ library.)
    10. Re:Low-resolution thread concurrency? by Misao · · Score: 1

      If you're trying to do 'parallel' processing for an FPGA (really, concurrent execution of statements/processes), you're much better off with one of the HDLs - Verilog or VHDL being the two most common - where the entire language is designed around parallelism.

      Verilog was originally developed by Cadence, IIRC, but is now a standard; VHDL was designed for the DoD's VHSIC program and is (loosly) based on ADA.

      -misao

    11. Re:Low-resolution thread concurrency? by Anonymous Coward · · Score: 0

      I got the Occam book in the bargain bin for $5. Great reading with new concepts. I like the PAR idea as well. I don't like the side by side coroutines though - you need some sort of wacky editor to write code for Occam. Just as some people dislike Python for using whitespace as syntax, they would dislike Occam for the same reasons.
      In spite of all of Occam's craziness, I found that its concept of channels make for good multi CPU parallelism and can be mapped fairly easily to producer/consumer work queues for threads.

  25. Re:YUO MUST BE STUPID by Anonymous Coward · · Score: 0

    Please don't feed the trolls.

  26. Re:Operating Systems by Tikiman · · Score: 2, Interesting
    I don't think you read the quote correctly:

    Emulators use virtual machines, operating systems use virtual machines (Microsoft's .NET), and programming languages use virtual machines (Perl, Java)".

    Microsoft's .NET is an example of a virtual machine used by a particular operating system - there are no claims that .NET is an operating system by itself. Similarly, the Perl and Java programing languages have been implemented on virtual machines - the JVM, and the stack-based (soon to be register-based) Perl virtual machine.

  27. Re:YHBT. YHL. HAND. by Anonymous Coward · · Score: 0

    No way, you've just been trolled.

  28. Re:OT: Perl Virtual Machine? by cxreg · · Score: 2

    Perl is a hybrid. It's interpreted at run-time like a scripting language, but before execution, it's pre-compiled to a VM-like bytecode. The idea is to get the best of all worlds. Things like mod_perl benefit from this a lot by only having to compile once but running many times.

  29. Re:UML is dying by Anonymous Coward · · Score: 0

    You need UML to design a VM. IF UML dies, all VMs die as well.

  30. YHBT YHL HAND by Anonymous Coward · · Score: 0
  31. YHBT YHL HAND by Anonymous Coward · · Score: 0
  32. Chips are virtual machines by Anonymous Coward · · Score: 0
    one slippery computer science concept that seems very hard for the vocationally inclined to understand is that hardware itself, processor chips, bitslice architectures, very long word, RISC, CISC, you name it, all of them, implement virtual machines! we don't "program the movement of electric fields and electrons". Rather, we code to the virtual machine that they implement.

    and that's part of the reason that you should go to college and study CS rather than teaching yourself.

    1. Re:Chips are virtual machines by tomhudson · · Score: 1

      FWIW, there's still another layer in betweem - the cpu's microcode (not to be confused with it's instruction set, which is implemented by the cpu's microcode).

  33. Re:So what moderator is hooking you up today? by Anonymous Coward · · Score: 0
    I wish I knew. I fucked up the formatting and forgot to check "post anonymously".

    I rule.

  34. Mainframe mentality creeping back in by totallygeek · · Score: 3, Insightful
    I for one am happy to see the influx of ideas that are representative of what mainframes and minicomputers of old were accomplishing. The use of virtual computers or machines along with centralized processing has been a welcome change from the mentality of the PC market for about the last 15 years.


    People had said for a long time that personal computers connected to file servers was a lower-cost, better system. However, now many places are going to web-based or host-based connections because of buggy issues at the desktop and the unmanageability of the personal computer. Couple this with the fact that licensing manangement is such a bear and you see why us Unix folks are glad to see the turn-around.


    Mainframes had been on their way out before the personal computer, in favor of smaller satellite processing via minicomputers. However, now people are realizing that virtual computers in a big iron case gives you a better managed array of computing power for multiple users or processes. I for one welcome this back, and hope that we will continue to see vitual computing take over the personal computer business market approach. Bring in the network computers!

  35. Best non-stadard use for a vm? by stevey · · Score: 1

    I'd like to nominate some software I wrote for the most random use of a virtual machine.

    I was asked to code a registration routine for a piece of software - after getting the username + serial number from the user I would have typically done some magic to calculate a checksum from the name and see if it matched the given key.

    Instead I wrote a small virtual machine which executed z80 machine code. The protection routine litererally started the VM - where all the magic happened. Each opcode was fetched decoded and executed. I think it would have been a real pain to decode ;)

    (I guess the clever cracker could have disassembled my windows binary with a z80 disassembler and gotten lucky; but it would have been hard to see what was being executed - unless they could do clever things like disassemble z80 in their head...)

    1. Re:Best non-stadard use for a vm? by Anonymous Coward · · Score: 0

      Why not encrypt the instruction set as well if you really want to get extream.

    2. Re:Best non-stadard use for a vm? by michael_cain · · Score: 1
      Ten years or so ago, I had to write an event dispatcher for a distributed processing arrangement. Processes on different machines were long-running and had persistant side effects that could cause problems, and it was important that the dispatcher made good choices about which processes saw any given event.

      The dispatcher ended up implementing a virtual machine with an instruction set tailored to the particular problem and the data structures that were involved in events and process responses to those events (which were returned through the dispatcher). The instruction set included the usual flow control stuff (branch on various conditions) and some odder things like "adding" two complicated data structures. The VM provided an efficient way to serialize the dispatch process.

      Writing programs for the virtual machine was a bitch, so I eventually implemented a high-level declarative language describing how different processes could respond to an event, and relationships like precedence and mutual exclusion that existed between the different processes, and a compiler that converted a set of declarations into procedural byte-code programs for the VM implemented in the dispatcher.

    3. Re:Best non-stadard use for a vm? by fava · · Score: 1
      I quote:
      (I guess the clever cracker could have disassembled my windows binary with a z80 disassembler and gotten lucky; but it would have been hard to see what was being executed - unless they could do clever things like disassemble z80 in their head...)
      No. A clever hacker would just patch the code to ignore the return value of your registration routine.
    4. Re:Best non-stadard use for a vm? by Vagary · · Score: 2, Funny
      "Greenspun's Tenth Rule of Programming: any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp."

      - Phil Greenspun

    5. Re:Best non-stadard use for a vm? by stevey · · Score: 1

      The whole point was that the registration routine wasn't in x86 assembler and couldn't be jumped around with. It was in the middle of essential code.

      As it was written in the z80 `bytecode`, setting bpx GetWindowText, et al wouldn't have helped terribly much - they'd have landed inside the bytecode intepretter.

      Basicaly it'd be like trying to crack visual basic programs with a disassembler - yes it can be done if everything standard and you "cheat" by bpx hmemcpy but otherwise it's hard. (In my case there's not bytecode disassembler available; so you couldn't resort to disassembly like you could for a pure VB program).

      I'd not stupid or arrogant enough to think it couldn't have been cracked - but I'm sure it would have been reasonably complex. (Speaking as a reader of +Fravia, and having done a lot of 'study' of different protections myself ;)

    6. Re:Best non-stadard use for a vm? by dutky · · Score: 2
      moron.

      Any protection scheme that relies on a single test point is child's play to circumvent. If you have code sequence like so:


      get user's authentication credentials

      <do some magic on the credentials>

      if the magic didn't work, exit


      can be trivially defeated by simply adding one jump:

      goto location A

      get user's authentication credentials

      <do some magic on the credentials>

      if the magic didn't work, exit

      (location A is here)

      now, insert your Z80 interpreter where the above code reads "<do some magic on the credentials>" and see how hard it is to defeat. Even liberally sprinkling your program with calls to the magic won't help, it just increases the number of times that cracker has to insert jumps into the machine code.
    7. Re:Best non-stadard use for a vm? by stevey · · Score: 1

      If you read the post above you'll see that isn't what I'm describing

      The interpretter actually includes the calculation of data which makes it onto the screen - if you just 'goto A' you'll end up with a blank display.

      The application is a spreadsheet. The core of the function intepretation is in z80 assembly. You can't jump over it. What I'm trying to say is that by embedding the protectin within this emulated code/intepretted VM it's harder to break than the simple schemes that are common - like that you describe.

      (This is why the instructions that are vm'd are z80 - it's close to x86 and hence doesn't slow down the main application).

      Oh. and moron to you to.

    8. Re:Best non-stadard use for a vm? by istartedi · · Score: 2

      So, your code is *not* just a jump to a registration routine that happens to run in a Z80 VM. That would indeed be trivial to hack.

      Instead, the code runs in the Z80 VM at a high level. Presumably, you run 99% of the cycles in native code, but the high level control is Z80 VM. So, let's say the top-level loop has 1000 or so instructions of Z80 code, some of which are the registration routine.

      If the attacker looks for the code that displays a dialog saying "you are not registered" they will simply find the code for branching in the VM, which is executing many times for other purposes.

      If I were the attacker, my approach would probably then be to find the address of the code that would be executed by the VM if it had *not* branched, and to replace the "you are not registered" code with a jump back to that location.

      Alternatively, I might observe that the same code was being executed again and again, and surmise that it had multiple purposes. I might splice in a test for the Nth execution of the code and have it not branch. That would slow down the VM, but since you aren't running much code in the VM it won't make a big difference.

      Bottom line? Yes, it probably would trip up some people. If your program is only $30, they will get discouraged. If it's $300 they will probably figure it out.

      Is there anything I'm missing?

      --
      For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
  36. PuNK!# by Anonymous Coward · · Score: 0

    for(;;){cout"YHBT. YHL. HAND."endl;}

  37. A crank eater... by Anonymous Coward · · Score: 0

    n/m

  38. VMs in the OS by miraj31415 · · Score: 1

    It seems to me that more and more languages nowadays are designed for a VM, thus adding a level in between the OS and the application. Of course, this leads to a slowdown because the JIT has to do its thing AND the compiled code that runs has to use system calls to do what it wants to. But has anybody given any thought to making a VM that runs almost on top of the hardware with almost no system calls? Perhaps the only interference the OS would make is scheduling and possibly memory management. This kind of approach (like the exokernel approach in the EROS project) would allow a VM to greatly speed up its resultant code because it would have almost direct control of the hardware, and the VM would be optimized for that hardware. I am working on an OS (Middle Earth OS) that is looking into this kind of design, and would appreciate your input either here or in the project's forums as to whether you think this would work (well) or not.

    1. Re:VMs in the OS by spitzak · · Score: 2
      It sounds to me like you are proposing an operating system that *only* runs programs written for the VM. This is a totally viable idea and I would agree it would produce the fastest VM possible.

      Probably the main thing that makes people not consider this idea is that it would be a new OS that does not run any existing programs. Although there are plenty of alternative OS's out there, most people see VM as a way to get their new interface onto an existing system so they never consider this way of writing it.

    2. Re:VMs in the OS by RevAaron · · Score: 2

      But has anybody given any thought to making a VM that runs almost on top of the hardware with almost no system calls?

      It's been done many times since the 70s. Not sure the first time a VM-based language was the OS, but it was the case with Smalltalk, as far back as 1972 or 1976. You can still get a Smalltalk-based OS with SqueakNOS. Squeak traditionally runs on top of a host OS like Linux, Mac OS, Windows and many others, but it has almost all of the features of an OS, including an awesome (but non-traditional) GUI system, compleat with remote viewing. The binaries are identical between the OS-version of Squeak an the hosted-on-Linux version.

      The current state of SqueakNOS is that you still have to write a little C for certain things. Luckily, you can write your low-level code in a subset of Smalltalk and have it translated to C. That's how the Squeak virtual machine is written, no manual C coding required. However, there is active work being done on Squeampiler, which allows Squeak itself to compile and generate native code. Which means the entire system 100% will be in Smalltalk.

      As it is now, if you want to change (in SqueakNOS or Squeak on top of a 'normal' OS) fundamental changes to the language can be made within the environment. The only thing compiled to C is the virtual machine and other C plugins, like OS-specific functions. Everything else, the bytecode compiler, the parser, an emulator for itself, all the development tools and libraries are all written in Smalltalk.

      I am working on an operating environment for PDAs, Dynapad along these lines. I'm doing the development on top of Linux/PPC, Solaris/SPARC, and Windows/x86 and run it on my iPAQ under WinCE/ARM. Eventually, I'd like to run it as the OS, if something like OSKit ever makes it's way to the iPAQ platform.

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    3. Re:VMs in the OS by miraj31415 · · Score: 1
      Probably the main thing that makes people not consider this idea is that it would be a new OS that does not run any existing programs.

      Actually, the purpose behind my proposed idea is for compatibility with existing systems (Linux, Mac, and Windows). Both Java and new .NET programs will compile to a form that is readable by a VM: Java to bytecodes and .NET (C#, VB.NET) to MSIL. And since this system is a few years off, I don't expect too many legacy non-.NET programs to be necessary to run on it. So we would write a JVM and a MSIL VM that would run over this minimal kernel.

      Furthermore the OS would have a "VM" that is actually the native API -- so that people could write code that is faster than those requiring an actual VM.

      Probably the most difficult part of this aspect of the project would be trying to get Linux compatibility. This would require a VM that interprets compiled Linux binaries and converts them to some form that our OS could use. Do you have any suggestions?

    4. Re:VMs in the OS by Doubting+Thomas · · Score: 1

      My primary focus in VM/language design is in agressive continuous optimization techniques, however, if/when I achieve my preliminary goals in that arena, one of the possibilities I see going forward is to create an OS that can run trusted user code closer to ring0 than untrusted native user code. This reduction in system call costs would partially offset the increased processing needed for the interpreter.

      In order to get access to a large library of native code, there are a number of linux projects that allow the kernel to be hosted on top of another OS, from Windows (Plex86), to various microkernels (like L4Linux), to Linux itself (User Mode Linux). Port Linux to your VM in a fashion similar to these guys, and you get your compatibility.

      --
      Just because it works, doesn't mean it isn't broken.
  39. Don't be so sure by Anonymous Coward · · Score: 0

    Never overestimate the intelligence of a slashbot.

  40. What language? by Anonymous Coward · · Score: 0

    What language is that written in, Visual Basic gave me a compile error

  41. Pipelining the KVM by BobLenon · · Score: 2, Informative

    Yea, so for a class project we took the kvm and (Java VM for embeded devices), and turned it into a pipelined architecture. It was very educational, but the practicality is lacking ... You at least need a 4 proc machine to be useful, as it was a simple 4-stage. But the speed was soo lacking.

    It was worthwile experience, though I do wish java was reg based. ;) .... as it was only a learning experince no big deal. By the end i could've written my java in assembly ;)

    --

    /* Lobster Stick To Magnet!*/
  42. Re:Operating Systems by Shalda · · Score: 1

    .NET is (for purposes here) a runtime environment/API. It's predicated upon Microsoft Intermediate Language (MSIL): basically, code that's easily compiled for a specific CPU or Operating system. The whole system is based upon a Just-In-Time compiler. It's all compiled to native code and executed as a normal program.

    As for whether or not this constitutes an Operating System, that's a little vague. It does provide some memory management functions (garbage collection), but it certainly doesn't do a lot of OS type things (device drivers, file systems). An operating system is many things, and .NET is just a small but growing part of the Windows(tm) operating system.

  43. Re:OT: Perl Virtual Machine? by god · · Score: 1

    We might as well get the terminology right. Perl 5 compiles the source code at compile time (at sometimes at runtime for eval STRING) into opcodes for the terribly-undocumented and very-well-hidden Perl 5 virtual machine. You just don't notice it 'cos it compiles it and runs it in one step.

    Perl 6 (not finished yet) aims to seperate the virtual machine (http://www.parrotcode.org/) from rest of the language.

    Hopefully this clears things up.

  44. YUO ARE STUPID by Anonymous Coward · · Score: 0
    Gentlemen, the time has come for a serious discussion on whether or not to continue using C for serious programming projects. As I will


    'c' has always been a *systems* programming language - it was never [originally] intended
    for applications programming ...

    explain, I feel that C needs to be retired, much the same way that Fortran, Cobol and Perl have been. Furthermore, allow me to be so bold as to suggest a superior replacement to this outdated language.


    fortran, cobol, and perl are very much thriving (not as popular, but still very much in use). my guess at the replacement is gonna be c++ or java.

    To give you a little background on this subject, I was recently asked to develop a client/server project on a Unix platform for a Fortune 500 company. While I've never coded in C before I have coded in VB for fifteen years, and in Java for over ten, I was stunned to see how poorly C fared compared to these two, more low-level languages.


    that's interesting, because java wont celebrate
    it's 10th birthday until May 23, 2005 - am i to
    assume you were using "oak" before that ?!??!

    C's biggest difficulty, as we all know, is the fact that it is by far one of the slowest languages in existance, especially when compared to more modern languages such as Java and C#.


    you have *GOT* to be kidding me. what do you think all the worlds' operating systems are written with? most good compilers go straight to binary. and some of these compilers put out some pretty efficient binary. i used to a boat-load of assembly development, and some of the cutting edge c-compilers were putting out efficient code.

    java is interpreted, although you can generate native binaries. vb is in the same boat, but its object-based, which is fairly wimpy. i cant talk about c#, all i know is that it was created as a marketing language to compete with java (cause microsoft couldnt shut it down).

    Although the reasons for this are varied, the main reasons seems to be the way C requires a programmer to laboriously work with chunks of memory.


    a c programmer worth his salt will know exactly how to use his chosen language. it's the typical 9-5 programmer that hasnt a clue.

    Requiring a programmer to manipulate blocks of memory is a tedious way to program. This was satisfactory back in the early days of coding, but then again, so were punchcards.


    that's not even a comparison, so try something else. learning how to release allocated memory is child's play - you just have to be an efficient developer.

    By using what are called "pointers" a C programmer is basically requiring the computer to do three sets of work rather than one. The first time requires the computer to duplicate whatever is stored in the memory space "pointed to" by the pointer. The second time requires it to perform the needed operation on this space. Finally the computer must delete the duplicate set and set the values of the original accordingly.


    you are obviously clueless, based on your previous paragraph. you dont "duplicate" memory so that a pointer can point to something. memory is first allocated, either on the heap or the stack (i hope i'm not using language that is unfamilar), and then a pointer is created, either on the stack or heap, so that you can access the memory it is pointing to. pointers are the most efficient way to access memory on the heap (and stack), short of reverting to assembly language. pointer arithmetic and the use of a pointer to "walk" memory locations is waaaaay more efficient then, say, using array offsets.

    Clearly this is a horrendous use of resources and the chief reason why C is so slow.


    again, it is an incredibly *fast* language - your
    lack of understanding is displayed through
    your naive statements.

    When one looks at a more modern (and a more serious) programming language like Java, C# or - even better - Visual Basic


    vb - what a joke. like i said, i've never dealt with c#, so i cant talk to it. and java is efficient for OTHER reasons - it's not faster than 'c'. there is a lot of plumbing in java that is included out of the box, is truly object oriented, and includes a garbage collector. but the garbage collector is very inefficient, in time-critical applications. you can get garbage collectors for c++ and c also.

    that lacks such archaic coding styles, one will also note a serious speed increase over C.


    i'll tell you what, let's decide on a back-end,
    speed critical application to run on a real OS,
    like Linux or Unix - you do it in VB, and i'll do
    it in C, and we'll do some speed runs and see
    what the outcome is.

    much of my experience developing real time
    systems involved, you guessed it, c. and why
    is that? because it is fast, compact, and very
    efficient.

    So what does this mean for the programming community? I think clearly that C needs to be abandonded. There are two candidates that would be a suitable replacement for it. Those are Java and Visual Basic.


    so, what happened to c++???? because i am
    sure you have no significant experience with
    it, you've already dismissed it.


    Having programmed in both for many years, I believe that VB has the edge.


    BWA HAHHAHHAHAHA ... thanks, i was
    feeling a little blue, but now i'm smiling :))


    Not only is it slightly faster than Java its also much easier to code in. I found C to be confusing, frightening and intimidating with its non-GUI-based coding style.


    like i said, you havent a clue about the language because of that typical microsoft mentality: "if it dont have a GUI, i'm lost"


    Furthermore, I like to see the source code of the projects I work with. Java's source seems to be under the monopolistic thumb of Sun much the way that GCC is obscured from us by the marketing people at the FSF.


    again, you havent a clue. what, do you think that sun owns all the code you write??? sheesh.


    I hope to see a switch from C to VB very soon. I've already spoken with various luminaries in the C coding world and most are eager to begin to transition.


    BWA HAHAHAHAHAHA. come on come on,
    *names* please - what "luminaries" in the
    industry are dying to move from c to vb.
  45. Parrot by god · · Score: 2, Informative

    For more information on Parrot, which will be the Perl 6 virtual machine, and which is register-based, you may want to check out http://www.parrotcode.org/.

    1. Re:Parrot by RevAaron · · Score: 2

      Parrot is what got me interested in perl. Perl is too inconsistent for me to take very seriously, but Parrot is promising as a .NET work-a-like with no MS tie-ins. :)

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
    2. Re:Parrot by PythonOrRuby · · Score: 2, Informative

      Parrot is the virtual machine runtime, so technically, it won't be compiling anything(though it will alow for JIT compiling of Parrot bytecode).

      Rather, the languages will implement compilers that generate Parrot Assembly language, and then the Parrot assembler will take it from there. This approach really does have a number of advantages. It means that the Parrot community can work on optimizing the heck out of the assembler and runtime, without worrying too much about the concerns of each individual lanuage.

      It also means that, for embedded use, Perl/Ruby/Python/Tcl/Scheme/etc. programs can be compiled and loaded onto a machine that only has to have the Parrot runtime installed.

  46. Overlooking importance of VM in kernel by gwayne · · Score: 2, Informative

    It seems to me that many of you are viewing VM as some kind of emulation application rather than a virtual machine. What you may not realize is that many(most?)OS kernels including Linux virtualize the hardware to make the software more portable and less able to crash your entire system. What you lose in performance you make up for in stability. Operating systems books are a great reference for studying VMs.

    Operating System Concepts by Abraham Silberschatz, et al.

    Design and Implementation of the 4.4bsd Operating System by McKusic, et al.

    Design of the UNIX Operating System by Bach

    Modern Operating Systems by Tanenbaum

    Operating Systems Design and Implementation by Tanenbaum

  47. OMG YUO FOR REAL? by Anonymous Coward · · Score: 0

    what time did he pass away
    i haven't heard anything on the news yet

  48. hmm infocom... by YakumoFuji · · Score: 3, Interesting

    but does it cover infocoms famous zmachine VM, which runs on more hardware than any other virtual machine ever... (considering it can run under java as well.. a vm runnnig a vm!)..

    or magnetic scrolls 68k VM, that that even ran on the c64 with its mighty 8bit chip, was emulating the 16/32bit 68K!

    aaah long live interactive fiction and virtual machines.

    --

    no sig for you
  49. Re:Operating Systems by smittyoneeach · · Score: 2

    It doesn't run without Windows?
    I guess you could say it blurs the line/is highly integrated with the underlying OS, but wasn't there just a protracted legal battle based on that?

    --
    Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  50. A Wonderful Tool by Anonymous Coward · · Score: 0

    A BEHAVIORAL simulation/VM can generally be brought up a great deal faster than a group of designers can create Verilog, tape out and get Si back. While this type of simulation isn't perfect as far as timing and bus cycles, a SW group can get a major head start preparing for new Si - both in terms of actual SW development and Post-Si validation.

  51. Virtual Analog Circuits and Stuff by namespan · · Score: 2

    Can anyone explain what's similar/different between doing this and doing something like ReBirth?

    --
    Libertarianism is rich wolves and poor sheep playing gambler's ruin for dinner.
  52. .net is not a virtual machine by r · · Score: 3, Insightful

    one thing to remember is that the microsoft .net infrastructure does not run on a virtual machine!

    .net code (c#, etc.) compiles down to a standard intermediate language, which gets JITted into machine code, and linked to .net support libraries. there is no interpreted code execution going on, and indeed, the IR is not optimized for interpreted execution. hence, there's no virtual machine running, unlike in the case of Java or other bytecode interpreters.

    .net is not a virtual machine any more than gcc is a virtual machine.

    --

    My other car is a cons.

    1. Re:.net is not a virtual machine by Anonymous Coward · · Score: 0

      This is nonsense. Of course CLR uses a VM. Do you think GC just "happens"? What about multicasting delegates? What do you think actually DOES the JITting? The VM. If you are not familiar with VMs please take a look at Mono for a concrete implementation of a CLR VM.

    2. Re:.net is not a virtual machine by r · · Score: 2

      This is nonsense. Of course CLR uses a VM. Do you think GC just "happens"? What about multicasting delegates? What do you think actually DOES the JITting? The VM. If you are not familiar with VMs please take a look at Mono for a concrete implementation of a CLR VM.

      garbage collection doesn't require a virtual machine, and neither do delegates, since they're merely function closures. and btw, by your JITting example, any compiler would be a 'virtual machine'. :)

      nice attempt at a troll, though.

      --

      My other car is a cons.

    3. Re:.net is not a virtual machine by Anonymous Coward · · Score: 0

      By this definition, the HotSpot JVM is not a VM.

    4. Re:.net is not a virtual machine by Anonymous Coward · · Score: 0

      Of course CLR's a VM. So is Mono.
      The VM runs _bytecode_ not x86 assembler, you jackass.
      Read the literature. Look at the code.
      See what the Mono developers call it themselves.
      Do you work for Sun or something?
      Moron.

  53. Hardware is already out there. by nurb432 · · Score: 1

    Sun always planned hardware chips.. modified sparc cores that ran Java on 'bare iron'...

    They got 'em now... have for a while now.

    --
    ---- Booth was a patriot ----
    1. Re:Hardware is already out there. by Anonymous Coward · · Score: 0

      Oh, I remember 1996 too. When all the Java guys I worked with were going on about how much ass Java would kick, just as as soon as Sun shipped their JavaChip...

      By the time the thing came out, it was slower than a Pentium running Windows and a JVM. So much for that idea...

  54. One of the nicest VM's I've seen by Rogerborg · · Score: 2

    Was in Unreal. That was, what, five years ago? It was a revalation to me as a commercial games developer. You could script object behaviour in C-like code, and load it dynamically at run time without having to restart the engine or try and do clever tricks with dll's. The development time that saved was simply breathtaking, and it pretty much defined the future of games engines and games development, which epitomise the RAD concept. Heck, the first thing that we did was crank out our own C-like VM, and we never looked back.

    --
    If you were blocking sigs, you wouldn't have to read this.
    1. Re:One of the nicest VM's I've seen by Junks+Jerzey · · Score: 2

      The development time that saved was simply breathtaking, and it pretty much defined the future of games engines and games development

      Of course, while UnrealScript is cool, let's not be too quick to give it credit for VMs in games. UnrealScript was heavily influenced by Quake C from two year earlier (much like everything in Unreal, which should be obvious enough anyone). And there were a number of games from the VGA days which included scripting languages. A popular example is the lame side-scroller Abuse, but there certainly were others.

  55. Because we can afford it by mugnyte · · Score: 1

    Because of the increased power of CPUs through time, we SHOULD expect features of development environments to be expanded.

    I'm in the camp that programming as a art should evolve to way beyond what we have today. GC may evolve to a more manageable version (defer/force intructions) but you can consider thick APIs and these features to be the norm in the future.

  56. Because they *must* be. by alienmole · · Score: 2
    Ha! I think your question is answered quite well by this message.

  57. What about HARDWARE VMs? by ssyladin · · Score: 1
    There is a lot of nit-picking about the performance of VMs running the software developed. I'd like to point out that Compaq and a few others are using hardware based virtual machines. "What?!?" you say. Quite simply, the Transmeta Crusoe processors and their kin take opcodes in ix86/PPC/68K/etc and translate them into a series of RISC instructions native to teh CPU core. EGAD! We have a hardware virtual machine!!!

    Although actual silicon being called virtual does kinda twist one's mind.

    1. Re:What about HARDWARE VMs? by turnidge · · Score: 1

      Transmeta's offering is a clever marriage of software and hardware. The translation, in particular is done by their software which is called CMS, the code morphing system.

  58. You're missing the point about VMs by Anonymous Coward · · Score: 0

    Security is not the issue. Having software that runs on any machine is. Java has hijacked the VM world into thinking a VM must support garbage collection. This is a falsehood. A VM merely has to run its code the same everywhere - ideally as fast as possible. Any software you run is potentially non-secure. You ultimately must trust its author or the vendor you bought it from. Sure, you could look at the source code in the case of free software - but no one actually does (or can even to hope to understand hundreds of thousands lines of code written in any language). For that matter, any standalone Java application is free to make the same logic mistakes as their supposedly non-secure traditional compiled language counterparts. Even a standalone Java application can be malicious - overwriting your files or emailing them to random people on the internet. Take the popular Java file-sharing application Limewire, for example, do you know for a fact what it is actually doing? Of course you don't. Is it "secure"? You believe it is - but who knows? You must ultimately trust the vendor.

  59. p-System apps by lseltzer · · Score: 1

    I was the maintainer of the p-System version of NPL, a 4GL for numerous platforms from Desktop Software out of Princeton.

    Given the hardware of the day (early-mid 80's), a VM system like p-System was (ahem) ahead of its time. It was really slow, even to our ancient sense of performance. But the same binary did run fine on numerous p-System implementations, including the IBM PC and DEC Rainbow.

    I also did work on the HP Pascal system on their Series 200 68000-based systems. The Pascal system was a native 68K port of the p-System. You got the UCSD Pascal, which was a great Pascal, and a number of other HP proprietary enhancements, and it was the fastest computer I had ever seen at the time.

    1. Re:p-System apps by Erbo · · Score: 2
      The apps I was thinking of in my earlier post were some of the PFS: applications for the Apple II. I was exposed to those applications after I'd taken a high school course in Pascal (which used the p-System on HP micros). Some of the error messages listed in the manual were similar, and I remember the notation "All system errors cause the system to I)nitialize itself...", which I recognized as p-System terminology.

      I never did get the p-Code interpreter card for my TI-99/4A, though; an environment like that might have run p-System programs a little faster. (There's an early example of "VMs implemented in hardware" for you...way ahead of the JavaChip.)

      Eric

      --
      Be who you are...and be it in style!
  60. Parrot by HiThere · · Score: 2

    Parrot is appearantly the result of an April fools joke that wouldn't die. As a result Parrot is supposed to compile not only Perl 6 but also Python and possibly Ruby.
    Whee!

    So a C/C++ library that interfaces well to Parrot would be accessible by LOTS of different scripting languages.

    (I haven't been following the developer lists, so this is just based on what I overheard as a casual outsider with a bit of interest.)

    --

    I think we've pushed this "anyone can grow up to be president" thing too far.
  61. It can probably be done, but not profitably. by Animats · · Score: 3, Informative
    It's not something to do for performance.

    Implementing a stack-based machine in hardware is straightforward, and has been done many times. The first one was the English Electric Leo Marconi KDF9, in 1958. Burroughs followed, and thirty years of Burroughs stack machines were sold. Java has a small implementation of the Java engine in hardware. Forth chips have been manufactured.

    But all these machines have used sequential execution - one instruction at a time. Nobody has yet built a stack machine with out-of-order execution. There's been a little research in this area. Sun's picoJava II machine has some paralellism in operand fetches and stores. But nobody has wanted to commit the huge resources needed to design a new type of superscalar processor. The design team for the Pentium Pro, Intel's first superscalar, was over 1000 people. And that architecture (which is in the Pentium II and III) didn't become profitable until the generation after the one in which it was first used.

    In the end, a superscalar stack machine probably could be designed and built with performance comparable to high-end register machines. For superscalar machines, the programmer-visible instruction set doesn't matter that much, which is why the RISC vs. CISC performance debate is over. But so far, there's no economic reason to do this. Sun perhaps hoped that Java would take off to the point that such machines would make commercial sense. But it didn't happen.

  62. caching jit for c by heh2k · · Score: 1

    instead of having native binary packages for each arch, why not compile to an intermediate bytecode (distribute that), then compile and cache the native binary? would too much optimization info be lost?

    amiga was working on something like this. were the resulting native binaries decently optimized?

    i'm imagining an isa that would use labels (instead of registers). the compiler would just do all the macro expansion, etc. maybe this wouldn't be much faster than just compiling it from scratch, though.

  63. ...and the concepts which allow them to exist by memfrob · · Score: 1

    I haven't seen much discussion about the concepts which allow virtual machines to exist, but isn't there a theory that any turing-complete system can emulate any other turing-complete system flawlessly? At least, if you ignore the infinite space requirement of a turing machine, any turing-complete system can at least simulate what any other turing complete system can do?

    I think this is the theory that the *AA, Microsoft, and any other DRM implementors are going to have to realize. It is not possible for software to trust hardware. Any hardware interrupts or memory-mapped I/O can be completely simulated; the only problem is getting the correct response back (i.e., through breaking the encryption keys or whatever. How long did it take dongles to be cracked?) The software can't even necessarily do anything malicious to the user if whatever authentications fail; any instructions can be executed conditionally at every step, and anything malicious simply ignored. The bytecode for a program is sort of like a book of instructions - the book may say "Step 4: if you don't have the password, burn this book", but the reader doesn't have to do anything of the sort.

    Of course, the problem is, the instructions may say "Step 5: Use the password to decrypt the hardware key, then use the decrypted key to decrypt the rest of this book." This is little more than security through obscurity.

    The cat is out of the bag, and all the czar's horses can't put it back in. They'll need to invent a system that is not turing-complete and then get the american sheeple to buy it; good luck.

    --
    The Wizard utters the word 'frobnoid!' and cackles gleefully
  64. Re:OT: Perl Virtual Machine? by PythonOrRuby · · Score: 1

    Python behaves similarly. Upon importing a module into another program, a ".pyc" file is created containing the compiled bytecode. Subsequently, Python uses the compiled module rather than the source file.

  65. Re:Stupid yourself by elflord · · Score: 1

    This is an obvious troll, and you sir, have been suckered. I'm not sure what's funnier -- the troll itself or the dimwits who took it seriously. What is clear from the amounts of responses this troll gets is that the troll is clearly more intelligent than the respondents !

  66. But is this book really that good? by jmischel · · Score: 1

    Has anybody here, other than the reviewer, actually read the book? The reviewer says:

    Blunden [the author] makes sure to cover every topic related to virtual machines in extreme depth.

    Fine, that I could believe...maybe...in a 650-page book. But then, he goes on to say:

    Initially he starts slowly, and introduces the reader to how CPUs work, how memory works, how paging works, and how almost any other system process you can imagine works. Nothing is missed out. Multitasking, threads, processes, porting.. he covers it all.

    All in just 2 chapters? Furthermore:

    ...a number of advanced topics (garbage collection, memory management, assembler construction, paging, token parsing) are dealt with in a very easy to understand way.

    Followed by a complete VM implementation, with assembler and debugger, including clear and pertinent code examples in C/C++? All in a 650-page book? Maybe the writing is really, really small?

    This book must be a tour de force of clear, concise writing. Either that, or the reviewer's ability to discriminate between hand waving and thorough discussion of a topic is limited, at best.

    If this book really is as good as the reviewer says, then I absolutely must get it. But, somehow, it sounds too good to be true.

  67. Well, by bmillerward · · Score: 1

    At least we know what C++ programmers are good for.

  68. You missed the point of the two doofuses by alienmole · · Score: 2
    That message focuses on security, presumably as a kind of PR hook, but it's really much more about integrity. There's a quote in there about "Then the programmer can never mess things up", and that's the real point about garbage collection.

    If a VM doesn't support garbage collection, then programs written for it will be buggier and less safe than programs written for a VM with garbage collection.

    One of the biggest reasons that existing software is so unreliable and unsafe is because of its dependence on C, and the lack of both type safety and garbage collection in C. This allows buffer overflows and memory access violations. You're correct that adding garbage collection (and true type safety) doesn't buy security in and of itself, but it buys a heck of a lot of safety.

  69. Parrot's not just a Perl VM by Fweeky · · Score: 2

    Although it's being done with Perl in mind, it's not just the Perl 6 VM; it's actually aimed at pretty much any dynamic language. Hence we should also see backends for Ruby, Python, Basic, any pretty much any language you care to impliment.

    There's also talk of Parrot bytecode to Java/CLR bytecode convertors. Interesting stuff, even if we're gonna have to wait ages to actually get something useful.

  70. Re: p-Systems by bubbaD · · Score: 0

    It would be great if someone was able to dig up some of these p-Systems and documentation and made them available. I imagine only binaries would be available. Wouldn't they scream on today's computers?

  71. Legality by yerricde · · Score: 2


    Can anyone give me a substantial difference between a virtual machine, and an emulator


    Others have commented on the theoretical differences, but I feel I should say something as to what distinguishes a VM from an emulator in practice. Virtual machines do not promote piracy because software is designed to run on virtual machines. On the other hand, an emulator is often written with unlawful redistribution of proprietary software in mind, even if it is wink-wink-nudge-nudge.


    because I can't see whats different between my mame and java virutal machine


    I find the most important difference between MAME and JVM that there is a much larger library of free software designed to run under JVM than under MAME.

    --
    Will I retire or break 10K?
  72. Lisp Machine by bubbaD · · Score: 0

    The programmers' holy grail, stuff of legends, the Lisp machine. It was virtualized by Symbolics and ported to the 64-bit Alpha. If I remember right, the Symbolics LispM had a variable length word and Megaword, which made the Alpha the only viable option. I believed it utilized Alpha microcode, and required Digital Unix to work correctly. The new "operating-system" was called Genera. I have a copy of it (somewhere around here) I intend to buy a Multia for myself someday, but I wonder if there was still some interest in porting Genera to a 64-bit x86? Hope so.

  73. Implementation vs testing by Anonymous Coward · · Score: 0

    Implementing a VM is bad enough -- imagine the testing matrix. It would have been nice if the author covered information on the most efficient methods of verifying the functionality of a VM, or comparing the actual behavior of an emulator against the target platform whether through the use of Formal Methods, instrumentation, or some exhaustive state-transition generator framework.

    Has anyone else had to test VMs or emulators?

    1. Re:Implementation vs testing by Anonymous Coward · · Score: 0

      The best way to test VMs are to hold it up to the light and "eyeball" it. See that there are no cracks, warps or bubbles. Make sure it is level. To build software you need a solid foundation - the VM is no exception.

    2. Re:Implementation vs testing by Anonymous Coward · · Score: 0

      Ah, I see -- so you don't know how. Well you could have just said that and left out the analogies.

    3. Re:Implementation vs testing by Anonymous Coward · · Score: 0

      Damn. Looks like Slashdot needs a "large type for the humor impaired" edition.

  74. you are a doofuss by Anonymous Coward · · Score: 0

    I got the point of the article, dumbass. Thanks for repeating it for no reason. GC will not save you from a logic error in your program that gives users unauthorized rights (or other privledges). And I guess you've never encountered runaway Java memory retention bugs - can you say "denial of service"? You're pretty closed minded. GC is not the sole answer to everyone's ills.

  75. sure - but will it ever be done? by Anonymous Coward · · Score: 0

    Parrot is going nowhere fast. Too many philosophical debates about VM purity and goodness. Too many crazy ops. It's not a VM - it's an operating system that will never be finished. Perhaps it will run on Hurd one day.

  76. CP-67: The "original" virtual machine? by Renegade+English+Maj · · Score: 1
    I haven't seen any references here to what I believe was the "original" implementation of virtual machines -- a system that came out of IBM's Cambridge Research Center, and was eventually marketed for the 360/67 mainframe in the early 1970s as CP-67.

    Rather than running user programs, CP-67 multitasked operating systems. Each client system ran believing that it was operating in supervisor mode on a bare 360/65. In fact, the clients were all running in user mode. CP-67 trapped the privileged instructions (including all i/o instructions), which it emulated on behalf its clients; and it used the Model 67's Dynamic Address Translation unit (what we'd call a VMM today) to present a flat model of the 360's address space to each client operating system.

    CP-67 was neither a bytecode interpreter nor a full-fledged emulator. All programs were compiled into 360 machine code, and most instructions (all of the non-privileged ones) executed natively. IBM referred to the client environment as a "virtual machine." The flat address space presented to each client (which could magically exceed the amount of physical memory in the machine) they called "virtual memory."

    1. Re:CP-67: The "original" virtual machine? by Anonymous Coward · · Score: 0

      Are you kidding or what? The average /.'r thinks that the first computer ever was the IBM PC and the first OS was DOS. Thats why todays developers are still reinventing stuff that was perfected years ago on big iron.

    2. Re:CP-67: The "original" virtual machine? by Anonymous Coward · · Score: 0


      ... which is the direct forefather of the modern VM operating system on IBM mainframes (you know, the one under which "Mainframe linux" runs multiple instances). In fact the hypervisor is still called "CP". -- TWZ

  77. Still missing the point by alienmole · · Score: 2
    Here's a clue for you about the severe bug in your ability to do logic in your head: "improvement" does not equal "perfection". Garbage collection is an improvement, in terms of integrity, reliability, and safety. Having garbage collection is an improvement over not having it. That doesn't make it perfect, and no-one's claiming it is.

  78. Re:VMs in the OS clarification by miraj31415 · · Score: 1

    I guess I should clarify. I didn't mean that just 1 VM is running on top of the hardware. It would actually be 2 or 3 (or more) VMs running simultaneously with a native "VM" that is not really virtual but actually the API to the kernel. The VMs would be subject to scheduling (obviously) by the kernel.

  79. gcc tutorial for custom VM? by dannys42 · · Score: 1

    I'd like to see a good book on writing backends to gcc so that you don't also have to write your own VM compiler. I have the Using and Porting GCC book, and admittedly I've yet to really sit down and go through it thoroughly, but it doesn't seem to make it plainly obvious to me just how you make gcc aware of what opcodes your system needs.

  80. EVEN MY 5 YEARS SON KNOWS MORE THAN YOU by ajaimes · · Score: 1

    I can't believe how this guy got a job! Man, when C dies your VB also will because VB creators will not be able to continue making your program! Damn, I don't know what to say about all this STUPID comment... man are you a lawyer? or maybe a sailor? because this is a tech/programmers site... just if you didn't know it.

  81. don't waste your time by dmoen · · Score: 2
    The reviewer said: Blunden makes sure to cover every topic related to virtual machines in extreme depth. ... Released in March 2002, this book is extremely up to date.

    I couldn't agree less. I flipped through the book in the bookstore, and I wasn't impressed. Blunden is a C/Assembly language programmer with little understanding of the requirements that a modern programming language places on a virtual machine. So his virtual machine is single threaded and runs in a fixed block of address space, with a fixed size code and data section, a growable stack, and a growable explicitly managed heap. This is fine if the target language is C or assembly language, but not so fine if you want garbage collection, threads, closures, first class continuations, or any of those other language features that were considered cutting edge back in the 1970s. How does his system link to external code, like the system calls in libc? Well, there are 11 "interrupts" called int0 through int10, sort of like the DOS system call interface.

    His explanation of why he doesn't support garbage collection is pretty muddled: basically, he's not comfortable with the idea, and doesn't think its practical.

    Although I think that a register machine probably is better than a stack machine for this kind of system, he gives none of the arguments I was expecting to see to support this design decision. Instead, we get vague handwaving: apparently, he's more comfortable with register machines, because that's what he's used to.

    Doug Moen

    --
    I have written a truly remarkable program which this sig is too small to contain.
    1. Re:don't waste your time by Anonymous Coward · · Score: 0

      Single threaded for portability; the only alternative is to implement a thread scheduler in user-space (which is also a bad idea, see Tanenbaum ). Using native thread schedulers gives inconsistent behavior!!!!

      No gc because of no threads!

      Registers because debugging is easier. If you screw up the stack, you are hosed! No artifacts!

      Go back and read the book again, goofball!

  82. Re:Virtual Machine (mostly OT) by ranulf · · Score: 1
    $DFF180? Ah, a (former?) Amiga user ;-)

    Indeed. But last time I touched my Amiga was sometime back in 1994 (just after I discovered UNIX :-) when I wrote this. At some point I really do need to go through my old floppy collection and transfer all my old source code to a UAE-able form before it gets irretrievably lost.

    Back on topic: Somewhere, I started on a Spectrum emulator that managed to emulate the weird Speccy screen layout by using the copper - the alternative at the time had to re-draw the screen every few frames, which really killed emulation speed.

    But I guess that illustrates the point nicely between an emulator and a VM. The side effect of changing a single byte could means lots of work for the emulator, whereas changing another byte at some other address with the same instruction could just be as simple as storing the data.

  83. Try Smalltalk (VisualWorks & VisualAge) VMs by crovira · · Score: 2

    They make the Java and php VMs look like the Johnny-come-lately's that they are. (Sorry Squeak! Wa-ay too slow.)

    Blazing fast object allocation (both) interning & loading (VA by a nose,) and both have a full IDE that the others have been trying to achieve since Smalltalk'80 came out.

    But remember thei're IDEs not production/delivery. For that you want internationalizable, database drivable GUIs, dialog managers, state machine and transition engines.

    All in all. Look at VW & VA and weep. (Or better yet learn.) They've been at it since the days of UCSD Pascal. They've forgot more than you'll ever know.

    --
    MSBPodcast.com The opinions expressed here are my own. If you don't like 'em... Think up your own stuff.
  84. Check out VMGen by ralphbecket · · Score: 1

    Anyone seriously interested in VM work should take a look at VMGen, which does a great deal of the hard work for you and produces high quality output.

  85. Perl uses a VM? by Anonymous Coward · · Score: 0

    Perl Uses a VM?

  86. +3 Insighful? Smoke another one by Anonymous Coward · · Score: 0

    +3 Insighful for an incorrect statement?

  87. micro-/green threads in Python by Rozzin · · Score: 1
    Are there any VMs currently, for Java, Python or some other language, that can execute each thread one VM instruction at a time?


    There are a couple of different options for doing this in Python:

    One is to use Christian Tismer's `Stackless Python'--the `uthread' module, if I recall correctly, allows the Python programmer to step op-by-op.

    The other method is to use Python 2.3's generators (via the `yield' statement) (via the `from __future__ import generators' statement in Python 2.2).

    There's an IBM-developerWorks article on the latter technique.
    --
    -rozzin.