Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf ·...

72

Transcript of Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf ·...

Page 1: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,
Page 2: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

UsingLLVMandSulongforLanguageCExtensions

ChrisSeatonResearchManagerVMResearchGroupOracleLabs

ManuelRigger,MatthiasGrimmerJKULinz

Page 3: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

SafeHarborStatementThefollowingisintendedtoprovidesomeinsightintoalineofresearchinOracleLabs.Itisintendedforinformationpurposesonly,andmaynotbeincorporatedintoanycontract. Itisnotacommitmenttodeliveranymaterial,code,orfunctionality,andshouldnotberelieduponinmakingpurchasingdecisions.Oraclereservestherighttoalteritsdevelopmentplansandpracticesatanytime,andthedevelopment,release,andtimingofanyfeaturesorfunctionalitydescribedinconnectionwithanyOracleproductorserviceremainsatthesolediscretionofOracle. AnyviewsexpressedinthispresentationaremyownanddonotnecessarilyreflecttheviewsofOracle.

3

Page 4: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Whoweareandwhatwe’redoing

4

Page 5: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 5

Page 6: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 6

Graal

Truffle

RRuby

Java Scala

JavaScript LLVM

TheRubyLogoisCopyright(c)2006,YukihiroMatsumoto.ItislicensedunderthetermsoftheCreativeCommonsAttribution-ShareAlike 2.5agreementJSLogoCopyright(c)2011ChristopherWilliams<[email protected]>,MITlicence

YoucandistributethelogounderthetermsoftheCreativeCommonsAttribution-ShareAlike 4.0Internationallicense(CC-BY-SA4.0)or(atyouroption)theGNUGeneralPublicLicenseversion2(GPL-2).

JVM

Page 7: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

LanguageCextensions

7

Page 8: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 8

TheRubyLogoisCopyright(c)2006,YukihiroMatsumoto.ItislicensedunderthetermsoftheCreativeCommonsAttribution-ShareAlike 2.5agreementJSLogoCopyright(c)2011ChristopherWilliams<[email protected]>,MITlicence

ThePythonlogoisatrademarkofthePythonSoftwareFoundation

Page 9: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 9

Page 10: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 10

Page 11: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 11

Page 12: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

PerformanceonRubyCExtensionsOilyPNGandPSDNative

12

M.Grimmer,C.Seaton,T.Würthinger,H.Mössenböck.DynamicallyComposingLanguagesinaModularWay:SupportingCExtensionsforDynamicLanguages.InProceedingsofthe14th InternationalConferenceonModularity,2015.

0

2

4

6

8

10

12

MRIPureRuby MRIWithCExtension

Page 13: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

TheCextensionproblem

13

Page 14: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 14

Structs declaredinthepublicAPI

Implementationdetailslikeembeddedstringsandsharing

exposed

Page 15: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 15

RubyStringobject

Exposesinnerchar*

Stringobjectwithchar*alreadyexposednowreturnedtoRuby

CalltoarbitraryCcode

ManagedRubyvalueontheCstack

Page 16: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 16

ValuesneedtobeconvertedastheygofromRubytonative

CallfromRubytonativeisextremelyhot

Page 17: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 17

Arrayimplementationpointertakenandstored

forlater

Whenthey’reusedthere’snoindicationsomeoneelseis

managingthem

Page 18: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Previoussolutions

18

Page 19: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 19

Copy Copy

Page 20: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Ournewsolution

20

Page 21: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

• InterpretboththeRubyandtheC• Actually,interprettheLLVMIRoftheCtosimplify• JITcompiletheRubyandtheC• UseasinglehighandlowlevelIRforboth• ForgetwhichlanguagetheIRcamefromandoptimisethemtogether• GivevirtualisedpointerstotheCprogram

21

Page 22: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

HowSulong andJRuby+Truffle work

22

Page 23: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Hotspot

Page 24: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Hotspot

Page 25: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Hotspot

JIT

Page 26: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Hotspot

JIT

Page 27: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Hotspot

JIT

JIT

Page 28: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Hotspot

JIT

JIT

Truffle

Page 29: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

U

U U

U

U I

I I

G

G I

I I

G

G

Node Rewriting for Profiling Feedback

AST InterpreterRewritten Nodes

AST InterpreterUninitialized Nodes

Compilation usingPartial Evaluation

Compiled Code

Node Transitions

S

UI

D

G

Uninitialized Integer

Generic

