x00000001000d5688:!rex.W test $0x1,%al x00000001000d568c:!jne 0x1000d56a6 x00000001000d5692:!add $0x2,%rax x00000001000d5699:!jno 0x1000d56cf x00000001000d569f:!sub $0x2,%rax x00000001000d56a6:!mov %rax,-0x10(%rbp) x00000001000d56ad:!movabs $0x2,%rax x00000001000d56b7:!mov %rax,%rbx x00000001000d56ba:!mov -0x10(%rbp),%rax x00000001000d56c1:!movabs $0x1000d5320,%r11 x00000001000d56cb:!rex.WB callq *%r11 x00000001000d56ce:!nop x00000001000d56cf:!mov %rax,-0x10(%rbp) x00000001000d56d6:!mov -0x10(%rbp),%r11 x00000001000d56dd:!mov %r11,-0x8(%rbp) x00000001000d56e4:!mov %r11,%rax понедельник, 2 июля 2012 г.

@indutny Twitter / Github / IRC понедельник, 2 июля 2012 г.

• Node.js core team member • Author of node-spdy module, Candor language and • Nodejitsu guy

the parts of node’s debugger

понедельник, 2 июля 2012 г.

The beginning

понедельник, 2 июля 2012 г.

Javascript function apiMethod(obj, prop) {   if (!obj) obj = {};   console.log('result: “' + obj[prop] + '”'); }

понедельник, 2 июля 2012 г.

Javascript function apiMethod(obj, prop) {   if (!obj) obj = {};   console.log('result: “' + obj[prop] + '”'); }

понедельник, 2 июля 2012 г.

Candor apiMethod(obj, prop) {   global.print('result: “' + obj[prop] + '”') }

Javascript

Candor

function apiMethod(obj, prop) {   if (!obj) obj = {};

apiMethod(obj, prop) {   global.print('result: “' + obj[prop] + '”') }

  console.log('result: “' + obj[prop] + '”'); }

Outputs apiMethod({}, 'wat?') // 'result: "undefined"'

понедельник, 2 июля 2012 г.

apiMethod({}, 'wat?') // 'result: ""'

Candor is different! And yes, it looks and feels like javascript

• • • • понедельник, 2 июля 2012 г.

No semicolons, new-lines are significant No `function` keyword No exceptions No prototype-chains

Candor is different! And yes, it looks and feels like javascript

• • • •

No semicolons No `function` keyword No prototype-chains No exceptions



NO MORE GLOBAL LEAKS

понедельник, 2 июля 2012 г.

What’s inside? • • •

понедельник, 2 июля 2012 г.

Simple syntax, minimal amount of keywords and no reserved words! Compiler-friendly language, possibility of various optimizations ECMAScript-like semantics

Why Candor?

понедельник, 2 июля 2012 г.

Why Candor? No, that’s not about naming

понедельник, 2 июля 2012 г.

ECMAScript is overcomplicated

понедельник, 2 июля 2012 г.

Not at useful for server-side as it was

понедельник, 2 июля 2012 г.

Something different should be created

понедельник, 2 июля 2012 г.

• • •

понедельник, 2 июля 2012 г.

No need in compatibility with legacy code Flexible specification OpenSource

Candor • • •

понедельник, 2 июля 2012 г.

No need in compatibility with legacy code Flexible specification OpenSource

Candor 1-minute syntax crash-course понедельник, 2 июля 2012 г.

Types nil boolean number

понедельник, 2 июля 2012 г.

string

array

cdata function object

nil <=> undefined

понедельник, 2 июля 2012 г.

Booleans true

понедельник, 2 июля 2012 г.

false

Number signed 31bit integer (63bit on x64 platform)

Automatically converted

Examples: `123`, `123.456`

понедельник, 2 июля 2012 г.

double

Strings

Just strings?

Example: “hello world”

понедельник, 2 июля 2012 г.

Objects

Hashmaps

Example: { a : 1, b: 2, “c”: {} }

понедельник, 2 июля 2012 г.

Objects c fi i c e p s e c i g g a a u g m n a h l t i No rties w ! r e u p o o i r v a p h be

Hashmaps

