1. Trang chủ
  2. » Ngoại Ngữ

Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman-Compilers - Principles, Techniques, and Tools-Pearson_Addison Wesley (2006)

1K 0 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Compilers Principles, Techniques, & Tools Second Edition This page intentionally left blank Compilers Principles, Techniques, & Tools Second Edition Alfred V Aho Columbia University Monica S Lam Stanford University Ravi Sethi Avaya Jeffrey D Ullman Stanford University Publisher Executive Editor Acquisitions Editor Project Editor Associate Managing Editor Cover Designer Digital Assets Manager Media Producer Senior Marketing Manager Marketing Assistant Senior Author Support/ Technology Specialist Senior Manufacturing Buyer Greg Tobin Michael Hirsch Matt Goldstein Katherine Harutunian Jeffrey Holcomb Joyce Cosentino Wells Marianne Groth Bethany Tidd Michelle Brown Sarah Milmore Cover Image Scott Ullman of Strange Tonic Productions (www.strangetonic.com) Joe Vetere Carol Melville Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed in initial caps or all caps This interior of this book was composed in LATEX Library of Congress Cataloging-in-Publication Data Compilers : principles, techniques, and tools / Alfred V Aho [et al.] 2nd ed p cm Rev ed of: Compilers, principles, techniques, and tools / Alfred V Aho, Ravi Sethi, Jeffrey D Ullman 1986 ISBN 0-321-48681-1 (alk paper) Compilers (Computer programs) I Aho, Alfred V II Aho, Alfred V Compilers, principles, techniques, and tools QA76.76.C65A37 2007 005.4'53 dc22 2006024333 Copyright © 2007 Pearson Education, Inc All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher Printed in the United States of America For information on obtaining permission for use of material in this work, please submit a written request to Pearson Education, Inc., Rights and Contracts Department, 75 Arlington Street, Suite 300, Boston, MA 02116, fax your request to 617-848-7047, or e-mail at http://www.pearsoned.com/legal/permissions.htm 10—CW—10 09 08 07 06 Preface In the time since the 1986 edition of this book, the world of compiler design has changed signi cantly Programming languages have evolved to present new compilation problems Computer architectures o er a variety of resources of which the compiler designer must take advantage Perhaps most interestingly, the venerable technology of code optimization has found use outside compilers It is now used in tools that nd bugs in software, and most importantly, nd security holes in existing code And much of the \front-end" technology | grammars, regular expressions, parsers, and syntax-directed translators | are still in wide use Thus, our philosophy from previous versions of the book has not changed We recognize that few readers will build, or even maintain, a compiler for a major programming language Yet the models, theory, and algorithms associated with a compiler can be applied to a wide range of problems in software design and software development We therefore emphasize problems that are most commonly encountered in designing a language processor, regardless of the source language or target machine Use of the Book It takes at least two quarters or even two semesters to cover all or most of the material in this book It is common to cover the rst half in an undergraduate course and the second half of the book | stressing code optimization | in a second course at the graduate or mezzanine level Here is an outline of the chapters: Chapter contains motivational material and also presents some background issues in computer architecture and programming-language principles Chapter develops a miniature compiler and introduces many of the important concepts, which are then developed in later chapters The compiler itself appears in the appendix Chapter covers lexical analysis, regular expressions, nite-state machines, and scanner-generator tools This material is fundamental to text-processing of all sorts v vi PREFACE Chapter covers the major parsing methods, top-down (recursive-descent, LL) and bottom-up (LR and its variants) Chapter introduces the principal ideas in syntax-directed de nitions and syntax-directed translations Chapter takes the theory of Chapter and shows how to use it to generate intermediate code for a typical programming language Chapter covers run-time environments, especially management of the run-time stack and garbage collection Chapter is on object-code generation It covers construction of basic blocks, generation of code from expressions and basic blocks, and register-allocation techniques Chapter introduces the technology of code optimization, including ow graphs, data- ow frameworks, and iterative algorithms for solving these frameworks Chapter 10 covers instruction-level optimization The emphasis is on the extraction of parallelism from small sequences of instructions and scheduling them on single processors that can more than one thing at once Chapter 11 talks about larger-scale parallelism detection and exploitation Here, the emphasis is on numeric codes that have many tight loops that range over multidimensional arrays Chapter 12 is on interprocedural analysis It covers pointer analysis, aliasing, and data- ow analysis that takes into account the sequence of procedure calls that reach a given point in the code Courses from material in this book have been taught at Columbia, Harvard, and Stanford At Columbia, a senior/ rst-year graduate course on programming languages and translators has been regularly o ered using material from the rst eight chapters A highlight of this course is a semester-long project in which students work in small teams to create and implement a little language of their own design The student-created languages have covered diverse application domains including quantum computation, music synthesis, computer graphics, gaming, matrix operations and many other areas Students use compiler-component generators such as ANTLR, Lex, and Yacc and the syntaxdirected translation techniques discussed in chapters two and ve to build their compilers A follow-on graduate course has focused on material in Chapters through 12, emphasizing code generation and optimization for contemporary machines including network processors and multiprocessor architectures At Stanford, a one-quarter introductory course covers roughly the material in Chapters through 8, although there is an introduction to global code optimization from Chapter The second compiler course covers Chapters through 12, plus the more advanced material on garbage collection from Chapter Students use a locally developed, Java-based system called Joeq for implementing data- ow analysis algorithms PREFACE vii Prerequisites The reader should possess some \computer-science sophistication," including at least a second course on programming, and courses in data structures and discrete mathematics Knowledge of several di erent programming languages is useful Exercises The book contains extensive exercises, with some for almost every section We indicate harder exercises or parts of exercises with an exclamation point The hardest exercises have a double exclamation point Gradiance On-Line Homeworks A feature of the new edition is that there is an accompanying set of on-line homeworks using a technology developed by Gradiance Corp Instructors may assign these homeworks to their class, or students not enrolled in a class may enroll in an \omnibus class" that allows them to the homeworks as a tutorial (without an instructor-created class) Gradiance questions look like ordinary questions, but your solutions are sampled If you make an incorrect choice you are given speci c advice or feedback to help you correct your solution If your instructor permits, you are allowed to try again, until you get a perfect score A subscription to the Gradiance service is o ered with all new copies of this text sold in North America For more information, visit the Addison-Wesley web site www.aw.com/gradiance or send email to computing@aw.com Support on the World Wide Web The book's home page is dragonbook.stanford.edu Here, you will nd errata as we learn of them, and backup materials We hope to make available the notes for each o ering of compiler-related courses as we teach them, including homeworks, solutions, and exams We also plan to post descriptions of important compilers written by their implementers Acknowledgements Cover art is by S D Ullman of Strange Tonic Productions Jon Bentley gave us extensive comments on a number of chapters of an earlier draft of this book Helpful comments and errata were received from: viii PREFACE Domenico Bianculli, Peter Bosch, Marcio Buss, Marc Eaddy, Stephen Edwards, Vibhav Garg, Kim Hazelwood, Gaurav Kc, Wei Li, Mike Smith, Art Stamness, Krysta Svore, Olivier Tardieu, and Jia Zeng The help of all these people is gratefully acknowledged Remaining errors are ours, of course In addition, Monica would like to thank her colleagues on the SUIF compiler team for an 18-year lesson on compiling: Gerald Aigner, Dzintars Avots, Saman Amarasinghe, Jennifer Anderson, Michael Carbin, Gerald Cheong, Amer Diwan, Robert French, Anwar Ghuloum, Mary Hall, John Hennessy, David Heine, Shih-Wei Liao, Amy Lim, Benjamin Livshits, Michael Martin, Dror Maydan, Todd Mowry, Brian Murphy, Je rey Oplinger, Karen Pieper, Martin Rinard, Olatunji Ruwase, Constantine Sapuntzakis, Patrick Sathyanathan, Michael Smith, Steven Tjiang, Chau-Wen Tseng, Christopher Unkel, John Whaley, Robert Wilson, Christopher Wilson, and Michael Wolf A V A., Chatham NJ M S L., Menlo Park CA R S., Far Hills NJ J D U., Stanford CA June, 2006 Table of Contents Introduction 1.1 Language Processors 1.1.1 Exercises for Section 1.1 1.2 The Structure of a Compiler 1.2.1 Lexical Analysis 1.2.2 Syntax Analysis 1.2.3 Semantic Analysis 1.2.4 Intermediate Code Generation 1.2.5 Code Optimization 1.2.6 Code Generation 1.2.7 Symbol-Table Management 1.2.8 The Grouping of Phases into Passes 1.2.9 Compiler-Construction Tools 1.3 The Evolution of Programming Languages 1.3.1 The Move to Higher-level Languages 1.3.2 Impacts on Compilers 1.3.3 Exercises for Section 1.3 1.4 The Science of Building a Compiler 1.4.1 Modeling in Compiler Design and Implementation 1.4.2 The Science of Code Optimization 1.5 Applications of Compiler Technology 1.5.1 Implementation of High-Level Programming Languages 1.5.2 Optimizations for Computer Architectures 1.5.3 Design of New Computer Architectures 1.5.4 Program Translations 1.5.5 Software Productivity Tools 1.6 Programming Language Basics 1.6.1 The Static/Dynamic Distinction 1.6.2 Environments and States 1.6.3 Static Scope and Block Structure 1.6.4 Explicit Access Control 1.6.5 Dynamic Scope 1.6.6 Parameter Passing Mechanisms ix 1 8 10 10 11 11 12 12 13 14 14 15 15 15 17 17 19 21 22 23 25 25 26 28 31 31 33 INDEX 996 Constraint See Control-dependence constraint, Data dependence, Resource constraint Context sensitivity 906{908, 945{951 Context-free grammar See Grammar Context-free language 200, 215{216 Context-sensitive analysis 906{907, 945{950 Contiguous evaluation 574 Continue-statement 416{417 Control equivalence 728 Control ow 399{409, 413{417, 525 Control link 434 Control-dependence constraint 710, 716{717 Control- ow equation 600, 605 Convex polyhedron 789{790, 795{ 796 Cook, B 962 Cooper, K D 580, 963 Copy propagation 590{591 Copy statement 544, 937 Copying garbage collector 478{482, 488, 497{498 Corasick, M J 189{190 Cousot, P 704 Cousot, R 704 C++ 13, 18, 34, 498 Critical cycle 758 Critical edge 643 Critical path 725 Cross edge 662 CUP 300, 302 Cutset 645 Cyclic garbage 488 CYK algorithm See Cocke-Younger-Kasami algorithm Cytron, R 704, 900 D DAG 359{362, 533{541, 951 Dain, J 300{301 Dalton, M 962 Dangling else 210{212, 281{283 Dangling pointer 461 Dantzig, G 900 Das, M 961, 963 Data abstraction 18 Data dependence 711{715, 732, 747{ 749, 771, 781{782, 804{805, 815{826 See also Antidependence, Output dependence, True dependence Data locality 891{892 See also Locality Data reuse 804{815, 887{888 Data space 779{780 Data-dependence graph 722{723 Data- ow analysis 18, 23, 597{705, 921 Data- ow analysis framework 618 Datalog 921{933 Datalog program 923 Davidson, E S 767 Dead code 533, 535, 550, 591{592 Dead state 172, 183 Dead variable 608 Deallocation, of memory 453, 460{ 463 Declaration 32, 373, 376 Declarative language 13 Decode 708 Def 609 De nition 32 De nition, of a variable 601 Dependency graph 310{312 Depth, of a ow graph 665 Depth- rst order 660 Depth- rst search 57 Depth- rst spanning tree 660 Dereferencing 461 DeRemer, F 300{301 Derivation 44{46, 199{202 See also Leftmost derivation, Rightmost derivation Descendant 46 INDEX Deterministic nite automaton 149{ 156, 164{166, 170{186, 206 DFA See Deterministic nite automaton Dijkstra, E W 502{503 Diophantine equation 818{820 Directed acyclic graph See DAG Direct-mapped cache 457, 788 Display 449{451 Distributive framework 625, 635{636 Distributivity 122 Do-across loop 743{745 Do-all loop 738 Domain, of a data- ow analysis 599, 615 Domain, of a relation 954 Dominator 656{659, 672, 728 Dominator tree 657 Donnelly, C 301 Downward code motion 731{732 Dumitran, D 963 Dynamic access 816 Dynamic loading 944 Dynamic policy 25 Dynamic programming 573{577 See also Cocke-Younger-Kasami algorithm Dynamic RAM 456 Dynamic scheduler 719, 737 Dynamic scope 31{33 Dynamic storage 429 See also Heap, Run-time stack E Earley, J 301 Earliest expression 649{650, 654 Eaves, B C 900 EDB See Extensional database predicate Edge See Advancing edge, Back edge, Critical edge, Cross edge, 997 Retreating edge Emami, M 961, 963 Empty string 44, 118, 121 Engler, D 963 Entry node 531, 605 Environment 26{28 Epilog 742 See Empty string -free grammar 232 -production 63, 65{66 Eqn 331 Equivalence-based analysis 935 Error correction 113{114, 192{196, 228{231 Error production 196 Error recovery 283{284, 295{297 Ershov, A P 426, 579{580, 705 Ershov number 567{572 Euclidean algorithm 820 Execution path 597, 628 Exit block 677 Exit node 605 Expression 94, 96{97, 101{105, 359, 568{572 See also Arithmetic expression, Boolean expression, In x expression, Post x expression, Pre x expression, Regular expression, Type expression Extensional database predicate 924 F Fahndrich, M 961, 963 Fall-through code 406 Farkas' lemma 872{875 Feautrier, P 900 Feldman, S I 426 Fenichel, R R 502{503 Ferrante, J 704, 900 Fetch 708 Field 377, 584, 935 Field load 937 Field store 937 INDEX 998 Fifth-generation language 13 Final state 130{131, 147, 205 Finite automaton See Automaton FIRST 220{222 First- t 458 First-generation language 13 Firstpos 175{177 Fischer, C N 580 Fisher, J A 766{767 Fission 848, 850, 854 Fixedpoint See Maximum xedpoint Flex 189{190 Floating garbage 484 Flow graph 529{531 See also Reducible ow graph, Super control- ow graph Flow sensitivity 933, 936{937 Floyd, R W 300{301 FOLLOW 220{222 Followpos 177{179 Formal parameter 33, 942 Fortran 113, 382, 779, 886 Fortran H 703 Forward ow 615, 618, 627, 668 Fourier-Motzkin algorithm 796{797 Fourth-generation language 13 Fragmentation 457{460 Framework See Data- ow analysis framework, Distributive framework, Monotone framework Fraser, C W 580 Free chunk 457 Free list 459{460, 471 Free state 473 Frege, G 502{503 Front end 4, 40{41, 357, 986 Frontier See Yield Full redundancy 645 Fully permutable loops 861, 864{ 867, 875{876 Fully ranked matrix 808 Function 29 See also Procedure Function call See Call Function type 371, 423 Functional language 443 Fusion 848, 850 G Ganapathi, M 579{580 Gao, G 902 Garbage collection 25, 430, 463{499 See also Mark-and-compact, Markand-sweep, Short-pause garbage collection GCD 818{820 Gear, C W 705 Gen 603, 611 Generational garbage collection 483, 488{489 Gen-kill form 603 Geschke, C M 705 Ghiya, R 961, 963 Gibson, R G 38 Glaeser, C D 767 Glanville, R S 579{580 Global code optimization See Code optimization Global variable 442 GNU 38, 426 Gosling, J 426 GOTO 246, 249, 261 Graham, S L 579{580 Grammar 42{50, 197{199, 204{205 See also Ambiguous grammar, Augmented grammar Grammar symbol 199 Granularity 917 Granularity, of parallelism 773{775 Graph See Call graph, DAG, Data-dependence graph, Dependency graph, Flow graph, Programdependence graph Graph coloring INDEX See Coloring Greatest common divisor See GCD Greatest lower bound 620, 622 Gross, T R 766{767 Ground atom 921 Group reuse 806, 811{813 Grune, D 302 Gupta, A 900{901 H Hallem, S 963 Halstead, M H 426 Handle 235{236 Hanson, D R 580 Hardware register renaming 714 Hardware synthesis 22 Head 42, 197, 923 Header 665, 672 Heap 428{430, 452{463, 518, 935 Hecht, M S 705 Height, of a semilattice 623, 626, 628 Heintze, N 961, 963 Hendren, L J 961{963 Hennessy, J L 38, 579{580, 766{ 767, 899, 901 Hewitt, C 502{503 Hierarchical reduction 761{762 Hierarchical time 857{859 Higher-order function 444 Hoare, C A R 302 Hobbs, S O 705 Hole 457 Hopcroft, J E 189{190, 302 Hopkins, M E 580 Hudson, R L 502{503 Hudson, S E 302 Hu man, D A 189{190 Huskey, H D 426 IDB I See Intensional database predicate 999 Ideal solution, to a data- ow problem 628{630 Idempotence 122, 619 Identi er 28, 79{80 Identity function 624 If-statement 401 Immediate dominator 657{658 Imperative language 13 Inclusion-based analysis 935 Increment instruction 509 Incremental evaluation 928{930 Incremental garbage collection 483{ 487 Incremental translation See On-the- y generation Independent variables test 820{821 Index 365 Indexed address 513 Indirect address 513 Indirect triples 368{369 Induction variable 592{596, 687{688 In x expression 40, 52{53 Ingerman, P Z 302 Inheritance 18 Inherited attribute 55, 304{305, 307 Initial state See Start state Initialization 615 Initiation interval 745 Inlining 903{904, 914 Input bu ering See Bu er Instruction pipeline 708{709 See also Software pipelining Integer linear programming 817{825 Intensional database predicate 924 Interleaving 887{890 Intermediate code 9, 91{105, 357{ 426, 507, 971{981 Interpreter Interprocedural analysis 713, 903{ 964 Interrupt 526 Intersection 612{613, 615, 620, 650 Intraprocedural analysis 903 INDEX 1000 Irons, E T 354 Item 242{243 See also Kernel item, Set of items, Valid item Iteration space 779{780, 788{799 Iterative data- ow algorithm 605{ 607, 610, 614, 626{628 J Jacobs, C J H 302 Java 2, 13, 18{19, 25, 34, 76, 381, 903, 934, 944 Java virtual machine 507{508 Jazayeri, M 354 JFlex 189{190 Johnson, R K 705 Johnson, S C 300{302, 355, 426, 502{503, 579{580 Join 621, 955 Jump 513, 527, 551{552 Jumping code 408, 974{977 Just-in-time compilation 508 JVM See Java virtual machine K Kam, J B 705 Kasami, T 301{302, 705 Kennedy, K 899{900, 963 Kernel 777 Kernel item 245, 272{273 Kernighan, B W 189{190 Keyword 50{51, 79{80, 132{133 Kill 601, 603, 611 Killdall, G 704{705 Kleene closure See Closure Kleene, S C 189{190 Knoop, J 705 Knuth, D E 189{190, 300, 302, 354{ 355, 502{503 Knuth-Morris-Pratt algorithm 136{ 138 Korenjak, A J 300, 302 Kosaraju, S R 705 Kuck, D J 766{767, 899{901 Kung, H T 901 L Label 46, 364, 366 LALR parser 259, 266{275, 283, 287 Lam, M S 767, 899{902, 961{964 Lamport, L 503, 766{767, 899{901 Language 44, 118 See also Java, Source language, Target language Lastpos 175{177 Latest expression 649, 654 Lattice 621 See also Semilattice Lattice diagram 621{622 L-attributed de nition 313{314, 331{ 352 Law See Associativity, Commutativity, Distributivity, Idempotence Lawrie, D H 900 Lazy code motion See Partial redundancy elimination Lea 458 Leader 526{527 Leaf 45{46 Leaf region 673 Least upper bound 621 LeBlanc, R J 580 Left side See Head Left-associativity 48 Left-factoring 214{215 Leftmost derivation 201 Left-recursion 67{68, 71, 212{214, 328{331 Left-sentential form 201 Leiserson, C E 901 Lesk, M E 189{190 Leu, T 963 Levin, V 962 INDEX Lewis, P M II 300, 302, 355 Lex 126{127, 140{145, 166{167, 189{ 190, 294{295 Lexeme 111 Lexical analyzer 5{7, 41, 76{84, 86, 109{190, 209{210, 294{295, 967{969 Lexical error 194 Lexical scope See Static scope Lexicographic order 791 Liao, S.-W 901 Lichtenber, J 962 Lieberman, H 502{503 Lim, A W 901 Linear programming See Integer linear programming List scheduling 723{726 Literal 922 Live variable 528{529, 608{610, 615 Livshits, V B 962{963 LL grammar 223 LL parser See Predictive parser LLgen 300 Load instruction 512 Loader Local code optimization See Basic block Locality 455, 769 See also Spatial locality, Temporal locality Location 26{28 Logical address 427 Logical error 194 Lohtak, O 962 Lookahead 78, 144{145, 171{172, 272{ 275 Lookahead-LR parser See LALR parser Loop 531, 554, 556, 655{656, 775 See also Do-all loop, Fully permutable loops, Natural loop Loop ssion See Fission 1001 Loop fusion See Fusion Loop nest 780, 791, 797, 862 Loop region 674 Loop reversal See Reversal Loop unrolling 735, 740{741, 743 Loop-invariant expression 641{642 Loop-residue test 822{823 Loveman, D B 901 Lowry, E S 579{580, 705 LR(0) automaton 243, 247{248, 252 LR parser 53{252, 275{277, 325, 348{ 352 See also Canonical LR parser, LALR parser, SLR parser L-value 26, 98 See also Location M Machine language 508 Macro 13 Main attribute 341 Mark-and-compact 476{482 Mark-and-sweep 471{476, 482 Marker nonterminal 349 Markstein, P W 580 Martin, A J 503 Martin, M C 963 Matrix multiplication 782{788 Maximum xedpoint 626{628, 630{ 631 Maydan, D E 899, 901 McArthur, R 426 McCarthy, J 189{190, 502{503 McClure, R M 302 McCullough, W S 189{190 McGarvey, C 962 McKellar, A C 900{901 McNaughton, R 189{190 McNaughton-Yamada-Thompson algorithm 159{161 Medlock, C W 579{580, 705 Meet 605, 615, 618{619, 622{623, 633, 678, 695 INDEX 1002 Meet-over-paths solution 629{631 Memoization 823 Memory 20, 772{773 See also Heap, Physical memory, Storage, Virtual memory Memory hierarchy 20, 454{455 Memory leak 25, 461 Message-passing machine 773, 894 META 300 Metal 918, 962 Method 29 See also Procedure, Virtual method Method call See Call Method invocation 33 MGU See Most general uni er Milanova, A 962{963 Milner, R 426 Minimization, of states 180{185 Minsky, M 503 ML 387, 443{445 Mock, O 426 Modular resource-reservation table 746{747, 758 Modular variable expansion 758{761 Monotone framework 624{628, 635 Moore, E F 189{190 MOP See Meet-over-paths solution Morel, E 705 Morris, D 354 Morris, J H 189{190 Moss, J E B 502{503 Most general uni er 393 See also Uni cation Motwani, R 189{190, 302 Mowry, T C 900{901 Multiprocessor 772{773, 895 See also SIMD, Single-program multiple data Muraoka, Y 766{767, 899, 901 Mutator 464 N NAA 690 NAC 633 Name 26{28 Narrowing 388{389 Natural loop 665{667, 673 Naur, P 300, 302 Neighborhood compaction 736 Neliac 425 Nested procedure declarations 442{ 445 Next- t 458{459 NFA See Nondeterministic nite automaton Node 46 Node merging 953 Nondeterministic nite automaton 147{148, 152{175, 205, 257 Nonreducible ow graph See Reducible ow graph Nonterminal 42{43, 45, 197{198 See also Marker nonterminal Nonuniform memory access 773 Null space 808{809 Nullable 175{177 Nullity 808 NUMA See Nonuniform memory access O Object code 358 See also Code generation Object creation 937 Object ownership 462 Object program 427{428 Object sensitivity 950 Object-oriented language See C++, Java O set 377{378 Ogden, W F 354 Olsztyn, J 426 Ondrusek, B 962 INDEX On-the- y generation 340{343, 380{ 381 Optimization See Code optimization Ordered BDD 952 Output dependence 711, 816 Overloading 99, 390{391 P Paakki, J 354{355 Padua, D A 902 Panic-mode garbage collection 492{ 493 Panic-mode recovery 195{196, 228{ 230, 283{284 Panini 300 Parafrase 899 Parallel garbage collection 495{497 Parallelism 19{20, 707{902, 917 Parameter 422 See also Actual parameter, Formal parameter, Procedure parameter Parameter passing 33{35, 365 Parametric polymorphism 391 See also Polymorphism Parent 46 Parr, T 302 Parse tree 45{48, 201{204 See also Annotated parse tree Parser 8, 41, 45, 60{61, 110{111, 191{302, 981{986 See also Bottom-up parser, Topdown parser Parser generator See Antlr, Bison, CUP, LLgen, Yacc Parser state 241{242 See also Set of items Partial garbage collection 483, 487{ 494 Partial order 619{621, 623 Partial redundancy elimination 639{ 655 Partially dead variable 655 1003 Partially ordered set See Poset Pass 11 Patel, J H 767 Path See Acyclic path, Critical path, Execution path, Meet-overpaths solution, Weight, of a path Pattern 111 Pattern matching, of trees 563{567 Patterson, D A 38, 579{580, 766{ 767, 899, 901 Pause time 465 See also Short-pause garbage collection P-code 386 PDG See Program-dependence graph Peephole optimization 549{552 Pelegri-Llopart, E 580 Permuation 849{850 Peterson, W W 705 PFC 899 Phase 11 Phoenix 38 Phrase-level recovery 196, 231 Physical address 427 Physical memory 454{455 Pierce, B C 426 Pincus, J D 962{963 Pipeline See Instruction pipeline, Pipelining, Software pipelining Pipelining 861{884 Pitts, W 189{190 Pnueli, A 964 Pointer 365, 373, 514, 539, 935 See also Dangling pointer, Stack pointer Pointer analysis 713, 903, 917, 933{ 951 Poison bit 718 Polyhedron See Convex polyhedron INDEX 1004 Polymorphism 391{395 Porter eld, A 900, 902 Poset 619 Positive closure 123 Postdominator 728 Post x expression 40, 53{54 Post x translation scheme 324{327 Postorder traversal 58, 432 See also Depth- rst order Postponable expression 646, 649, 651{ 654 Power set 620 Pratt, V R 189{190 PRE See Partial redundancy elimination Precedence 48, 121{122, 279{281, 293{294 Predecessor 529 Predicate 921{922 Predicated execution 718, 761 Predictive parser 64{68, 222{231, 343{ 348 Prefetch 457 Prefetching 718, 896 Pre x 119, 918, 962 Pre x expression 327 Preorder traversal 58, 432 Preprocessor Prioritized topological order 725{726 Private 31 Privatizable variable 758 Procedure 29, 422{424 Procedure call See Call Procedure parameter 448{449 Processor space 779{781, 838{841 Product lattice 622{623 Production 42{43, 45, 197, 199 See also Error production Proebsting, T A 580 Program-dependence graph 854{857 Programming language 12{14, 25{ 35 See also Ada, C, C++, Fortran, Java, ML Projection 955 Prolog 742 Prosser, R T 705 Protected 31 Pseudoregister 713 PTRAN 900 Public 31 Pugh, W 899, 902 Purify 25, 462 Q Qian, F 962 Quadruple 366{368 Quicksort 431{432, 585 R Rabin, M O 189{190 Rajamani, S K 962 Randell, B 502{503 Rank, of a matrix 807{809 Rau, B R 767 Reaching de nitions 601{608, 615 Read barrier 486 Record 371, 376{378, 584 Recursive descent 338{343 Recursive type 372 Recursive-descent parser 64, 219{222 Reduced instruction-set computer See RISC Reduce-reduce ict 238{240, 293 Reducible ow graph 662, 664, 673{ 677, 684{685 Reduction 234, 324 Reduction in strength 536, 552, 592{ 596 Reference See Pointer Reference count 462{463, 466, 468{ 470 Reference variable 34, 686{689 Re ection 944{945 Re exivity 619 INDEX Region 672{686, 694{699, 733{734, 911 Region-based allocation 463 Register 18, 20, 454{455, 542{543, 714{715 See also Pseudoregister, Rotating register le Register allocation 510{512, 553{557, 570{572, 716, 743 Register assignment 510, 556 Register descriptor 543, 545{547 Register pair 510 Register renaming See Hardware register renaming Regular de nition 123 Regular expression 116{122, 159{163, 179{180, 189, 210 Rehof, J 961, 963 Re-indexing 848, 850 Relation 922, 954 Relative address 371, 373, 381 Remembered set 491 Renvoise, C 705 Reserved word See Keyword Resource constraint 711 Resource-reservation table 719{720 See also Modular resource-reservation table Retreating edge 661, 664{665 Return 365, 467, 518{522, 906, 942 Return value 434 Reuse See Data reuse Reversal 849{850 Right side See Body Right-associativity 48 Rightmost derivation 201 Right-sentential form 201, 256 Rinard, M 962{963 RISC 21, 507{508 Ritchie, D M 426, 502{503 Rodeh, M 766{767 1005 Root 46 Root set 466{467, 488 Rosen, B K 704 Rosenkrantz, D J 355 Rotating register le 762 Rothberg, E E 900{901 Rounds, W C 354 Rountev, A 962{963 Row See Tuple Row-major order 382, 785 Roy, D 963 Rule 922{923 Run time 25 Run-time environment 427 Run-time stack 428{451, 468 Russell, L J 502{503 Ruwase, O 962{963 R-value 26, 98 Ryder, B G 962{963 S Sadgupta, S 767 Safety See Conservative data- ow analysis Samelson, K 354{355 Sarkar, V 902 S-attributed de nition 306, 312{313, 324 Scaling 848, 850 Scanned state 474 Scanning 110 See also Lexical analyzer SCC See Strongly connected component Scheduling 710{711, 716 Scholten, C S 503 Schorre, D V 302 Schwartz, J T 579, 581, 704 Scope 86 Scott, D 189{190 Scott, M L 38 Scripting language 13{14 1006 SDD See Syntax-directed de nition SDT See Syntax-directed translation SDV 962 Secondary storage 20 Second-generation language 13 Sedgewick, R 585 Self reuse 806{811 Semantic analysis 8{9 Semantic error 194 Semantic rule See Syntax-directed de nition Semantics 40 Semilattice 618{623 Sensitivity See Context sensitivity, Flow sensitivity Sentence 200 Sentential form 200 See also Left-sentential form, Rightsentential form Sentinel 116 Set associativity 457 Set of items 243{246, 257 See also Canonical LR(0) set of items, Canonical LR(1) set of items Sethi, R 38, 579, 581 Shannon, C 189{190 Sharir, M 964 Shift-reduce ict 238{240, 293 Shift-reduce parser 236{240 Short-circuiting 953 Short-pause garbage collection 483{ 494 Shostak, R 902 Side e ect 306, 314{316, 727 Siela , D J 962{963 Signature 361 SIMD 21, 895{896 Simple syntax-directed de nition 56 Simulation 23 Single instruction, multiple data See SIMD INDEX Single production 232 Single-program multiple data 776 Skewing 849{850 SLAM 962 SLR parser 252{257, 283 SMP See Symmetric multiprocessor Software pipelining 738{763, 895 Software productivity 23{25 Software vulnerability See Vulnerability, of software SOR See Successive over-relaxation Sound type system 387 Source language Space See Data space, Iteration space, Null space, Processor space Space-partition constraint 831{838 Spatial locality 455{457, 465, 777, 884 Spatial reuse 806, 809{811 Speculative execution 708, 717{719 Spilling, of registers 716 SPMD See Single-program multiple data SQL 22{23 SQL injection 918{919 SSA See Static single-assignment form Stable set 488 Stack 325, 518, 520 See also Run-time stack Stack machine 507 Stack pointer 437 Stallman, R 301 Start state 131, 147, 205 Start symbol 43, 45, 197 State 147, 205 See also Dead state, Minimization, of states, Parser state State (of the program store) 26{28 Statement 93{94, 100{101, 978{981 See also Break-statement, Continuestatement, If-statement, Switch- INDEX statement, While-statement Static access 816 Static allocation 518, 524 Static checking 97{98, 357 See also Type checking Static policy 25 Static RAM 456 Static scope 25, 28{31, 442 See also Scope Static single-assignment form 369{ 370 Static storage 429, 442 Steady state 742 Stearns, R E 300, 302, 355 Steel, T 426 Steensgaard, B 961, 964 Ste ens, E F M 503 Storage See Dynamic storage, Static storage Storage layout 373 Storage-related dependence See Antidependence, Output dependence Store instruction 512 Strati ed Datalog program 930{931 Strength reduction See Reduction in strength String 118{119, 373 Strong, J 426 Strongly connected component 751, 859 Strongly typed language 387 Structure See Class, Record Subgoal 923 Subsequence 119 Subset construction 153{154 Substring 119 Successive over-relaxation 863 Successor 529 Su x 119 Summary-based analysis 911{914 Super control- ow graph 906 Superscalar machine 710 1007 Switch-statement 418{421 Symbol table 4{5, 11, 85{91, 423, 970{971 Symbolic analysis 686{699 Symbolic constant 793 Symbolic map 690 Symmetric multiprocessor 772 Synchronization 828, 832, 853{854, 880{882 Syntax 40 See also Grammar Syntax analysis See Parser Syntax error 194 Syntax tree 41, 69{70, 92{93, 318{ 321, 358, 367, 981{986 Syntax-directed de nition 54{56, 304{ 316 Syntax-directed translation 40, 57{ 60, 324{352 Synthesis Synthesized attribute 54{56, 304{ 305 T Table See Relation, Resource-reservation table, Symbol table, Transition table Tail recursion 73 Takizuka, T 767 Tamura, E 767 Tardieu, O 961, 963 Target code See Object code Target language Target set 488 Task parallelism 776 Temporal locality 455{457, 777, 884{ 885 Temporal reuse 806 Terminal 42{43, 45, 197{198, 305 TeX 331 Third-generation language 13 Thompson, K 189{190 INDEX 1008 Three-address code 42, 99, 363{369 Tick See Clock Tiling 560{563 Time-partition constraint 868{875, 989{992 Tjiang, S W K 579{580 TMG 300 Token 41, 43, 76, 111 Tokoro, M 767 Tokura, N 705 Top element 619, 622 Top-down parser 61{68, 217{233 See also Predictive parser, Recursivedescent parser Topological order 312 See also Prioritized topological order Torczon, L 580, 963 Towle, R A 902 Trace-based garbage collection 470{ 471 See also Mark-and-compact, Markand-sweep Train algorithm 483, 490{493 Transfer barrier 486 Transfer function 599{600, 603{604, 615, 623{624, 629, 634, 676{ 679, 691{693 Transition 205 Transition diagram 130{131, 147{ 148 See also Automaton Transition function 147, 150 Transition table 148{149, 185{186 Transitivity 619{620 Traversal 56{57 See also Depth- rst search, Postorder traversal, Preorder traversal Tree 46, 56 Tree rewriting 558{567 Triple 367{368 Tritter, A 426 True dependence 711, 815 T1-T2 reduction 677 Tuple 954 Type 938 See also Basic type, Function type, Recursive type Type checking 24, 98{99, 370, 386{ 398 Type conversion 388{390 See also Coercion Type equivalence 372{373 Type expression 371{372, 393, 395 Type inference 387, 391{395 Type safety 19, 464{465 Type synthesis 387 Type variable 391 U Ullman, J D 189{190, 301{302, 579, 581, 705, 962, 964 Umanee, N 962 UNCOL 425 UNDEF 633 Uni cation 393, 395{398 Union 119, 121{122, 605, 613, 615, 620, 650, 955{957 Unkel, C 963 Unreachable code See Dead code Unreached state 473 Unsafe Datalog rule 930 Unsafe language 498 Unscanned state 474 Upward code motion 730{732 Usage count 554{555 Use 609 Use before de nition 602 Used expression 649, 653{654 Used variable 528{529 Ustuner, A 962 V Valid item 256 Value 26{27 Value-number 360{362, 390 INDEX Variable 26{28 See also Nonterminal, Reference variable Variable expansion See Modular variable expansion Variable-length data 438{440 Vector machine 886, 895{896 Very-busy expression See Anticipated expression Very-long instruction word See VLIW Viable pre x 256{257 Virtual machine See also Java virtual machine Virtual memory 454{455 Virtual method 904, 916{917, 934, 941{944 VLIW 19{21, 710 Von Neumann language 13 Vulnerability, of software 917{921 Vyssotsky, V 704{705 W Wavefronting 876{877 Weber, H 300, 302 Wegman, M N 704 Wegner, P 704{705 Wegstein, J 426 Weight, of a path 822 Weinberger, P J 189{190 Weinstock, C B 705 Wexelblat, R L 38 Whaley, J 961, 963{964 While-statement 401 White space 41, 77{78 Widening 388{389 Widom, J 962, 964 Width, of a type 374 Wilderness chunk 458 Wilson, P R 502{503 Wirth, N 300, 302, 426 Wolf, M E 900{902 Wolfe, M J 902 Wonnacott, D 899, 902 Wood, G 767 1009 Write barrier 486{487 Wulf, W A 705 Y Yacc 287{297, 354 Yamada, H 189{190 Yield 46{47, 201 Yochelson, J C 502{503 Younger, D H 301{302 Z Zadeck, F K 704 Zhu, J 961, 964 Alfred V Aho is the Lawrence Gussman professor of computer science at Columbia University Professor Aho has won several awards, including the Great Teacher Award for 2003 from the Society of Columbia Graduates and the Institute of Electrical and Electronics Engineers (IEEE) John von Neumann Medal He is a member of the National Academy of Engineering (NAE) and a fellow of the Association of Computing Machinery (ACM) and IEEE Monica S Lam is a professor of computer science at Stanford University, was the chief scientist at Tensilica, and is the founding chief executive o cer of moka5 She led the SUIF project, which produced one of the most popular research compilers, and pioneered numerous compiler techniques used in industry Ravi Sethi launched the research organization in Avaya and is president of Avaya Labs Previously, he was a senior vice president at Bell Laboratories and chief technical o cer for communications software at Lucent Technologies He has held teaching positions at the Pennsylvania State University and the University of Arizona and has taught at Princeton University and Rutgers University He is a fellow of the ACM Je rey D Ullman is chief executive o cer of Gradiance Corp and Stanford W Ascherman professor of computer science (emeritus) at Stanford University His research interests include database theory, database integration, data mining, and education using the information infrastructure He is a member of the NAE, a fellow of the ACM, and winner of the Karlstrom Award and Knuth Prize ... Cataloging-in-Publication Data Compilers : principles, techniques, and tools / Alfred V Aho [et al.] 2nd ed p cm Rev ed of: Compilers, principles, techniques, and tools / Alfred V Aho, Ravi Sethi, Jeffrey. .. Sethi, Jeffrey D Ullman 1986 ISBN 0-3 2 1-4 868 1-1 (alk paper) Compilers (Computer programs) I Aho, Alfred V II Aho, Alfred V Compilers, principles, techniques, and tools QA76.76.C65A37 2007 005.4'53... to Trace-Based Collection 7.6.1 A Basic Mark -and- Sweep Collector 7.6.2 Basic Abstraction 7.6.3 Optimizing Mark -and- Sweep 7.6.4 Mark -and- Compact

Ngày đăng: 01/11/2022, 23:56

w