Submit Search
Upload
How I tried to compile JavaScript
•
Download as PPTX, PDF
•
0 likes
•
539 views
Ingvar Stepanyan
Follow
Talk from KharkivJS 2016
Read less
Read more
Technology
Report
Share
Report
Share
1 of 41
Download now
Recommended
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
Ingvar Stepanyan
A very quick intro to astrophotography
A very quick intro to astrophotography
Ingvar Stepanyan
Asyncifying WebAssembly for the modern Web
Asyncifying WebAssembly for the modern Web
Ingvar Stepanyan
Building fast interpreters in Rust
Building fast interpreters in Rust
Ingvar Stepanyan
Rust ⇋ JavaScript
Rust ⇋ JavaScript
Ingvar Stepanyan
Your code is not a string
Your code is not a string
Ingvar Stepanyan
es6.concurrency()
es6.concurrency()
Ingvar Stepanyan
React for WinRT apps
React for WinRT apps
Ingvar Stepanyan
Recommended
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
Ingvar Stepanyan
A very quick intro to astrophotography
A very quick intro to astrophotography
Ingvar Stepanyan
Asyncifying WebAssembly for the modern Web
Asyncifying WebAssembly for the modern Web
Ingvar Stepanyan
Building fast interpreters in Rust
Building fast interpreters in Rust
Ingvar Stepanyan
Rust ⇋ JavaScript
Rust ⇋ JavaScript
Ingvar Stepanyan
Your code is not a string
Your code is not a string
Ingvar Stepanyan
es6.concurrency()
es6.concurrency()
Ingvar Stepanyan
React for WinRT apps
React for WinRT apps
Ingvar Stepanyan
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
More Related Content
Featured
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Featured
(20)
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
How I tried to compile JavaScript
1.
How I spent
my summer tried to compile javascript INGVAR STEPANYAN AKA @RREVERSER
2.
Compilers pipeline
3.
Compilers pipeline
4.
function factorial(n) { var
result = 1; for (var i = 2; i <= n; i++) { result *= i; } return result; }
5.
‘var result =
1’
6.
[‘v’,‘a‘,‘r’,‘ ‘,‘r’,‘e’,‘s’,‘u’,‘l’,‘t’,‘ ‘,‘=‘,‘ ‘,‘1’] Keyword
Identifier Punctuator Number
7.
[Keyword(‘var’), Identifier(‘result’), Punctuator(‘=‘),
Number(‘1’)] VarDeclaration VarDeclarator Identifier Expression
8.
function factorial(n) { var
result = 1; for (var i = 2; i <= n; i++) { result *= i; } return result; }
9.
function factorial(n) { var
result = 1, i = 2; while (i <= n) { result *= i++; } return result; }
10.
function factorial(n) { var
result = 1, i = 1; do { result *= i++; } while (i <= n); return result; }
11.
function factorial(n) { var
result = 1; for (var i = 2; i <= n; i++) { result *= i; } return result; }
12.
function factorial(n) { var
n, result, i; // all vars result = 1; for (i = 2; i <= n; i++) { result *= i; } return result; }
13.
function factorial(n) { var
n, result, i; // all vars result = 1; for (i = 2; i <= n; i = i + 1) { result = result * i; } return result; }
14.
function factorial(n) { var
n, result, i; // all vars result = 1; i = 2; while (i <= n) { result = result * i; i = i + 1; } return result; }
15.
function factorial(n) { result
= undefined; i = undefined; result = 1; i = 2; while (i <= n) { result = result * i; i = i + 1; } return result; }
16.
// B1 result =
undefined; i = undefined; result = 1; i = 2; goto B2; // B4 return result; // B3 result = result * i; i = i + 1; goto B2; // B2 cond = i <= n; goto cond ? B3 : B4;
17.
// B1 result =
undefined; i = undefined; result = 1; i = 2; cond = i <= n; goto cond ? B2 : B3; // B3 return result; // B2 result = result * i; i = i + 1; cond = i <= n; goto cond ? B2 : B3;
18.
// B1 r[1] =
undefined; i[1] = undefined; r[2] = 1; i[2] = 2; cond[1] = i[2] <= n[1]; goto cond ? B2 : B3; // B3 return r; // B2 r = r * i; i = i + 1; cond = i <= n; goto cond ? B2 : B3;
19.
// B1 r[1] =
undefined; i[1] = undefined; r[2] = 1; i[2] = 2; cond[1] = i[2] <= n[1]; goto cond[1] ? B2 : B3; // B3 return r[4]; // B2 i[3] = phi(B1:i[2], B2:i[4]); r[3] = phi(B1:r[2], B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= n[1]; goto cond[2] ? B2 : B3;
20.
// B1 r[2] =
1; i[2] = 2; cond[1] = i[2] <= n[1]; goto cond[1] ? B2 : B3; // B3 return phi(B1:r[2], B2:r[4]); // B2 i[3] = phi(B1:i[2], B2:i[4]); r[3] = phi(B1:r[2], B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= n[1]; goto cond[2] ? B2 : B3;
21.
// B1 cond[1] =
2 <= n[1]; goto cond[1] ? B2 : B3; // B3 return phi(B1:1, B2:r[4]); // B2 i[3] = phi(B1:2, B2:i[4]); r[3] = phi(B1:1, B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= n[1]; goto cond[2] ? B2 : B3;
22.
// n[1]: 1 //
B1 cond[1] = 2 <= n[1]; goto cond[1] ? B2 : B3; // B3 return phi(B1:1, B2:r[4]); // B2 i[3] = phi(B1:2, B2:i[4]); r[3] = phi(B1:1, B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= n[1]; goto cond[2] ? B2 : B3;
23.
// n[1]: 1 //
B1 cond[1] = 2 <= 1; goto cond[1] ? B2 : B3; // B3 return phi(B1:1, B2:r[4]); // B2 i[3] = phi(B1:2, B2:i[4]); r[3] = phi(B1:1, B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= 1; goto cond[2] ? B2 : B3;
24.
// n[1]: 1 //
B1 cond[1] = false; goto cond[1] ? B2 : B3; // B3 return phi(B1:1, B2:r[4]); // B2 i[3] = phi(B1:2, B2:i[4]); r[3] = phi(B1:1, B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= 1; goto cond[2] ? B2 : B3;
25.
// n[1]: 1 //
B1 goto B3; // B3 return 1;
26.
// B3 return 1;
27.
// n[1]: 10 //
B1 cond[1] = 2 <= 10; goto cond[1] ? B2 : B3; // B3 return phi(B1:1, B2:r[4]); // B2 i[3] = phi(B1:2, B2:i[4]); r[3] = phi(B1:1, B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= 10; goto cond[2] ? B2 : B3;
28.
// n[1]: 10 //
B1 cond[1] = true; goto cond[1] ? B2 : B3; // B3 return phi(B1:1, B2:r[4]); // B2 i[3] = phi(B1:2, B2:i[4]); r[3] = phi(B1:1, B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= 10; goto cond[2] ? B2 : B3;
29.
// n[1]: 10 //
B1 goto B2; // B3 return r[4]; // B2 i[3] = phi(B1:2, B2:i[4]); r[3] = phi(B1:1, B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= 10; goto cond[2] ? B2 : B3;
30.
// n[1]: 10 //
B1 goto B2; // B3 return r[4]; // B2 i[3] = phi(B1:2, B2:i[4]); r[3] = phi(B1:1, B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= 10; goto cond[2] ? B2 : B3;
31.
// n[1]: 10 //
B1 goto B2; // B3 return r[4]; // B2 r[4] = 3628800
32.
// B3 return 3628800;
33.
// B1 r[1] =
undefined; i[1] = undefined; r[2] = 1; i[2] = 2; cond[1] = i[2] <= n[1]; goto cond[1] ? B2 : B3; // B3 return r[4]; // B2 i[3] = phi(B1:i[2], B2:i[4]); r[3] = phi(B1:r[2], B2:r[4]); r[4] = r[3] * i[3]; i[4] = i[3] + 1; cond[2] = i[4] <= n[1]; goto cond[2] ? B2 : B3;
34.
function sum(x, y)
{ return x + y; } // B1 result = x + y; return result;
35.
function sum(x: ???,
y: ???) { return x + /* ??? */ y; }
36.
struct JSValue { type:
int8; value: int64; } @readnone function runtime.binop.add(x, y); function sum(x: JSValue, y: JSValue) { return runtime.binop.add(x, y); }
37.
struct JSValue { type:
int8; value: float64; } @readnone function runtime.binop.add(x, y); function inc(x: JSValue) { y = JSValue { type: 3 /* number */, value: 1. }; return runtime.binop.add(x, y); }
38.
function distance(x1, y1,
x2, y2) { diff1 = runtime.binop.sub(x1, y1); diff2 = runtime.binop.sub(x2, y2); sqrdiff1 = runtime.binop.mul(diff1, diff1); sqrdiff2 = runtime.binop.mul(diff2, diff2); sum = runtime.binop.add(sqrdiff1, sqrdiff2); return runtime.unop.sqrt(sum); }
39.
x1_number = runtime.unbox_to_number(x1); y1_number
= runtime.unbox_to_number(y1); diff1 = x1_number – y1_number; … sqrdiff1 = diff1 * diff1; … sum = sqrdiff1 + sqrdiff2; result = sqrt(sum); return runtime.box_number(result);
40.
41.
// TODO: More
slides
Download now