DoubleString

T.Würthinger,C.Wimmer,A.Wöß,L.Stadler,G.Duboscq,C.Humer,G.Richards,D.Simon,andM.Wolczko.OneVMtorulethemall.InProceedingsofOnward!,2013.

Page 30: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

U

U U

U

U I

I I

G

G I

I I

G

G

Node Rewriting for Profiling Feedback

AST InterpreterRewritten Nodes

AST InterpreterUninitialized Nodes

Compilation usingPartial Evaluation

Compiled Code

Node Transitions

S

UI

D

G

Uninitialized Integer

Generic

DoubleString

T.Würthinger,C.Wimmer,A.Wöß,L.Stadler,G.Duboscq,C.Humer,G.Richards,D.Simon,andM.Wolczko.OneVMtorulethemall.InProceedingsofOnward!,2013.

Page 31: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

U

U U

U

U I

I I

G

G I

I I

G

G

Node Rewriting for Profiling Feedback

AST InterpreterRewritten Nodes

AST InterpreterUninitialized Nodes

Compilation usingPartial Evaluation

Compiled Code

Node Transitions

S

UI

D

G

Uninitialized Integer

Generic

DoubleString

T.Würthinger,C.Wimmer,A.Wöß,L.Stadler,G.Duboscq,C.Humer,G.Richards,D.Simon,andM.Wolczko.OneVMtorulethemall.InProceedingsofOnward!,2013.

Page 32: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 32

codon.com/compilers-for-free

Presentation,byTomStuart,licensedunderaCreativeCommonsAttributionShareAlike 3.0

Page 33: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

U

U U

U

U I

I I

G

G I

I I

G

G

Node Rewriting for Profiling Feedback

AST InterpreterRewritten Nodes

AST InterpreterUninitialized Nodes

Compilation usingPartial Evaluation

Compiled Code

Node Transitions

S

UI

D

G

Uninitialized Integer

Generic

DoubleString

T.Würthinger,C.Wimmer,A.Wöß,L.Stadler,G.Duboscq,C.Humer,G.Richards,D.Simon,andM.Wolczko.OneVMtorulethemall.InProceedingsofOnward!,2013.

Page 34: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|13/09/2016

T.Würthinger,C.Wimmer,A.Wöß,L.Stadler,G.Duboscq,C.Humer,G.Richards,D.Simon,andM.Wolczko.OneVMtorulethemall.InProceedingsofOnward!,2013.

I

I I

G

G I

I I

G

G

Deoptimizationto AST Interpreter

D

I D

G

G D

I D

G

G

Node Rewriting to Update Profiling Feedback

Recompilation usingPartial Evaluation

Page 35: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|13/09/2016 OracleConfidential– Internal/Restricted/HighlyRestricted

T.Würthinger,C.Wimmer,A.Wöß,L.Stadler,G.Duboscq,C.Humer,G.Richards,D.Simon,andM.Wolczko.OneVMtorulethemall.InProceedingsofOnward!,2013.

I

I I

G

G I

I I

G

G

Deoptimizationto AST Interpreter

D

I D

G

G D

I D

G

G

Node Rewriting to Update Profiling Feedback

Recompilation usingPartial Evaluation

Page 36: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|13/09/2016 OracleConfidential– Internal/Restricted/HighlyRestricted

T.Würthinger,C.Wimmer,A.Wöß,L.Stadler,G.Duboscq,C.Humer,G.Richards,D.Simon,andM.Wolczko.OneVMtorulethemall.InProceedingsofOnward!,2013.

I

I I

G

G I

I I

G

G

Deoptimizationto AST Interpreter

D

I D

G

G D

I D

G

G

Node Rewriting to Update Profiling Feedback

Recompilation usingPartial Evaluation

Page 37: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 37

Page 38: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 38

Frequently executed call

Page 39: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 39

Page 40: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 40

BigInteger

double

int

Page 41: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 41

BigInteger

double

int

Page 42: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 42

double

int

BigInteger

Page 43: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Hotspot

Graal

Truffle

JS RubyR

Java

C++JVMCI

(JVMCompilerInterface)

Page 44: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Hotspot

Graal

Truffle

JS RubyR

viaMavenetc

Java9

Page 45: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 45

Page 46: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Completeness– languageandcorelibrary

OracleConfidential– Internal

RubylanguageJRuby passes94%

95% RubycorelibraryJRuby passes95%

99%

