Identifying A Unifying Mechanism for the Implementation of Concurrency Abstractions on...

Post on 02-Jul-2015

777 views 0 download

description

Supporting all known abstractions for concurrent and parallel programming in a virtual machines (VM) is a futile undertaking, but it is required to give programmers appropriate tools and performance. Instead of supporting all abstractions directly, VMs need a unifying mechanism similar to INVOKEDYNAMIC for JVMs. Our survey of parallel and concurrent programming concepts identifies concurrency abstractions as the ones benefiting most from support in a VM. Currently, their semantics is often weakened, reducing their engineering benefits. They require a mechanism to define flexible language guarantees. Based on this survey, we define an ownership-based meta-object protocol as candidate for VM support. We demonstrate its expressiveness by implementing actor semantics, software transactional memory, agents, CSP, and active objects. While the performance of our prototype confirms the need for VM support, it also shows that the chosen mechanism is appropriate to express a wide range of concurrency abstractions in a unified way.

transcript

!"#$%&'($)*+**

,$(&'($)*-#./+$(01*&23*4/#*!156#1#$4+%2$*2&**

72$.833#$.'*9:043+.%2$0*2$*-86%;<+$)8+)#*=-0*

>4#&+$*-+33?*@/#2*ABC2$"4*>2DE+3#*<+$)8+)#0*<+:*

@FF<>*G8325#?*HI4/*2&*-+'*JIKJ*

9)#$"+*

•  9556(.+%2$0*($*4/#*186%.23#*+)#*

•  9*>83L#'M*E/+4*0/286"*E#*0855234N*

•  9*,$(&'($)*9:043+.%2$*

•  GL+68+%2$*

!"#"$#%&' &'

7O,0*"2$B4*)#4*P+04#3*Q84*-86%56'*

!"#"$#%&' !'()*'+,-.')/*'011*'+,-.'

"2&'

%2$'

!23'!2!!'

I*

K*

J*

H*

R*

KSSI* KSST* JIII* JIIT* JIKI*

4'516,.'

UCV*

%'516,'

=-0*42"+'*

O#3&231+$.#* -#123'*-+$+)#1#$4*

7!"

-86%;<+$)8+)#*G.2*>'04#1* O6+W231*!$"#5#$"#$4*

!"#"$#%&' 8'

9*,):';1*,:<'#L#$4;62250*23*+.4230*

C2E*42*(156#1#$4*+*-+(6*.6(#$4N*

,0#3*!$4#3&+.#*+0'$./32$280*#L#$4;"3(L#$*

!"#"$#%&' $'

!"#$%&'&(")'$*+,-.*$/01,2340*56073809,,:;#$/0,40&-$53,1<=<=<>-.*$/0?,<-@A0B',,CD2EF2,FEG#2,'88&0--0-,HDIJ7K,$3/L,'88&0--L,@5BB03/MN,

,

CD2EF2,FEG#2,B0--'O0-,HDIJ7K,$3/L,B0--'O0P$8L,85@QB03/P$8L,$3P&06*(P/5L,&0B5/0P$8,$3/L,-0380&,$3/RMN,

C2E*42*(156#1#$4*+*-+(6*.6(#$4N*

A+4+*>423+)#* .2$0(04#$.'*3#X8(3#"*43+$0+.%2$+6*:+.Y#$"0*

9*,):';1*,:<'43+$0+.%2$+6*6+$)8+)#*12"#6*

!"#"$#%&' 4'

C2E*42*(156#1#$4*+*-+(6*.6(#$4N*

A+4+*9$+6'0(0*+$"*O32.#00($)* 5#3&231+$.#*0#$0(%L#*

9*,):';1*,:<'"+4+;5+3+66#6*X8#3(#0?*1+5Z3#"8.#?*&23YZ[2($*

72$.833#$.'*>855234*($*-86%;<+$)8+)#*=-0*@2"+'N*

!"#"$#%&' ='

ECMA-335 4th Edition / June 2006

Common Language Infrastructure (CLI)

Partitions I to VI

@/3#+"0* <2.Y0* >./#"86($)*

@/#*:+0(.0*2$6'M*C+3"*42*:8(6"*2$*425\*

