Table Of Content
Ability to use Flex or similar tools to create a lexical analyzer and Yacc/Bison tools to create a parser. The third programming assignment must be completed and submittedentirely on your own. This is one of the major assessments for the course,and you should treat it like a take-home exam. And, what design studio would be complete without a resident feline?
Generating Code for Method Calls
Let’s assume we choose the first option, and consider the code we mightgenerate for a method call like l.sum(). You will get an invite to in the first few days of the quarter. If you needanything in the meantime or can’t find your invite, you can email Joe
P.C. Rossin College ofEngineering & Applied
We will also assign weekly readings from around the Web highlighting toolsand techniques we need, and research papers that explore the space ofcompiler design. This project will allow us to explore a number of interesting features ofcompilation and build deployable, user-facing programming environments. The main course project is building an in-browser, interactive compiler from(typed) Python programs to WebAssembly.
Storing Shared Variables on the Heap
Fluency in describing the theory and practice of compilation, in particular, the lexical analysis, syntax, and semantic analysis, code generation and optimization phases of compilation. So adding an extra parameter works, but not if we want to support use casesthat share updateable variables between functions. That is, the classes appear in order as they are declared in the file.
Methods Without Inheritance
Another attempt could be to store, update, and access shared variables on theheap (in WASM, the linear memory). This is promising, because the memorypersists across all function calls, and indeed, in our setup, across otherboundaries like modules. Our approach will be to give special treatment andattention to variables that both updated at some point, and used withina nested function, like x in our f-g-h example above. One straightforward option, if g is not recursive, and not too large, andnot used too many times, is inlining. In many programs, nested functions aresmall helpers, and their code can be easily copied to the point where theyare called. In this case, that would mean replacing the expressions g(10)with x + 10, and g(7) with x + 7.
Search code, repositories, users, issues, pull requests...
Since WASM doesn’t permit access to the stackoutside of the current function, such a cross-call variable reference isprohibited. We need another strategy to implement nested functions atop WASM.Our approach to this could be multi-faceted, depending on the particularconstraints of g and f. These techniques may come in handy, no matter what field of CS you end up working in. For nested functions with ChocoPy’s restrictions (we’ll revisit thisrestriction later), we know that all calls to g must occur within the bodyof f. Generally, all calls to a nested function appear within the body ofthe function it is declared in.
Sharon Barcarse provides over 30 years of experience in the graphic design industry, including branding, publications, advertising, marketing collateral, and online design. She spent 13 years in publication and advertising; both as an art director and later as a creative director overseeing more than 50 annual publications. Clients have ranged from large healthcare biotech firms to small non-profit groups. And, if you’re a fellow foodie, be sure to follow Sharon’s restaurant posts on Instagram. Ability to create lexical rules and grammars for a programming language. Inlining is an implementation technique that we can perform at the sourcelevel by transforming the AST directly, and the updated AST would then haveWASM code generated for it as usual.
Adding Inheritance
Here we have a classic case in compiler design – for different kinds ofcomplexity in a program, we can use different compilation techniques tocompile the “same” programming language feature (in this case nestedfunctions). Another view is that adding references around variables alwaysworks as a fully general solution, but if the variable is never updated it’ssafe to remove the references as an optimization, and if the function issufficiently small, we could inline instead. All three of these strategies—inlining, adding extra arguments, and creatingreferences for variables variables—are useful. Inlining can actually reducethe number of instructions run by a program. Adding extra arguments causesmore work (extra pushing of arguments) in exchange for working on recursivefunctions and functions that might be too costly to inline.
Ability to implement semantic rules into a parser that performs attribution while parsing. Ability to implement a parser such as a bottom-up SLR parser without using Yacc/Bison or any other compiler-generation tools. In the case of no inheritance, where we have our decorated AST, let’sconsider the c.inc() expressions in this program.
At the same time, you will get a feeling for what research is like in the area of program analysis and compilers by reading research papers, and getting your feet wet in a small project. If you haven't picked an area of research to work in, being exposed to some research will help you make a better decision. If you have already picked an area of research to work in, seeing what research is like in other fields of CS will broaden your perspective. Weekly lectures will be a mix of practical tutorials on necessary tools andtechniques, discussions of compilers concepts that we can apply to ourprojects, and review of solutions generated by the class. Ability to design a compiler for a concise programming language.
This requires implementing a new algorithm in our compiler that calculatesthe set of nonlocal variables in a function definition. The calculation ofthis set of variables is similar to the kinds of calculations we have to doto build environments for our functions or look for undefined identifiers,but with the goal of finding names that need this extra-argument treatment. This puts a new demand on our compiler – some time before generating code, weneed to build the mapping from each class to a starting index and from eachclass-method pair to an offset. This will allow us to create this table andreference it correctly from generated code.
On alarge compiler team, a single developer’s entire job might be to test outdifferent heuristics that work well for deciding which functions to inline! In this example we begin to see the true sophistication that goes into moderncompiler design. A concrete proposal for handling nested functions is to find all of thevariables that the function uses that aren’t defined within the function(and aren’t global), and add them as extra arguments. This has a nice side effect – we canmove these programs to the toplevel, because they no longer refer to anyvariables that aren’t global or their own parameters! This immediately givesus a compilation strategy for them (with a little work on naming). The students are given eleven homework assignments, two major programming projects of three weeks duration each, a midterm exam, and a final examination.
Aside from modifying theREPL/runner to consume and produce this new information there’s no newinfrastructure required. The WASM tool is tables and the call_indirectinstruction,which allow us to refer to a function by a numeric (i32) index into a tablerather than by a name that needs to be known at compile-time. WASM currentlysupports a single table per module, so we will need to organize all methodreferences within the same module-level table.
No comments:
Post a Comment