diff options
Merge branch '2020/intro'
2 files changed, 99 insertions, 7 deletions
| -rw-r--r-- | website/content/slides/00_intro/_index.md | 39 | ||||
| -rw-r--r-- | website/content/slides/01_dragons/_index.md | 67 |
diff --git a/website/content/slides/00_intro/_index.md b/website/content/slides/00_intro/_index.md index 0625219..9341dfb 100644 --- a/website/content/slides/00_intro/_index.md +++ b/website/content/slides/00_intro/_index.md @@ -65,6 +65,7 @@ We are going to study and enhance a JavaScript interpreter. - understandable - working - extensible +- embeddable --- ## How you are going to be graded? @@ -133,15 +134,16 @@ contribution. - Follow the pull request template - Add your faculty number in the description +--- ## What are the requirements? -1. {{< frag c="Will to learn and time to experiment and write code" >}} -2. {{< frag c="Programming with C++, fluent in C++ will be better" >}} -2. {{< frag c="Programming with JavaScript or other dynamic language" >}} -3. {{< frag c="Data structures" >}} -4. {{< frag c="Languages, Finite Automata, Computability" >}} -5. {{< frag c="How computers work - CPU, memory hierarchy, etc" >}} +1. Will to learn and time to experiment and write code +2. Programming with C++, fluent in C++ will be better +2. Programming with JavaScript or other dynamic language +3. Data structures +4. Languages, Finite Automata, Computability +5. How computers work - CPU, memory hierarchy, etc --- # Contents of the course @@ -182,6 +184,7 @@ Abstract Syntax Tree 1. How to grow one? 2. What to do with it? 3. Evaluating the syntax tree +4. Transforming the syntax tree {{% note %}} - language transformation at syntax level @@ -205,8 +208,10 @@ Virtual machines 1. What is a virtual machine? 2. Implementing the language features in the VM + - Library - arrays, hash maps, etc - OOP - Exception handling +3. Communicating with the "real" machine --- ## 7. GC @@ -228,6 +233,18 @@ Garbage collection 3. Ahead of Time --- +# Plan for the course + +1. Introduction - week 1 +2. Lexers - week 2 +3. Parser - week 2 +4. AST - week 3, 4 +5. Bytecode - weeks 5, 6 +6. VMs - weeks 7, 8, 10 +7. GC - weeks 10, 11 +8. JIT & AOT code generation - weeks 11, 12, 13 + +--- ## Resources - https://github.com/SofiaCPP/IPL @@ -237,4 +254,14 @@ Garbage collection - Links to resources will be there too! --- +## Resources + +Real world virtual machines: + +- V8, SpiderMonkey, JavaScriptCore, ChakraCore and many more +- duktape +- lua, luajit +- cPython, PyPy, ... + +--- # ? diff --git a/website/content/slides/01_dragons/_index.md b/website/content/slides/01_dragons/_index.md index 52ecf91..756066b 100644 --- a/website/content/slides/01_dragons/_index.md +++ b/website/content/slides/01_dragons/_index.md @@ -197,7 +197,26 @@ LR(n) and LALR(n) are family of parsing algorithms for CFG --- ###### AST -# TODO: use JavaScript AST dumper +https://esprima.org/demo/parse.html?code=function%20answer()%20%7B%0A%20%20%20%20return%206%20*%207%3B%0A%7D + + { + "type": "FunctionDeclaration", + "id": { "type": "Identifier", "name": "answer" }, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "*", + "left": { "type": "Literal", "value": 6 }, + "right": { "type": "Literal", "value": 7 } + } + } + ] + }, + } --- ### Middle @@ -233,6 +252,37 @@ that is convenient for: } --- +### WebAssembly + +WebAssembly is actually an IR. + + (module + (func (export "add") (param $n1 i32) (param $n2 i32) (result i32) + get_local $n1 + get_local $n2 + i32.add + ) + ) + +--- +### .NET CIL + +- C#, F#, Basic (some versions), etc target the .NET virtual machine +- Common Intermediate Language + + .class public Foo + { + .method public static int32 Add(int32, int32) cil managed + { + .maxstack 2 + ldarg.0 // load the first argument; + ldarg.1 // load the second argument; + add // add them; + ret // return the result; + } + } + +--- ### Back end > Takes the IR and produces native code for a particular machine @@ -336,5 +386,20 @@ expressions. - antlr --- +### Crash course in JSImpl + +- repository organization +- continous integration +- pull requests + +--- +### Crash course in JSImpl + +- projects +- allocators +- tests + + +--- # ? --- |