>?@ABC']/+4*"2*E#*$##"*&23*+*-86%;<+$)8+)#*=(348+6*-+./($#N*

!"#"$#%&' 3'

!"#"$#%&' D'

>83L#'*>8:[#.40M*@2*("#$%&'*72$.#540*

•  J*083L#'0M*Q3(24*#4*+6^_H`?*>Y(66(.23$*a*@+6(+*_HI`*•  <+$)8+)#0*b($"8043'*c*3#0#+3./d*•  O+5#30?*&23*2:L(280*)+50*

!"#"$#%&' %%'

9.%L#*F:[#.40*_Ke`* 7/+31cc** P2343#00*** F..+1;5(*** >(156#*f+L+***9"+* 7(6Y*** U2*** F5#$7<* >Y(66(.23$a@+6(+*_HI`*9("+*_JI`*** 762[83#*** !2*** F5#$-O*** >6'***96(.#*** 72Q2g#0*_Je`*** f7>O*** F36#+$0*_T`*** >43#+1!@***91:(#$4@+6Y*** 72$.833#$4*C+0Y#66*** f+L+*=(#E0*_e`*** FV*** >E($)***94#[(*Oh*** 72$.833#$4*-<*** f2($*f+L+*** O9-*_Ji`*** ,O7***9g81*** 72$.833#$4*F:[#.40* <($"+*_KK`*** j#+.%L#*F:[#.40*_JT`*hKI*Q3(24*#4*+6^*_H`*** 72$.833#$4*O+0.+6*** -O!*** >7FFO*_JR`* h7***7k*** G36+$)*** -+5j#"8.#*_JK`* >@-*_JS`* **7/+5#6*** P2343+$*JIIe*** -86%<(05*_KH`*** >(156#*7Z7cc*** **

>83L#'*l8#0%2$0*

N9( *7+$*(4*:#*(156#1#$4#"*+0*+*6(:3+3'N*

>B; *A2#0*(4*3#X8(3#*38$%1#*0855234*42*)8+3+$4##*(40*0#1+$%.0N*

OB@7 *]286"*38$%1#*0855234*#$+:6#*0()$(m.+$4*5#3&231+$.#*(1532L#1#$40N*

OP *!0*(4*0855234#"*:'*021#*=-*+63#+"'N*

!"#"$#%&' %&'

>83L#'*j#08640*

O6L16'P6H' OP' N9(' >B;' OB@7'PH1QL5'O6LQLRS,.' h* ;* ;* h*J1T61ER/,.' h* ;* ;* h*J1/*LR1/'A)6L)F:,.' h* h* ;* h*J6LR5):'>,5R1/.' h* h* ;* h*0:1F):'P**6,..'>I)5,.' h* h* ;* h*06,,/'UV6,)*.' h* ;* ;* ;*9QQEH)FL:LHW' h* ;* h* h*X1L/' h* ;* ;* ;*N15Y.' h* h* ;* h*;,Q16W';1*,:' h* ;* h* h*;,HV1*'9/S15)R1/' h* ;* ;* h*@)5,TP/*T@,I)L6' h* h* ;* ;*UV6,)*'O11:.' h* h* ;* ;*UV6,)*T:15):'A)6L)F:,.' h* h* ;* h*UV6,)*.' h* h* ;* ;*A1:)R:,.' h* ;* h* ;*Z6)II,6'[FG,5H.' h* h* ;* h*

!"#"$#%&' %!'

•  eJ*.2$.#540*("#$%m#"?*nI*.2$0("#3#"*"(0%$.4*NLF6)6W'>1:ER1/.' OP' N9(' >B;' OB@7'PK,/H.' ;* \' ;* ;*PO0P>' ;* \' ;* ;*PH1Q.' ;* \' ;* ;*J1/5E66,/H'[FG,5H.' ;* \' ;* ;*BS,/HTN11I' ;* \' ;* ;*BS,/H.' ;* \' ;* ;*7)6T@,],6,/5,.' ;* \' ;* ;*716Y#X1L/' ;* \' ;* ;*7EHE6,.' ;* \' ;* ;*0E)6*.' ;* \' ;* ;*;,..)K,'^E,E,' ;* \' ;* ;*[/,T.L*,*'J1QQE/L5)R1/' ;* \' ;* ;*