Example: { a : 1, b: 2, “c”: {} }

понедельник, 2 июля 2012 г.

Arrays Example: [1,2,3,”a”,”b”,{a:1,b:2,c:3}]

понедельник, 2 июля 2012 г.

Functions Example: a(x,y,z) { return x + y + z }

понедельник, 2 июля 2012 г.

Functions with vararg Example: a(x, y, z...) { return x + y + z[0] } Call: a(x, y, z...) or a(x, y, a, b, c)

понедельник, 2 июля 2012 г.

CData Container for a C structure or pointer

понедельник, 2 июля 2012 г.

How I can interact with these types?

понедельник, 2 июля 2012 г.

How I can interact with these types? Keywords

понедельник, 2 июля 2012 г.

How I can interact with these types? Keywords

понедельник, 2 июля 2012 г.

Binary operations

How I can interact with these types? Keywords

понедельник, 2 июля 2012 г.

Binary operations

Unary operations

How I can interact with these types? Keywords

Binary operations Functions

понедельник, 2 июля 2012 г.

Unary operations

Keywords typeof

delete sizeof

понедельник, 2 июля 2012 г.

keysof

clone

typeof typeof nil === “nil” typeof 1 === “number” typeof “value” === “string” typeof {} === “object” typeof [] === “array” typeof () {} === “function” typeof cdata === “cdata”

понедельник, 2 июля 2012 г.

sizeof sizeof nil === 0, sizeof 1 === 0, ... sizeof “value” === 5 sizeof [1,2,3] === 3

понедельник, 2 июля 2012 г.

keysof keysof nil === [], keysof 1 === [], ... keysof [1,2,3] === [0,1,2] keysof {a:1,b:2} === [“a”, “b”]

понедельник, 2 июля 2012 г.

delete delete obj.property

понедельник, 2 июля 2012 г.

clone obj = { a: 1, b: 2 } cobj = clone obj print(cobj.a) // 1

понедельник, 2 июля 2012 г.

=== ==

<<

||

+

/

Binary operations

>>> &&

Almost the same as in javascript |

>> *

понедельник, 2 июля 2012 г.

!==

& -

%

^ !=

Type coercion • • • • •

coerce(nil, any) = (coerceTo(typeof any, nil), any) coerce(‘string’, other) = (‘string’, toString(other)) coerce(boolean, other) = (boolean, toBoolean(other)) coerce(number, other) = (number, toNumber(other)) coerce(function|object|array|cdata:first, other) = depending on operation:

• • понедельник, 2 июля 2012 г.

(toString(first), toString(other)) (toNumber(first), toNumber(other))

Unary operations

++

понедельник, 2 июля 2012 г.

--

!

+

-

