A Basis for Ubiquitous Virtual Machines

A Basis for Ubiquitous Virtual Machines

Mite a basis for ubiquitous virtual machines Reuben Rhys Thomas St John's College A dissertation submitted for the Ph.D. degree November 2000 Ars est celare artem To Basil Rose, who did it first, and Tony Thomas, who hooked me. Preface Mite is a virtual machine intended to provide fast language and machine-neutral just-in-time translation of binary-portable object code into high quality native code, with a formal foundation. Chapter 1 discusses the need for fast good quality translation of portable code at run time, and, having considered what functionality is needed, sets out a list of goals that Mite should reach, then states the contribution of the thesis. Chapter 2 discusses related work, concentrating on the extent to which the various systems examined fulfil Mite's goals. Chapter 3 elaborates Mite's design, and chapter 4 anal- yses the choices that it makes. Chapter 5 examines the implementation, consisting of a C compiler back end targeting Mite and a virtual code translator for the ARM processor, and shows how it could be extended to other languages and processors. Chapter 6 describes and analyses a series of tests performed on the implementation, then assesses both the design and implementation in their light. Chapter 7 describes future work; finally, chapter 8 concludes the thesis with an appraisal of how well Mite meets its goals, and a final perspective. Appendices A–C give Mite's definition, appendix 6.1 lists two of the benchmark programs used in chapter 6, and appendix E gives the data collected from the tests. This dissertation is my own work and includes nothing resulting from collabora- tion. I owe many thanks. Alistair Turnbull's keen insight, blunt criticism and imagi- native advice elaborated in many hours of enjoyable discussion have cheered and smoothed my path. Simon Peyton Jones has been a smiling source of balanced en- couragement and criticism. Eugenia Cheng once again ran her merciless eagle eye over my text. Martin Richards supervised me with a light hand, and lit the murk of bureaucracy. Several kindly souls gave useful advice and help with tools, ideas and language; in particular, Dave Hanson and Chris Fraser advised me far beyond the call of duty in my abuse of their LCC compiler, and Arthur Norman gave useful advice on the shape a thesis should have. i ii Contents 1 Introduction 1 1.1 Motivation . 1 1.2 Scope and goals . 2 1.2.1 Required functionality . 2 1.2.2 Goals . 3 1.2.3 Non-goals . 4 1.3 Contribution of this thesis . 4 2 Context 6 2.1 Java VM . 6 2.2 Dis . 7 2.3 VCODE . 8 2.4 ANDF . 9 2.5 ¢¡£¡ . 10 2.6 TAL and TALx86 . 11 2.7 Other systems . 12 2.8 Comparison . 16 3 Design 18 3.1 Architecture . 18 3.1.1 Quantities . 18 3.1.1.1 Offsets and sizes . 18 3.1.2 Memory . 19 3.1.3 Stack . 19 3.1.4 The flags . 20 3.2 Instruction set . 20 3.2.1 Creating and destroying stack items . 20 3.2.2 Register assignment . 20 3.2.3 Data processing . 21 3.2.3.1 Simple arithmetic . 21 3.2.3.2 Division . 21 3.2.3.3 Logic and shifts . 22 3.2.3.4 Comparisons . 22 3.2.4 Addressing memory . 22 3.2.5 Branching . 23 iii Contents 3.2.6 Subroutines . 23 3.2.7 Functions . 24 3.2.8 Non-local exit . 26 3.2.9 Escape . 27 3.2.10 optimization directives . 27 3.3 Data . 27 3.4 Object format . 27 3.5 Pitfalls . 28 4 Rationale 30 4.1 Architecture . 30 4.1.1 Load-store three-address register model . 30 4.1.2 Memory . 32 4.1.3 Three-component numbers . 33 4.2 Registers . 34 4.2.1 Unlimited virtual registers . 34 4.2.2 Stack . 35 4.2.3 Numbering . 37 4.2.4 Sizes . 38 4.2.5 Constants . 38 4.3 The instruction set . 38 4.3.1 Registers . 39 4.3.1.1 Creation and destruction . 39 4.3.1.2 Ranking . 40 4.3.1.3 ¢¡¤£¦¥¨§ © . 41 4.3.2 Flags . 42 4.3.3 Function calling . 43 4.3.4 Division . 43 4.3.5 Escape . 44 4.3.6 Seeming superfluities . 44 ¤ 4.3.6.1 and . 44 ¢ 4.3.6.2 . 48 4.4 Object format . 48 4.5 Semantics . 49 4.6 Shortcomings . 49 4.7 Summary . 50 5 Implementation 52 5.1 Mite's components . 52 5.1.1 Assembler . 53 5.1.2 Translator . 53 5.1.3 Compiler back end . 54 5.1.4 Run-time system . 54 5.1.5 Standard library access . 54 iv Contents 5.2 A sample translation . 55 5.2.1 C code . 55 5.2.2 Translation to Mite virtual code . 55 5.2.3 Translation to ARM assembly . 59 5.2.3.1 Idiosyncratic code . 61 5.2.3.2 Physical register usage . 62 5.2.3.3 Immediate constants . 63 5.2.3.4 Address constants . 63 5.2.3.5 Register allocation and spilling . 63 5.2.4 Summary . 65 5.3 Optimizing compilation . 65 5.3.1 The test program . 65 5.3.2 LCC-style optimization . 66 5.3.3 GNU C-style optimization . 67 5.3.3.1 Hits . 68 5.3.3.2 Misses . 70 5.4 Other languages . 70 5.4.1 Static chains . 71 5.4.1.1 Putting variables in a chunk . 72 5.4.1.2 Walking the stack . 72 5.4.2 Exceptions . 73 5.4.2.1 C style exceptions . 73 5.4.2.2 Java style exceptions . 74 5.4.2.3 ML style exceptions . 75 5.4.3 Garbage collection . 76 5.4.3.1 Reference counting . 76 5.4.3.2 Conservative . 76 5.4.3.3 Accurate tracing . 76 5.5 Other target processors . 77 5.5.1 Flags without a dedicated register . 77 5.5.2.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    180 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us