O)6)::,:'(E:Y'[I,6)R1/.' ;* \' ;* ;*

O0P>' ;* \' ;* ;*@,*E5,6.' ;* \' ;* ;*>L/K:,'(:15Y.' ;* \' ;* ;*>H)H,'@,51/5L:L)R1/' ;* \' ;* ;*

>83L#'*j#08640*@,_EL6,'A;'>EII16H' OP' N9(' >B;' OB@7'

P5RS,'[FG,5H.' ;* h* h* ;*

P5H16.' ;* h* h* h*

P.W/5V61/1E.'9/S15)R1/' ;* h* h* h*

P`EQTa1Q)L/.' ;* h* h* ;*

()66L,6.' ;* h* ;* h*

(WTA):E,' ;* h* h* h*

JV)//,:.' ;* h* h* h*

J:15Y.' ;* h* ;* h*

a)H)';1S,Q,/H' ;* ;* ;* h*

a)H)'>H6,)Q.' ;* h* h* h*

9QI:L5LH'O)6)::,:L.Q' ;* h* ;* h*

9.1:)R1/' ;* h* h* h*

N15):LHW' ;* ;* ;* h*

!"#"$#%&' %8'

@,_EL6,'A;'>EII16H' OP' N9(' >B;' OB@7'

;)I#@,*E5,' ;* h* h* ;*

;,..)K,'.,/*.' ;* h* h* h*

;L6616.' ;* h* ;* h*

+1T9/H,65,..L1/' ;* h* h* h*

[-/,6.VLI' ;* ;* ;* h*

O,6.L.H,/H'a)H)'>H6E5HE6,.' ;* h* h* ;*

@,I:L5)R1/' ;* h* h* ;*

>L*,TBb,5H'76,,' ;* ;* h* h*

>I,5E:)RS,'B`,5ER1/' ;* ;* h* h*

U6)/.)5R1/.' ;* h* h* h*

UEI:,'>I)5,.' ;* h* h* ;*

A)H.' ;* h* h* h*

A,5H16'[I,6)R1/.' ;* h* ;* h*

>83L#'*72$.680(2$*

•  O+3+66#6*.2$.#540*+0*6(:3+3(#0*– b23*&23*L#3'*05#.(m.*25%1(V+%2$0d*

•  72$.833#$.'*.2$.#540*3#X8(3#*=-*0855234*– P23*5#3&231+$.#*– G$&23.#*#$.+5086+%2$?*(1184+:(6(4'*– G$&23.#*+0'$.^*#g#.8%2$?*o*

!"#"$#%&' %$'

A#"8.#"*j#X8(3#1#$40*&23*=-0*

!"#"$#%&' %4'

-+$+)#"*-84+%2$*

-+$+)#"*Gg#.8%2$*

p2%2$*2&*FE$#30/(5*

72$43266+:6#*G$&23.#1#$4*

