Metaprogramming: Interpretaaon Interpreters

Total Page:16

File Type:pdf, Size:1020Kb

Metaprogramming: Interpretaaon Interpreters How to implement a programming language Metaprogramming InterpretaAon An interpreter wriDen in the implementaAon language reads a program wriDen in the source language and evaluates it. These slides borrow heavily from Ben Wood’s Fall ‘15 slides. TranslaAon (a.k.a. compilaAon) An translator (a.k.a. compiler) wriDen in the implementaAon language reads a program wriDen in the source language and CS251 Programming Languages translates it to an equivalent program in the target language. Spring 2018, Lyn Turbak But now we need implementaAons of: Department of Computer Science Wellesley College implementaAon language target language Metaprogramming 2 Metaprogramming: InterpretaAon Interpreters Source Program Interpreter = Program in Interpreter Machine M virtual machine language L for language L Output on machine M Data Metaprogramming 3 Metaprogramming 4 Metaprogramming: TranslaAon Compiler C Source x86 Target Program C Compiler Program if (x == 0) { cmp (1000), $0 Program in Program in x = x + 1; bne L language A } add (1000), $1 A to B translator language B ... L: ... x86 Target Program x86 computer Output Interpreter Machine M Thanks to Ben Wood for these for language B Data and following pictures on machine M Metaprogramming 5 Metaprogramming 6 Interpreters vs Compilers Java Compiler Interpreters No work ahead of Lme Source Target Incremental Program Java Compiler Program maybe inefficient if (x == 0) { load 0 Compilers x = x + 1; ifne L } load 0 All work ahead of Lme ... inc See whole program (or more of program) store 0 Time and resources for analysis and opLmizaLon L: ... (compare compiled C to compiled Java) Metaprogramming 7 Metaprogramming 8 Compilers... whose output is interpreted Interpreters... that use compilers. Source Target Source Program Java Compiler Program Program Compiler Target Target Program Program Virtual Output Java Machine Virtual Output Machine Data Data Doesn’t this look familiar? Metaprogramming 9 Metaprogramming 10 JIT Compilers and OpAmizaAon Virtual Machine Model Source Program High-Level Language Program • HotSpot JVM Just In Time • Jikes RVM Ahead-of-Lme Compiler Bytecode Compiler • SpiderMonkey compiler compiler • v8 compile Ame • Transmeta Virtual Machine Language run Ame Target Performance • ... JIT Program Monitor Virtual machine compiler Output (interpreter) Virtual Machine Data NaLve Machine Language Metaprogramming 11 Metaprogramming 12 Typical Compiler How to implement a programming language Can describe by deriving a “proof” of the implementaLon Source Lexical Analyzer Program using these inference rules: Syntax Analyzer Interpreter Rule Semantic Analyzer Analysis P-in-L program L interpreter machine P machine Intermediate Code Synthesis Generator Translator Rule Code Optimizer P-in-S program S-to-T translator machine Code Generator P-in-T program Target Program Metaprogramming 13 Metaprogramming 14 ImplementaAon DerivaAon Example ImplementaAon DerivaAon Example SoluAon Prove how to implement a "251 web page machine" using: • 251-web-page-in-HTML program (a web page wriDen in HTML) • HTML-interpreter-in-C program (a web browser wriDen in C) • C-to-x86-translator-in-x86 program (a C compiler wriDen in x86) • x86 interpreter machine (an x86 computer) We can omit some occurrences of “program” and “machine”: No peaking ahead! Metaprogramming 15 Metaprogramming 16 ImplementaAon DerivaAon Are Trees DerivaAon Exercise And so we can represent them as nested structures, like nested bulleted lists: How to execute the Racket factorial o factorial-in-Racket program program given these parts? o Racket-to-Python-translator-in-Python program q 251-web-page-in-HTML program o Python-interpreter-in-C program Version that shows o HTML-interpreter-in-C program o C-to-x86-translator-in-x86 program conclusions below bullets. Warning: cannot start • C-to-x86 compiler-in-x86 program o x86 computer (i.e., x86 interpreter machine) • X86 computer More similar to derivaLons the following way: with horizontal lines, but o C-to-x86 compiler machine (I) harder to create and read factorial machine (I) ² HTML-interpreter-in-x86 program (T) q factorial-in-Racket program ² x86 computer q Racket interpreter machine (I) q HTML interpreter machine (I) …. 251 web page machine (I) Why not? 251 web page machine (I) Preferred “top-down” q 251-web-page-in-HTML program version that shows q HTML interpreter machine (I) conclusions above bullets. ² HTML-interpreter-in-x86 program (T) o HTML-interpreter-in-C program o C-to-x86 compiler machine (I) • C-to-x86 compiler-in-x86 program • X86 computer ² x86 computer Metaprogramming 17 Metaprogramming 18 DerivaAon Exercise: SoluAon Metaprogramming: Bootstrapping Puzzles How to execute the Racket factorial o factorial-in-Racket program program given these parts? o Racket-to-Python-translator-in-Python program o Python-interpreter-in-C program How can a Racket interpreter be wriDen in Racket? o C-to-x86-translator-in-x86 program Put your soluAon here: o x86 computer (i.e., x86 interpreter machine) How can a Java compiler be wriDen in Java? How can gcc (a C-to-x86 compiler) be wriDen in C? Metaprogramming 19 Metaprogramming 20 Metacircularity and Bootstrapping Metacircularity Example 1: Problem Many examples: Suppose you are given: • Lisp in Lisp / Scheme in Scheme/Racket in Racket • Racket-interpreter-in-Python program • Python in Python: PyPy • Python machine • Java in Java: Jikes RVM, Maxine VM • Racket-interpreter-in-Racket program • … How do you create a Racket interpreter machine using the • C-to-x86 compiler in C: gcc Racket-interpreter-in-Racket program? • eval construct in languages like Lisp, JavaScript How can this be possible? Key insights to bootstrapping: • The first implementaLon of a language cannot be in itself, but must be in some other language. • Once you have one implementaLon of a language L, you can can implement (enhanced versions of) L in L. Metaprogramming 21 Metaprogramming 22 Metacircularity Example 1: SoluAon Metacircularity Example 1: More RealisAc Suppose you are given: Suppose you are given: • Racket-interpreter-in-Python program • Racket-subset-interpreter-in-Python program (implements • Python machine only core Racket features; no desugaring or other frills) • Racket-interpreter-in-Racket program • Python machine How do you create a Racket interpreter machine using the • Full-Racket-interpreter-in-Racket-subset program Racket-interpreter-in-Racket program? How do you create a Full-Racket interpreter machine using the Full-Racket-interpreter-in-Racket-subset program? Racket interpreter machine #2 (I) q Racket-interpreter-in-Racket program Full-Scheme interpreter machine (I) q Racket-interpreter machine #1 (I) q Full-Racket-interpreter-in-Racket-subset program ² Racket-interpreter-in-Python program q Racket-subset interpreter machine #1 (I) ² Python machine ² Racket-subset-interpreter-in-Python program ² Python machine But why create Racket interpreter machine #2 when you already have Racket-interpreter machine #1? Metaprogramming 23 Metaprogramming 24 Metacircularity Example 2: Problem Metacircularity Example 2: SoluAon Suppose you are given: Suppose you are given: • C-to-x86-translator-in-x86 program (a C compiler wriDen in x86) • C-to-x86-translator-in-x86 program (a C compiler wriDen in x86) • x86 interpreter machine (an x86 computer) • x86 interpreter machine (an x86 computer) • C-to-x86-translator-in-C program • C-to-x86-translator-in-C program How do you compile the C-to-x86-translator-in-C ? How do you compile the C-to-x86-translator-in-C ? C-to-x86-translator machine #2 (I) q C-to-x86-translator-in-x86 program #2 (T) ² C-to-x86-translator-in-C ² C-to-x86-translator machine #1 (I) o C-to-x86-translator-in-x86 program #1 o x86 computer q x86 computer But why create C-to-x86-translator-in-x86 program #2 (T) when you already have C-to-x86-translator-in-x86 program #1? Metaprogramming 25 Metaprogramming 26 A long line of C compilers Metacircularity Example 2: More RealisAc C-version_n-to-target_n-translator machine (I) Suppose you are given: q C-version_n-to-target_n-translator program in target_n-1 (T) ² C-version_n-to-target_n-translator program in C-version_n-1 • C-subset-to-x86-translator-in-x86 program ² C-version_n-1-to-target_n-1 translator machine (I) (a compiler for a subset of C wriDen in x86) o C-version_n-1-to-target_n_1-translator program in target_n-2 (T) • x86 interpreter machine (an x86 computer) … • Full-C-to-x86-translator-in-C-subset program Ø C-version_2-to-target_2-translator-program in target_1 (T) (a compiler for the full C language wriDen in a subset of C) § C-version_2-to-target_2-translator program in C-version_1 How do you create a Full-C-to-x86-translator machine ? § C-version_1-to-target_1 translator machine (I) • C-version_1-to-target_1-translator program in assembly_0 Full-C-to-x86-translator machine (I) • assembly_0 computer q Full-C-to-x86-translator-in-x86 program (T) Ø target_1 computer … ² Full-C-to-x86-translator-in-C-subset ² C-subset-to-x86-translator machine (I) o target_n-2 computer q target_n-1 computer o C-subset-to-x86-translator-in-x86 program o x86 computer o The versions of C and target languages can change at each stage. q x86 computer o Trojan horses from earlier source files can remain in translator machines even if they’re not in later source file! See Ken Thompson’s Reflec4on on Trus4ng Trust Metaprogramming 27 Metaprogramming 28 More Metaprogramming in SML Remember: language != implementaAon o We’ve already seen PostFix and s-expressions in • Easy to confuse "the way this language is usually Racket; next
Recommended publications
  • SJC – Small Java Compiler
    SJC – Small Java Compiler User Manual Stefan Frenz Translation: Jonathan Brase original version: 2011/06/08 latest document update: 2011/08/24 Compiler Version: 182 Java is a registered trademark of Oracle/Sun Table of Contents 1 Quick introduction.............................................................................................................................4 1.1 Windows...........................................................................................................................................4 1.2 Linux.................................................................................................................................................5 1.3 JVM Environment.............................................................................................................................5 1.4 QEmu................................................................................................................................................5 2 Hello World.......................................................................................................................................6 2.1 Source Code......................................................................................................................................6 2.2 Compilation and Emulation...............................................................................................................8 2.3 Details...............................................................................................................................................9
    [Show full text]
  • A Case for High Performance Computing with Virtual Machines
    A Case for High Performance Computing with Virtual Machines Wei Huangy Jiuxing Liuz Bulent Abaliz Dhabaleswar K. Panday y Computer Science and Engineering z IBM T. J. Watson Research Center The Ohio State University 19 Skyline Drive Columbus, OH 43210 Hawthorne, NY 10532 fhuanwei, [email protected] fjl, [email protected] ABSTRACT in the 1960s [9], but are experiencing a resurgence in both Virtual machine (VM) technologies are experiencing a resur- industry and research communities. A VM environment pro- gence in both industry and research communities. VMs of- vides virtualized hardware interfaces to VMs through a Vir- fer many desirable features such as security, ease of man- tual Machine Monitor (VMM) (also called hypervisor). VM agement, OS customization, performance isolation, check- technologies allow running different guest VMs in a phys- pointing, and migration, which can be very beneficial to ical box, with each guest VM possibly running a different the performance and the manageability of high performance guest operating system. They can also provide secure and computing (HPC) applications. However, very few HPC ap- portable environments to meet the demanding requirements plications are currently running in a virtualized environment of computing resources in modern computing systems. due to the performance overhead of virtualization. Further, Recently, network interconnects such as InfiniBand [16], using VMs for HPC also introduces additional challenges Myrinet [24] and Quadrics [31] are emerging, which provide such as management and distribution of OS images. very low latency (less than 5 µs) and very high bandwidth In this paper we present a case for HPC with virtual ma- (multiple Gbps).
    [Show full text]
  • A Light-Weight Virtual Machine Monitor for Blue Gene/P
    A Light-Weight Virtual Machine Monitor for Blue Gene/P Jan Stoessx{1 Udo Steinbergz1 Volkmar Uhlig{1 Jonathan Appavooy1 Amos Waterlandj1 Jens Kehnex xKarlsruhe Institute of Technology zTechnische Universität Dresden {HStreaming LLC jHarvard School of Engineering and Applied Sciences yBoston University ABSTRACT debugging tools. CNK also supports I/O only via function- In this paper, we present a light-weight, micro{kernel-based shipping to I/O nodes. virtual machine monitor (VMM) for the Blue Gene/P Su- CNK's lightweight kernel model is a good choice for the percomputer. Our VMM comprises a small µ-kernel with current set of BG/P HPC applications, providing low oper- virtualization capabilities and, atop, a user-level VMM com- ating system (OS) noise and focusing on performance, scal- ponent that manages virtual BG/P cores, memory, and in- ability, and extensibility. However, today's HPC application terconnects; we also support running native applications space is beginning to scale out towards Exascale systems of directly atop the µ-kernel. Our design goal is to enable truly global dimensions, spanning companies, institutions, compatibility to standard OSes such as Linux on BG/P via and even countries. The restricted support for standardized virtualization, but to also keep the amount of kernel func- application interfaces of light-weight kernels in general and tionality small enough to facilitate shortening the path to CNK in particular renders porting the sprawling diversity applications and lowering OS noise. of scalable applications to supercomputers more and more a Our prototype implementation successfully virtualizes a bottleneck in the development path of HPC applications.
    [Show full text]
  • Opportunities for Leveraging OS Virtualization in High-End Supercomputing
    Opportunities for Leveraging OS Virtualization in High-End Supercomputing Kevin T. Pedretti Patrick G. Bridges Sandia National Laboratories∗ University of New Mexico Albuquerque, NM Albuquerque, NM [email protected] [email protected] ABSTRACT formance, making modest virtualization performance over- This paper examines potential motivations for incorporating heads viable. In these cases,the increased flexibility that vir- virtualization support in the system software stacks of high- tualization provides can be used to support a wider range end capability supercomputers. We advocate that this will of applications, to enable exascale co-design research and increase the flexibility of these platforms significantly and development, and provide new capabilities that are not pos- enable new capabilities that are not possible with current sible with the fixed software stacks that high-end capability fixed software stacks. Our results indicate that compute, supercomputers use today. virtual memory, and I/O virtualization overheads are low and can be further mitigated by utilizing well-known tech- The remainder of this paper is organized as follows. Sec- niques such as large paging and VMM bypass. Furthermore, tion 2 discusses previous work dealing with the use of virtu- since the addition of virtualization support does not affect alization in HPC. Section 3 discusses several potential areas the performance of applications using the traditional native where platform virtualization could be useful in high-end environment, there is essentially no disadvantage to its ad- supercomputing. Section 4 presents single node native vs. dition. virtual performance results on a modern Intel platform that show that compute, virtual memory, and I/O virtualization 1.
    [Show full text]
  • Java (Programming Langua a (Programming Language)
    Java (programming language) From Wikipedia, the free encyclopedialopedia "Java language" redirects here. For the natural language from the Indonesian island of Java, see Javanese language. Not to be confused with JavaScript. Java multi-paradigm: object-oriented, structured, imperative, Paradigm(s) functional, generic, reflective, concurrent James Gosling and Designed by Sun Microsystems Developer Oracle Corporation Appeared in 1995[1] Java Standard Edition 8 Update Stable release 5 (1.8.0_5) / April 15, 2014; 2 months ago Static, strong, safe, nominative, Typing discipline manifest Major OpenJDK, many others implementations Dialects Generic Java, Pizza Ada 83, C++, C#,[2] Eiffel,[3] Generic Java, Mesa,[4] Modula- Influenced by 3,[5] Oberon,[6] Objective-C,[7] UCSD Pascal,[8][9] Smalltalk Ada 2005, BeanShell, C#, Clojure, D, ECMAScript, Influenced Groovy, J#, JavaScript, Kotlin, PHP, Python, Scala, Seed7, Vala Implementation C and C++ language OS Cross-platform (multi-platform) GNU General Public License, License Java CommuniCommunity Process Filename .java , .class, .jar extension(s) Website For Java Developers Java Programming at Wikibooks Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few impimplementation dependencies as possible.ble. It is intended to let application developers "write once, run ananywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to rurun on another. Java applications ns are typically compiled to bytecode (class file) that can run on anany Java virtual machine (JVM)) regardless of computer architecture. Java is, as of 2014, one of tthe most popular programming ng languages in use, particularly for client-server web applications, witwith a reported 9 million developers.[10][11] Java was originallyy developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems'Micros Java platform.
    [Show full text]
  • A Virtual Machine Environment for Real Time Systems Laboratories
    AC 2007-904: A VIRTUAL MACHINE ENVIRONMENT FOR REAL-TIME SYSTEMS LABORATORIES Mukul Shirvaikar, University of Texas-Tyler MUKUL SHIRVAIKAR received the Ph.D. degree in Electrical and Computer Engineering from the University of Tennessee in 1993. He is currently an Associate Professor of Electrical Engineering at the University of Texas at Tyler. He has also held positions at Texas Instruments and the University of West Florida. His research interests include real-time imaging, embedded systems, pattern recognition, and dual-core processor architectures. At the University of Texas he has started a new real-time systems lab using dual-core processor technology. He is also the principal investigator for the “Back-To-Basics” project aimed at engineering student retention. Nikhil Satyala, University of Texas-Tyler NIKHIL SATYALA received the Bachelors degree in Electronics and Communication Engineering from the Jawaharlal Nehru Technological University (JNTU), India in 2004. He is currently pursuing his Masters degree at the University of Texas at Tyler, while working as a research assistant. His research interests include embedded systems, dual-core processor architectures and microprocessors. Page 12.152.1 Page © American Society for Engineering Education, 2007 A Virtual Machine Environment for Real Time Systems Laboratories Abstract The goal of this project was to build a superior environment for a real time system laboratory that would allow users to run Windows and Linux embedded application development tools concurrently on a single computer. These requirements were dictated by real-time system applications which are increasingly being implemented on asymmetric dual-core processors running different operating systems. A real time systems laboratory curriculum based on dual- core architectures has been presented in this forum in the past.2 It was designed for a senior elective course in real time systems at the University of Texas at Tyler that combines lectures along with an integrated lab.
    [Show full text]
  • The Java® Language Specification Java SE 8 Edition
    The Java® Language Specification Java SE 8 Edition James Gosling Bill Joy Guy Steele Gilad Bracha Alex Buckley 2015-02-13 Specification: JSR-337 Java® SE 8 Release Contents ("Specification") Version: 8 Status: Maintenance Release Release: March 2015 Copyright © 1997, 2015, Oracle America, Inc. and/or its affiliates. 500 Oracle Parkway, Redwood City, California 94065, U.S.A. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. The Specification provided herein is provided to you only under the Limited License Grant included herein as Appendix A. Please see Appendix A, Limited License Grant. To Maurizio, with deepest thanks. Table of Contents Preface to the Java SE 8 Edition xix 1 Introduction 1 1.1 Organization of the Specification 2 1.2 Example Programs 6 1.3 Notation 6 1.4 Relationship to Predefined Classes and Interfaces 7 1.5 Feedback 7 1.6 References 7 2 Grammars 9 2.1 Context-Free Grammars 9 2.2 The Lexical Grammar 9 2.3 The Syntactic Grammar 10 2.4 Grammar Notation 10 3 Lexical Structure 15 3.1 Unicode 15 3.2 Lexical Translations 16 3.3 Unicode Escapes 17 3.4 Line Terminators 19 3.5 Input Elements and Tokens 19 3.6 White Space 20 3.7 Comments 21 3.8 Identifiers 22 3.9 Keywords 24 3.10 Literals 24 3.10.1 Integer Literals 25 3.10.2 Floating-Point Literals 31 3.10.3 Boolean Literals 34 3.10.4 Character Literals 34 3.10.5 String Literals 35 3.10.6 Escape Sequences for Character and String Literals 37 3.10.7 The Null Literal 38 3.11 Separators
    [Show full text]
  • GT-Virtual-Machines
    College of Design Virtual Machine Setup for CP 6581 Fall 2020 1. You will have access to multiple College of Design virtual machines (VMs). CP 6581 will require VMs with ArcGIS installed, and for class sessions we will start the semester using the K2GPU VM. You should open each VM available to you and check to see if ArcGIS is installed. 2. Here are a few general notes on VMs. a. Because you will be a new user when you first start a VM, you may be prompted to set up Microsoft Explorer, Microsoft Edge, Adobe Creative Suite, or other software. You can close these windows and set up specific software later, if you wish. b. Different VMs allow different degrees of customization. To customize right-click on an empty Desktop area and choose “Personalize”. Change your background to a solid color that’s a distinctive color so you can easily distinguish your virtual desktop from your local computer’s desktop. Some VMs will remember your desktop color, other VMs must be re-set at each login, other VMs won’t allow you to change the background color but may allow you to change a highlight color from the “Colors” item on the left menu just below “Background”. c. Your desktop will look exactly the same as physical computer’s desktop except for the small black rectangle at the middle of the very top of the VM screen. Click on the rectangle and a pop-down horizontal menu of VM options will appear. Here are two useful options. i. Preferences then File Access will allow you to grant VM access to your local computer’s drives and files.
    [Show full text]
  • Building Useful Program Analysis Tools Using an Extensible Java Compiler
    Building Useful Program Analysis Tools Using an Extensible Java Compiler Edward Aftandilian, Raluca Sauciuc Siddharth Priya, Sundaresan Krishnan Google, Inc. Google, Inc. Mountain View, CA, USA Hyderabad, India feaftan, [email protected] fsiddharth, [email protected] Abstract—Large software companies need customized tools a specific task, but they fail for several reasons. First, ad- to manage their source code. These tools are often built in hoc program analysis tools are often brittle and break on an ad-hoc fashion, using brittle technologies such as regular uncommon-but-valid code patterns. Second, simple ad-hoc expressions and home-grown parsers. Changes in the language cause the tools to break. More importantly, these ad-hoc tools tools don’t provide sufficient information to perform many often do not support uncommon-but-valid code code patterns. non-trivial analyses, including refactorings. Type and symbol We report our experiences building source-code analysis information is especially useful, but amounts to writing a tools at Google on top of a third-party, open-source, extensible type-checker. Finally, more sophisticated program analysis compiler. We describe three tools in use on our Java codebase. tools are expensive to create and maintain, especially as the The first, Strict Java Dependencies, enforces our dependency target language evolves. policy in order to reduce JAR file sizes and testing load. The second, error-prone, adds new error checks to the compilation In this paper, we present our experience building special- process and automates repair of those errors at a whole- purpose tools on top of the the piece of software in our codebase scale.
    [Show full text]
  • Functional SMT Solving: a New Interface for Programmers
    Functional SMT solving: A new interface for programmers A thesis submitted in Partial Fulfillment of the Requirements for the Degree of Master of Technology by Siddharth Agarwal to the DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING INDIAN INSTITUTE OF TECHNOLOGY KANPUR June, 2012 v ABSTRACT Name of student: Siddharth Agarwal Roll no: Y7027429 Degree for which submitted: Master of Technology Department: Computer Science & Engineering Thesis title: Functional SMT solving: A new interface for programmers Name of Thesis Supervisor: Prof Amey Karkare Month and year of thesis submission: June, 2012 Satisfiability Modulo Theories (SMT) solvers are powerful tools that can quickly solve complex constraints involving booleans, integers, first-order logic predicates, lists, and other data types. They have a vast number of potential applications, from constraint solving to program analysis and verification. However, they are so complex to use that their power is inaccessible to all but experts in the field. We present an attempt to make using SMT solvers simpler by integrating the Z3 solver into a host language, Racket. Our system defines a programmer’s interface in Racket that makes it easy to harness the power of Z3 to discover solutions to logical constraints. The interface, although in Racket, retains the structure and brevity of the SMT-LIB format. We demonstrate this using a range of examples, from simple constraint solving to verifying recursive functions, all in a few lines of code. To my grandfather Acknowledgements This project would have never have even been started had it not been for my thesis advisor Dr Amey Karkare’s help and guidance. Right from the time we were looking for ideas to when we finally had a concrete proposal in hand, his support has been invaluable.
    [Show full text]
  • SUBJECT-COMPUTER CLASS-12 CHAPTER 9 – Compiling and Running Java Programs
    SUBJECT-COMPUTER CLASS-12 CHAPTER 9 – Compiling and Running Java Programs Introduction to Java programming JAVA was developed by Sun Microsystems Inc in 1991, later acquired by Oracle Corporation. It was developed by James Gosling and Patrick Naughton. It is a simple programming language. Writing, compiling and debugging a program is easy in java. It helps to create modular programs and reusable code. Bytecode javac compiler of JDK compiles the java source code into bytecode so that it can be executed by JVM. The bytecode is saved in a .class file by compiler. Java Virtual Machine (JVM) This is generally referred as JVM. Before, we discuss about JVM lets see the phases of program execution. Phases are as follows: we write the program, then we compile the program and at last we run the program. 1) Writing of the program is of course done by java programmer. 2) Compilation of program is done by javac compiler, javac is the primary java compiler included in java development kit (JDK). It takes java program as input and generates java bytecode as output. 3) In third phase, JVM executes the bytecode generated by compiler. This is called program run phase. So, now that we understood that the primary function of JVM is to execute the bytecode produced by compiler. Characteristics of Java Simple Java is very easy to learn, and its syntax is simple, clean and easy to understand. Multi-threaded Multithreading capabilities come built right into the Java language. This means it is possible to build highly interactive and responsive apps with a number of concurrent threads of activity.
    [Show full text]
  • Feature-Specific Profiling
    Feature-Specific Profiling LEIF ANDERSEN, PLT @ Northeastern University, United States of America VINCENT ST-AMOUR, PLT @ Northwestern University, United States of America JAN VITEK, Northeastern University and Czech Technical University MATTHIAS FELLEISEN, PLT @ Northeastern University, United States of America While high-level languages come with significant readability and maintainability benefits, their performance remains difficult to predict. For example, programmers may unknowingly use language features inappropriately, which cause their programs to run slower than expected. To address this issue, we introduce feature-specific profiling, a technique that reports performance costs in terms of linguistic constructs. Festure-specific profilers help programmers find expensive uses of specific features of their language. We describe the architecture ofa profiler that implements our approach, explain prototypes of the profiler for two languages withdifferent characteristics and implementation strategies, and provide empirical evidence for the approach’s general usefulness as a performance debugging tool. ACM Reference Format: Leif Andersen, Vincent St-Amour, Jan Vitek, and Matthias Felleisen. 2018. Feature-Specific Profiling. 1,1 (September 2018), 35 pages. https://doi.org/10.1145/nnnnnnn.nnnnnnn 1 PROFILING WITH ACTIONABLE ADVICE When programs take too long to run, programmers tend to reach for profilers to diagnose the problem. Most profilers attribute the run-time costs during a program’s execution to cost centers such as function calls or statements in source code. Then they rank all of a program’s cost centers in order to identify and eliminate key bottlenecks (Amdahl 1967). If such a profile helps programmers optimize their code, we call it actionable because it points to inefficiencies that can be remedied with changes to the program.
    [Show full text]