Page 47: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Completeness– thebasicRailsstack

OracleConfidential– Internal

ActiveModel

ActiveSupport

ActiveRecord

ActionView

ActionPack

ActionMailer

Railties

Sprockets-Rails

ActiveJob

Spring

100%

100%

98%Basicfunctionalityworks

37%

Page 48: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Classicresearchbenchmarks– 10-20xfaster

Confidential– OracleInternal/Restricted/HighlyRestricted 48

05

1015202530354045

Speedu

pCo

mparedtoRub

y

GraalVM JRuby+invokedynamic Ruby

BenchmarksboundbyallocationorBigInteger

performance

Page 49: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 49

Page 50: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 50

Page 51: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 51

Page 52: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

HowweimplementCextensions

52

Page 53: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 53

cmyk_to_rgb

psd_native_util_clamp

FIX2INT

Page 54: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 54

cmyk_to_rgb

psd_native_util_clamp

FIX2INT

Page 55: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 55

Page 56: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 56

InsteadofRARRAY_PTRreturningapointer(anumber),returna

properJavaobject

Operationslikegetelementptr canreturnanewJavaobjectthat

rememberstheoriginalobject,andwhatoffsettouse

LetSSAnamesstoreJavaobjectsaswellasnumbers

TheloadcanthenusewhateverlogicwewanttoactuallyreadavaluefromtheJavaobject– reusenormalRubyarray

logic

Page 57: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 57

Page 58: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 58

Virtualised pointer– reallypointstoaJavaobjectwhichrepresentsourRubystring

TheCprogramhasnowayofknowingit’snotarealchar*

Intrinsicoperationsonthepointerareredirectedtobe

methodcalls

Page 59: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Evaluation

59

Page 60: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Evaluationisbasedonearlierwork• WeusedtohaveaCinterpreter– TruffleC• We’vemovedonfromthis,becausewewanttosupportmorelanguages• Butwearen’tabletorunallthesamebenchmarksyet• Sowe’veshowingresultsfromouroldimplementationinthemeantime• We’reprettysureresultswillbesimilar,asthecompiledcodeissimilar

60

Page 61: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

PerformanceonRubyCExtensionsOilyPNGandPSDNative

61

0

5

10

15

20

25

30

35

MRIPureRuby MRIWithCExtension

RubiniusWithCExtension

JRubyWithCExtension

JRuby+TruffleWithCExtension

JRuby+TruffleWithCExtension

(NoInline)

M.Grimmer,C.Seaton,T.Würthinger,H.Mössenböck.DynamicallyComposingLanguagesinaModularWay:SupportingCExtensionsforDynamicLanguages.InProceedingsofthe14th InternationalConferenceonModularity,2015.

Page 62: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

PerformanceonRubyCExtensionsOilyPNGandPSDNative

62

0

5

10

15

20

25

30

35

MRIPureRuby MRIWithCExtension

RubiniusWithCExtension

JRubyWithCExtension

JRuby+TruffleWithCExtension

JRuby+TruffleWithCExtension

(NoInline)

M.Grimmer,C.Seaton,T.Würthinger,H.Mössenböck.DynamicallyComposingLanguagesinaModularWay:SupportingCExtensionsforDynamicLanguages.InProceedingsofthe14th InternationalConferenceonModularity,2015.

NativeCextensionsgiveanorderofmagnitudeperformanceboost

Page 63: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

PerformanceonRubyCExtensionsOilyPNGandPSDNative

63

0

5

10

15

20

25

30

35

MRIPureRuby MRIWithCExtension

RubiniusWithCExtension

JRubyWithCExtension

JRuby+TruffleWithCExtension

JRuby+TruffleWithCExtension

(NoInline)

M.Grimmer,C.Seaton,T.Würthinger,H.Mössenböck.DynamicallyComposingLanguagesinaModularWay:SupportingCExtensionsforDynamicLanguages.InProceedingsofthe14th InternationalConferenceonModularity,2015.

Existingattempttomixmanaged/nativearevery

disappointing

Page 64: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

PerformanceonRubyCExtensionsOilyPNGandPSDNative

64

0

5

10

15

20

25

30

35

MRIPureRuby MRIWithCExtension

RubiniusWithCExtension

JRubyWithCExtension

JRuby+TruffleWithCExtension

JRuby+TruffleWithCExtension

(NoInline)