J[+J?@@B+JC'a[;P9+>'G$&23.($)*>#1+$%.0*E(4/*+*-#4+;2:[#.4*O3242.26*

!"#"$#%&' %='

72$.833#$.'*A21+($0M*FE$#30/(5;:+0#"*-#4+2:[#.4*O3242.26*

!"#"$#%&' %3'

readField(obj, idx)writeField(obj, idx, val)reqExec(obj, method, args)newThread(closure)readGlobal(glob)writeGlobal(glob, val)primitiveCopy(obj)primitive*(...)

DomainObject

10..*

owned by

10..*

runs inenforced : bool

Thread

A21+($*#$&23.($)*!1184+:(6(4'*

!"#"$#%&' %D'

Main Cell with #foo Immutable Domain

enforced

cell.set(#bar)

cell.set(#bar) → reqExec(cell, set, #bar)

writeToField(cell, 1, #bar)

ImmutabilityError(cell, 1, #bar)

cell = new Cell()

cell.set(#foo)

domain.adopt(cell)

enforced()

A21+($*A#m$(%2$*@*'--,7BBK5B'$3,09/038-,K5B'$3,_,,,,45$8,!"#$%&'(#%)*H5%`L,$89L,4'*M,_,,,,,/A&5U,30U,7BBQ/'%$*$/(2&&5&H5%`L$89L4'*MN,,,a,,,,45$8,+"#,-.$/0$15%`L,$89L,4'*M,_,,,,,/A&5U,30U,7BBQ/'%$*$/(2&&5&H5%`L$89L4'*MN,,,a,,,"",R,'**,BQ/'/$3O,560&'/$53-,b,6&$B$/$40-,a,

!"#"$#%&' &%'

BAPN?PU9[+'9$"?*"2#0*(4*0.+6#N*

!"#"$#%&' &&'

Gg53#00(L#$#00M*762[83#B0*9)#$40*J:)..' c;,HV1*.' N[J'PK,/H'd)*TV15ef' e* HK*

!"#"$#%&' &!'

J:)..' c;,HV1*.' N[J'PK,/H' e* RK*PK,/Ha1Q)L/' R* HR*9QQEH)F:,a1Q)L/' n* Ki*

%3' D&'

qE(4/284*#$&23.#1#$4*2&*0#1+$%.0*

Gg53#00(L#$#00*($*<F7*

P*TV15' [-/,6.VLITF).,*';[O'

PK,/H.' HKq* iH*>U;' een** Kni*PQFL,/HU):Y>U' KnH* KKT*P5RS,[FG,5H.' ;* iH*J>Ogπ' ;* HS*-FO*:+0#*0'04#1* KIne*

!"#"$#%&' &8'

qE(4/284*#$&23.#1#$4*2&*0#1+$%.0*

O#3&231+$.#*!156#1#$4+%2$M*Q'4#.2"#*@3+$0&231+%2$*

!"#"$#%&' &$'

Bina

ry T

rees

(AT)

Fann

kuch

Redu

x (A

T)

Fast

a (A

T)

NBod

y (A

T)

Bina

ry T

rees

(LR)

Fann

kuch

Redu

x (L

R)

Fast

a (L

R)

NBod

y (L

R)

0.0

0.2

0.4

0.6

0.8

1.0

1.2

Kernel Benchmarks

Spee

d Ra

tio: A

d−ho

c/M

OP−

base

d

Arra

y Ac

cess

(AT)

Inst

ance

Var

. (AT

)

Loca

l Sen

ds (A

T)

Rem

ote

Send

s (A

T)

Rem

ote

Send

s (A

T)wi

th 1

0 ar

gum

ents

Arra

y Ac

cess

(LR)

Inst

ance

Var

. (LR

)

Send

s (L

R)

Send

s (L

R)wi

th 1

0 ar

gum

ents

0.0

0.2

0.4

0.6

0.8

1.0

1.2

Microbenchmarks

Spee

d Ra

tio: A

d−ho

c/M

OP−

base

d

91:(#$4@+6Y>@* >@-*

J[+JN?>9[+>'

!"#"$#%&' &4'

!"#$%m#"*j#X8(3#1#$40*&23*,$(&'($)*9:043+.%2$*

!"#"$#%&' &='

-+$+)#"*-84+%2$*

-+$+)#"*Gg#.8%2$*

p2%2$*2&*FE$#30/(5**

7436^*G$&23.#1#$4*j#X8(3#1#$40*:+0#"*2$*083L#'*

FE$#30/(5;:+0#"*-FO*+0*72$.833#$.'*9:043+.%2$*&23*=-0*

!"#"$#%&' &3'

FE$#30/(5;:+0#"*-FO*+0*.2112$*&28$"+%2$*

9)#$40*

91:(#$4@+6Y>@*

7>Ocπ*

>@-*

9.%L#F:[#.40*

readField(obj, idx)writeField(obj, idx, val)reqExec(obj, method, args)newThread(closure)readGlobal(glob)writeGlobal(glob, val)primitiveCopy(obj)primitive*(...)

DomainObject

10..*

owned by

10..*

runs inenforced : bool

Thread

P8483#*]23Y*

•  =-*>855234*– U2+6M*:#*5#3&231+$.#*$#843+6*– Q+0#"*2$*7O,B0*-#123'*-+$+)#1#$4*,$(4*– >E##4*0524M*7>O?*9.4230?*9.%L#*F:[#.40?o*

•  !$4#3+.%$)*72$.833#$.'*-2"#60*– 9.4230*c*>@-?o*– >#1+$%.0*

!"#"$#%&' &D'

l*a*9'