Control flow syntax if (a) {   // when a == true } else {   // when a == false }

понедельник, 2 июля 2012 г.

while (a) {   // code }

Control flow syntax if (a) {   // when a == true } else {   // when a == false }

while (a) {   // code }

No for loops! понедельник, 2 июля 2012 г.

Array wrapper example

понедельник, 2 июля 2012 г.

1 Array = { 2 init: (self) { 3 self._list = [] 4 }, 5 at: (self, i) { 6 return self._list[i] 7 }, 8 length: (self, i) { 9 return sizeof self._list 10 }, 11 push: (self, values...) { 12 i = sizeof self._list 13 j = 0 14 while (j < sizeof values) { 15 self._list[i] = values[j] 16 i++ 17 j++ 18 } 19 }, 20 pop: (self) { 21 i = sizeof self._list - 1 22 last = self._list[i] 23 24 delete self._list[i] 25 26 return last 27 } 28 } понедельник, 2 июля 2012 г.

1 Array = { 2 init: (self) { 3 self._list = [] 4 }, 5 at: (self, i) { 6 return self._list[i] 7 }, 8 length: (self, i) { 9 return sizeof self._list 10 }, 11 push: (self, values...) { 12 i = sizeof self._list 13 j = 0 14 while (j < sizeof values) { 15 self._list[i] = values[j] 16 i++ 17 j++ 18 } 19 }, 20 pop: (self) { 21 i = sizeof self._list - 1 22 last = self._list[i] 23 24 delete self._list[i] 25 26 return last 27 } 28 } понедельник, 2 июля 2012 г.

Wrapper is an object

1 Array = { 2 init: (self) { 3 self._list = [] 4 }, 5 at: (self, i) { 6 return self._list[i] 7 }, 8 length: (self, i) { 9 return sizeof self._list 10 }, 11 push: (self, values...) { 12 i = sizeof self._list 13 j = 0 14 while (j < sizeof values) { 15 self._list[i] = values[j] 16 i++ 17 j++ 18 } 19 }, 20 pop: (self) { 21 i = sizeof self._list - 1 22 last = self._list[i] 23 24 delete self._list[i] 25 26 return last 27 } 28 } понедельник, 2 июля 2012 г.

Constructor/Initializer

1 Array = { 2 init: (self) { 3 self._list = [] 4 }, 5 at: (self, i) { 6 return self._list[i] 7 }, 8 length: (self, i) { 9 return sizeof self._list 10 }, 11 push: (self, values...) { 12 i = sizeof self._list 13 j = 0 14 while (j < sizeof values) { 15 self._list[i] = values[j] 16 i++ 17 j++ 18 } 19 }, 20 pop: (self) { 21 i = sizeof self._list - 1 22 last = self._list[i] 23 24 delete self._list[i] 25 26 return last 27 } 28 } понедельник, 2 июля 2012 г.

Methods are receiving reference to the instance

1 Array = { 2 init: (self) { 3 self._list = [] 4 }, 5 at: (self, i) { 6 return self._list[i] 7 }, 8 length: (self, i) { 9 return sizeof self._list 10 }, 11 push: (self, values...) { 12 i = sizeof self._list 13 j = 0 14 while (j < sizeof values) { 15 self._list[i] = values[j] 16 i++ 17 j++ 18 } 19 }, 20 pop: (self) { 21 i = sizeof self._list - 1 22 last = self._list[i] 23 24 delete self._list[i] 25 26 return last 27 } 28 } понедельник, 2 июля 2012 г.

Usage example: a = clone Array a:init() a:push(1, 2, 3) print("length:", a:length()) print("items: ", a:at(0), a:at(1), a:at(2)) print("pop: ", a:pop(), a:pop()) print("length:", a:length())

1 Array = { 2 init: (self) { 3 self._list = [] 4 }, 5 at: (self, i) { 6 return self._list[i] 7 }, 8 length: (self, i) { 9 return sizeof self._list 10 }, 11 push: (self, values...) { 12 i = sizeof self._list 13 j = 0 14 while (j < sizeof values) { 15 self._list[i] = values[j] 16 i++ 17 j++ 18 } 19 }, 20 pop: (self) { 21 i = sizeof self._list - 1 22 last = self._list[i] 23 24 delete self._list[i] 25 26 return last 27 } 28 } понедельник, 2 июля 2012 г.

Colon calls Usage example: a = clone Array a:init() a:push(1, 2, 3) print("length:", a:length()) print("items: ", a:at(0), a:at(1), a:at(2)) print("pop: ", a:pop(), a:pop()) print("length:", a:length())

1 Array = { 2 init: (self) { 3 self._list = [] 4 }, 5 at: (self, i) { 6 return self._list[i] 7 }, 8 length: (self, i) { 9 return sizeof self._list 10 }, 11 push: (self, values...) { 12 i = sizeof self._list 13 j = 0 14 while (j < sizeof values) { 15 self._list[i] = values[j] 16 i++ 17 j++ 18 } 19 }, 20 pop: (self) { 21 i = sizeof self._list - 1 22 last = self._list[i] 23 24 delete self._list[i] 25 26 return last 27 } 28 } понедельник, 2 июля 2012 г.

a:init() <=> a.init(a) Usage example: a = clone Array a.init(a) a.push(a, 1, 2, 3) print("length:", a.length(a)) print("items: ", a.at(a, 0), a.at(a, 1), a.at(a, 2)) print("pop: ", a.pop(a), a.pop(a)) print("length:", a.length(a))

1 Array = { 2 init: (self) { 3 self._list = [] 4 }, 5 at: (self, i) { 6 return self._list[i] 7 }, 8 length: (self, i) { 9 return sizeof self._list 10 }, 11 push: (self, values...) { 12 i = sizeof self._list 13 j = 0 14 while (j < sizeof values) { 15 self._list[i] = values[j] 16 i++ 17 j++ 18 } 19 }, 20 pop: (self) { 21 i = sizeof self._list - 1 22 last = self._list[i] 23 24 delete self._list[i] 25 26 return last 27 } 28 } понедельник, 2 июля 2012 г.

Usage example: a = clone Array a.init(a) a.push(a, 1, 2, 3) print("length:", a.length(a)) print("items: ", a.at(a, 0), a.at(a, 1), a.at(a, 2)) print("pop: ", a.pop(a), a.pop(a)) print("length:", a.length(a))

Very Lua-like

How can I run Candor code?

понедельник, 2 июля 2012 г.

How can I run Candor code? • • •

понедельник, 2 июля 2012 г.

Using website ( http://candor-lang.org/ ) Using Candor.js ( https://github.com/creationix/candor.js ) Using development version of JIT VM ( https://github.com/indutny/candor )

Wait, have you said JIT VM?

понедельник, 2 июля 2012 г.

x00000001000d5688:!rex.W test $0x1,%al x00000001000d568c:!jne 0x1000d56a6 x00000001000d5692:!add $0x2,%rax x00000001000d5699:!jno 0x1000d56cf x00000001000d569f:!sub $0x2,%rax x00000001000d56a6:!mov %rax,-0x10(%rbp) x00000001000d56ad:!movabs $0x2,%rax x00000001000d56b7:!mov %rax,%rbx x00000001000d56ba:!mov -0x10(%rbp),%rax x00000001000d56c1:!movabs $0x1000d5320,%r11 x00000001000d56cb:!rex.WB callq *%r11 x00000001000d56ce:!nop x00000001000d56cf:!mov %rax,-0x10(%rbp) x00000001000d56d6:!mov -0x10(%rbp),%r11 x00000001000d56dd:!mov %r11,-0x8(%rbp) x00000001000d56e4:!mov %r11,%rax

Yes!

понедельник, 2 июля 2012 г.

Candor is not just another language that compiles to javascript

понедельник, 2 июля 2012 г.

VM Compiler + Runtime + Heap + GC

понедельник, 2 июля 2012 г.

Compiler’s structure Source code Lexer

понедельник, 2 июля 2012 г.

Compiler’s structure Source code Lexer Parser

понедельник, 2 июля 2012 г.

Compiler’s structure Source code Lexer Parser JIT Code generator

понедельник, 2 июля 2012 г.

Compiler’s structure Source code Lexer Parser JIT Code generator Machine code понедельник, 2 июля 2012 г.

It wasn’t really fast #> time ./can test/benchmarks/while.can real!0m7.079s user!0m7.072s sys!0m0.006s #> time node while.js real!0m1.492s user!0m1.482s sys!0m0.020s

понедельник, 2 июля 2012 г.

It wasn’t really fast #> time ./can test/benchmarks/while.can real!0m7.079s user!0m7.072s sys!0m0.006s #> time node while.js real!0m1.492s user!0m1.482s sys!0m0.020s

понедельник, 2 июля 2012 г.

x5 times slower!

WARNING! Assembly code in next slide!

понедельник, 2 июля 2012 г.

x00000001000d5688:!rex.W test $0x1,%al x00000001000d568c:!jne 0x1000d56a6 x00000001000d5692:!add $0x2,%rax x00000001000d5699:!jno 0x1000d56cf x00000001000d569f:!sub $0x2,%rax x00000001000d56a6:!mov %rax,-0x10(%rbp) x00000001000d56ad:!movabs $0x2,%rax x00000001000d56b7:!mov %rax,%rbx x00000001000d56ba:!mov -0x10(%rbp),%rax x00000001000d56c1:!movabs $0x1000d5320,%r11 x00000001000d56cb:!rex.WB callq *%r11 x00000001000d56ce:!nop x00000001000d56cf:!mov %rax,-0x10(%rbp) x00000001000d56d6:!mov -0x10(%rbp),%r11 x00000001000d56dd:!mov %r11,-0x8(%rbp) x00000001000d56e4:!mov %r11,%rax понедельник, 2 июля 2012 г.

x00000001000d5688:!rex.W test $0x1,%al x00000001000d568c:!jne 0x1000d56a6 x00000001000d5692:!add $0x2,%rax x00000001000d5699:!jno 0x1000d56cf x00000001000d569f:!sub $0x2,%rax x00000001000d56a6:!mov %rax,-0x10(%rbp) x00000001000d56ad:!movabs $0x2,%rax x00000001000d56b7:!mov %rax,%rbx x00000001000d56ba:!mov -0x10(%rbp),%rax x00000001000d56c1:!movabs $0x1000d5320,%r11 x00000001000d56cb:!rex.WB callq *%r11 x00000001000d56ce:!nop x00000001000d56cf:!mov %rax,-0x10(%rbp) x00000001000d56d6:!mov -0x10(%rbp),%r11 x00000001000d56dd:!mov %r11,-0x8(%rbp) x00000001000d56e4:!mov %r11,%rax

And thatʼs just “i + 1”

понедельник, 2 июля 2012 г.

Good news: New compiler is in development!

понедельник, 2 июля 2012 г.

Compiler’s structure Source code Lexer Parser JIT Code generator Machine code понедельник, 2 июля 2012 г.

Compiler’s structure Source code

HIR

Lexer

Optimization

Parser

LIR

JIT Code generator

Register allocation

Machine code понедельник, 2 июля 2012 г.

HIR (CFG) // start if (a) { x=1 // some code } else { x=2 // other code } return x

понедельник, 2 июля 2012 г.

// start branch (a) x=1 // some code

x=2 // other code

return x

HIR (SSA) // start if (a) { x=1 // some code } else { x=2 // other code } return x

понедельник, 2 июля 2012 г.

// start branch (a0) x0 = 1 // some code

x1 = 2 // other code

x2 = phi(x0, x1) return x2

Optimizations • • • • понедельник, 2 июля 2012 г.

Dead-code elimination Common subexpression elimination Hoisting code out of hot loop And some others

LIR Back from graph to the linear representation

понедельник, 2 июля 2012 г.

cmp r0 jz &else_branch mov 1, r1 jmp &end_if else_branch: mov 2, r2 end_if: // resolved phi mov r3, %ax ret понедельник, 2 июля 2012 г.

LIR // start branch (a0) x0 = 1 // some code

x1 = 2 // other code

x2 = phi(x0, x1) return x2

cmp r0 jz &else_branch

LIR cmp %bx jz &else_branch

mov 1, r1 jmp &end_if else_branch: mov 2, r2 end_if: // resolved phi mov r3, %ax ret понедельник, 2 июля 2012 г.

Register allocation

mov 1, %eax jmp &end_if else_branch: mov 2, %eax end_if: ret

Feel free to contribute! To `feature-ssa` branch on github: https://github.com/indutny/candor/tree/feature-ssa

понедельник, 2 июля 2012 г.

Future plans: • • • • понедельник, 2 июля 2012 г.

Finishing feature-ssa branch of compiler Implementing SSA form optimizations Creating debugger for JIT VM And improving language!

http://candor-lang.org/ понедельник, 2 июля 2012 г.

Thank you! Sorry, no Q&A

понедельник, 2 июля 2012 г.

return - GitHub

Jul 2, 2012 - x00000001000d56e4:mov. %r11,%rax понедельник, 2 июля 2012 г. Page 2. @indutny. Twitter / Github / IRC понедельник, 2 июля 2012 г.

421KB Sizes 1 Downloads 302 Views

Recommend Documents

return x + value - GitHub
movl %esi, (%rdi) retq. __ZN4Plus6plusmeEi: ... static code and data auto plus = Plus(1); ... without garbage collection using object = std::map;.

Return-To-Neveryon-Return-To-Neveryon.pdf
... Hugo and Nebula award-winner Samuel R. Delany appropriated the conceits of ... personally to only get PDF formatted books to download that are safer and ...

Return to Thedas!
Dragon Age video game series and those inspired and adapted to showcase ... Spell Expertise talent and provide a host of new options. The rest of the chapter ...

The Stags Return
IPO. Sector. Subsector. Freefloat. Proceeds. 3M ADT. Returns from IPO price ..... please contact your J.P. Morgan Representative or visit the OCC's website at ...

Return nims island
Douglasadams pdf. ... Darling cherry tornmona walesand ella nova.Return nims. island.Woman in gold.ita. Magictown 1947.Thecompleteios 8 course with swift. ... Hamletstates that which forevermoreshall befromthis point forward I may act ...

Worldline return Label.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Worldline return ...

Return Competition Info.pdf
Page 1 of 8. Organization Name Contact Person. Street Address City, State, Zip. Home Phone Cell or Work Phone. Email. Total # of Athletes : ______ ______ x ...

Maximizing Website Return on Investment:
helping site visitors to understand the company's products, services, or solutions, ... software can be worth thousands of dollars, it is essential that a website works .... 2 .5M/mo. 100K/mo. 5,000/mo. % web lead conversions to sales. 20%. 10%.

Return 2 base
Flash gallery. factory deluxe. Return 2 base- Download.Return 2 base. ... Arussian journal pdf.Counter-Strike Source nosteam.Return 2 base.Port ofcall bergman ...

Imm_Vaccine-Return-Guidance.pdf
If you need further assistance with spoiled, wasted or expired VFC supplied vaccine please call the. Colorado VFC program at 303 692-2650 or email [email protected]. 2 |. Updated 6/26/2015. Page 2 of 2. Imm_Vaccine-Return-Guidance.pdf. Imm_Vaccin

Imm_Vaccine-Return-Checklist.pdf
your email spam folder. ... Give the labeled box or boxes to the UPS delivery person next time they come to your office. ... Imm_Vaccine-Return-Checklist.pdf.

GitHub
domain = meq.domain(10,20,0,10); cells = meq.cells(domain,num_freq=200, num_time=100); ...... This is now contaminator-free. – Observe the ghosts. Optional ...

GitHub
data can only be “corrected” for a single point on the sky. ... sufficient to predict it at the phase center (shifting ... errors (well this is actually good news, isn't it?)

Service Tax Return extension.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Main menu.

return of the jedi despecialize.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. return of the jedi ...

Return-Path: Gilbert_Lovell@ccmail
Mechanisms Committee Teleconference, March 17, 1997 and received in the following ten days. ... 9, deleted "Computation and Software", changed "Theoretical.

Return-Oriented Programming: Systems, Languages, and Applications
systems, has negative implications for an entire class of security mechanisms: those that seek to prevent malicious ... understood that W⊕X is not foolproof [Solar Designer 1997; Krahmer 2005; McDonald. 1999], it was thought to be a ..... The remai

the risk-return fallacy
We assume that in the world of business, higher risks are only taken when rewarded with higher expected returns. ... the investor, who must attain his most preferred risk-return profile by constructing a suitable portfolio mix. ... Although capital m

[PDF] River of No Return
... a single week we got the message It’s Time To Go Gates of Vienna has moved to a new address Another nice feature on the Craft is the big dial on the top ...

Guidance note on Annual Return - ICSI
company having paid-up share capital of Rs.10 crore or more or turnover of Rs. 50 ... Accordingly, the annual return in terms of section 92 of the Companies Act, ...

return to paradise dvdr.pdf
ПаралÐμльÐ1⁄2Ñ– ÑÐ2Ñ–Ñ‚Ð ̧ / sliders /. ÑÐμзÐ3⁄4Ð1⁄2 1 5 1995 2000 dvdrip ukr. Rapidmoviez ul/ob/180u. alpha house 2014 dvdrip x264 ac3 ...

A Return Visit to Araby
class. But her enticing whiteness, in Updike's sly parody, is also given a luminous, halo-like ... Queenie bows to no one, but the “clear bare plane of the top of her chest . . . [is] like a .... Business goes on, arid-----~--as at Aral,i_v- the mo

In Return by Odesza.pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document. Retrying... Download. Connect ...