M.Grimmer,C.Seaton,T.Würthinger,H.Mössenböck.DynamicallyComposingLanguagesinaModularWay:SupportingCExtensionsforDynamicLanguages.InProceedingsofthe14th InternationalConferenceonModularity,2015.

Oursolutionis3xfasterthannative!

Page 65: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

PerformanceonRubyCExtensionsOilyPNGandPSDNative

65

0

5

10

15

20

25

30

35

MRIPureRuby MRIWithCExtension

RubiniusWithCExtension

JRubyWithCExtension

JRuby+TruffleWithCExtension

JRuby+TruffleWithCExtension

(NoInline)

M.Grimmer,C.Seaton,T.Würthinger,H.Mössenböck.DynamicallyComposingLanguagesinaModularWay:SupportingCExtensionsforDynamicLanguages.InProceedingsofthe14th InternationalConferenceonModularity,2015.

It’sclearthatcross-languageinlining isakeypartofthe

performance

Page 66: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Conclusions

66

Page 67: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 67

Page 68: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

OpenSource• https://github.com/graalvm/graal-core

– Graal compiler• https://github.com/graalvm/truffle

– Trufflelanguageimplementationframework• https://github.com/graalvm/fastr

– FastRruntime• https://github.com/graalvm/sulong

– DynamicruntimeforLLVMbitcode• https://github.com/jruby/jruby/wiki/Truffle

– FastRubyruntime

68

Page 69: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

Acknowledgements

69

OracleDaniloAnsaloniStefanAnzingerCosminBascaDanieleBonettaMatthiasBrantnerPetrChalupaJürgenChristLaurentDaynèsGillesDuboscqMartinEntlicherBrandonFishBastianHossbachChristianHumerMickJordanVojinJovanovicPeterKesslerDavidLeopoldsederKevinMenardJakubPodlešákAleksandarProkopecTomRodriguez

Oracle(continued)RolandSchatzChrisSeatonDougSimonŠtěpánŠindelářZbyněkŠlajchrtLukasStadlerCodrutStancuJanŠtolaJaroslavTulachMichaelVanDeVanterAdamWelcChristianWimmerChristianWirthPaulWögererMarioWolczkoAndreasWößThomasWürthinger

JKULinzProf.HanspeterMössenböckBenoitDalozeJosefEislThomasFeichtingerMatthiasGrimmerChristianHäublJosefHaiderChristianHuberStefanMarrManuelRiggerStefanRumzuckerBernhardUrban

Universityof EdinburghChristopheDubachJuanJoséFumero AlfonsoRanjeet SinghToomas Remmelg

LaBRIFloréal Morandat

Universityof California,IrvineProf.MichaelFranzGulfemSavrunYeniceriWeiZhang

Purdue UniversityProf.JanVitekTomasKaliberaPetrMajLeiZhao

T.U.DortmundProf.PeterMarwedelHelenaKotthausIngoKorb

Universityof California,DavisProf.DuncanTempleLangNicholasUlle

Universityof Lugano,SwitzerlandProf.WalterBinderSunHaiyangYudiZheng

OracleInternsBrianBellevilleMiguelGarciaShamsImamAlexeyKaryakinStephenKellAndreasKunftVolkerLantingGeroLeinemannJulianLettnerJoeNashDavidPiorkowskiGregorRichardsRobertSeilbeckRifatShariyar

AlumniErikEcksteinMichaelHauptChristosKotselidisHyunjinLeeDavidLeibsChrisThalingerTillWestmann

Page 70: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|

SafeHarborStatementTheprecedingisintendedtoprovidesomeinsightintoalineofresearchinOracleLabs.Itisintendedforinformationpurposesonly,andmaynotbeincorporatedintoanycontract. Itisnotacommitmenttodeliveranymaterial,code,orfunctionality,andshouldnotberelieduponinmakingpurchasingdecisions.Oraclereservestherighttoalteritsdevelopmentplansandpracticesatanytime,andthedevelopment,release,andtimingofanyfeaturesorfunctionalitydescribedinconnectionwithanyOracleproductorserviceremainsatthesolediscretionofOracle. AnyviewsexpressedinthispresentationaremyownanddonotnecessarilyreflecttheviewsofOracle.

70

Page 71: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,

Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.| 71

Page 72: Using LLVM and Sulong for Language C Extensionsllvm.org/devmtg/2016-09/slides/Seaton-Sulong.pdf · contract. It is not a commitment to deliver any material, code, or functionality,